Visual Autoregressive Modeling: Scalable Image Generation via Next-Scale Prediction

Keyu Tian, Yi Jiang, Zehuan Yuan, Bingyue Peng, Liwei Wang

Introduction

The advent of GPT series and other autoregressive (AR) large language models (LLMs) has heralded a new epoch in the field of artificial intelligence. These models exhibit promising intelligence in generality and versatility that, despite issues like hallucinations , are still considered to take a solid step toward the general artificial intelligence (AGI). The crux behind these large models is a self-supervised learning strategy – predicting the next token in a sequence, a simple yet profound approach. Studies into the success of these large AR models have highlighted their scalability and generalizabilty: the former, as exemplified by scaling laws , allows us to predict large model’s performance from smaller ones and thus guides better resource allocation, while the latter, as evidenced by zero-shot and few-shot learning , underscores the unsupervised-trained models’ adaptability to diverse, unseen tasks. These properties reveal AR models’ potential in learning from vast unlabeled data, encapsulating the essence of “AGI”.

In parallel, the field of computer vision has been striving to develop large autoregressive or world models , aiming to emulate their impressive scalability and generalizability. Trailblazing efforts like VQGAN and DALL-E along with their successors have showcased the potential of AR models in image generation. These models utilize a visual tokenizer to discretize continuous images into grids of 2D tokens, which are then flattened to a 1D sequence for AR learning (Fig. 2 b), mirroring the process of sequential language modeling (Fig. 2 a). However, the scaling laws of these models remain underexplored, and more frustratingly, their performance significantly lags behind diffusion models , as shown in Fig. 3. In contrast to the remarkable achievements of LLMs, the power of autoregressive models in computer vision appears to be somewhat locked.

Autoregressive modeling requires defining the order of data. Our work reconsiders how to “order” an image. Humans typically perceive or create images in a hierachical manner, first capturing the global structure and then local details. This multi-scale, coarse-to-fine method naturally suggests an “order” for images. Also inspired by the widespread multi-scale designs , we define autoregressive learning for images as “next-scale prediction” in Fig. 2 (c), diverging from the conventional “next-token prediction” in Fig. 2 (b). Our approach begins by encoding an image into multi-scale token maps. The autoregressive process is then started from the 1×\times1 token map, and progressively expands in resolution: at each step, the transformer predicts the next higher-resolution token map conditioned on all previous ones. We refer to this methodology as Visual AutoRegressive (VAR) modeling.

VAR directly leverages GPT-2-like transformer architecture for visual autoregressive learning. On the ImageNet 256×\times256 benchmark, VAR significantly improves its AR baseline, achieving a Fréchet inception distance (FID) of 1.80 and an inception score (IS) of 356.4, with inference speed 20×\times faster (see Sec. 4.4 for details). Notably, VAR surpasses the Diffusion Transformer (DiT) – the foundation of leading diffusion systems like Stable Diffusion 3.0 and SORA – in FID/IS, data efficiency, inference speed, and scalability. VAR models also exhibit scaling laws akin to those witnessed in LLMs. Lastly, we showcase VAR’s zero-shot generalization capabilities in tasks like image in-painting, out-painting, and editing. In summary, our contributions to the community include:

A new visual generative framework using a multi-scale autoregressive paradigm with next-scale prediction, offering new insights in autoregressive algorithm design for computer vision.

An empirical validation of VAR models’ Scaling Laws and zero-shot generalization potential, which initially emulates the appealing properties of large language models (LLMs).

A breakthrough in visual autoregressive model performance, making GPT-style autoregressive methods surpass strong diffusion models in image synthesis for the first time A related work named “language model beats diffusion” belongs to BERT-style masked-prediction model. .

A comprehensive open-source code suite, including both VQ tokenizer and autoregressive model training pipelines, to help propel the advancement of visual autoregressive learning.

Related Work

