用优化新键值对压缩注意力缓存,显著提升长文本生成效率。
KVSculpt: KV Cache Compression as Distillation
- 不选也不合并原键值对,而是优化少量自由参数的连续嵌入
- 在2048令牌上下文中,相比现有方法降低3.5至4.1倍的注意力误差
- 动态分配压缩预算,让难压缩层获得更多资源,无额外计算开销
KV缓存压缩对高效长上下文大模型推理至关重要。现有方法在序列长度维度上主要分为纯淘汰(选择保留哪些键值对)和合并(将相似对合并为更少数量),均依赖原始缓存条目。本文提出KVSculpt,从该谱系另一端出发:不筛选或合并原始对,而是通过连续嵌入空间中优化一组无约束的更小键值对,以保持每层注意力行为。键通过L-BFGS优化,值则通过最小二乘法闭式求解,每几步交替进行。此外,引入自适应预算分配机制,利用一次低成本预压缩运行,根据各组件难度动态分配压缩预算至不同层与注意力头。在Qwen2.5-1.5B-Instruct模型、2048令牌上下文下,相较于Select+Fit(注意力得分淘汰+最小二乘值拟合),在压缩比r ∈ {0.3, 0.5, 0.7}时,KL散度降低3.5–4.1倍;自适应分配带来额外1.3倍的降噪收益,且无额外推理开销。分析显示压缩难度极不均匀:各层间预估均方误差差异达100倍,单层内两注意力头间差异高达467倍,证明细粒度预算分配至关重要。
原文摘要 · Abstract (English)
KV cache compression is critical for efficient long-context LLM inference. Approaches that reduce the per-pair footprint -- quantization and low-rank decomposition -- are orthogonal to those that reduce the sequence length of the cache. Along the sequence-length dimension, existing methods range from pure eviction -- selecting which KV pairs to keep -- to merging, which combines similar pairs into fewer ones. Both remain anchored to the original cache entries. We propose KVSculpt, which moves to the other end of this spectrum: instead of selecting or combining original pairs, we optimize a smaller set of unconstrained KV pairs in continuous embedding space to preserve each layer's attention behavior. Keys are optimized via L-BFGS and values are solved in closed form via least squares, alternating every few steps. On top of this, we introduce adaptive budget allocation, which uses a cheap pilot compression run to redistribute the compression budget across layers and KV heads based on per-component difficulty. On Qwen2.5-1.5B-Instruct with 2048-token contexts, KVSculpt reduces KL divergence by 3.5-4.1x compared to Select+Fit -- attention-score eviction with least-squares value fitting -- across compression ratios r in {0.3, 0.5, 0.7}. Adaptive allocation provides an additional 1.3x KL reduction at no extra inference cost. Analysis reveals that compression difficulty is highly non-uniform: per-layer pilot MSE varies by up to 100x across layers, and the two KV heads within a single layer can differ by up to 467x -- demonstrating that fine-grained budget allocation is essential.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。