arXiv:2502.03805cs.CL2025-02被引 22

从输出扰动角度优化大模型缓存淘汰,显著降低压缩损失。

CriticalKV: Optimizing KV Cache Eviction from an Output Perturbation Perspective

  • 通过分析注意力输出扰动,识别关键缓存条目
  • 在29个数据集上平均压缩损失减少超一半
  • 通用插件式设计,计算开销极小,适合所有大模型

大型语言模型虽推动自然语言处理发展,但因Transformer架构依赖自注意力机制,尤其在长序列推理中需大量KV缓存,导致存储与运行成本高昂。现有基于注意力权重剪枝缓存条目的方法多为经验性,缺乏理论基础。本文从输出扰动视角出发,系统分析关键缓存条目,发现不仅注意力权重,值状态及预训练参数矩阵也至关重要。据此提出受扰动约束的筛选算法,以最小化最坏情况下的输出扰动来识别关键条目。实验表明,该算法为通用、即插即用的增强方案,计算开销可忽略不计;集成于三种先进缓存淘汰方法,在三个不同LLM上,对29个来自Ruler和LongBench基准的数据集,平均压缩损失减少超过一半。头级别与层级别的扰动分析进一步验证了其有效性。本工作为缓存淘汰提供了新的形式化视角,开启未来研究新方向。代码已公开于https://github.com/FFY0/DefensiveKV。

原文摘要 · Abstract (English)

Large language models have revolutionized natural language processing but face significant challenges of high storage and runtime costs, due to the transformer architecture's reliance on self-attention, particularly the large KV cache for long-sequence inference. Recent efforts to reduce KV cache size by pruning less critical entries based on attention weights remain empirical and lack formal grounding. This paper presents a formal study on identifying critical KV cache entries by analyzing attention output perturbation. Our analysis reveals that, beyond attention weights, the value states within KV entries and pretrained parameter matrices are also crucial. Based on this, we propose a perturbation-constrained selection algorithm that optimizes the worst-case output perturbation to identify critical entries. We demonstrate that our algorithm is a universal, plug-and-play enhancement that incurs negligible computational overhead. When integrated with three state-of-the-art cache eviction methods on three distinct LLMs, our algorithm significantly reduces the compression loss by more than \textit{half} on average across 29 datasets from the Ruler and LongBench benchmarks. Further perturbation analysis, at both the head and layer levels, confirms the principles underlying our effectiveness. This work offers a new, formally grounded perspective to cache eviction , opening promising avenues for future research. The code is publicly available at https://github.com/FFY0/DefensiveKV.

大模型优化缓存管理注意力机制性能提升

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