Scaling laws. Power-law scaling laws mathematically describe the relationship between the growth of model parameters, dataset sizes, computational resources, and the performance improvements of machine learning models, conferring several distinct benefits. First, they facilitate the extrapolation of a larger model’s performance through the scaling up of model size, data size, and computational cost. This helps save unnecessary costs and provides principles to allocate the training budget. Second, the scaling laws have evidenced a consistent and non-saturating increase in performance, corroborating their sustained advantage in enhancing model capability. Propelled by the principles of scaling laws in neural language models , several Large Language Models have been proposed, embodying the principle that increasing the scale of models tends to yield enhanced performance outcomes. GPT , predicated on a transformer decoder architecture, undergoes generative pre-training and scales the model size to an unprecedented 175B parameters. LLama release a collection of pre-trained and fine-tuned large language models (LLMs) ranging in scale from 7 billion to 70 billion parameters. The manifest efficacy of scaling laws applied to language models has proffered a glimpse into the promising potential of upscale in visual models .

Zero-shot generalization. Zero-shot generalization refers to the ability of a model, particularly a Large Language Model, to perform tasks that it has not been explicitly trained on. Within the realm of the vision community, there is a burgeoning interest in the zero-shot and in-context learning abilities of foundation models, CLIP , SAM , Dinov2 . Innovations like Painter and LVM have leveraged visual prompts to design in-context learning paradigms, thereby facilitating the generalization to downstream unseen tasks.

2 Visual generation

Image tokenizer and autoregressive models. Language models rely on Byte Pair Encoding (BPE ) or WordPiece algorithms for text tokenization. Visual generation models based on language models also necessitate the encoding of 2D images into 1D token sequences. Early endeavors VQVAE have demonstrated the ability to represent images as discrete tokens, although the reconstruction quality was relatively moderate. VQGAN advances VQVAE by incorporating adversarial loss and perceptual loss to improve image fidelity, and employs a decoder-only transformer to generate image tokens in standard raster-scan autoregressive manner. VQVAE-2 and RQ-Transformer also follow VQGAN’s raster-scan autoregressive method but further improve VQVAE via extra scales or stacked codes. Parti capitalizes on the foundational architecture of ViT-VQGAN to scale the transformer model size to 20 billion parameters, achieving remarkable results in text-to-image synthesis.

Masked-prediction model. MaskGIT employs a masked prediction framework alongside a VQ autoencoder to generate image tokens based through a “greedy” algorithm. MagViT adapts this approach to video data, and MagViT-2 enhances MaskGIT by introducing an improved VQVAE. MUSE scales MaskGIT’s architecture to 3 billion parameters and merges it with the T5 language model , setting new benchmarks in text-to-image synthesis.

Diffusion models are considered the forefront of visual synthesis, given their superior generation quality and diversity. Progress in diffusion models has centered around improved sampling techniques, faster sampling , and architectural enhancements . Imagen incorporates the T5 language model for text condition and builds an image generation system through multiple independent diffusion models for cascaded generation and super resolution. Latent Diffusion Models (LDM) apply diffusion in latent space, improving efficiency in training and inference. DiT replaces the traditional U-Net with a transformer-based architecture , and is used in recent image or video synthesis systems like Stable Diffusion 3.0 and SORA .

Method

Formulation. Consider a sequence of discrete tokens x=(x1,x2,,xT)x=(x_{1},x_{2},\dots,x_{T}), where each token xt[V]x_{t}\in[V] is an integer from a vocabulary of size VV. The next-token autoregressive model posits that the probability of observing the current token xtx_{t} depends only on its prefix (x1,x2,,xt1)(x_{1},x_{2},\dots,x_{t-1}). This assumption of unidirectional token dependency allows us to decompose the likelihood of sequence xx into the product of TT conditional probabilities:

Training an autoregressive model pθp_{\theta} parameterized by θ\theta involves optimizing the pθ(xtx1,x2,,xt1)p_{\theta}(x_{t}\mid x_{1},x_{2},\dots,x_{t-1}) across a dataset. This optimization process is known as the “next-token prediction”, and the trained pθp_{\theta} can generate new sequences.

where lookup(Z,v)\text{lookup}(Z,v) means taking the vv-th vector in codebook ZZ. To train the quantized autoencoder, ZZ is looked up by every q(i,j)q^{(i,j)} to get f^\hat{f}, the approximation of original ff. Then a new image im^\hat{im} is reconstructed using the decoder D()\mathcal{D}(\cdot) given f^\hat{f}, and a compound loss L\mathcal{L} is minimized:

