KIVI quantizes an LLM’s key-value (KV) cache down to 2 bits with zero calibration or fine-tuning, cutting peak GPU memory (including model weights) by 2.6x, enabling 4x larger batch sizes, and delivering 2.35x to 3.47x higher serving throughput on Llama-2-7B. Zirui Liu, Jiayi Yuan, Hongye Jin, Shaochen Zhong, Zhaozhuo Xu, Vladimir Braverman, Beidi Chen, and Xia Hu found that naive 2-bit KV quantization collapses because keys and values fail along opposite tensor axes: keys must be quantized per-channel, while values must be quantized per-token.

  • 5x lower key score error, 15x lower value output error: On Llama-2-13B, quantizing keys per-channel instead of per-token cut attention-score error from 47.00 to 9.60; quantizing values per-token instead of per-channel cut attention-output error from 49.89 to 3.73.
  • 2-bit collapse avoided on generation and reasoning: Naive 2-bit per-token quantization (K-T, V-T) dropped Llama-2-13B CoQA from 66.37 to 52.93 and Llama-2-7B GSM8K from 13.50% to 0.83%, while KIVI-2 preserved 66.23 CoQA and 12.74% GSM8K.
  • Long-context accuracy stays intact: Across eight LongBench tasks, KIVI-2 scored 44.27 vs 44.52 FP16 on Llama-2-7B, 44.69 vs 44.85 on Llama-2-13B, and 45.85 vs 46.58 on Mistral-7B, while preserving Needle-in-a-Haystack retrieval up to 27K to 30K tokens.
  • 2.6x memory reduction, 3.47x throughput: On an 80GB A100 running ShareGPT workloads (161 prompt / 338 output tokens), fused CUDA Q_MatMul kernels pushed batch capacity up 4x and throughput 2.35x to 3.47x.
Why 2-bit KV quantization requires opposite axes for keys and values
Llama-2-13B Config (G = 32)CoQA (EM ↑)TruthfulQA (BLEU ↑)GSM8K (EM ↑)
16-bit FP16 baseline66.3729.5322.67
4-bit (K-T, V-T)66.7329.1420.92
2-bit (K-T, V-T) naive52.9324.984.55
2-bit (K-C, V-C) or (K-T, V-C)2.88 / 2.800.74 / 0.260.00 / 0.08
2-bit (K-C, V-T) no residual63.5328.6012.21
KIVI-2 (K-C, V-T + R=128)66.2329.8420.77

C = per-channel quantization, T = per-token quantization, G = 32 group size, R = 128 FP16 residual tokens. Source: Liu et al. (2024), Tables 1 and 3.

Why keys and values break along different axes

In batched long-context inference, the KV cache dominates both HBM capacity and decode latency (for OPT-175B at batch 512 and 512+32 length, the KV cache alone takes 1.2 TB, 3.8x the weights, and must be loaded from HBM on every generated token). Prior systems applied uniform per-token round-to-nearest quantization because new tokens stream in along the token dimension, which holds at 4 bits but fails badly at 2 bits.

Inspecting activations across Llama-2 and Falcon revealed two distinct mechanisms behind that failure:

  • Key caches have persistent channel outliers: A small subset of fixed channels exhibits very large magnitudes across every token. Grouping elements per-channel isolates each outlier to its own scale and zero-point, keeping normal channels clean and cutting relative attention-score error nearly 5x (47.00 to 9.60 on Llama-2-13B).
  • Value caches rely on attention sparsity: Value tensors lack channel outliers, yet quantizing values per-channel destroys accuracy (CoQA plunges from 66.37 to 2.88). Because attention weights are roughly 84.3% sparse on Llama-2-13B, the attention output sums only a handful of critical tokens. Per-token quantization confines rounding noise inside each token so low-weight tokens never corrupt high-weight ones, cutting attention-output error nearly 15x (49.89 to 3.73).

Streaming residual cache and fused kernels

Per-token value quantization appends smoothly as tokens decode, whereas per-channel key quantization spans multiple tokens. KIVI resolves that mismatch with a two-part streaming structure using group size G = 32 and a recent full-precision residual buffer of up to R tokens (R = 128 or 32):

KIVI streaming KV cache layout during prefill and decode
Grouped 2-bit cache
Bulk of historical context

Keys are quantized per-channel in groups of G = 32 tokens (Q(X_Kg)). Values are quantized per-token across G = 32 channels (Q(X_Vg)) once evicted from the queue.

FP16 residual window
Up to R = 128 recent tokens

New decoded tokens stay in FP16 (X_Kr, X_Vr) until the buffer fills and flushes a quantized chunk. Keeping local tokens unquantized recovers Llama-2-13B GSM8K from 12.21% back to 20.77%.

Fused Q_MatMul
CUDA + Triton execution

Tiled CUDA kernels dequantize 2-bit blocks on the fly inside attention matmuls, while prefill passes full-precision keys and values to subsequent layers.

Streaming grouped quantization and residual window mechanics. Source: Liu et al. (2024), Section 3.3 and Algorithm 1.

Because KIVI only compresses the KV cache, it composes cleanly with weight-only methods such as GPTQ and AWQ, as well as serving allocators like PagedAttention.

Caveats and builder takeaway

Three constraints define where 2-bit KIVI needs adjustment:

  • Already-compressed MQA and GQA caches: On Falcon-7B (which uses single-head Multi-Query Attention), 2-bit KIVI cut CoQA from 59.83 to 57.48 and MultiNews from 11.09 to 6.78, so the authors recommend 4-bit KIVI there (59.67 CoQA, 8.78 LongBench avg vs 8.71 FP16). Even on GQA-based Llama-3-8B-Instruct, 2-bit KIVI dropped code completion on LCC (57.00 to 50.84) and RepoBench-P (51.22 to 46.65), whereas KIVI-4 matched FP16 (45.31 vs 45.21 avg).
  • Group size sensitivity: Raising group size G from 64 to 128 caused Llama-2-13B GSM8K to drop from 21.00% to 17.29%, and shrinking residual length R from 128 to 32 shaved roughly 1 to 2 points off hard reasoning on Mistral-7B (36.01% to 34.34%).
  • Kernel overhead on short contexts: If KV cache is small relative to weights (short prompts, small batch sizes), 2-bit unpacking adds overhead for little memory gain; furthermore, KIVI had not yet fused quantization into upstream projections.

For long-context or high-concurrency serving on MHA models, KIVI-2 cuts memory enough to nearly triple throughput with negligible quality loss; on GQA/MQA models or code-heavy workloads, KIVI-4 offers a safer drop-in default.