KVSculpt: KV Cache Compression as Distillation
Organizations: Temple University
Abstract
KV cache compression is critical for efficient long-context LLM inference. Approaches that reduce the per-pair footprint -- quantization and low-rank decomposition -- are orthogonal to those that reduce the sequence length of the cache. Along the sequence-length dimension, existing methods range from pure eviction -- selecting which KV pairs to keep -- to merging, which combines similar pairs into fewer ones. Both remain anchored to the original cache entries. We propose KVSculpt, which moves to the other end of this spectrum: instead of selecting or combining original pairs, we optimize a smaller set of unconstrained KV pairs in continuous embedding space to preserve each layer's attention behavior. Keys are optimized via L-BFGS and values are solved in closed form via least squares, alternating every few steps. On top of this, we introduce adaptive budget allocation, which uses a cheap pilot compression run to redistribute the compression budget across layers and KV heads based on per-component difficulty. On Qwen2.5-1.5B-Instruct with 2048-token contexts, KVSculpt reduces KL divergence by 3.5-4.1x compared to Select+Fit -- attention-score eviction with least-squares value fitting -- across compression ratios r in {0.3, 0.5, 0.7}. Adaptive allocation provides an additional 1.3x KL reduction at no extra inference cost. Analysis reveals that compression difficulty is highly non-uniform: per-layer pilot MSE varies by up to 100x across layers, and the two KV heads within a single layer can differ by up to 467x -- demonstrating that fine-grained budget allocation is essential.
Figures & tables
| Method | |||
|---|---|---|---|
| Random | |||
| Attn Score | |||
| Select+Fit | |||
| Joint Opt | |||
| KVSculpt | |||
| vs. Select+Fit |
| Seq | Select+Fit | KVSculpt | Improvement |
|---|---|---|---|
| 0 (easy) | |||
| 1 (hard) | |||
| 2 (hard) | |||
| 3 (easy) | |||
| 4 (easy) | |||
| Mean |
| Layer | Adam | L-BFGS | Oracle | Gap |
|---|---|---|---|---|
| L2 | ||||
| L14 | ||||
| L26 |
| Strategy | Near attn cos | Far attn cos |
|---|---|---|
| Bootstrap (last 128) | 0.950 | 0.737 |
| Uniform spread | 0.948 | 0.759 |
| Random sample | 0.948 | 0.756 |
| -means centroids | 0.947 | 0.756 |
| Farthest-point | 0.925 | 0.758 |
| Seq | Uniform KL | vs. Uni. |
|---|---|---|
| 0 | ||
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| Mean |
| Seq | Uniform | Pilot-MSE 0.5 | vs. Uniform |
|---|---|---|---|
| 0 | |||
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | |||
| Mean |
| Seq | Mean ratio | Max ratio | Layer |
|---|---|---|---|
| 0 | L0 | ||
| 1 | L15 | ||
| 2 | L15 | ||
| 3 | L15 | ||
| 4 | L15 |
| Seq | Per-layer | Per-layer+head | |
|---|---|---|---|
| 0 | |||
| 1 | |||
| 2 | |||
| 3 | |||
| 4 | |||
| Mean |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
| Method | ||||
|---|---|---|---|---|
| Random | ||||
| Attn Score | ||||
| Select+Fit | ||||
| Joint Opt |
| KL | vs. Uniform | |||
|---|---|---|---|---|
| 0 (uniform) | ref | 358 | 358 | |
| 0.3 | 277 | 480 | ||
| 0.5 | 231 | 578 | ||
| 0.7 | 191 | 689 | ||
| 1.0 | 140 | 880 |
KV-Cache Management
Key-value (KV) cache management reduces and coordinates Transformer attention state to make long-context inference faster and more memory-efficient.
See all 193 papers