where LP()\mathcal{L}_{\text{P}}(\cdot) is a perceptual loss such as LPIPS , LG()\mathcal{L}_{\text{G}}(\cdot) a discriminative loss like StyleGAN’s discriminator loss , and λP\lambda_{\text{P}}, λG\lambda_{\text{G}} are loss weights. Once the autoencoder {E,Q,D}\{\mathcal{E},\mathcal{Q},\mathcal{D}\} is fully trained, it will be used to tokenize images for subsequent training of a unidirectional autoregressive model.

The image tokens in q[V]h×wq\in[V]^{h\times w} are arranged in a 2D grid. Unlike natural language sentences with an inherent left-to-right ordering, the order of image tokens must be explicitly defined for unidirectional autoregressive learning. Previous AR methods flatten the 2D grid of qq into a 1D sequence x=(x1,,xh×w)x=(x_{1},\dots,x_{h\times w}) using some strategy such as row-major raster scan, spiral, or z-curve order. Once flattened, they can extract a set of sequences xx from the dataset, and then train an autoregressive model to maximize the likelihood in (1) via next-token prediction.

Discussion. The above tokenizing and flattening enable next-token autoregressive learning on images, but they introduce several issues:

Mathematical premise violation. Image encoders typically produce image feature map ff with inter-dependent feature vectors f(i,j)f^{(i,j)} for all i,ji,j. So after quantization and flattening, the sequence of tokens (x1,x2,,xh×w)(x_{1},x_{2},\dots,x_{h\times w}) exhibits bidirectional correlations. This contradicts the unidirectional dependency assumption of autoregressive models, which dictates that each token xtx_{t} should only depend on its prefix (x1,x2,,xt1)(x_{1},x_{2},\dots,x_{t-1}).

Structural degradation. The flattening disrupts the spatial locality inherent in image feature maps. For instance, the token q(i,j)q^{(i,j)} and its 4 immediate neighbors q(i±1,j)q^{(i\pm 1,j)}, q(i,j±1)q^{(i,j\pm 1)} are closely correlated due to their proximity. This spatial relationship is compromised in the linear sequence xx, where unidirectional constraints diminish these correlations.

Inefficiency. Generating an image token sequence x=(x1,x2,,xn×n)x=(x_{1},x_{2},\dots,x_{n\times n}) with a conventional self-attention transformer incurs O(n2)\mathcal{O}(n^{2}) autoregressive steps and O(n6)\mathcal{O}(n^{6}) computational cost.

The disruption of spatial locality (issue 2) is obvious. Regarding issue 1, we present empirical evidence in the Appendix, analyzing the token dependencies in the popular quantized autoencoder and revealing significant bidirectional correlations. The proof of computational complexity for issue 3 is detailed in the Appendix. These theoretical and practical limitations call for a rethinking of autoregressive models in the context of image generation.

2 Visual autoregressive modeling via next-scale prediction

where each autoregressive unit rk[V]hk×wkr_{k}\in[V]^{h_{k}\times w_{k}} is the token map at scale kk, and the sequence (r1,r2,,rk1)(r_{1},r_{2},\dots,r_{k-1}) serves as the the “prefix” for rkr_{k}. During the kk-th autoregressive step, all distributions over the hk×wkh_{k}\times w_{k} tokens in rkr_{k} are inter-dependent and will be generated in parallel, conditioned on rkr_{k}’s prefix and associated kk-th position embedding map. This “next-scale prediction” methodology is what we define as visual autoregressive modeling (VAR), depicted on the right side of Fig. 4.

Discussion. VAR addresses the previously mentioned three issues as follows:

The mathematical premise is satisfied if we constrain each rkr_{k} to depend only on its prefix, that is, the process of getting rkr_{k} is solely related to (r1,r2,,rk1)(r_{1},r_{2},\dots,r_{k-1}). This constraint is acceptable as it aligns with the natural, coarse-to-fine progression characteristics like human visual perception and artistic drawing. Further details are provided in the Tokenization below.

The spatial locality is preserved as (i) there is no flattening operation in VAR, and (ii) tokens in each rkr_{k} are fully correlated. The multi-scale design additionally reinforces the spatial structure.

