SemKV: Semantic Mixed-Precision KV Cache Quantization Guided by the Quality Cliff for Long-Context LLM Inference
Organizations: Electronics and Telecommunications Research Institute (ETRI), Daejeon, Republic of Korea
Abstract
The key-value (KV) cache is the dominant memory bottleneck of long-context large language model (LLM) inference, growing linearly with context length. We show that uniform KV quantization on a fractional-bit grid does not degrade gracefully: under a prespecified multi-seed statistical protocol, Llama-3.1-8B-Instruct with an affine quantizer is statistically indistinguishable from FP16 KV down to 2.322 code bits/value and collapses at 2.0 bits - a quality cliff in (2.0, 2.322] that reappears in generation-time quantization and multi-turn dialogue and transfers to Mistral-7B. The cliff reframes importance-aware mixed precision: above it, eight model-internal importance indicators are statistically interchangeable, so the benefit of mixing is grid interpolation, reaching average precisions uniform quantization cannot realize. SemKV preserves every token, ranks tokens by a model-internal score, and assigns two adjacent above-cliff precisions, achieving a measured 6.0x storage reduction with no statistically detectable quality difference from full KV (n=900, three seeds), and outperforming FP16 token pruning granted a 1.5x larger memory budget. Replacing the affine base with a distortion-optimized quantizer (TurboQuant-MSE) lowers the cliff in every protocol tested, raising the no-detectable-loss operating point to 7.9x. The recipe: measure the cliff for the target deployment setting, then interpolate above it.
Figures & tables
| Method family | Deletes tokens | Per-token bits | Indicator | Cliff-mapped frac. grid | Gen.-time |
|---|---|---|---|---|---|
| Uniform quantization | No | No | — | No | Partial |
| Eviction / pruning | Yes | No | Attn. | No | Yes |
| Importance-aware quant. | Varies | Yes | Attn. | No | Partial |
| SKVQ | No | Window | Recency | No | Yes |
| SemKV (this work) | No | Yes | Model-internal (8 tested) | Yes | Yes (block-exact) |
| Configuration | Value |
|---|---|
| Backbone models | Llama-3.1-8B-Instruct / Mistral-7B-Instruct-v0.3 |
| Scoring (default) | Hidden-state delta norm, last 4 layers |
| Indicator ablation | 8 model-internal indicators (4 families) |
| Precision pair | , (above-cliff grid points) |
| High-precision fraction | 25% (single-turn) / 35% (multi-turn incl. generation) |
| Quantizer | Integer-level scalar quantization + Hadamard rotation |
| Method | Nominal avg. code bits | Compression | Score | vs. full ( ) |
|---|---|---|---|---|
| Full KV | 16.0 | 0.4406 | — | |
| Uniform 2.585-bit | 2.585 | 0.4312 | (0.09) | |
| SemKV hidden-norm | 2.39 | 0.4383 | (0.70) | |
| SemKV variance | 2.39 | 0.4377 | (0.64) | |
| SemKV cos-delta | 2.39 | 0.4317 | (0.10) | |
| SemKV key-norm | 2.39 | 0.4328 | (0.17) |
| Method | Nominal / mem.-equiv. bits | Compr. | Score | vs. full |
|---|---|---|---|---|
| Full KV | 16.0 | 0.4406 | — | |
| SemKV hidden-norm | 2.39 | 0.4383 | (0.70) | |
| Prune keep-25% (hidden-norm) | 4.0 | 0.0650 | ( ) | |
| Prune keep-25% (variance) | 4.0 | 0.0676 | ( ) | |
| Prune keep-25% (cos-delta) | 4.0 | 0.1493 | ( ) | |
| Prune keep-25% (random) | 4.0 | 0.0632 | ( ) |
| Method | Compr. | Llama-3.1-8B | Mistral-7B |
|---|---|---|---|
| Uniform 3.0-bit | (0.11) | (0.24) | |
| Uniform 2.585-bit | (0.09) | (0.86) | |
| Uniform 2.322-bit | (0.24) | (0.19) | |
| Uniform 2.0-bit | ( ) | ( ) | |
| SemKV 2.39-bit (delta-norm) | (0.84) | (0.62) |
| Method | Code bits | Eff. bits | Score | vs. full ( ) |
|---|---|---|---|---|
| Full KV | 16.0 | 16.0 | 0.4406 | — |
| Affine uniform 2.322-bit | 2.333 | 2.583 | 0.4338 | (0.25) |
| Affine uniform 2.0-bit | 2.000 | 2.250 | 0.3958 | ( ) |
| TQ uniform 3.0-bit | 3.000 | 3.125 | 0.4296 | (0.02 † ) |
| TQ uniform 2.585-bit | 2.600 | 2.725 | 0.4347 | (0.23) |
| TQ uniform 2.322-bit | 2.333 | 2.458 | 0.4380 | (0.63) |
| Protocol | Method | Eff. bits | ( ) | Note |
| Gen. | Affine gen 2.0b | 2.250 | ( ) | anchor (Sec. 4.4) |
| Gen. | TQ gen 2.322b | 2.458 | (0.13) | safe |
| Gen. | TQ gen 2.0b | 2.125 | (0.88) | safe |
| Gen. | TQ gen 1.585b | 1.725 | (0.34) | safe |
| Gen. | TQ gen 1.0b | 1.125 | ( ) | gen cliff: |
| MT | Affine uniform 2.0b | 2.250 | ( ) | anchor (Sec. 4.6) |
KV-Cache Quantization
Key-value cache quantization compresses transformer attention state to reduce memory use and bandwidth during long-context inference.
See all 99 papers