arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2504.09261cs.CV
收藏

面向头部的KV缓存压缩以实现高效的视觉自回归建模

Head-Aware KV Cache Compression for Efficient Visual Autoregressive Modeling

Ziran Qin, Youru Lv, Mingbao Lin, Hang Guo, Zeren Zhang, Danping Zou, Weiyao Lin

AI总结:

HACK通过面向头部的KV缓存压缩技术,有效降低VAR模型的注意力复杂度和内存开销,实现70%的缓存压缩率和1.57倍的推理加速。

摘要:

视觉自回归(VAR)模型采用下一层预测范式,能够以显著更少的解码步骤生成高质量内容。然而,现有VAR模型由于在不同尺度上累积键值(KV)缓存而面临显著的注意力复杂度和严重的内存开销。在本文中,我们通过引入KV缓存压缩到下一层生成范式中来解决这一挑战。我们首先提出一个关键观察:VAR模型中的注意力头可以分为两种功能上不同的类别:上下文头专注于保持语义一致性,而结构头则负责保持空间一致性。这种结构差异导致现有的通用压缩方法在VAR模型上表现不佳。为此,我们提出了HACK,一个无需训练的面向头部的KV缓存压缩框架。HACK利用一种离线分类方案来分离头部类型,使其能够应用针对模式的压缩策略,并为每个类别分配不对称的缓存预算。通过这样做,HACK有效限制了平均KV缓存长度在固定预算B内,将理论上的注意力复杂度从O(n⁴)降低到O(Bn²)。在多个VAR模型上进行的广泛实验验证了HACK的有效性和通用性。它在不降低输出质量的情况下实现了高达70%的KV缓存压缩,从而实现了内存节省和更快的推理。例如,HACK在Infinity-8B上提供了1.75倍的内存减少和1.57倍的速度提升。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