The complexity for generating an image with n×nn\times n latent is significantly reduced to O(n4)\mathcal{O}(n^{4}), see Appendix for proof. This efficiency gain arises from the parallel token generation in each rkr_{k}.

Tokenization. We develope a new multi-scale quantization autoencoder to encode an image to KK multi-scale discrete token maps R=(r1,r2,,rK)R=(r_{1},r_{2},\dots,r_{K}) necessary for VAR learning (6). We employ the same architecture as VQGAN but with a modified multi-scale quantization layer. The encoding and decoding procedures with residual design on ff or f^\hat{f} are detailed in algorithms 1 and 2. We empirically find this residual-style design, akin to , can perform better than independent interpolation. Algorithm 1 shows that each rkr_{k} would depend only on its prefix (r1,r2,,rk1)(r_{1},r_{2},\dots,r_{k-1}). Note that a shared codebook ZZ is utilized across all scales, ensuring that each rkr_{k}’s tokens belong to the same vocabulary [V][V]. To address the information loss in upscaling zkz_{k} to hK×wKh_{K}\times w_{K}, we use KK extra convolution layers {ϕk}k=1K\{\phi_{k}\}_{k=1}^{K}. No convolution is used after downsampling ff to hk×wkh_{k}\times w_{k}.

3 Implementation details

VAR tokenizer. As aforementioned, we use the vanilla VQVAE architecture with a multi-scale quantization scheme with KK extra convolutions (0.03M extra parameters). We use a shared codebook for all scales with V=4096V=4096 and a latent dim of 32. Following the baseline , our tokenizer is also trained on OpenImages with the compound loss (5). See the Appendix for more details.

VAR transformer. Our main focus is on VAR algorithm so we keep a simple model architecture design. We adopt the architecture of standard decoder-only transformers akin to GPT-2 and VQGAN , with the only modification of substituting traditional layer normalization for adaptive normalization (AdaLN) – a choice motivated by its widespread adoption and proven effectiveness in visual generative models . For class-conditional synthesis, we use the class embedding as the start token [s] and also the condition of AdaLN. We do not use advanced techniques in modern large language models, such as rotary position embedding (RoPE), SwiGLU MLP, or RMS Norm . Our model shape hyperparameter follows a simple rule that the width ww, head counts hh, and drop rate drdr are linearly scaled with the depth dd as follows:

Consequently, the main parameter count NN of a VAR transformer with depth dd is given byDue to resource limitation, we use a single shared adaptive layernorm (AdaLN) acorss all attention blocks in 512×\times512 synthesis. In this case, the parameter count would be reduced to around 12dw2+6w249152d312dw^{2}+6w^{2}\approx 49152\,d^{3}. :

All models are trained with the similar settings: a base learning rate of 10410^{-4} per 256 batch size, an AdamW optimizer with β1=0.9\beta_{1}=0.9, β2=0.95\beta_{2}=0.95, decay=0.05\text{decay}=0.05, a batch size from 512 to 1024 and training epochs from 200 to 350 (depends on model size). Our subsequent evaluations in Sec. 4 will suggest that such a simple model design are capable of scaling and generalizing well.

Empirical Results

This section first compares VAR with other image generative model familiesFor fairness, methods with advanced VQVAE are excluded in this model family comparison, e.g. the BERT-style masked-pred model MagViT-2 . Practitioners can combine them with VAR for better results. in terms of performance and and efficiency in Sec. 4.1. Evaluations on the scalability and generalizability of VAR models are presented in Sec. 4.2 and Sec. 4.3. We do some ablations and visualizations at the end.

Setup. We test VAR models with depths 16, 20, 24, and 30 on ImageNet 256×\times256 and 512×\times512 conditional generation benchmarks and compare them with the state-of-the-art image generation model families. Among all VQVAE-based AR or VAR models, VQGAN and ours use the same architecture (CNN) and training data (OpenImages ) for VQVAE, while ViT-VQGAN uses a ViT autoencoder, and both it and RQTransformer trains the VQVAE directly on ImageNet. The results are summaried in Tab. 1 and Tab. 2.

