NeurIPS 2026: CompilerKV retains 1.56% of prefill KV and delivers 2.45× decoding throughput in a 32K test

CompilerKV compresses prefill KV with offline-calibrated head weights and risk thresholds. It reports 42.31 on LongBench across four 7B/8B models at a 512-token budget, and 2.45× FullKV decoding throughput on one A100-80GB with 32K input and 8K output. The ratio is not total GPU-memory savings.
As large language models' context windows continue to expand, the GPU-memory overhead of the KV cache is becoming a major bottleneck in long-context inference. Earlier research has noted that, for a 7B-parameter model with a 128K context, the KV cache alone can exceed 100 GB of GPU memory. Supporting longer contexts and more concurrent requests within limited GPU memory, while preserving as much key information as possible, has become an important problem in optimizing large-model inference.
A research team from the Institute of Automation of the Chinese Academy of Sciences, the University of Electronic Science and Technology of China, the Chinese University of Hong Kong, Shenzhen, Tianjin University and the University of Science and Technology Beijing has proposed CompilerKV: a method based on offline experience compilation for risk-adaptive KV cache compression. Through offline calibration, the method learns the reliability of different attention heads and the compression risk of different prompts, compiling them into two lookup tables for direct lookup during inference.
With a 32K context, CompilerKV retains the KV states of only 512 input tokens per layer. On LongBench evaluations across four 7B/8B models, its average score reaches 42.31, close to FullKV's 42.14. In addition, the paper reports that, on a single A100-80GB with 32K input and 8K output, decoding throughput reaches 2.45 times FullKV's.

- Paper title: CompilerKV: Risk-Adaptive KV Cache Compression via Offline Experience Compilation.
- Paper link: https://arxiv.org/pdf/2602.08686
- Code link: https://github.com/Chengzhi-W/CompilerKV
1. The core insight: a single prompt is the 'wrong statistical unit'
Why can estimating KV importance online from a single input so easily go wrong?
After an in-depth analysis of attention distributions, the researchers found that the two core signals determining whether KV compression succeeds—the functional reliability of attention heads (Per-head Reliability) and the compression risk of the context (Prompt-level Compression Sensitivity)—often have an extremely low signal-to-noise ratio within a single prompt and are highly susceptible to local token fluctuations. Viewed across samples, however, they exhibit very strong Cross-prompt Regularity.

Figure 1: Empirical evidence of three failure modes: noisy attention statistics within a single prompt, polarized head reliability, and compression damage that varies systematically with entropy and perplexity.
The experiments provide highly convincing evidence: when the team independently ranked attention-head reliability using academic-paper corpora (arXiv + PubMed) and everyday-conversation corpora (ShareGPT + UltraChat), the mean Spearman rank correlation between the two reached ρ = 0.90 (0.89–0.91) across several mainstream models.
This means that which heads handle long-range retrieval and which need only attend to a local window are essentially the model's own Portable Architectural Priors, rather than properties that change dramatically with each input. Recomputing these architectural priors online for every input, when they should have been distilled offline, not only wastes computation but can also cause catastrophic mistaken evictions in extremely long or highly noisy contexts.
2. CompilerKV: offline tables under 100 KB take over online retention decisions
Building on this insight, CompilerKV reformulates KV compression as a two-stage paradigm: 'offline experience compilation + online O(1) table lookup.' The team developed three tightly connected core components, each corresponding precisely to one of the three sources of error in prefill compression:

Figure 2: CompilerKV's overall framework. Offline, CQL compiles two decision tables. Online, after a standard Observation Window scan, constant-time lookups correct for Head Reliability and perform prompt-risk-adaptive selection.
1. Parameter-free Stabilized Token Utility
Online, CompilerKV retains the standard observation-window scan, aggregating attention mass within the window and incorporating the norms of the Value vectors (Value Norm) for normalization. Without any learnable parameters, this step smooths transient attention spikes from individual query positions and provides a clean base signal for subsequent scoring.
2. An offline-compiled Head Heterogeneity Table
Using approximately 50,000 calibration examples, the researchers employ CQL-regularized Offline Reward Regression to compile a continuous reliability-weight table, Whead, for every attention head in every layer of the model.
Notably, for the GQA (grouped-query attention) architecture widely used in modern large models, CompilerKV deliberately keeps weight indexing at the finer Query Head granularity, aggregating scores within each layer through Weighted Max-Pooling. This gives a single long-range retrieval query head in a GQA group 'veto power' when it considers a token crucial, countering the averaging tendency of other local heads and increasing the chance of retaining key memories, without guaranteeing completely lossless compression.
3. Risk-Adaptive Threshold Lookup Table (LUT)
Different prompts have very different 'compression tolerance': loosely structured casual conversation can remain fluent after 90% of the cache is removed, while information-dense multi-hop reasoning or needle-in-a-haystack tasks can collapse after a mistaken eviction. CompilerKV compiles a risk-threshold table offline, jointly indexed by layer, Attention Entropy, Local Perplexity and the layer budget.
During online inference, a single O(1) lookup based on the current input's entropy and perplexity dynamically adjusts the retention threshold. For simple, low-risk text, it raises the threshold and decisively removes redundancy; for complex, high-risk text, it automatically relaxes the threshold, using CQL's out-of-distribution (OOD) conservative regularization to reduce the risk of tail failures. This is not a guarantee that failures will never occur on any input.
The two compiled lookup tables are extremely compact: for a 32-layer, 8B model, their total storage footprint is under 100 KB; even for a 72B-scale model, the tables remain well below 1 MB.
3. Experimental evaluation: retaining only 1.56% of the cache while supporting 128K contexts and batch-16 inference
The team conducted comprehensive evaluations on several mainstream backbones, including LLaMA-3, Qwen2, Mistral, InternLM-2.5 and the latest Qwen3-8B. The results show significant advantages for CompilerKV under extremely tight GPU-memory budgets:
New compressed-method state of the art across LongBench (Figure 3): under an extremely tight 512 Token cache budget, CompilerKV achieves the best compressed-method result on all four backbones, outperforming the strongest prefill-only baseline by an average of +1.67 points (95% confidence interval [+1.08, +2.37]). On Qwen3-8B, the score at a 512-token budget reaches 49.67, ahead of all compressed baselines (48.93) and even slightly above uncompressed FullKV (49.46).

