KV cache quantisation: storing keys and values in fewer bits
Every cached number takes 16 bits. How many could we drop before the model stops noticing?
A cached key holds 128 numbers, and each number is written with 16 bits.
Does it need all 16?
Fewer bits, a smaller cache
At 2 bits the cache is an eighth of the size. What would we lose?
Can a number survive in 2 bits?
Two bits can only name four values. So we pick four levels, evenly spaced, and round each number to the nearest one.
We get 1 back, rather than 0.6. The orange gap is the rounding error.
One big number spoils the group
Numbers that share a spacing form a group. If one number is huge, the levels stretch to reach it, and the ordinary numbers pile onto the same few levels.
The cache is a grid: a row for each token, a column for each channel. We can group by row or by column.
Keys and values break differently
Some key channels are large for every token, so a column holds the trouble. Value sizes change from token to token, so a row does.
Would rows or columns make better groups? Compare the originals with their rounded copies below, then switch the grouping.
Rounding changes what attention sees. Always compare the quantised model’s answers with the original’s.
We have made each entry cheaper to store. But how much memory sits wasted around them? That is PagedAttention.
Sources and assumptions
- KIVI (2024, Zirui Liu and colleagues), a tuning-free asymmetric 2-bit method with keys grouped per channel and values per token. It reported little quality change on its tested Llama, Falcon and Mistral workloads and about 2.6 times less peak memory, including weights.
- KVQuant (2024, Coleman Hooper and colleagues), a different design with per-channel keys, pre-RoPE key quantisation, non-uniform levels and outlier handling.
- Serving support: vLLM’s FP8 cache and TensorRT-LLM’s INT8 and FP8 caches, checked on 14 October 2026. Support changes between releases; use the backend’s current documentation for your model and hardware.
Cache sizes for the selected model are ideal payload storage at its longest context: tokens, attention layers and cached numbers per token, times the bytes per number. Models that cache a compressed latent use that. Real schemes also store a scale and an offset per group, which adds about a quarter of a bit per number for groups of 128 (two 16-bit values per 128 numbers). They also keep a recent full-precision buffer and padding. The 2.6 times figure is a whole-system result and differs from the ideal eightfold shrinkage of a 2-bit payload.
The rounding is uniform integer rounding: a group’s smallest and largest values set the spacing, `s = (max - min) / (2^b - 1)`, a number is stored as the nearest level index, and `level × s + min` rebuilds it. Other schemes use an integer zero point. FP8 uses uneven floating-point spacing; the widget does not simulate it. The cache in the widget is generated with a fixed seed, 16 tokens by 16 channels, with a few large key channels as in real keys. KIVI’s streaming method also uses finite groups and a recent full-precision buffer. Whether a real model’s answers stay acceptable needs testing on its actual tasks. FP8 quality depends on calibration, scales and backend support.