Overall comparison. In comparison with existing generative approaches including generative adversarial networks (GAN), diffusion models (Diff.), BERT-style masked-prediction models (Mask.), and GPT-style autoregressive models (AR), our visual autoregressive (VAR) establishes a new model class. As shown in Tab. 1, VAR not only achieves the best FID/IS but also demonstrates remarkable speed in image generation. VAR also maintains decent precision and recall, confirming its semantic consistency. These advantages hold true on the 512×\times512 synthesis benchmark, as detailed in Tab. 2. Notably, VAR significantly advances traditional AR capabilities. To our knowledge, this is the first time of autoregressive models outperforming Diffusion transformers, a milestone made possible by VAR’s resolution of AR limitations discussed in Section 3.

Efficiency comparison. Conventional autoregressive (AR) models suffer a lot from the high computational cost, as the number of image tokens is quadratic to the image resolution. A full autoregressive generation of n2n^{2} tokens requires O(n2)\mathcal{O}(n^{2}) decoding iterations and O(n6)\mathcal{O}(n^{6}) total computations. In contrast, VAR only requires O(log(n))\mathcal{O}(\log(n)) iterations and O(n4)\mathcal{O}(n^{4}) total computations. The wall-clock time reported in Tab. 1 also provides empirical evidence that VAR is around 20 times faster than VQGAN and ViT-VQGAN even with more model parameters, reaching the speed of efficient GAN models which only require 1 step to generate an image.

Compared with popular diffusion transformer. do not report DiT-L/2’s performance with CFG so we use official code to reproduce it. The VAR model surpasses the recently popular diffusion models Diffusion Transformer (DiT), which serves as the precursor to the latest Stable-Diffusion 3 and SORA , in multiple dimensions: 1) In image generation diversity and quality (FID and IS), VAR with 2B parameters consistently performs better than DiT-XL/2 , L-DiT-3B, and L-DiT-7B . VAR also maintains comparable precision and recall. 2) For inference speed, the DiT-XL/2 requires 45×\times the wall-clock time compared to VAR, while 3B and 7B models would cost much more. 3) VAR is considered more data-efficient, as it requires only 350 training epochs compared to DiT-XL/2’s 1400. 4) For scalability, Fig. 3 and Tab. 1 show that DiT only obtains marginal or even negative gains beyond 675M parameters. In contrast, the FID and IS of VAR are consistently improved, aligning with the scaling law study in Sec. 4.2. These results establish VAR as a more efficient and scalable model for image generation than models like DiT.

2 Power-law scaling laws

Background. Prior research have established that scaling up autoregressive (AR) large language models (LLMs) leads to a predictable decrease in test loss LL. This trend correlates with parameter counts NN, training tokens TT, and optimal training compute CminC_{\text{min}}, following a power-law:

where XX can be any of NN, TT, or CminC_{\text{min}}. The exponent α\alpha reflects the smoothness of power-law, and LL denotes the reducible loss normalized by irreducible loss LL_{\infty} See for some theoretical explanation on scaling laws on negative-loglikelihood losses.. A logarithmic transformation to LL and XX will reveal a linear relation between log(L)\log(L) and log(X)\log(X):

These observed scaling laws not only validate the scalability of LLMs but also serve as a predictive tool for AR modeling, which facilitates the estimation of performance for larger AR models based on their smaller counterparts, thereby saving resource usage by large model performance forecasting. Given these appealing properties of scaling laws brought by LLMs, their replication in computer vision is therefore of significant interest.

Setup of scaling VAR models. Following the protocols from , we examine whether our VAR model complies with similar scaling laws. We trained models across 12 different sizes, from 18M to 2B parameters, on the ImageNet training set containing 1.28M images (or 870B image tokens under our VQVAE) per epoch. For models of different sizes, training spanned 200 to 350 epochs, with a maximum number of tokens reaching 305 billion. Below we focus on the scaling laws with model parameters NN and optimal training compute CminC_{\text{min}} given sufficient token count TT.

