2025-05-22 · 专家 · 机器学习 · 自然语言处理

dKV-Cache: The Cache for Diffusion Language Models

该论文提出了一种名为dKV-Cache的新机制,用于加速扩散语言模型(DLMs)的解码过程,通过延迟和条件缓存策略显著提高了解码速度,同时保持了性能。

更新于 2025-05-22。作者:Xinyin Ma、Runpeng Yu、Gongfan Fang、Xinchao Wang。

中文摘要

扩散语言模型(DLMs)被视为自回归语言模型的潜在竞争对手。然而,扩散语言模型长期以来一直受到慢速推理的限制。一个核心挑战是,它们的非自回归架构和双向注意力阻止了加速解码的关键值缓存。我们通过提出一种类似于KV缓存的机制,即延迟KV-Cache,来解决这一瓶颈,用于DLMs的降噪过程。我们的方法源于观察,不同的标记在整个扩散过程中具有不同的表示动态。因此,我们提出了一种延迟和条件化的缓存策略,用于键和值状态。我们设计了两种互补的变体来逐步缓存键和值:(1)dKV-Cache-Decode,它提供了几乎无损的加速,甚至在长序列上提高了性能,这表明现有的DLMs可能在推理过程中未充分利用上下文信息。(2)dKV-Cache-Greedy,它具有积极的缓存策略,但生命周期较短,以二次时间复杂度的代价实现了更高的加速,但牺牲了一些性能。最终,dKV-Cache在推理中实现了2-10倍的加速,大大缩小了自回归模型和DLMs之间的差距。我们在几个基准测试上评估了我们的dKV-Cache,在通用语言理解、数学和代码生成基准测试中实现了加速。实验表明,缓存也可以用于DLMs,甚至可以在不进行训练的情况下从当前的DLMs中实现。

英文摘要

Diffusion Language Models (DLMs) have been seen as a promising competitor for autoregressive language models. However, diffusion language models have long been constrained by slow inference. A core challenge is that their non-autoregressive architecture and bidirectional attention preclude the key-value cache that accelerates decoding. We address this bottleneck by proposing a KV-cache-like mechanism, delayed KV-Cache, for the denoising process of DLMs. Our approach is motivated by the observation that different tokens have distinct representation dynamics throughout the diffusion process. Accordingly, we propose a delayed and conditioned caching strategy for key and value states. We design two complementary variants to cache key and value step-by-step: (1) dKV-Cache-Decode, which provides almost lossless acceleration, and even improves performance on long sequences, suggesting that existing DLMs may under-utilise contextual information during inference. (2) dKV-Cache-Greedy, which has aggressive caching with reduced lifespan, achieving higher speed-ups with quadratic time complexity at the cost of some performance degradation. dKV-Cache, in final, achieves from 2-10x speedup in inference, largely narrowing the gap between ARs and DLMs. We evaluate our dKV-Cache on several benchmarks, delivering acceleration across general language understanding, mathematical, and code-generation benchmarks. Experiments demonstrate that cache can also be used in DLMs, even in a training-free manner from current DLMs.

解读

一句话总结

该论文提出了一种名为dKV-Cache的新机制,用于加速扩散语言模型(DLMs)的解码过程,通过延迟和条件缓存策略显著提高了解码速度,同时保持了性能。

问题1:这篇论文想要解决什么具体问题?

问题2:论文的核心创新点是什么?

问题3:实验结果如何验证了方法的有效性?

问题4:这个研究的实际应用价值是什么?

来源