Figure 3: LLaMA-3-8B performance at different KV cache budgets. The left panel shows the LongBench average, and the right shows cross-task tail performance, Task-P10. CompilerKV maintains strong compression performance across cache budgets.
128K ultra-long-context stress test (Figure 4): keeping the prefill-cache retention ratio fixed at 1.56% (512/32k) means retaining 2,048 entries on the 128K RULER long-context benchmark, rather than always keeping only 512. Under this setting, the conventional method SnapKV falls to 38 points, while CompilerKV still achieves approximately 73 points, close to FullKV's 79 points with the full cache. In the 32K Needle-in-a-Haystack (NIAH) test, its retrieval accuracy reaches 0.89, more than twice SnapKV's 0.42.

Figure 4: Needle-in-a-Haystack stress test: with only 1.56% of the cache retained, CompilerKV's retrieval accuracy is still 2.1 times SnapKV's.
Relieving GPU-memory pressure and doubling throughput (Table 1): at a 32K input length, FullKV runs out of memory (OOM) at Batch-16 concurrency, while CompilerKV can still serve in this single-GPU experiment. Here, 1.56% refers only to the proportion of prefill KV entries retained, not total GPU-memory usage; KV states for newly generated tokens are still appended normally. In the batch-1 setting with 32K input + 8K output, end-to-end latency falls from 706.56 seconds to 285.00 seconds, corresponding to a speedup of 2.48×, and generation throughput rises from 11.65 tokens/s to 28.50 tokens/s (2.45×).

Table 1: Batch stress test with 32k input: FullKV runs out of memory at batch 16, while CompilerKV continues serving and achieves up to 4.4× throughput.
4. Engineering deployment: offline compilation costs and SGLang integration conditions
For industry, the overhead of offline compilation and compatibility with production engines are equally important. The team's newly added engineering experiments provide clear answers:
1. Manageable compilation costs that can be amortized: The paper reports approximately 20 GPU-hours for full offline compilation of an 8B model on A100-80GB, and approximately 169 GPU-hours for a 72B model. More than 96% is spent collecting statistics through forward passes of a frozen model; table fitting takes approximately 0.7 GPU-hours in the 8B setting and approximately 3 GPU-hours in the 72B setting. The offline cost could be amortized through continuous serving, but the payback period depends on actual request volume, hardware and workload. A 2.45× decoding-throughput gain alone cannot guarantee payback within a few days. The compiled lookup tables also support cross-model transfer: in the paper's tests, directly reusing them between similarly sized models with different architectures costs an average of 0.4–0.8 LongBench points.

Table 2: Direct cross-model transfer of compiled tables: a loss of only 0.3–0.4 points within the same family, and an average of 0.4–0.8 points across families.
2. Native integration with a paged-memory engine (SGLang): CompilerKV requires no changes to the underlying decoding operators. It triggers a single 'KV-slot Remapping' operation at the boundary between prefill and decode, copying the selected 512 physical KV blocks into compact storage, releasing the remaining paged GPU memory, and decoupling logical sequence length (32,768) from physical cache length (512). Subsequent generation can therefore preserve correct rotary positional encoding, while the attention kernel scans the retained 512 prefill entries and subsequently generated KV states, adapting to the paged-inference setting described. This is the serving integration reported in the paper; its tests disable Radix Cache, chunked prefill and CUDA Graph. The current public code release does not yet include this SGLang integration. The 512 entries refer to the retained prefill portion, excluding generated KV states that are subsequently appended normally.
Conclusion
CompilerKV offers a highly illuminating perspective on optimizing long-context inference: many dynamic heuristic decisions in large-model inference are essentially repeated, inefficient estimates of fixed architectural priors. By separating out 'attention-head reliability' and 'risk sensitivity' for offline experience compilation, CompilerKV uses static lookup tables under 100 KB to obtain robust accuracy and concurrent serving throughput at extreme compression ratios, laying out a clean, practical engineering path toward lower-cost deployment of LLMs with exceptionally large contexts.
This article comes from Synced, and was written by Synced.
Related topics
After reading
Join the AINRK community
Read how to join the community and connect with people working in AI.