Scaling laws with model parameters NN. We first investigate the test loss trend as the VAR model size increases. The number of parameters N(d)=73728d3N(d)=73728\,d^{3} for a VAR transformer with depth dd is specified in (8). We varied dd from 66 to 3030, yielding 12 models with 18.5M to 2.0B parameters. We assessed the final test cross-entropy loss LL and token prediction error rates ErrErr on the ImageNet validation set of 50,000 images . We computed LL and ErrErr for both the last scale (at the last next-scale autoregressive step), as well as the global average. The results are plotted in Fig. 5, where we observed a clear power-law scaling trend for LL as a function of NN, as consistent with . The power-law scaling laws can be expressed as:

Although the scaling laws are mainly studied on the test loss, we also empirically observed similar power-law trends for the token error rate ErrErr:

These results verify the strong scalability of VAR, by which scaling up VAR transformers can continuously improve the model’s test performance.

Scaling laws with optimal training compute CminC_{\text{min}}. We then examine the scaling behavior of VAR transformers when increasing training compute CC. For each of the 12 models, we traced the test loss LL and token error rate ErrErr as a function of CC during training quoted in PFlops (101510^{15} floating-point operations per second). The results are plotted in Fig. 6. Here, we draw the Pareto frontier of LL and ErrErr to highlight the optimal training compute CminC_{\text{min}} required to reach a certain value of loss or error.

The fitted power-law scaling laws for LL and ErrErr as a function of CminC_{\text{min}} are:

These relations (13, 14) hold across 6 orders of magnitude in CminC_{\text{min}}, and our findings are consistent with those in : when trained with sufficient data, larger VAR transformers are more compute-efficient because they can reach the same level of performance with less computation.

Visualizations. To better understand how VAR models are learning when scaled up, we compare some generated 256×256256\times 256 samples from VAR models of 4 different sizes (depth 6, 16, 26, 30) and 3 different training stages (20%, 60%, 100% of total training tokens) in Fig. 7. To keep the content consistent, a same random seed and teacher-forced initial tokens are used. The observed improvements in visual fidelity and soundness are consistent with the scaling laws, as larger transformers are thought able to learn more complex and fine-grained image distributions.

3 Zero-shot task generalization

Image in-painting and out-painting. VAR-dd30 is tested. For in- and out-painting, we teacher-force ground truth tokens outside the mask and let the model only generate tokens within the mask. No class label information is injected into the model. The results are visualized in Fig. 8. Without modifications to the network architecture or tuning parameters, VAR has achieved decent results on these downstream tasks, substantiating the generalization ability of VAR.

Class-conditional image editing. Following MaskGIT we also tested VAR on the class-conditional image editing task. Similar to the case of in-painting, the model is forced to generate tokens only in the bounding box conditional on some class label. Fig. 8 shows the model can produce plausible content that fuses well into the surrounding contexts, again verifying the generality of VAR.

4 Ablation Study

In this study, we aim to verify the effectiveness and efficiency of our proposed VAR framework. Results are reported in Tab. 3.

Effectiveness and efficiency of VAR. Starting from the vanilla AR transformer baseline implemented by , we replace its methodology with our VAR and keep other settings unchanged to get row 2. VAR achieves a way more better FID (18.65 vs. 5.22) with only 0.013×\times inference wall-clock cost than the AR model, which demonstrates a leap in visual AR model’s performance and efficiency.

Component-wise ablation. We further test some key components in VAR. By replacing the standard Layer Normalization (LN) with Adaptive Layer Normalization (AdaLN), VAR starts yielding better FID than baseline. By using the top-kk sampling similar to the baseline, VAR’s FID is further improved. By using the classifier-free guidance (CFG) with ratio 2.02.0, we reach the FID of 3.60, which is 15.05 lower to the baseline, and its inference is still 45 times faster. Due to the observed effectiveness, we equip our final VAR models with AdaLN, top-kk sampling, and classifier-free guidance. We finally scale up VAR size to 2.0B and achieve an FID of 1.80. This is 16.85 better than the baseline FID.

Future Work

In this work, we mainly focus on the design of learning paradigm and keep the VQVAE architecture and training unchanged from the baseline to better justify VAR framework’s effectiveness. We expect advancing VQVAE tokenizer as another promising way to enhance autoregressive generative models, which is orthogonal to our work. We believe iterating VAR by advanced tokenizer or sampling techniques in these latest work can further improve VAR’s performance or speed.

