Attention Is All You Need for KV Cache in Diffusion LLMs
该论文提出了一种名为 Elastic-Cache 的自适应缓存策略,用于扩散大型语言模型(DLMs)的键值(KV)缓存,以最大化预测精度同时最小化解码延迟。
更新于 2026-02-09。作者:Quan Nguyen-Tri、Mukul Ranjan、Zhiqiang Shen。
中文摘要
这项工作研究了如何自适应地重新计算扩散大型语言模型(DLM)的关键值(KV)缓存,以最大化预测精度同时最小化解码延迟。先前的方法在每一步去噪和每一层都重新计算所有标记的QKV,尽管KV状态在大多数步骤中变化很小,尤其是在浅层,这导致了大量的冗余。我们提出了三个观察结果:(1)远距离的{bf MASK}标记主要充当长度偏差,并且可以在活动预测窗口之外按块缓存;(2)KV动态随深度增加,表明从深层开始进行选择性刷新是足够的;(3)最被关注的标记展现出最小的KV漂移,为其他标记的缓存变化提供了一个保守的下限。基于这些观察,我们提出了{bf Elastic-Cache},这是一种无需训练、架构无关的策略,它联合决定何时刷新(通过在最高关注的标记上进行注意力感知的漂移测试)以及在哪里刷新(通过深度感知的调度,从选定的层开始重新计算,同时重用浅层缓存和窗口外的MASK缓存)。与固定周期方案不同,Elastic-Cache对扩散LLM执行自适应、层感知的缓存更新,减少冗余计算,并以可忽略的生成质量损失加速解码。在LLaDA-Instruct、LLaDA-1.5和LLaDA-V上的数学推理和代码生成任务实验中,证明了持续的速度提升:GSM8K(256个标记)上提升了8.7倍,长序列上提升了45.1倍,HumanEval上提升了4.8倍,同时始终保持着比基线更高的精度。我们的方法在保持生成质量的同时,实现了比现有基于置信度的方法显著更高的吞吐量(GSM8K上提升了6.8倍),使得扩散LLM的实用部署成为可能。
英文摘要
This work studies how to adaptively recompute key-value (KV) caches for diffusion large language models (DLMs) to maximize prediction accuracy while minimizing decoding latency. Prior methods' decoders recompute QKV for all tokens at every denoising step and layer, despite KV states changing little across most steps, especially in shallow layers, leading to substantial redundancy. We make three observations: (1) distant {bf MASK} tokens primarily act as a length-bias and can be cached block-wise beyond the active prediction window; (2) KV dynamics increase with depth, suggesting that selective refresh starting from deeper layers is sufficient; and (3) the most-attended token exhibits the smallest KV drift, providing a conservative lower bound on cache change for other tokens. Building on these, we propose {bf Elastic-Cache}, a training-free, architecture-agnostic strategy that jointly decides {when} to refresh (via an attention-aware drift test on the most-attended token) and {where} to refresh (via a depth-aware schedule that recomputes from a chosen layer onward while reusing shallow-layer caches and off-window MASK caches). Unlike fixed-period schemes, Elastic-Cache performs adaptive, layer-aware cache updates for diffusion LLMs, reducing redundant computation and accelerating decoding with negligible loss in generation quality. Experiments on LLaDA-Instruct, LLaDA-1.5, and LLaDA-V across mathematical reasoning and code generation tasks demonstrate consistent speedups: 8.7times on GSM8K (256 tokens), 45.1times on longer sequences, and 4.8times on HumanEval, while consistently maintaining higher accuracy than the baseline. Our method achieves significantly higher throughput (6.8times on GSM8K) than existing confidence-based approaches while preserving generation quality, enabling practical deployment of diffusion LLMs.
解读
一句话总结
该论文提出了一种名为 Elastic-Cache 的自适应缓存策略,用于扩散大型语言模型(DLMs)的键值(KV)缓存,以最大化预测精度同时最小化解码延迟。
问题1:这篇论文想要解决什么具体问题?
- 问题背景:DLMs 的解码过程计算密集,现有方法在解码过程中对所有标记在每个层进行重新计算,尽管大多数步骤中 KV 状态变化很小。
- 现有方案不足:现有方法的解码器在每次去噪步骤和层中重新计算 QKV,导致大量冗余计算。
- 研究目标:确定如何和何时在解码过程中自适应地重新计算 KV 缓存,以最大化预测质量同时最小化实际延迟。
问题2:论文的核心创新点是什么?
- 技术创新:提出了 Elastic-Cache,一种基于注意力和层感知的 KV 缓存更新策略。
- 方法改进:通过关注最被关注的标记的 KV 飘移,自适应地决定何时刷新缓存,以及从哪个层开始刷新。
- 优势:与固定周期方案相比,Elastic-Cache 可以减少冗余计算,加速解码,同时保持生成质量。
问题3:实验结果如何验证了方法的有效性?
- 关键实验:在 LLaDA-Instruct、LLaDA-1.5 和 LLaDA-V 上进行实验,涵盖数学推理和代码生成任务。
- 性能提升:在 GSM8K 上实现 8.7 倍的速度提升,在更长的序列上实现 45.1 倍的速度提升,在 HumanEval 上实现 4.8 倍的速度提升。
- 对比结果:与基线方法相比,Elastic-Cache 在保持更高准确性的同时,实现了显著更高的吞吐量。
问题4:这个研究的实际应用价值是什么?
- 应用场景:适用于需要高性能解码的 DLMs,如数学推理和代码生成。
- 实施建议:根据具体任务和数据集调整超参数,如注意力相似度阈值 γ 和滑动窗口大小 β。
- 局限与展望:未来可以进一步优化漂移阈值,将该方法扩展到自回归 LLMs 和多模态扩散框架。