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

让每个token计数:通过KV缓存淘汰提升长上下文性能

Make Each Token Count: Towards Improving Long-Context Performance with KV Cache Eviction

Department of Computer Science Yale University(耶鲁大学计算机科学系);The Chinese University of Hong Kong(香港中文大学)

Ngoc Bui, Hieu Trung Nguyen, Arman Cohan, Rex Ying

AI总结:

本文提出一种基于全局保留的KV缓存淘汰方法,通过学习每个token的未来效用,减少缓存内存占用并提升长上下文推理性能。

摘要:

关键值(KV)缓存是长上下文推理中的主要瓶颈,其中内存和计算量随序列长度增加而增长。现有KV淘汰方法减少了成本,但通常会降低性能相对于全缓存推理。我们的关键见解是全缓存注意力不总是最优:在长上下文中,无关token会稀释注意力远离有用证据,因此选择性、可学习的淘汰可以改善生成而非仅仅近似全缓存。我们引入了一种基于全局保留的KV淘汰方法,该方法在统一的内存预算下学习每个token的未来效用。轻量级保留门为缓存的KV条目分配效用分数,而共享的最终评分投影校准这些分数跨所有层和头部。这使得能够实现一个单一的全局淘汰策略,其中来自不同层、头部和模态的token直接竞争缓存容量。我们进一步提供理论分析,证明优先保留有用token可以减少注意力稀释,并证明几何保留作为查询无关的未来效用代理。在多样化的长上下文语言和视觉语言推理以及多轮对话基准测试中,我们的方法显著减少了KV内存占用,同时匹配或超越全缓存推理。这些结果表明,学习的、全局校准的KV淘汰不仅是压缩技术,也是改进长上下文推理的机制。

英文摘要:

The key-value (KV) cache is a major bottleneck in long-context inference, where memory and computation grow with sequence length. Existing KV eviction methods reduce this cost but typically degrade performance relative to full-cache inference. Our key insight is that full-cache attention is not always optimal: in long contexts, irrelevant tokens can dilute attention away from useful evidence, so selective, learnable eviction can improve generation rather than merely approximate the full cache. We introduce a global retention-based KV eviction method that learns each token's future utility under a unified memory budget. Lightweight retention gates assign utility scores to cached KV entries, and a shared final scoring projection calibrates these scores across all layers and heads. This enables a single global eviction policy in which tokens from different layers, heads, and modalities compete directly for cache capacity. We further provide theoretical analysis showing that preferentially retaining useful tokens reduces attention dilution, and we justify geometric retention as a query-agnostic proxy for future utility. Across diverse long-context language and vision-language reasoning, and multi-turn dialogue benchmarks, our method substantially reduces KV memory while matching or surpassing full-cache inference. These results suggest that learned, globally calibrated KV eviction is not only a compression technique, but also a mechanism for improving long-context reasoning.

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

↑