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

CriticalKV: 从输出扰动角度优化 KV 缓存淘汰

CriticalKV: Optimizing KV Cache Eviction from an Output Perturbation Perspective

School of Computer Science, University of Science and Technology of China(科学技术大学计算机科学学院);School of Biomedical Engineering, USTC(USTC生物医学工程学院);Data Darkness Lab, MIRACLE Center, Suzhou Institute for Advanced Research(苏州先进研究院数据黑暗实验室、奇迹中心);School of Computer Science and Technology, Xidian University(西安电子科技大学计算机科学与技术学院)

Yuan Feng, Junlin Lv, Haoyu Guo, Yukun Cao, S Kevin Zhou, Xike Xie

AI总结:

本文通过分析注意力输出扰动,提出一种基于扰动约束的 KV 缓存条目选择算法,显著降低压缩损失。

摘要:

大型语言模型彻底改变了自然语言处理,但由于 Transformer 架构对自注意力的依赖,特别是长序列推理中的大型 KV 缓存,面临着高存储和运行时成本的重大挑战。最近通过基于注意力权重剪枝不太重要的条目来减小 KV 缓存大小的努力仍然是经验性的,缺乏形式化基础。本文通过分析注意力输出扰动,对识别关键 KV 缓存条目进行了形式化研究。我们的分析表明,除了注意力权重之外,KV 条目中的值状态和预训练参数矩阵也至关重要。基于此,我们提出了一种扰动约束选择算法,该算法优化最坏情况下的输出扰动以识别关键条目。我们证明了我们的算法是一种通用的、即插即用的增强方法,且计算开销可忽略不计。当与三种最先进的缓存淘汰方法集成在三个不同的 LLM 上时,我们的算法在来自 Ruler 和 LongBench 基准测试的 29 个数据集上,平均将压缩损失减少了超过一半。进一步的头部和层级的扰动分析证实了我们有效性背后的原理。这项工作为缓存淘汰提供了新的、形式化的视角,为未来的研究开辟了有希望的途径。代码公开在 https://github.com/FFY0/DefensiveKV。

英文摘要:

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.

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

↑