arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.07651cs.CLcs.AI
收藏

OBCache: 面向高效长上下文LLM推理的最优脑KV缓存剪枝

OBCache: Optimal Brain KV Cache Pruning for Efficient Long-Context LLM Inference

University of Science and Technology of China(中国科学技术大学)

Yuzhe Gu, Xiyu Liang, Jiaojiao Zhao, Enmao Diao

AI总结:

提出OBCache框架,将缓存驱逐形式化为逐层结构化剪枝问题,基于最优脑损伤理论量化令牌显著性,通过输出感知分数改进现有驱逐策略,在长上下文任务中提升准确性。

摘要:

具有扩展上下文窗口的大型语言模型(LLM)实现了强大的应用,但带来了显著的内存开销,因为缓存所有键值(KV)状态随序列长度和批大小线性扩展。现有的缓存驱逐方法通过利用注意力稀疏性来解决这一问题,但它们通常使用累积注意力权重对令牌进行启发式排名,而不考虑其对注意力输出的真实影响。我们提出了最优脑缓存(OBCache),一个将缓存驱逐形式化为逐层结构化剪枝问题的原则性框架。基于最优脑损伤(OBD)理论,OBCache通过测量由剪枝令牌引起的注意力输出扰动来量化令牌显著性,并为孤立键、孤立值以及联合键值对推导出闭式分数。我们的分数不仅考虑了注意力权重,还考虑了值状态和注意力输出的信息,从而通过输出感知信号增强了现有的驱逐策略。在LLaMA和Qwen模型上的实验表明,将现有工作中跨不同查询位置估计令牌显著性的启发式分数替换为OBCache的输出感知分数,持续提高了长上下文准确性。代码可在 https://github.com/DreamSoul-AI/OBCache 获取。

英文摘要:

Large language models (LLMs) with extended context windows enable powerful applications but impose significant memory overhead, as caching all key-value (KV) states scales linearly with sequence length and batch size. Existing cache eviction methods address this by exploiting attention sparsity, yet they typically rank tokens heuristically using accumulated attention weights without considering their true impact on attention outputs. We propose Optimal Brain Cache (OBCache), a principled framework that formulates cache eviction as a layer-wise structured pruning problem. Building upon the Optimal Brain Damage (OBD) theory, OBCache quantifies token saliency by measuring the perturbation in attention outputs induced by pruning tokens, with closed-form scores derived for isolated keys, isolated values, and joint key-value pairs. Our scores account not only for attention weights but also for information from value states and attention outputs, thereby enhancing existing eviction strategies with output-aware signals. Experiments on LLaMA and Qwen models demonstrate that replacing the heuristic scores in existing works, which estimate token saliency across different query positions, with OBCache's output-aware scores consistently improves long-context accuracy. Code is available at https://github.com/DreamSoul-AI/OBCache.

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

↑