✨ From vibe coding to vibe deployment. UBOS MCP turns ideas into infra with one message.

Learn more
Andrii Bidochko
  • Updated: January 18, 2026
  • 8 min read

NVIDIA Releases KVzap: A Lightweight Surrogate for Near‑Lossless KV Cache Compression in LLMs

NVidia’s KVzap: Near‑Lossless 2‑4× KV‑Cache Pruning for Long‑Context LLMs

KVzap illustration – KV‑cache pruning for large language models
KVzap visualised: a lightweight surrogate predicts KV‑importance scores to prune the cache.

KVzap is NVidia’s open‑source surrogate model that predicts the importance of each key‑value (KV) entry in a transformer’s cache, enabling 2‑4× memory compression with almost no loss in accuracy for long‑context inference.

Why KV‑Cache Size Is the New Bottleneck in LLM Deployments

Modern large language models (LLMs) such as Llama‑3, Qwen‑3, and Gemini can now process tens of thousands of tokens in a single prompt. While the attention matrix scales quadratically with sequence length, the key‑value (KV) cache grows linearly, storing a copy of every token’s hidden state for every layer and head. At 128 k tokens, a 65‑billion‑parameter model can require more than 300 GB of GPU memory in bfloat16 – a size that exceeds the capacity of most production GPUs and forces developers to shrink batch sizes or truncate prompts.

Existing engineering tricks—grouped‑query attention, sliding‑window attention, or hybrid state‑space layers—compress the cache along the head or value dimensions but leave the sequence axis untouched. The result is that long‑context serving still stalls on memory bandwidth, not compute. A practical solution must therefore prune cache entries that contribute little to future token predictions.

NVidia’s AI news hub has highlighted a surge of research around KV‑cache pruning, culminating in the LLM optimizations page that tracks the latest breakthroughs. KVzap is the most recent addition, promising near‑lossless compression with a tiny compute overhead.

What Is KVzap? – A Surrogate‑Based Pruning Engine

KVzap replaces the expensive oracle scoring used by earlier methods (e.g., KVzip and KVzip+) with a lightweight MLP surrogate that operates directly on the hidden states produced by each transformer layer. Instead of running a duplicated “repeat‑prompt” pass to compute attention‑based importance scores, KVzap predicts a log‑score for every KV head in a single forward pass.

The method is motivated by two observations:

  • Oracle scores are accurate but slow. KVzip+ needs an extended prompt that doubles the context length, making it unsuitable for real‑time inference.
  • Hidden states already encode token relevance. A small neural network can learn to map these states to the same importance distribution that KVzip+ would produce.

By learning this mapping, KVzap delivers the same pruning quality while adding less than 1 % extra FLOPs—practically free in the quadratic‑cost regime of long‑context attention.

Technical Details – From Surrogate Design to Inference Pipeline

Surrogate Architecture

Two variants were evaluated:

  1. KVzap Linear – a single linear projection from the hidden vector hₜ to a log‑score per head.
  2. KVzap MLP – a two‑layer MLP with GELU activation and a hidden width equal to one‑eighth of the model’s hidden size. This version consistently outperformed the linear variant, achieving Pearson‑squared correlations of 0.77 vs. 0.63 on validation data.

Training Pipeline

The surrogate was trained on the Nemotron Pretraining Dataset. After filtering for prompts between 750 and 1,250 tokens, the authors sampled up to 500 prompts per length bucket and extracted 500 token positions per prompt. For each head, this yielded roughly 1.2 M (hidden state, KVzip+ score) pairs, plus a 23 k‑pair validation set.

The loss function minimized the mean‑squared error between the predicted log‑score and the oracle KVzip+ score. Training converged in under 12 hours on a single A100 GPU, demonstrating that the surrogate can be learned with modest resources.

Inference Workflow

During decoding, KVzap processes the hidden state of each layer, emits a score for every KV entry, and prunes entries whose score falls below a global threshold. A sliding window of the most recent 128 tokens is always retained (scores set to ∞) to guarantee that the model never loses immediate context.

The pruning step is inserted after the attention operation, which means the model still benefits from the full attention context for the current token before discarding low‑value entries. The entire operation is encapsulated in a few lines of PyTorch code, making integration trivial for any existing KV‑press pipeline.

Performance Benchmarks – RULER, LongBench, and AIME‑25

KVzap was evaluated on three widely‑used long‑context suites using three base models: Qwen‑3‑8B, Llama‑3.1‑8B‑Instruct, and Qwen‑3‑32B.

RULER (Synthetic Scaling)

RULER measures accuracy across synthetic tasks from 4 k to 128 k tokens. KVzap achieved compression ratios between 2.7× and 3.5× while keeping the average score within 0.2 points of the full‑cache baseline. For Qwen‑3‑8B at 16 k tokens, KVzap removed >70 % of KV entries yet the task score dropped by less than 0.1.

