RandAR: Decoder-only Autoregressive Visual Generation in Random Orders

Ziqi Pang, Tianyuan Zhang, Fujun Luan, Yunze Man, Hao Tan, Kai Zhang, William T. Freeman, Yu-Xiong Wang

Introduction

Autoregressive (AR) models have dominated visual generation by adapting the "next-token prediction" paradigm from Large Language Models. However, images are inherently two-dimensional, whereas text is one-dimensional. To bridge this gap, standard models like LlamaGen typically flatten images into a 1D sequence using a fixed "raster order" (top-left to bottom-right). This approach imposes a rigid inductive bias: the model can only attend to pixels above and to the left of the current target, limiting its ability to handle bi-directional context or tasks like inpainting naturally.

The RandAR Framework

RandAR (Random-order AutoRegressive) breaks this constraint by training on random token sequences. The core innovation is the Position Instruction Token. Instead of relying on sequence position to imply spatial location, RandAR inserts a coordinate token $P_i$ before every visual token $x_i$. This token explicitly informs the model of the 2D coordinates using 2D Rotary Positional Embeddings (2D-RoPE).

Overview of RandAR capabilities including random order generation, parallel decoding, inpainting, outpainting, and resolution extrapolation.

Random Order Training

During training, image tokens are shuffled into arbitrary sequences. The model learns to predict the next token based on a random subset of previously generated pixels from anywhere in the image. This removes the "raster order" crutch and forces the model to learn a more robust, order-agnostic distribution of visual data.

Advanced Inference Capabilities

By decoupling generation from a fixed order, RandAR unlocks several powerful features:

  1. Parallel Decoding: Since the model can predict tokens at any location, it can generate multiple tokens simultaneously. Using a cosine schedule to manage the number of tokens predicted per step, RandAR achieves a 2.5× speedup over standard sequential decoding (e.g., reducing generation time from 16.8s to 6.6s for a 1.4B parameter model).
  2. Zero-Shot Image Editing: Inpainting and outpainting become straightforward. Known pixels are provided as initial context, and the model fills in the remaining coordinates regardless of their spatial relationship to the "start" of a traditional sequence.
  3. Resolution Extrapolation: RandAR can generate 512×512 images despite being trained at 256×256. It employs a hierarchical strategy, first generating a low-resolution layout and then populating high-frequency details.

Performance and Results

Evaluations on the ImageNet 256×256 benchmark demonstrate that RandAR-XXL achieves an FID of 2.15, matching or exceeding the performance of state-of-the-art raster-order models. Beyond generation quality, RandAR's bi-directional feature extraction—achieved via a "second pass" where tokens attend to the full image context—significantly improves performance on semantic correspondence tasks, as measured on the SPair-71k dataset.

Conclusion

RandAR demonstrates that fixed generation orders are not a requirement for high-quality autoregressive visual synthesis. By treating position as a query, the model gains the flexibility of non-autoregressive models while retaining the simplicity and KV-cache efficiency of the decoder-only transformer architecture. Future work will focus on refining high-frequency detail generation at extreme resolutions and further optimizing parallel decoding schedules.

Summary updated

BibTeX
@inproceedings{pang2025randar,
  author = {Ziqi Pang and Tianyuan Zhang and Fujun Luan and Yunze Man and Hao Tan and Kai Zhang and William T. Freeman and Yu-Xiong Wang},
  title = {{RandAR: Decoder-only Autoregressive Visual Generation in Random Orders}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  url = {https://openreview.net/forum?id=S4e66AQh4B},
}
Figure