dKV-Cache: The Cache for Diffusion Language Models

Xinyin Ma, Runpeng Yu, Gongfan Fang, Xinchao Wang
5/21/2025
cs.CL

No official code found. Best implementation: horseee/dKV-Cache (134 stars, last commit 2025-05-22).

Abstract

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.

View on arXivView PDF

Code Implementations(1)

horseee/dKV-CacheCommunity100%

[NeurIPS'25] dKV-Cache: The Cache for Diffusion Language Models

13412PythonMay 21, 20251 years ago

Similar Papers

Cite this paper

@article{ma2025dkvcache,
  title  = {dKV-Cache: The Cache for Diffusion Language Models},
  author = {Xinyin Ma and Runpeng Yu and Gongfan Fang and Xinchao Wang},
  year   = {2025},
  eprint = {2505.15781},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2505.15781v1},
  journal = {NEURIPS 2025 2025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2505.15781.svg)](https://codeofpaper.com/paper/2505.15781)

Discussion