LongBench (Real‑World Documents)

On LongBench, which contains heterogeneous documents (legal, scientific, narrative), KVzap maintained near‑baseline performance up to a 2–3× compression factor. Competing fixed‑budget methods such as Expected Attention degraded noticeably beyond 2× compression, whereas KVzap’s adaptive threshold kept the error margin under 1 % across all subsets.

AIME‑25 (Olympiad‑Level Math)

AIME‑25 evaluates reasoning on 30 high‑difficulty math problems. KVzap‑MLP preserved the pass@4 metric at a 2× compression and even slightly improved it on some prompts, demonstrating that pruning does not harm the model’s ability to retain critical reasoning steps.

KVpress Leaderboard Impact

When submitted to the public KVpress leaderboard, KVzap claimed the top spot, outperforming prior SOTA methods (H2O, DuoAttention, Compactor) on the combined RULER + LongBench score while offering the lowest compute overhead.

How KVzap Stands Against Existing Pruning Techniques

The table below summarises the key trade‑offs:

Method Compression (×) Accuracy Δ Compute Overhead
KVzip+ 2–3 ≈ 0 % (oracle) ~ 30 % (requires double prompt)
Expected Attention 1.5–2 ‑0.5 % to ‑1 % ~ 0.5 %
KVzap Linear 2–2.5 ‑0.1 % to ‑0.3 % ~ 0.02 %
KVzap MLP (SOTA) 2.7–3.5 ‑0.05 % to +0.1 % ~ 1.1 %

KVzap’s advantage lies in its adaptive thresholding—a single global score threshold automatically yields different compression ratios per prompt, reflecting the varying information density of the input. This flexibility eliminates the need for per‑task hyper‑parameter tuning.

Practical Impact – Easy Integration and Minimal Overhead

For developers, KVzap translates into three concrete benefits:

  • Plug‑and‑play code. The open‑source kvpress repository ships a ready‑to‑use PyTorch function that accepts hidden states and returns compressed KV tensors.
  • Negligible latency. In a 32‑B model, the MLP variant adds only ~1 % FLOPs, which is dwarfed by the quadratic attention cost at >8 k tokens.
  • Scalable across hardware. Because the surrogate runs on the same device as the model, no extra GPU memory is required; the only additional memory is a few megabytes for the per‑layer MLP weights.

Companies can therefore serve 128 k‑token prompts on a single A100, cut inference cost by up to 30 %, and keep latency within production SLAs. This opens the door for new use‑cases such as full‑document summarisation, legal contract analysis, and multi‑turn chat with extensive context histories.

Where to Learn More and How to Get Started

NVidia has released the full paper and checkpoints on Hugging Face. To experiment, clone the kvpress repo, drop the kvzap_mlp.pt checkpoint into your model directory, and wrap your inference loop with the provided prune_kv_cache() helper.

For a broader view of how KV‑cache pruning fits into the AI ecosystem, explore the AI news hub and the LLM optimizations page on UBOS. These resources discuss complementary techniques such as ChatGPT and Telegram integration and the OpenAI ChatGPT integration, which often benefit from reduced memory footprints.

If you are a startup or SMB looking to embed KVzap‑enabled models into your product, UBOS offers ready‑made solutions:

For rapid prototyping, the UBOS templates for quick start include a “KV‑Cache Optimiser” starter that wires KVzap into a Flask‑based API. Pricing details are transparent on the UBOS pricing plans page.

Conclusion – A New Era for Long‑Context LLM Inference

KVzap demonstrates that a well‑trained surrogate can replace heavyweight oracle scoring without sacrificing accuracy. By delivering 2‑4× KV‑cache compression with sub‑percent compute overhead, it removes the primary memory barrier that has limited the practical deployment of ultra‑long context models.

As the community continues to push token limits beyond 200 k, methods like KVzap will become foundational building blocks. Developers can now experiment with richer prompts, multi‑document reasoning, and interactive agents that remember entire conversations—all while staying within a single GPU’s memory budget.

Stay ahead of the curve by following the latest AI news, and consider integrating KVzap into your next LLM service. The open‑source nature of the project means you can adapt the surrogate to your own model family, further extending its impact.

For the original detailed write‑up, see the MarkTechPost article.


Andrii Bidochko

CTO UBOS

Andrii Bidochko is an AI entrepreneur and researcher focused on AI agents, reinforcement learning, and autonomous systems. He writes about the technologies shaping the future of machine intelligence, from frontier models and agent architectures to real-world AI applications.

Sign up for our newsletter

Stay up to date with the roadmap progress, announcements and exclusive discounts feel free to sign up with your email.

Sign In

Register

Reset Password

Please enter your username or email address, you will receive a link to create a new password via email.