KVSlimmer: Theoretical Insights and Practical Optimizations for Asymmetric KV Merging
Organizations: School of Information and Communication Engineering, Hainan University, Haikou, China · School of Cyberspace Security, Hainan University, Haikou, China · MAC Lab, Department of Artificial Intelligence, School of Informatics, Xiamen University, Xiamen, China · School of Computer Science and Technology, Hainan University, Haikou, China
Abstract
The growing computational and memory demands of the Key-Value (KV) cache significantly limit the ability of Large Language Models (LLMs). While KV merging has emerged as a promising solution, existing methods that rely on empirical observations of KV asymmetry and gradient-based Hessian approximations lack a theoretical foundation and incur suboptimal compression and inference overhead. To bridge these gaps, we establish a theoretical framework that characterizes this asymmetry through the spectral energy distribution of projection weights, demonstrating that concentrated spectra in Query/Key weights induce feature homogeneity, whereas dispersed spectra in Value weights preserve heterogeneity. Then, we introduce KVSlimmer, an efficient algorithm that captures exact Hessian information through a mathematically exact formulation, and derives a closed-form solution utilizing only forward-pass variables, resulting in a gradient-free approach that is both memory- and time-efficient. Extensive experiments across various models and benchmarks demonstrate that KVSlimmer consistently outperforms SOTA methods. For instance, on Llama3.1-8B-Instruct, it improves the LongBench average score by 0.92 while reducing memory costs and latency by 29% and 28%, respectively.Code is available at https://github.com/lianjunl13-sudo/KVSlimmer.
Figures & tables
| Single-Doc | Multi-Doc | Sum | Few-shot | Synthetic | Code | Avg. | |
|---|---|---|---|---|---|---|---|
| Llama3.1-8B-Instruct | |||||||
| Full Context | 43.73 | 44.49 | 29.12 | 69.36 | 53.56 | 50.95 | 48.07 |
| StreamingLLM | 28.15 | 27.19 | 25.15 | 63.17 | 16.33 | 52.15 | 35.50 |
| LongCache | 28.98 | 27.84 | 25.35 | 64.73 | 19.68 | 51.61 | 36.46 |
| H 2 O | 33.30 | 34.43 | 26.60 | 66.23 | 14.75 | 52.65 | 38.53 |
| LLMLingua-2 | 32.02 | 32.24 | 24.99 | 27.87 | 17.67 | 50.07 | 30.43 |
| Model | Overall | Easy | Hard | Short | Medium | Long |
|---|---|---|---|---|---|---|
| Full Context | 30.02 | 30.73 | 29.58 | 35.00 | 27.91 | 25.93 |
| StreamingLLM | 27.04 | 27.60 | 26.69 | 32.78 | 23.26 | 25.00 |
| LongCache | 28.43 | 28.13 | 28.62 | 32.78 | 25.58 | 26.85 |
| H 2 O | 28.23 | 28.12 | 28.29 | 31.67 | 26.98 | 25.00 |
| CaM | 28.23 | 28.64 | 27.97 | 31.67 | 26.98 | 25.00 |
| AsymKV | 30.02 | 30.23 | 29.90 | 32.78 | 27.44 | 28.85 |
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
KV-Cache Compression
Key-value cache compression reduces the memory and bandwidth needed to retain attention states during long-context inference.
See all 267 papers