随机注意力:重新思考KV缓存驱逐以实现高效推理

·

研究论文 · 2026/09/04

大型语言模型在需要扩展推理的任务上表现优异,但长思维链使KV缓存成为严重的内存瓶颈。现有的KV缓存压缩方法遵循同一范式:通过某种估计为每个缓存token打分,并保留得分最高的token。我们表明,这种选择信号几乎不起作用。随机注意力保留提示,并在每个注意力头内均匀随机驱逐,不计算任何分数;在四个模型和六个推理任务上,它匹配最强的先前驱逐器,同时在vLLM部署中提供比其高32-43%的吞吐量。受控实验解释了这一现象:1) 提示是缓存中最脆弱的部分,选择器之间的差距大多在于其选择信号是否恰好保留了提示;2) 推理轨迹通过两个层面的冗余来保护自身免受驱逐:文本层面(模型在推理过程中会重述其仍需要的内容)和跨注意力头层面(每个头保留轨迹的副本),因此一旦提示安全,随机抽取就能保留足够多的所需副本,无需评分来选择。我们的代码公开于 https://github.com/SalesforceAIResearch/Random-Attention。

本文挑战了KV缓存压缩中评分选择的普遍假设,提出简单有效的随机注意力方法,并通过实验揭示其有效性的深层原因,对推理效率优化有重要启示。

Large language models achieve superior performance on tasks that require extended reasoning, but long chains of thought make the KV cache a severe memory bottleneck. Existing KV cache compression methods share one paradigm: score each cached token by some estimate of how much it will matter later, and keep the top-scoring ones. We show that the selection signal contributes almost nothing. Random Attention keeps the prompt and evicts uniformly at random within each attention head, computing no score at all; across four models and six reasoning tasks it matches the strongest prior evictor while serving 32-43% higher throughput than it in vLLM deployment. Controlled experiments explain this by showing that 1) the prompt is the fragile part of the cache, and most of the gap between selectors is just whether their selection signal happened to keep it; 2) the reasoning trace protects itself against eviction with redundancy at two levels, in the text (the model restates what it still needs as it works) and across attention heads (each keeps its own copy of the trace), so once the prompt is safe, a random draw retains enough copies of what the model still needs, and no score is required to pick them. Our code is publicly available at https://github.com/SalesforceAIResearch/Random-Attention.

阅读原文

参与讨论