RAZOR: learning what to forget in the KV cache
Our first paper. A small gate, trained in 39 minutes on one T4, lets a frozen LLM delete 76% of its KV cache and read 123k tokens on a 16 GB GPU.

Today we are publishing our first paper: RAZOR: Learning What to Forget in the KV Cache with a Description-Length Price, by Himansu Rawal.
The problem
A language model keeps a record of every token it has read, called the KV cache. The cache grows with every token, and at long context it takes more GPU memory than the model itself. For Qwen3-4B, 128k tokens of cache need about 19 GB, against 8 GB for the weights.
What RAZOR does
RAZOR is a small gate attached to a frozen model. As each token is written to the cache, the gate decides whether the model will need it again. Tokens it drops are freed from GPU memory, not just hidden.
The gate is trained with two pressures:
- Change nothing. The model's predictions with the reduced cache must match its predictions with the full cache.
- Pay for what you keep. Every kept token has a price. The price adjusts itself during training until a memory budget is met, so there is no weight to tune by hand.
The keep/drop decisions are binary during training, exactly as they are when the model runs, so the gate is trained on the same cache it will produce in use. The base model is never modified. The gate adds 1.7% to the parameter count and trains in 39 minutes on a single NVIDIA T4, using documents of at most 1,000 tokens.
Results
Three quarters of the cache, almost none of the quality
RULER at 4,096 tokens, Qwen3-1.7B (650 samples, 13 tasks)
| Full cachenothing evicted | |
|---|---|
| RAZOR76% evicted, mean of 5 seeds | |
| KVzip+76% evicted, reads the context twice | |
| Same gate, KVzap's objective76% evicted |
RAZOR ties KVzip+, the strongest method in the harness, which has to read the context a second time to score it. RAZOR scores tokens during the normal forward pass.
It holds far beyond its training length
The gate never saw a document longer than 1,024 tokens. It still works at 16 and 100 times that length:
| Benchmark | Full cache | RAZOR | Evicted |
|---|---|---|---|
| RULER 16k, Qwen3-1.7B | 77.9 | 75.4 | 81% |
| RULER 4k, Qwen3-4B | 94.3 | 93.9 | 74% |
Both rows use 195 samples. On InfiniteBench at 100k tokens (Qwen3-4B, four tasks, 12 samples each), RAZOR is within one item of the full cache on every task while evicting 76–84% of the cache.
123k tokens on one 16 GB GPU
Because evicted entries are actually freed, a longer context fits on the same card. On a single T4, Qwen3-4B with the full cache fits about 31k tokens and runs out of memory at 61k. With RAZOR it reads 123k tokens with a 2.8 GB cache.
Decoding gets faster as well, because each new token attends to a much smaller cache:
| Context | Full cache | RAZOR |
|---|---|---|
| 8k tokens | 8.8 tokens/s | 8.2 tokens/s |
| 15k tokens | 4.7 tokens/s | 8.0 tokens/s |
| 29k tokens | 2.6 tokens/s | 7.5 tokens/s |
| 61k tokens | out of memory | 4.5 tokens/s |
| 115k tokens | out of memory | 2.7 tokens/s |
At 29k tokens RAZOR decodes 2.9× faster. At 8k, where the cache is small, it is 7% slower because of the gate's own overhead. These are single runs on a T4, so treat the exact ratios as approximate.
The price means something
The price the gate pays per kept token is set automatically during training. We trained gates at four memory budgets and found that, at every one, the price the training settles on matches the slope of the quality-versus-memory curve. In other words, it measures what one more unit of cache is worth to the model. It rises 68-fold as the budget tightens from 50% to 10% of the cache.
What the gate learns
Nothing tells the gate how to organise the model's attention heads, but a structure appears. Of 224 heads, 18 keep more than 90% of tokens and 73 keep fewer than 5%, working only from the most recent 128 tokens. The gate keeps line breaks and content words most often, and drops articles and prepositions.
Limits
The paper has a full limitations section. The main ones:
- Scale. We tested 1.7B and 4B models on free T4 GPUs. Larger models are untested.
- Counting tasks. RAZOR loses accuracy on tasks that need every occurrence of a repeated word, because repeats look redundant to the gate.
- Baselines. We compare against the methods in kvpress and a KVzap-style gate we trained ourselves. We have not yet run head-to-head comparisons with other recently published learned gates.
- Sample sizes. Several results use 195 samples or fewer; differences under about 3 points at that size are within noise.
The paper also reports five variants we tried that did not help.
What's next
We are scaling RAZOR to larger models, running the missing comparisons and preparing a code release. Manaslu Labs is a member of NVIDIA Inception.
For questions about the paper, get in touch.



