arXiv:2506.12035cs.LGcs.AI2025-06

通过缓存注意力与选择性刷新,提升掩码自回归图像生成速度

MARché: Fast Masked Autoregressive Image Generation with Cache-Aware Attention

  • 分活跃与缓存令牌,分别处理以复用计算结果
  • 仅更新关键上下文相关令牌,减少冗余计算达1.7倍
  • 无需训练,适配现有模型,适合高效图像生成场景

掩码自回归(MAR)模型通过固定顺序预测并利用双向注意力生成图像,兼具掩码与自回归优势。但其在解码每一步时需重新计算所有令牌的注意力与前馈表示,导致显著计算开销,尽管多数令牌语义稳定。本文提出无需训练的MARché框架,包含缓存注意力与选择性键值刷新机制:缓存注意力将令牌分为活跃与缓存集,实现独立计算路径,高效复用先前的键/值投影;然而缓存令牌不可无限使用,因上下文随步骤变化。MARché据此引入选择性键值刷新:基于新生成令牌的注意力分数识别上下文相关令牌,仅对需更新者重新计算,其余保持不变,从而维持图像质量。实验表明,MARché在不改变原架构前提下,实现最高1.7倍加速,显著降低冗余计算,为高效掩码变压器生成提供可扩展、普适解决方案。

原文摘要 · Abstract (English)

Masked autoregressive (MAR) models unify the strengths of masked and autoregressive generation by predicting tokens in a fixed order using bidirectional attention for image generation. While effective, MAR models suffer from significant computational overhead, as they recompute attention and feed-forward representations for all tokens at every decoding step, despite most tokens remaining semantically stable across steps. We propose a training-free generation framework MARché to address this inefficiency through two key components: cache-aware attention and selective KV refresh. Cache-aware attention partitions tokens into active and cached sets, enabling separate computation paths that allow efficient reuse of previously computed key/value projections without compromising full-context modeling. But a cached token cannot be used indefinitely without recomputation due to the changing contextual information over multiple steps. MARché recognizes this challenge and applies a technique called selective KV refresh. Selective KV refresh identifies contextually relevant tokens based on attention scores from newly generated tokens and updates only those tokens that require recomputation, while preserving image generation quality. MARché significantly reduces redundant computation in MAR without modifying the underlying architecture. Empirically, MARché achieves up to 1.7x speedup with negligible impact on image quality, offering a scalable and broadly applicable solution for efficient masked transformer generation.

图像生成自回归缓存优化注意力机制

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。