Autoregressive (AR) models have revolutionized text generation and are now making significant strides in the visual domain. By predicting the "next visual token" in a sequence, models like Janus and LlamaGen produce high-fidelity images. However, these models face a substantial hurdle during inference: the Key-Value (KV) cache. As an image is generated, the memory required to store previous tokens grows linearly, leading to increased latency and massive hardware requirements.
A new research paper introduces LineAR, a training-free method that dramatically reduces memory usage and boosts generation speed. The core insight is that, unlike text, image generation possesses unique 2D spatial dependencies that allow the model to function effectively while "forgetting" the majority of previously generated pixels.
The KV Cache Bottleneck in Image Generation
In AR image generation, an image is typically flattened into a long 1D sequence of tokens. To generate each subsequent token, the model must attend to all previous tokens, which are stored in a KV cache to avoid redundant computation. For a high-resolution $1024 \times 1024$ image, this sequence can exceed 4,000 tokens. Storing these for every layer of a large transformer consumes gigabytes of VRAM and slows down the attention mechanism significantly.
Methods: A 2D Raster-Line Perspective
LineAR addresses this by managing the KV cache through a 2D raster-line perspective rather than a 1D sequence. The approach relies on three primary components:
- 2D Cache Partitioning: LineAR divides the cache into three functional zones: Initial Anchors (the first tokens establishing global style), Recent Lines (tokens immediately preceding the current line for local context), and the Mid-region (older tokens between the two).
- Progressive Compression: Instead of a one-time purge, LineAR progressively evicts tokens from the "Mid-region" as generation moves down the image.
- Inter-line Guided Eviction: Because adjacent lines in an image are highly similar, the model uses the attention patterns of the current line to decide which tokens in the mid-region are least important and safe to delete.
Crucially, LineAR is training-free, meaning it can be integrated into existing pre-trained models like Janus or LlamaGen without any additional fine-tuning.
Key Insights: Why It Works
The researchers identified two critical properties of visual attention in AR models:
- Sink-Heavy Attention: As generation progresses, the model's attention shifts heavily toward the conditional tokens (the text prompt) and the very first visual tokens (the anchors). The "middle" tokens become increasingly redundant.
- Spatial Locality: Image generation is highly local. To draw a specific detail, the model primarily needs information about the immediate surrounding area, not distant parts of the image.
Performance and Results
LineAR delivers massive efficiency gains across various model architectures (Janus-Pro, Lumina-mGPT, and LlamaGen) while maintaining—and sometimes even improving—image quality.
Key results include:
- Speed & Memory: On LlamaGen-XL, LineAR achieved a 7.57× throughput speedup and a 67.61% reduction in memory usage. Janus-Pro-7B saw a 5.62× speedup.
- Quality Preservation: Surprisingly, on LlamaGen-XL, the FID score improved from 2.77 to 2.68 while using only 1/6th of the KV cache, suggesting that pruning redundant tokens may help the model focus on relevant context.
- Generality: The method was successfully validated across six different model architectures in a zero-shot manner.
Conclusion
LineAR demonstrates that "remembering everything" is an unnecessary and expensive habit for autoregressive image models. By exploiting 2D spatial locality and the sink-heavy nature of visual attention, LineAR provides a simple, effective, and training-free path toward high-speed, memory-efficient image generation.
Summary updated