TL;DR
VAR, short for Visual AutoRegressive modeling, is a way to generate images with a Transformer that predicts the image in stages, from a single coarse token to the full grid. Each stage is a whole token map at a higher resolution, and all its tokens are produced at once. The authors report that this makes a GPT-style model beat strong diffusion transformers on ImageNet 256 by FID, while sampling in about 20 times less time.
Builds on: Autoregressive Model, Transformer, Vector Quantization · Leads to: Diffusion Transformer (DiT), Neural Scaling Laws
Why it mattered
Before VAR, image models built from autoregressive transformers were clearly behind diffusion models on image quality. The paper's Table 1 lists VQGAN, an earlier autoregressive image generator, at an FID of 18.65 on ImageNet 256, while diffusion models such as DiT-XL/2 reached 2.27. VAR reports 1.73 for its largest model. The result matters because it shows that the autoregressive recipe that works for language can also reach top image quality once the order of generation is changed, and because the paper reports scaling trends that look like those of language models. The paper itself names text-to-image and video extensions as future work.
The problem
A language model predicts the next word, and words come in a natural left-to-right order. An image has no such order. Earlier image autoregressive models turned the image into a grid of discrete tokens and flattened the grid into a sequence, usually row by row. The paper points out four problems with this:
- The tokens of a quantized autoencoder are correlated in both directions, but autoregressive modelling assumes that each token depends only on the tokens before it. The flattened sequence therefore breaks the model's own assumption.
- The model cannot naturally do tasks that need the bottom of an image to inform the top, such as filling in a region.
- Flattening separates a token from its spatial neighbours, which weakens the local structure of the image.
- Generating an n by n token grid one token at a time takes n squared sequential steps, and the paper counts the total cost as order n to the sixth.
VAR keeps the transformer and changes the unit that is predicted, so that these problems are reduced.
How it works
Take a toy image whose latent token grid is 4 by 4. The toy uses three token maps, of sizes 1 by 1, 2 by 2 and 4 by 4, and the largest map must match the resolution of the image's latent grid.
- Encode the image into several token maps. A multi-scale autoencoder produces r1 (1 by 1), r2 (2 by 2) and r3 (4 by 4). Check: the sizes are the squares of 1, 2 and 4, and the total number of tokens is 1 + 4 + 16 = 21.
- Predict the coarsest map first. The transformer starts from a special start token and predicts r1, which is a single token. Check: this is one forward pass, and r1 captures the overall layout.
- Predict the next map in parallel. Conditioned on r1, the transformer predicts all four tokens of r2 at once. Check: four tokens, one step, and each one can depend on r1 but not on the other tokens of r2.
- Predict the finest map in parallel. Conditioned on r1 and r2, the transformer predicts all sixteen tokens of r3 at once. Check: sixteen tokens, one step.
- Decode. The decoder turns the three token maps back into a 4 by 4 latent grid and then into pixels. Check: the final map has the same grid size as the encoder's output.
Three sequential steps produce the image, where a raster-order model would need sixteen. The same idea applies to larger grids. With scales that double in size, the number of steps is the number of scales, which grows with the logarithm of the grid size. The paper's complexity result is O(n^4) computation for an n by n grid, against O(n^6) for raster order (Appendix B).
flowchart LR S[start token] --> R1[r1: 1 by 1, one step] R1 --> R2[r2: 2 by 2, one parallel step] R2 --> R3[r3: 4 by 4, one parallel step] R3 --> D[decoder: image]
Worked examples
Use the three scales from "How it works": sizes 1, 2 and 4.
- Count the tokens in each map: 1 by 1 gives 1, 2 by 2 gives 4, 4 by 4 gives 16.
- Add them: 1 + 4 + 16 = 21 tokens in total.
- A raster-order model generates the 16 tokens of the 4 by 4 grid one at a time, which is 16 sequential steps.
- VAR generates the same grid in 3 steps: one for r1, one for the 4 tokens of r2, and one for the 16 tokens of r3.
- Compare the step counts: 16 for raster order, 3 for VAR.
Interpretation: VAR produces 5 extra tokens in the coarse maps, and in exchange it needs far fewer sequential steps. The extra tokens are cheap because they are small maps.
Use scales 1, 2, 4 and 8.
- The side lengths are 1, 2, 4 and 8, so the token counts per map are 1, 4, 16 and 64.
- The total is 1 + 4 + 16 + 64 = 85 tokens.
- Check with the geometric-series formula for doubling scales: (2^8 - 1) / (2^2 - 1) = 255 / 3 = 85.
- A raster-order model for the 8 by 8 grid needs 64 sequential steps.
- VAR needs 4 sequential steps, one per scale.
- The total number of tokens rises from 64 to 85, about a third more, while the step count falls from 64 to 4.
Interpretation: the number of steps is the number of scales, which grows slowly with the grid size, while the extra tokens add a modest overhead. This trade is the reason the paper's efficiency claim holds.
The paper's tokenizer downsamples by 16, so a 256 by 256 image has a 16 by 16 latent grid. The main text does not give the scale list used for this model, so take the doubling schedule 1, 2, 4, 8, 16 as an illustration of the counting, not as the paper's exact configuration.
- The number of scales is 5.
- The token counts per map are 1, 4, 16, 64 and 256.
- The total is 1 + 4 + 16 + 64 + 256 = 341 tokens.
- A raster-order model would generate the 256 tokens of the final grid in 256 sequential steps.
- Under this schedule VAR needs 5 steps, and it generates 341 tokens in total, 85 more than the grid alone.
Try it: under the same schedule, how many tokens are generated in total for the 16 by 16 grid, and how many sequential steps does VAR need? Answer: 341 tokens in total, and 5 sequential steps, against 256 steps for raster order.
The math
Step 1 in symbols: the tokenizer
A quantized autoencoder maps the image to a feature map f and then to a token map q by choosing, for each position, the nearest vector in a learned codebook Z with V entries:
Here f^(i,j) is the feature vector at position (i, j), and lookup(Z, v) returns the v-th codebook vector. VAR uses a shared codebook with V = 4096 entries for all scales, and a spatial downsampling ratio of 16. So a 256 by 256 image gives a 16 by 16 latent grid, as the paper's downsampling factor implies.
Step 2 in symbols: the multi-scale token maps
The encoder produces K token maps r_1, ..., r_K, each at a higher resolution than the one before, with r_K matching the full latent grid. The paper's residual design builds each map from the previous ones, so r_k depends only on r_1 through r_(k-1), as its autoregressive assumption needs.
Step 3 in symbols: next-scale likelihood
The probability of the whole image is factorised over scales rather than over tokens:
Each factor is a distribution over all h_k times w_k tokens of the map at scale k, which are generated in parallel. Training uses a block-wise causal attention mask, so that the tokens of r_k can attend to r_1 through r_k but not to later scales. The loss is the standard cross-entropy on the predicted tokens. At inference the mask is not needed, and key-value caching can be used.
Step 4 in symbols: counting tokens and steps
If the scales double each time, with side lengths n_k = 2^(k-1), the total number of tokens up to scale K is the sum of n_k squared. Because the square of n_k is 4^(k-1), the sum is a geometric series with closed form (a^(2K) - 1) / (a^2 - 1) at a = 2. For the toy 4 by 4 example, K = 3 gives (64 - 1) / 3 = 21, as in step 1 of the walkthrough. The number of sequential steps is K, which is about log base 2 of the grid size plus one.
Results
ImageNet 256 by 256. The paper's Table 1 compares generator families on class-conditional ImageNet 256. The headline entry is VAR-d30 with rejection sampling, which reaches an FID of 1.73 and an Inception Score (IS) of 350.2 with 2.0 billion parameters. Without rejection sampling the same model reaches an FID of 1.92 and an IS of 323.1. The validation images themselves score an FID of 1.78, which the paper uses as a reference. FID compares the statistics of generated and real images, and lower is better. IS rewards images that are both sharp and varied, and higher is better. The paper also lists DiT-XL/2 with 675 million parameters at FID 2.27 and IS 278.2, and it reports that DiT-XL/2 needs about 45 times the wall-clock time of VAR. Its VQGAN baseline is listed at FID 18.65 and IS 80.4, numbers taken from MaskGIT.
ImageNet 512 by 512. Table 2 reports a VAR model of depth 36 that uses a single shared AdaLN layer, marked "-s", because of resource limits. It reaches an FID of 2.63 and an IS of 303.2, against 3.04 and 240.8 for DiT-XL/2.
Ablation. Table 3 starts from a plain GPT-2-style model trained with the raster-order algorithm, at FID 18.65. Switching the algorithm to VAR gives FID 5.22 with a cost of 0.013 relative to the baseline. Adding adaptive layer normalization gives 4.95, top-k sampling gives 4.64, classifier-free guidance gives 3.60, and normalising queries and keys gives 3.30. Scaling to 2.0 billion parameters gives 1.73. A note on arithmetic: subtracting the printed FIDs gives a reduction of 16.92 for the last row, while the table prints 16.85. This lesson uses the printed FIDs and does not rely on that difference.
Scaling. The paper trains 12 models with depths from 6 to 30, ranging from 18.5 million to 2.0 billion parameters, and fits power laws of the form L = (c N)^alpha. For the final-scale loss the fit is L_last = (2.0 N)^(-0.23), and the linear correlation coefficient of that log-log fit is near -0.998. The same kind of fit holds against training compute, over six orders of magnitude of compute according to the paper.
Limits the paper states. The tokenizer uses the VQGAN architecture with a modified multi-scale quantization layer. Text-to-image generation and video generation are not implemented; the paper describes them as directions for future work. The 512 by 512 result uses the shared AdaLN shortcut.
Reading guide
Read the paper in this order, with the lessons that cover each part.
- Section 1 (Introduction) and Section 2 (Related Work) need Autoregressive Model, Neural Scaling Laws and Diffusion Model.
- Section 3.1 (Preliminary) needs Cross-Entropy Loss for the next-token loss and Vector Quantization for the tokenizer.
- Section 3.2 (Next-scale prediction) is the core. It needs Attention Mechanism for the causal mask and KV Cache for inference.
- Section 4 (Implementation) needs Transformer, Adaptive Layer Normalization and Layer Normalization.
- Section 5 (Empirical results) needs Fréchet Inception Distance and Power Law.
- Section 6 and 7 need Classifier-Free Guidance for the guidance ablation.
Check yourself
QuestionIn the toy 4 by 4 example, why does VAR need 3 sequential steps while a raster-order model needs 16?Show answer
VAR generates a whole token map in one step, so the three maps of sizes 1, 2 and 4 take three steps. A raster-order model emits one token per step, so the 16 tokens of the 4 by 4 grid take 16 steps. The tokens within each VAR map are generated in parallel, which is where the saving comes from.
QuestionWith scales 1, 2, 4 and 8, how many tokens does VAR generate in total, and what does the paper's closed form give?Show answer
The per-map counts are 1, 4, 16 and 64, which add to 85. The closed form (a^(2K) - 1) / (a^2 - 1) with a = 2 and K = 4 gives (256 - 1) / 3 = 85, so the two agree.
QuestionWhy does VAR use a block-wise causal attention mask during training but not during inference?Show answer
During training the model must predict every scale in one pass, so the mask stops the tokens of scale k from seeing scales after k, which keeps the factorisation valid. During inference the scales are generated in order, so later scales do not exist yet when they are needed, and no mask is required.
QuestionA reader concludes from Table 1 that VAR is always better than diffusion models in every respect. What should they check?Show answer
The table shows VAR ahead on FID and IS for the reported models, but the headline 1.73 uses rejection sampling, and the comparisons are on class-conditional ImageNet at 256 and 512 pixels, against the baselines the paper chose. The paper also says text-to-image and video generation are not yet done, so the claim is limited to class-conditional ImageNet generation.