提出分头压缩方法,让视觉自回归模型生成更快更省内存。
Head-Aware KV Cache Compression for Efficient Visual Autoregressive Modeling
- 按注意力头功能分类,分别采用不同压缩策略。
- 最高压缩70%缓存,保持图像质量不变。
- 无需训练,适合作为通用加速插件使用。
视觉自回归(VAR)模型通过逐尺度预测实现高质量内容生成,且解码步数显著减少。然而,现有模型因多尺度键值(KV)缓存累积导致注意力复杂度高、内存开销大。本文提出一种无需训练的分头感知KV缓存压缩框架HACK。关键观察发现:注意力头可分为语义一致性保持的上下文头与空间连贯性维护的结构头,现有统一压缩方法效果不佳。HACK通过离线分类区分头类型,对不同类别施加特定压缩策略和不对称缓存预算,将平均KV缓存长度控制在固定预算B内,使理论注意力复杂度从$/mathcal{O}(n^4)$降至$/mathcal{O}(Bn^2)$。在多个文本到图像及类别条件任务的VAR模型上验证,HACK最多实现70%缓存压缩,不损失输出质量,带来显著内存节省与推理加速。例如,在Infinity-8B上实现1.75倍内存减少与1.57倍速度提升。
原文摘要 · Abstract (English)
Visual Autoregressive (VAR) models adopt a next-scale prediction paradigm, offering high-quality content generation with substantially fewer decoding steps. However, existing VAR models suffer from significant attention complexity and severe memory overhead due to the accumulation of key-value (KV) caches across scales. In this paper, we tackle this challenge by introducing KV cache compression into the next-scale generation paradigm. We begin with a crucial observation: attention heads in VAR models can be divided into two functionally distinct categories: Contextual Heads focus on maintaining semantic consistency, while Structural Heads are responsible for preserving spatial coherence. This structural divergence causes existing one-size-fits-all compression methods to perform poorly on VAR models. To address this, we propose HACK, a training-free Head-Aware KV cache Compression frameworK. HACK utilizes an offline classification scheme to separate head types, enabling it to apply pattern-specific compression strategies with asymmetric cache budgets for each category. By doing so, HACK effectively constrains the average KV cache length within a fixed budget $B$, reducing the theoretical attention complexity from $\mathcal{O}(n^4)$ to $\mathcal{O}(Bn^2)$. Extensive experiments on multiple VAR models across text-to-image and class-conditional tasks validate the effectiveness and generalizability of HACK. It achieves up to 70% KV cache compression without degrading output quality, resulting in memory savings and faster inference. For example, HACK provides a $1.75\times$ memory reduction and a $1.57\times$ speedup on Infinity-8B.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。