CompilerKV: Risk-Adaptive KV Cache Compression via Offline Experience Compilation
Ning Yang, Chengzhi Wang, Yibo Liu, Baoliang Tian, Haijun Zhang
NeurIPS page · OpenReview · alphaXiv · Open on the map
Category: Efficient LLM Inference & Training › KV Cache Optimization · Type: new method · Keywords: KV cache compression, offline compilation, portable architectural priors, language model inference, memory-efficient serving
Summary
CompilerKV introduces offline-compiled KV-retention tables that act as portable architectural priors, achieving state-of-the-art compression on multiple language models.
Explained to a 5-year-old
A big computer brain reads a lot of words before it talks. It writes down notes called a cache, but the notes take up a lot of space. The old way decides which notes to keep by looking at each conversation, which can be wrong. The new way looks at many conversations beforehand and learns which notes are usually helpful. Then during a conversation it quickly picks the useful notes, so the brain talks faster and uses less memory.
Explained to a 5-year-old, longer
A big computer brain reads a lot of words before it starts talking. While it reads, it saves little notes so it can remember what it saw. These notes are called a cache, and they can become very big. If the cache is too big, the computer needs a lot of memory, which can be expensive. Some scientists tried to shrink the cache by keeping only the most important notes. They looked at each conversation one by one to decide which notes to keep. But this method sometimes chose the wrong notes because each conversation is a bit noisy. The scientists noticed that the same kind of notes are useful in many different conversations. So they collected many conversations beforehand and learned which notes are usually helpful. They stored this knowledge in tables that act like a recipe for picking notes. When the computer talks, it just looks up the recipe and picks the right notes quickly. This way the brain can talk faster, use less memory, and still remember the important things.
For a technical reader
The system pre-computes retention rules from a large set of examples, turning them into simple lookup tables. During inference it only consults these tables to decide which cached keys to keep, avoiding per-prompt calculations. This reduces memory usage while preserving performance across different models and tasks.
Problem
Prefill-only KV compression freezes a token subset at the end of prefill, making retention decisions irreversible. Existing methods estimate corrective signals online from a single noisy prompt, which can be statistically unreliable.
Method
The approach compiles corrective tables offline from a calibration corpus, creating portable retention rankings that can be transferred across models. At decode time, it performs O(1) lookups from these tables and clamps the budget, eliminating the need for per-prompt online estimation.
Results
At a 512-token budget, the approach attains compressed-SOTA on all four backbones, improving over the strongest prefill-only baseline by +1.67 points on average (95% CI [+1.08,+2.37]), and under high pressure it remains the strongest compressed method on RULER (≈73 vs FullKV 79, SnapKV 38), reaches 0.89 on NIAH (vs 0.42 SnapKV), and retains only 1.56% of prefill KV while keeping batch-16 serving feasible.
Contributions
It shows that corrective signals for KV retention have high cross-prompt regularity and can be compiled offline into portable tables, providing a simple O(1) lookup mechanism for efficient compression. The work also demonstrates strong transferability of these tables across models and tasks, achieving state-of-the-art compression under various pressure regimes.
Practical relevance
The approach enables memory-efficient KV compression for large language model serving, allowing batch inference under tight cache budgets where full KV storage would be infeasible.
This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. Suggest a correction