E8 Lattice Key Quantization for Low-Bit KV-Cache Compression
Organizations: Technical University of Berlin Berlin, Germany · logsight.ai Berlin, Germany
Abstract
Compressing the key-value (KV) cache is essential for serving long-context large language models (LLMs) under memory constraints. While current scalar quantization methods achieve significant compression, they typically face a quality-fidelity trade-off, either suffering from performance instability at 2-bit precision or necessitating 3-bit keys to maintain model quality. In this work, we demonstrate that a uniform low-bit k2v2 configuration (2-bit keys and 2-bit values) can preserve near-baseline quality by using vector quantization (VQ) based on the lattice for KV keys. We show that structured VQ exploits correlations across adjacent dimensions to achieve signal-to-quantization-noise ratios (SQNR) higher than those of independent scalar quantization at the same key payload rate. To ensure practical utility, we adapt a table-based asymmetric scoring algorithm that avoids explicit codebook dequantization during attention computation and preserves decode-throughput parity with scalar baselines. Across five LLM families, our k2v2 approach yields \textasciitilde KV compression, roughly 20% smaller than scalar k3v2 (3-bit keys and 2-bit values), while retaining near-baseline long-context perplexity. In our full-suite perplexity evaluation, improves over scalar k3v2 in 80% of model--dataset--context settings. These results indicate that lattice VQ improves quality per byte while keeping throughput at parity, suggesting that structured key quantization is a useful primitive for KV-compression stacks. Overall, our work provides a low-overhead primitive for expanding the quality-memory frontier in long-context LLM inference.
Figures & tables
| Model | Ctx | WikiText-2 | C4 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Base | KIVI | Scalar | E8 | Base | KIVI | Scalar | E8 | ||||||||
| Qwen2.5-14B | 512 | 5.90 | 7.16 | +1.26 | 6.29 | +0.39 | 6.13 | +0.23 | 11.11 | 12.47 | +1.36 | 11.59 | +0.48 | 11.35 | +0.24 |
| 2K | 5.01 | 7.32 | +2.31 | 5.61 | +0.60 | 5.29 | +0.28 | 10.32 | 13.82 | +3.50 | 11.31 | +0.99 | 10.60 | +0.29 | |
| 4K | 4.84 | 7.88 | +3.04 | 5.51 | +0.68 | 5.13 | +0.29 | 10.18 | 15.38 | +5.20 | 11.59 | +1.41 | 10.47 | +0.29 | |
| Llama-3.1-8B | 512 | 7.33 | 9.40 | +2.07 | 7.70 | +0.36 | 7.51 | +0.18 | 11.34 | 15.00 | +3.65 | 11.93 | +0.59 | 11.71 | +0.37 |
| 2K | 6.45 | 15.91 | +9.45 | 6.97 | +0.51 | 6.67 | +0.21 | 10.90 | 32.72 | +21.82 | 11.84 | +0.94 | 11.35 | +0.45 | |
| Model | Baseline | Scalar k3v2 | E8 Lattice k2v2 | ||||
|---|---|---|---|---|---|---|---|
| (B/tok) | (B/tok) | Ratio | (B/tok) | Ratio | |||
| Qwen2.5-14B | 48 | 8 | 196,608 | 40,944 | 4.8 | 32,592 | 6.0 |
| Llama-3.1-8B | 32 | 8 | 131,072 | 27,296 | 4.8 | 21,728 | 6.0 |
| Mistral-7B | 32 | 8 | 131,072 | 27,296 | 4.8 | 21,728 | 6.0 |
| Falcon3-7B | 28 | 4 | 114,688 | 22,652 | 5.1 | 18,452 | 6.2 |
| Granite-3.1-8B | 40 | 8 | 163,840 | 34,120 | 4.8 | 27,160 | 6.0 |
| Model | Context | Baseline | KIVI k2v2 | Scalar k3v2 | E8 Lattice k2v2 |
|---|---|---|---|---|---|
| Qwen2.5-14B | 1K | 49.4 | 49.4 | 49.4 | 49.4 |
| 4K | 48.4 | 48.4 | 48.4 | 48.4 | |
| Llama-3.1-8B | 1K | 89.0 | 88.9 | 88.9 | 89.0 |
| 4K | 86.9 | 87.0 | 87.0 | 87.0 | |
| Mistral-7B | 1K | 92.9 | 92.9 | 92.9 | 93.0 |
| 4K | 90.7 | 90.7 | 90.8 | 90.8 |
| Model | Baseline | KIVI k2v2 | Scalar k3v2 | E8 k2v2 |
|---|---|---|---|---|
| Cell format: HellaSwag / ARC-C / WinoGrande / Avg | ||||
| Qwen2.5-14B | 65.5 / 60.5 / 75.1 / 67.1 | 65.7 / 60.3 / 75.3 / 67.1 | 65.7 / 60.4 / 75.3 / 67.1 | 65.7 / 60.3 / 75.3 / 67.1 |
| Llama-3.1-8B | 59.8 / 53.8 / 73.6 / 62.4 | 59.7 / 53.6 / 73.4 / 62.2 | 59.7 / 53.7 / 73.4 / 62.3 | 59.7 / 53.7 / 73.4 / 62.3 |
| Mistral-7B | 65.8 / 57.8 / 74.9 / 66.2 | 65.8 / 57.8 / 74.8 / 66.1 | 65.8 / 57.8 / 74.8 / 66.1 | 65.8 / 57.8 / 74.8 / 66.1 |
| Falcon3-7B | 60.3 / 55.8 / 70.3 / 62.1 | 60.3 / 55.9 / 70.4 / 62.2 | 60.3 / 55.9 / 70.4 / 62.2 | 60.3 / 56.0 / 70.4 / 62.2 |
| Granite-3.1-8B | 64.0 / 51.4 / 75.5 / 63.7 | 64.0 / 51.7 / 74.8 / 63.5 | 64.0 / 51.7 / 74.8 / 63.5 | 64.0 / 51.7 / 74.8 / 63.5 |
| 1 | 4 | 8 | 10 | 12 | 15 | 20 | 30 | |
|---|---|---|---|---|---|---|---|---|
| MSE | 0.0577 | 0.0045 | 0.0011 | 0.0008 | 0.0007 | 0.0008 | 0.0013 | 0.0024 |
| cos | 0.292 | 0.727 | 0.913 | 0.940 | 0.953 | 0.960 | 0.959 | 0.952 |
KV-Cache Compression
Key-value cache compression reduces the memory and bandwidth needed to retain attention states during long-context inference.
See all 265 papers