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

MomentKV:消除长上下文推理中KV缓存驱逐的方向差距

MomentKV: Closing the Directional Gap in KV Cache Eviction for Long-Context Inference

George Washington University(乔治·华盛顿大学);Princeton University(普林斯顿大学)

Yu Li, Binxu Li, Tian Lan

AI总结:

针对长上下文推理中KV缓存驱逐导致输出退化的问题,提出MomentKV方法,通过维护驱逐令牌集的矩统计量(计数、键均值、值均值和值-键协方差)来识别与累积摘要对齐的令牌,并在推理时提供驱逐注意力输出的一阶近似,实现选择性驱逐与精确校正的相互增强。

摘要:

基于Transformer的语言模型中的自回归解码依赖于KV缓存,其内存占用随序列长度线性增长,成为长上下文推理的主要瓶颈。KV缓存驱逐通过保留固定大小的键值对子集并丢弃其余部分来解决这一问题。我们发现输出退化的一个主要来源并非驱逐令牌上的残余注意力质量(现有方法已最小化),而是保留令牌集与驱逐令牌集之间的方向不匹配。具体而言,实际中被驱逐的令牌通常与保留的令牌接近正交。因此,即使少量的驱逐质量也可能对最终的方向分布产生过大影响,并放大为显著的输出误差。这揭示了现有策略的根本局限性。为解决此问题,我们提出MomentKV,它在驱逐令牌集上维护紧凑的小规模矩统计量,包括计数、键均值、值均值和值-键协方差。在驱逐过程中,利用矩统计量识别已经与累积摘要良好对齐并被其捕获的令牌,保持驱逐集的几何规则性。在推理过程中,它们产生驱逐注意力输出的闭式一阶近似,在选择性驱逐与精确校正之间形成相互增强的循环。在LongBench和RULER上使用LLaMA-3.1-8B-Instruct和Qwen3-4B-Instruct进行的实验表明,MomentKV在每个缓存预算下均优于所有基线,在激进压缩下增益最大。

英文摘要:

Autoregressive decoding in Transformer-based language models relies on the KV cache, whose memory footprint grows linearly with sequence length and becomes the primary bottleneck for long-context inference. KV cache eviction addresses this by retaining a fixed-size subset of key-value pairs and discarding the rest. We identify that a primary source of output degradation is not the residual attention mass on evicted tokens, which existing methods already minimize, but a directional mismatch between the retained and evicted token sets. Specifically, the evicted tokens in practice are often near-orthogonal to the retained ones. Thus, even a small evicted mass could have an oversized impact on the resulting direction distribution and amplify into substantial output error. This reveals a fundamental limit in existing strategies. To address this, we propose MomentKV, which maintains compact, small-size moment statistics over the evicted token set, including a count, key mean, value mean, and value-key covariance. During eviction, the moment statistics is leveraged to identify tokens already well aligned with and captured by the accumulated summary, keeping the evicted set geometrically regular. During inference, they yield a closed-form first-order approximation of the evicted attention output, forming a mutually reinforcing loop between selective eviction and accurate correction. On LongBench and RULER with LLaMA-3.1-8B-Instruct and Qwen3-4B-Instruct, MomentKV outperforms all baselines at every cache budget, with the largest gains under aggressive compression.

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

↑