D-Quant: Driftable Entropy Coding for KV Cache Quantization

Yi Su, Hong Liu, Guanghua Yu, Jianchen ZhuarXiv 2026

TL;DR

D-Quant introduces a novel framework for Large Language Model (LLM) KV cache compression that combines the high compression efficiency of entropy coding with hardware-friendly, fixed-stride memory layouts. By implementing a mathematical "drift" mechanism, it packs variable-length entropy-coded tokens into fixed-size containers, achieving near-lossless performance at just 2.26 bits per element while boosting decoding throughput by up to 3.5×.

What Problem Does This Paper Address?

As LLMs are deployed for long-context applications like multi-turn conversations and document analysis, the Key-Value (KV) cache becomes a massive memory bottleneck. The KV cache grows linearly with both sequence length and batch size, severely limiting serving capacity and straining GPU memory bandwidth.

While quantization (reducing the precision of numbers) is a popular solution, standard fixed-width approaches (e.g., uniform 2-bit integers) suffer from exponential information loss. Furthermore, they fail to exploit the highly non-uniform distribution of KV values, where most numbers cluster near the center and very few sit in the tails.

Entropy coding naturally solves this by assigning shorter codes to frequent values and longer codes to rare ones. However, entropy coding produces variable-length outputs. This creates a major problem for GPUs: highly parallel attention kernels rely on regular, fixed-stride memory layouts to achieve high performance. Variable-length bitstreams break this parallelism.

Methods

D-Quant bridges the gap between variable-length entropy coding and parallel GPU computing through a two-stage pipeline:

  1. Preprocessing: The framework applies Hadamard rotation to spread out structured outliers across channels and removes channel-wise means for keys. It then applies token-wise affine quantization to map values to discrete symbol indices.
  2. Fixed-Size Entropy Coding via "Drift": Instead of letting the entropy-coded stream vary in size, D-Quant allocates a fixed-size container ($C$ bytes) per token stream. To guarantee that the variable-length codes fit exactly into this fixed container, the authors introduce a drift mechanism.

The drift mechanism formulates quantization as a length-constrained assignment problem. If the entropy-coded bitstream exceeds the byte budget, a small fraction of values are allowed to "drift" from high-cost symbols to nearby lower-cost, more frequent symbols. This optimization problem is solved efficiently on-chip using a Lagrangian formulation with bisection.

Figure 1: Overview of our method. A stream is the Keys or Values of one token and shares a single scale and offset. After preprocessing (rotation, mean removal, affine grid) and affine quantization, the symbol indices are entropy-coded into a container of fixed byte length, and a length-constrained assignment makes every stream fit that container exactly.

Datasets

The authors evaluated D-Quant on two prominent long-context benchmarks:

  • RULER: Used to evaluate effective context behaviors at lengths ranging from 4K to 128K tokens.
  • LongBench-E: Used to test long-context English language understanding across various subsets.

Evaluations were performed using two popular open-source models: Qwen3-8B and Llama-3.1-8B-Instruct.

Key Insights and Ideas

  • Calibration-Free Probability Modeling: A key discovery is that after Hadamard rotation and mean removal, the KV cache distribution beautifully approximates a standard normal distribution. Because of this predictability, the entropy coding probability table can be derived analytically from standard Gaussian statistics, making D-Quant entirely calibration-free.
  • Decoupling Levels from Bit-Width: In traditional quantization, a 2-bit representation strictly limits you to $2^2 = 4$ reconstruction levels. Because entropy coding allocates bits dynamically, D-Quant can support a much richer alphabet (e.g., 8 levels for keys and 6 levels for values) within the exact same average storage budget (2.26 bits).
  • Surgical, Sparse Adjustments: Rather than uniformly degrading the precision of an entire tensor when memory runs tight, the drift mechanism acts like a surgical strike. It only alters a tiny fraction of symbols (0.75% of keys and 5.00% of values) by at most one reconstruction level to satisfy the hard container constraint.
Figure 2: Distribution of KV values before and after preprocessing. Raw KV tensors exhibit strong outliers and non-Gaussian patterns. Hadamard rotation substantially reduces distribution irregular- ity, and mean removal further centers key distributions.

Key Results

  • Superior Accuracy at Long Contexts: At an average allocation of 2.26 bits per value (BPV), D-Quant maintains near-BF16 baseline accuracy. On the RULER benchmark, D-Quant achieved an average score of 86.50 (vs. 87.31 for BF16) on Qwen3-8B, dramatically outperforming existing low-bit baselines like KIVI, QuaRot, and OScaR, which degrade rapidly at 128K context lengths.
  • Massive Memory Savings: D-Quant reduces the KV cache memory footprint by up to 7× during long-context decoding.
  • Throughput Gains: By shrinking the memory footprint, the GPU can handle significantly larger batch sizes. At maximum feasible batch sizes, D-Quant achieves up to a 3.5× improvement in decoding throughput compared to full-precision BF16.

Limitations and Future Work

  • Compute Overhead at Small Batches: Entropy decoding introduces additional mathematical operations on the GPU. When serving very small batch sizes (where memory bandwidth is not yet the primary bottleneck), the computational overhead of rANS decoding can make D-Quant slightly slower than raw BF16 execution.
  • Future Directions: While the paper extensively optimizes the GPU kernels for token-centric decoding, future work could explore how driftable entropy coding interacts with quantized model weights or speculative decoding frameworks to push LLM serving efficiency even further.

Summary updated

BibTeX
@misc{su2026d,
  author = {Yi Su and Hong Liu and Guanghua Yu and Jianchen Zhu},
  title = {{D-Quant: Driftable Entropy Coding for KV Cache Quantization}},
  year = {2026},
  eprint = {2609.19880},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.19880},
}
Figure