无需注意力矩阵的顿悟感知KV缓存淘汰
EpiKV: Epiphany-Aware KV Cache Eviction Without the Attention Matrix
AI总结:
提出EpiKV方法,通过模型内部表示变化(顿悟分数)而非注意力权重来淘汰KV缓存,无需训练或自定义内核,支持FlashAttention,在MATH-500上达到72%准确率,速度提升2.8倍。
摘要:
随着推理模型生成数万token的思维链,KV缓存日益成为部署瓶颈。现有的缓存淘汰方法根据注意力权重对token进行排序,这在长推理轨迹中是一个噪声较大的重要性代理,并且通过强制模型物化注意力矩阵,禁止在生产推理中使用融合内核。在这项工作中,我们转而使用一种我们称为顿悟分数的度量来对token进行评分:模型内部表示的变化,直接从前向传播中读取,无需注意力矩阵且额外状态可忽略。我们由此得到的缓存淘汰方法EpiKV无需训练、分类器或自定义内核,可以直接在FlashAttention推理栈中不变地使用——扩展到比基于注意力评分的方法长16倍的可行上下文。我们展示了在中间层(上层正面,中上层负面)的顿悟分数与注意力权重不同,并通过因果滚动z-score消除位置趋势。在4096-token缓存下,EpiKV在MATH-500上达到72%,与最强的基于注意力的基线(ThinKV 71%,H2O 67%)相当;一种滞后归一化的KV变体在AIME-2024上以8192 token达到37%,优于最佳基线(33%),速度提升高达2.8倍。
英文摘要:
Reasoning models can generate chains of thought tens of thousands of tokens long, making the key--value (KV) cache that holds them a major bottleneck for inference throughput. Existing eviction policies for long reasoning traces typically rank cached tokens using attention weights, requiring access to the attention matrix and making them incompatible with fast inference kernels. In this work we study the limits of such policies under tight cache budgets. Surprisingly, we find that under the strongest of them the generations that finish are wrong about as often as without eviction; most of the accuracy loss comes from generations that enter loops and run until the length limit, and retaining more tokens according to a fixed importance score exacerbates this behavior. What stops the looping is keeping the tokens the model's recent queries point to, and the forward pass the model already runs reveals them without the attention matrix. Motivated by this observation, we introduce epiphany-aware KV cache eviction EpiKV, which combines hidden-state shifts with the model's recent query--key relevance to rank cached tokens without materializing the attention matrix. On multiple benchmarks, EpiKV matches or outperforms the strongest attention-based eviction baselines while running directly in vLLM with unmodified attention kernels.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。