Text-prompt generation is an ongoing direction of our research. Given that our model is fundamentally similar to modern LLMs, it can easily be integrated with them to perform text-to-image generation through either an encoder-decoder or in-context manner. This is currently in our high priority for exploration.

Video generation is not implemented in this work, but it can be naturally extended. By considering multi-scale video features as 3D pyramids, we can formulate a similar “3D next-scale prediction” to generate videos via VAR. Compared to diffusion-based generators like SORA , our method has inherent advantages in temporal consistency or integration with LLMs, thus can potentially handle longer temporal dependencies. This makes VAR competitive in the video generation field, because traditional AR models can be too inefficient for video generation due to their extremely high computational complexity and slow inference speed: it is becoming prohibitively expensive to generate high-resolution videos with traditional AR models, while VAR is capable to solve this. We therefore foresee a promising future for exploiting VAR models in the realm of video generation.

Conclusion

We introduced a new visual generative framework named Visual AutoRegressive modeling (VAR) that 1) theoretically addresses some issues inherent in standard image autoregressive (AR) models, and 2) makes language-model-based AR models first surpass strong diffusion models in terms of image quality, diversity, data efficiency, and inference speed. Upon scaling VAR to 2 billion parameters, we observed a clear power-law relationship between test performance and model parameters or training compute, with Pearson coefficients nearing 0.998-0.998, indicating a robust framework for performance prediction. These scaling laws and the possibility for zero-shot task generalization, as hallmarks of LLMs, have now been initially verified in our VAR transformer models. We hope our findings and open sources can facilitate a more seamless integration of the substantial successes from the natural language processing domain into computer vision, ultimately contributing to the advancement of powerful multi-modal intelligence.

Appendix A Token dependency in VQVAE

To examine the token dependency in VQVAE , we check the attention scores in the self-attention layer before the vector quantization module. We randomly sample 4 256×\times256 images from the ImageNet validation set for this analysis. Note the self-attention layer in only has 1 head so for each image we just plot one attention map. The heat map in Fig. 9 shows the attention scores of each token to all other tokens, which indicate a strong, bidirectional dependency among all tokens. This is not surprising since the VQVAE model, trained to reconstruct images, leverages self-attention layers without any attention mask. Some work has used causal attention in self-attention layers of a video VAE, but we did not find any image VAE work uses causal self-attention.

Appendix B Time complexity of AR and VAR generation

We prove the time complexity of AR and VAR generation.

For a standard self-attention transformer, the time complexity of AR generation is O(n6)\mathcal{O}(n^{6}), where h=w=nh=w=n and h,wh,w are the height and width of the VQ code map, respectively.

The total number of tokens is h×w=n2h\times w=n^{2}. For the ii-th (1in21\leq i\leq n^{2}) autoregressive iteration, the attention scores between each token and all other tokens need to be computed, which requires O(i2)\mathcal{O}(i^{2}) time. So the total time complexity would be:

Which is equivalent to O(n6)\mathcal{O}(n^{6}) basic computation. ∎

For VAR, it needs us to define the resolution sequense (h1,w1,h2,w2,,hK,wK)(h_{1},w_{1},h_{2},w_{2},\dots,h_{K},w_{K}) for autoregressive generation, where hi,wih_{i},w_{i} are the height and width of the VQ code map at the ii-th autoregressive step, and hK=h,wK=wh_{K}=h,w_{K}=w reaches the final resolution. Suppose nk=hk=wkn_{k}=h_{k}=w_{k} for all 1kK1\leq k\leq K and n=h=wn=h=w, for simplicity. We set the resolutions as nk=a(k1)n_{k}=a^{(k-1)} where a>1a>1 is a constant such that a(K1)=na^{(K-1)}=n.

For a standard self-attention transformer and given hyperparameter a>1a>1, the time complexity of VAR generation is O(n4)\mathcal{O}(n^{4}), where h=w=nh=w=n and h,wh,w are the height and width of the last (largest) VQ code map, respectively.

Consider the kk-th (1kK1\leq k\leq K) autoregressive generation. The total number of tokens of current all token maps (r1,r2,,rk)(r_{1},r_{2},\dots,r_{k}) is:

So the time complexity of the kk-th autoregressive generation would be:

By summing up all autoregressive generations, we have:

References