KV Cache Compression Through the Lens of Transform Coding
Organizations: Technical University of Darmstadt, the Technical University of Munich and the Munich Center for Machine Learning · Massachusetts Institute of Technology · Red Hat AI Innovation Team and the MIT-IBM Watson AI Lab · John A. Paulson School Of Engineering And Applied Sciences at Harvard University
Abstract
The key-value (KV) cache stores information from past tokens and is a major memory bottleneck in long-context inference. Existing quantization methods address this bottleneck by representing the KV cache uniformly with lower-precision data types and designing quantization schemes to minimize reconstruction error in the cache itself, without accounting for how that error propagates through attention mechanisms. We prove that, under a white-noise quantization model, the expected attention-aware distortion decomposes into additive key and value contributions that factor across tokens and channels. Building on transform coding and reverse water-filling, which are classical tools from signal processing and rate-distortion theory, we introduce Attention-Aware Transform Coding (AATC), which allocates bits over a calibration set to minimize attention-aware distortion. On Llama-3.1-8B-Instruct and Qwen-2.5-7B-Instruct, evaluated across LongBench, RULER, GSM8K, MMLU-Pro, and MATH-500, our method achieves near-lossless accuracy at approximately compression, whereas each baseline degrades in at least some settings.
Figures & tables
| Factor | Design axis | Mechanism | Representative methods |
| (token) | token eviction | drop tokens | H2O [ 9 ] , SnapKV [ 22 ] , StreamingLLM [ 10 ] , VATP [ 23 ] , CriticalKV [ 24 ] , Expected Attention [ 26 ] |
| (token) | output-relevance | drop tokens | CAOTE [ 25 ] (pre- ) |
| , (K channel) | query-aware key precision | VQ/MP/rotation/ TC+bit-alloc. | A 2 ATS [ 12 ] , MixKVQ [ 21 ] , OSCAR [ 19 ] , SQuat [ 20 ] , Ours (Section V ) |
| (V channel) | output-projection- aware value | TC+bit-alloc | (implicit in KVQuant [ 6 ] ), Ours (Section V ) |
| , | per-channel sensitivity | scaling/codebook/ SVD/MP/ TC+bit-alloc | KIVI [ 5 ] , KVQuant [ 6 ] , KVTC [ 8 ] , PALU [ 7 ] , RateQuant [ 11 ] , Ours (Section V ) |
| LongBench | RULER | Reasoning | ||||||||
| Method | Comp. | avg. | 4k | 8k | 16k | 32k | GSM8K | MMLU -m | MMLU -cs | MATH-500 |
| Llama-3.1-8B-Instruct | ||||||||||
| Baseline | 1.00 | 0.570 | 0.859 | 0.856 | 0.828 | 0.775 | 0.789 | 0.438 | 0.456 | 0.454 |
| KIVI | 5.00 | 0.564 | 0.846 | 0.840 | 0.810 | 0.763 | 0.730 | 0.390 | 0.420 | 0.452 |
| PALU | 5.39 | 0.550 | 0.851 | 0.849 | 0.83 | 0.769 | 0.617 | 0.274 | 0.320 | 0.314 |
| KVQuant | 5.91 | 0.549 | 0.715 | 0.729 | 0.676 | 0.654 | 0.754 | 0.376 | 0.402 | 0.392 |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Method | TriviaQA | Qasper | TREC | SAMSum | LCC | RepoB-P | QMSum | avg. | |
| Llama-3.1-8B-Instruct | Baseline | 0.917 | 0.455 | 0.725 | 0.437 | 0.634 | 0.567 | 0.254 | 0.570 |
| KIVI | 0.913 | 0.440 | 0.725 | 0.448 | 0.619 | 0.552 | 0.250 | 0.564 | |
| PALU | 0.892 | 0.449 | 0.710 | 0.438 | 0.539 | 0.576 | 0.248 | 0.550 | |
| KVQuant | 0.921 | 0.413 | 0.675 | 0.415 | 0.633 | 0.546 | 0.241 | 0.549 | |
| AATC var | 0.922 | 0.452 | 0.715 | 0.430 | 0.634 | 0.559 | 0.251 | 0.566 | |
| AATC (ours) | 0.919 | 0.444 | 0.690 | 0.434 | 0.623 | 0.546 | 0.252 | 0.558 |
| LongBench | RULER | Reasoning | |||||||||
| Method | Comp. | avg. | 4k | 8k | 16k | 32k | GSM8K | MMLU-m | MMLU-cs | MATH | |
| Llama | Baseline (FP16) | 1.00 | 0.570 | 0.859 | 0.856 | 0.828 | 0.775 | 0.789 | 0.438 | 0.456 | 0.454 |
| AATC var | 7.0 | 0.543 | 0.818 | 0.822 | 0.775 | 0.677 | 0.767 | 0.402 | 0.427 | 0.484 | |
| AATC (ours) | 7.0 | 0.568 | 0.851 | 0.861 | 0.809 | 0.735 | 0.756 | 0.416 | 0.434 | 0.448 | |
| Qwen | Baseline (FP16) | 1.00 | 0.574 | 0.720 | 0.716 | 0.718 | 0.720 | 0.818 | 0.708 | 0.567 | 0.680 |
| AATC var | 6.9 | 0.518 | 0.688 | 0.653 | 0.640 | 0.566 | 0.795 | 0.644 | 0.510 | 0.664 | |
| Config | Comp | TriviaQA | Qasper | TREC | SAMSum | LCC | RepoB-P | QMSum | LB avg. | GSM8K | |
| Llama-3.1-8B–Instruct | Baseline FP16 | 1.0 | 0.917 | 0.455 | 0.725 | 0.437 | 0.634 | 0.567 | 0.254 | 0.570 | 0.789 |
| KIVI 4-bit | 3.1 | 0.917 | 0.454 | 0.725 | 0.440 | 0.634 | 0.568 | 0.250 | 0.570 | 0.795 | |
| KVQuant 4-bit | 3.4 | 0.914 | 0.447 | 0.725 | 0.426 | 0.631 | 0.560 | 0.256 | 0.566 | 0.779 | |
| AATC 4-bit | 3.8 | 0.916 | 0.446 | 0.725 | 0.436 | 0.624 | 0.565 | 0.253 | 0.566 | 0.783 | |
| KIVI 3-bit | 3.8 | 0.914 | 0.450 | 0.725 | 0.435 | 0.634 | 0.564 | 0.254 | 0.568 | 0.792 | |
| KVQuant 3-bit | 4.3 | 0.921 | 0.452 | 0.725 | 0.433 | 0.631 | 0.559 | 0.250 | 0.567 | 0.776 |
| AATC variant (2-bit, Llama-3.1-8B-Instruct ) | TriviaQA | Qasper | TREC | SAMSum | LCC | RepoB-P | QMSum | LB avg. | GSM8K |
| AATC 2-bit (standard) | 0.917 | 0.456 | 0.720 | 0.438 | 0.630 | 0.570 | 0.248 | 0.568 | 0.751 |
| Allocation | |||||||||
| no in allocation | 0.910 | 0.410 | 0.685 | 0.444 | 0.545 | 0.473 | 0.248 | 0.531 | 0.752 |
| no in allocation | 0.916 | 0.452 | 0.720 | 0.430 | 0.602 | 0.551 | 0.251 | 0.560 | 0.763 |
| per-layer allocation | 0.913 | 0.430 | 0.715 | 0.445 | 0.583 | 0.533 | 0.249 | 0.553 | 0.760 |
| global allocation | 0.847 | 0.337 | 0.595 | 0.432 | 0.475 | 0.462 | 0.231 | 0.483 | 0.740 |
KV-Cache Compression
Key-value cache compression reduces the memory and bandwidth needed to retain attention states during long-context inference.
See all 257 papers