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 E8 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 E8 k2v2 approach yields \textasciitilde6× 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, E8 improves over scalar k3v2 in 80% of model--dataset--context settings. These results indicate that E8 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
Figure 1: Rate-distortion comparison on 128-dimensional Gaussian vectors. E8 lattice VQ achieves SQNR between scalar 3-bit and 4-bit quantization at a comparable low key rate.
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
Table 1: Perplexity on WikiText-2 and C4 across context lengths. Each block reports compressed-method perplexity deltas against fp16 baseline; lower is better. Bold marks the best compressed configuration within each dataset/model/context.
Model
L
Hkv
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 ×
Table 2: Effective compressed KV-cache bytes per token for the quantized cache region. The accounting includes packed key/value data and per-token metadata (key norms/QJL signs and value scale/zero groups), but excludes fixed model-level tables/rotations and the finite recent-token residual window.
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
Table 3: Decode throughput (tok/s) with table-based asymmetric scoring. E8 Lattice matches Scalar throughput despite using structured VQ, thanks to lookup-table scoring that avoids codebook dequantization.
Figure 2: Average downstream accuracy across the core residual-sweep models versus residual window size. At W=0 , compression quality differences are visible; by W=128 , methods are nearly indistinguishable.
Figure 3: Left: per-layer cosine similarity between compressed and fp16 keys captured from model forward passes. Right: per-layer KL divergence in a controlled attention-distribution probe. Lines show mean over models and shaded bands show the min–max range after normalizing each architecture’s layer index to [0,1] .
LUMIA Lab, School of Artificial Intelligence, Shanghai Jiao Tong University · Shanghai Innovation Institute · Shanghai Artificial Intelligence Laboratory +2