LazyMAR: Accelerating Masked Autoregressive Models via Feature Caching
Feihong Yan, Qingyan Wei, Jiayi Tang, Jiajun Li, Yulin Wang, Xuming Hu, Huiqi Li, Linfeng Zhang
TL;DR
This work addresses the efficiency bottleneck of Masked Autoregressive (MAR) models, whose bidirectional attention prevents effective KV caching. It introduces LazyMAR, a training-free, plug-and-play caching framework that exploits two redundancies: Token Redundancy and Condition Redundancy, via a Token Cache and a Condition Cache with a periodic cache-refresh strategy to bound error accumulation. By computing all tokens and both conditional/unconditional paths only in initial steps and then selectively reusing cached features or residuals, LazyMAR achieves about a 2.83× acceleration with minimal degradation in image quality on ImageNet 256×256 across MAR variants. The method is validated through extensive ablations, showing that both caches contribute to speedups and that a similarity-based token selection strategy yields the best results, making high-speed MAR generation practical without extra training.
Abstract
Masked Autoregressive (MAR) models have emerged as a promising approach in image generation, expected to surpass traditional autoregressive models in computational efficiency by leveraging the capability of parallel decoding. However, their dependence on bidirectional self-attention inherently conflicts with conventional KV caching mechanisms, creating unexpected computational bottlenecks that undermine their expected efficiency. To address this problem, this paper studies the caching mechanism for MAR by leveraging two types of redundancy: Token Redundancy indicates that a large portion of tokens have very similar representations in the adjacent decoding steps, which allows us to first cache them in previous steps and then reuse them in the later steps. Condition Redundancy indicates that the difference between conditional and unconditional output in classifier-free guidance exhibits very similar values in adjacent steps. Based on these two redundancies, we propose LazyMAR, which introduces two caching mechanisms to handle them one by one. LazyMAR is training-free and plug-and-play for all MAR models. Experimental results demonstrate that our method achieves 2.83 times acceleration with almost no drop in generation quality. Our codes will be released in https://github.com/feihongyan1/LazyMAR.
