Introducing RAZOR
Occam's razor, turned into a price: a model pays for every write to long-term memory, and when it declines to pay, memory stays exactly as it was.

RAZOR is an ongoing experiment at Manaslu Labs. The name stands for Recurrent Attention with Zero-redundancy Occam Registers, and the name is the idea: Occam's razor, turned into a price.
The Minimum Description Length principle (Rissanen, 1978) says the total cost of a model is the cost of its errors plus the cost of its own complexity. RAZOR applies this to memory. During training, the model is penalised a little for every write it makes to long-term storage, on top of the ordinary penalty for predicting text badly.
Because writing has a price, the model learns to write only when a token carries information likely to pay for itself later (a definition, a signature, a constant) and to leave memory untouched for filler.
Three ways to keep a record, and a fourth
When a language model reads, it needs some record of the past, and every existing way of keeping that record has a cost:
- Storing everything runs out of memory.
- Compressing everything risks slow forgetting.
- Deleting what looks unimportant sometimes deletes the wrong things.
RAZOR tries a fourth option: a learned on/off switch that decides, as each token arrives, whether it is worth writing into long-term memory.
01
Store everything
Exact, but memory grows with every token.
02
Compress everything
Fixed size, but every token blurs what is stored.
03
Delete what looks unimportant
Bounded, but a quiet definition can be evicted before it is needed.
04
RAZOR: pay to write
Writes only when a token is worth its price; otherwise exactly nothing changes.
A switch that is exactly off
The switch must be binary, because a gate left 99.9% open is still a leak. Across filler tokens, a stored value decays as , which after a few thousand tokens is close to nothing. So RAZOR's gate is forced to exactly 0 or exactly 1, using a straight-through estimator during training.
Each register follows the recurrence
When the gate reads , this becomes and . The old state is multiplied by 1.0 and exactly 0.0 is added. Not approximately: bit-for-bit. Filler tokens cannot erode what is stored.
How RAZOR is trained
Either way, training with the MDL penalty always means the task loss plus the penalty. The penalty shapes behaviour; it is not the teacher.
Native RAZOR
Trained from scratch on the ordinary task loss (predict the next token, or the answer) plus the MDL state penalty:
The strength stays at zero for the first part of training, then ramps up, so the model learns syntax before it is pressured to economise on writes.
RAZOR-Qwen
A bolt-on version for a pretrained model. We freeze the entire
Qwen2.5-Coder-1.5B backbone (1.54 billion parameters) and train only small
gates, about 1.4 million parameters across 28 layers, under 0.09% of the
model. The objective combines three terms:
- ordinary prediction error;
- a self-distillation term: the gated model imitates its own ungated self, so no human labels are needed;
- the MDL write penalty.
A feedback controller (dual ascent) adjusts the penalty strength at every step so the fraction of retained cache lands on a chosen budget, here 15%:
At inference, the cache keeps three kinds of positions and physically slices out the rest:
What the lab's tests show
Tracking one bit through noise
Native models were trained on 64-token sequences with about 85% noise tokens, then tested on much longer ones. The task is to track a single bit of state (parity) through the noise. Chance is 50%.
Noisy parity tracking, accuracy by test length (N = 200 each)
| Model | T = 64 | 256 | 512 | 1,024 | 2,048 |
|---|---|---|---|---|---|
| RAZOR | 100.0% | 100.0% | 100.0% | 98.5% | 98.0% |
| Soft gate, no MDL | 100.0% | 100.0% | 99.5% | 99.0% | 94.0% |
| Gated DeltaNet | 49.0% | 50.0% | 52.0% | 52.5% | 52.5% |
| Sliding window | 56.0% | 49.5% | 51.5% | 48.0% | 50.0% |
| Full attention | 58.0% | 45.5% | 47.0% | 50.5% | 45.5% |
RAZOR holds 98.0% through 2,048 tokens of noise. The same recurrence with a continuous gate and no penalty is close behind until it starts to drift at the longest length, which is the leak the binary gate is meant to close.
Remembering variables through distractors
Four variable bindings at the start of a sequence, up to 2,000 distractor tokens, then a query for one of them.
Associative variable recall, accuracy by test length (N = 200 each)
| Model | T = 64 | 256 | 512 | 1,024 | 2,048 |
|---|---|---|---|---|---|
| RAZOR | 100.0% | 100.0% | 100.0% | 100.0% | 100.0% |
| Full attention | 100.0% | 99.5% | 99.0% | 100.0% | 100.0% |
| Soft gate, no MDL | 98.0% | 98.5% | 98.5% | 99.0% | 98.0% |
| Gated DeltaNet | 9.0% | 11.5% | 15.0% | 12.0% | 9.0% |
| Sliding window | 8.5% | 10.0% | 15.0% | 11.5% | 7.5% |
A frozen Qwen model with 85% less cache
On the lab's passkey test, a secret number is placed in filler and asked for at the end. With 15% of the cache retained, RAZOR-Qwen gets every sample right at every length we tested.
Qwen2.5-Coder-1.5B passkey retrieval at a 15% cache budget (N = 50 each)
| Cache policy | T = 128 | 256 | 512 | 1,024 |
|---|---|---|---|---|
| RAZOR (15%) | 100.0% | 100.0% | 100.0% | 100.0% |
| Full cache (100%) | 100.0% | 100.0% | 100.0% | 100.0% |
| H2O (15%) | 18.0% | 16.0% | 100.0% | 100.0% |
| StreamingLLM (15%) | 12.0% | 28.0% | 18.0% | 42.0% |
| Random eviction (15%) | 16.0% | 18.0% | 16.0% | 24.0% |
The same pattern holds on two other lab tasks at 256 tokens: tracking Python variables defined long before they are used, and keeping intermediate facts in multi-step maths problems.
Lab tasks at T = 256 with a 15% cache budget (N = 50 each)
| Cache policy | Code variables | Math facts |
|---|---|---|
| RAZOR (15%) | 100.0% | 100.0% |
| Full cache (100%) | 100.0% | 100.0% |
| StreamingLLM (15%) | 44.0% | 32.0% |
| H2O (15%) | 38.0% | 30.0% |
| Random eviction (15%) | 36.0% | 26.0% |
Because evicted positions are sliced out of the cache tensors rather than masked, the savings are real memory:
Measured KV cache per sequence at T = 1,024 (all 28 layers, fp16)
| Full cache | |
|---|---|
| RAZOR6.7× smaller | |
| StreamingLLMwindow only |
What it costs, and where it fails
Compression is not free. In a separate run on public benchmarks (gates calibrated to retain 12.56% of the cache), the frozen Qwen model keeps most of its coding ability but not all of it:
HumanEval pass@1, Qwen2.5-Coder-1.5B (N = 30)
| Full cache (100%) | |
|---|---|
| RAZOR (12.56%) | |
| StreamingLLM (15%) | |
| H2O (15%) |
| WikiText-2 perplexity (lower is better) | T = 512 | T = 1,024 |
|---|---|---|
| Full cache (100%) | 15.02 | 12.43 |
| H2O (15%) | 20.97 | 17.12 |
| RAZOR (12.56%) | 20.97 | 19.60 |
| StreamingLLM (15%) | 27.58 | 26.68 |
On language modelling, RAZOR ties H2O at 512 tokens and trails it at 1,024. And on RULER's multi-key passkey task (1,024 to 4,096 tokens), RAZOR, H2O and StreamingLLM all score 0 of 25, while the full cache scores 25 of 25. A perfect score on our own passkey test does not carry over to a harder one.
Update: RULER, with a gate trained end to end
The RULER result above was the hardest one in this post, so it is where we went next. Instead of calibrating gates by hand, we trained RAZOR's write price directly into a cache-eviction gate for Qwen3-1.7B, and scored it with NVIDIA's open-source kvpress harness, against the methods that harness ships.
The gate is the same small MLP that KVzap uses, so the comparison is about how it is trained, not its size. KVzap trains it to imitate a hand-designed importance score. RAZOR trains it on the objective itself: the compressed model must predict the same next token as the full model, and every token it keeps has a price.
The keep decision is hard and binary in the forward pass, exactly as in the rest of this post, and adjusts itself during training to hold a target keep rate of 30%. The most recent 128 tokens are never evicted. One training run took about 40 minutes on a single GPU.
RULER at 4,096 tokens, Qwen3-1.7B (650 samples, 13 tasks)
| Full cachenothing evicted | |
|---|---|
| RAZOR gate76% evicted | |
| KVzip+76% evicted | |
| KVzap-style gate76% evicted |
At matched compression, the RAZOR gate keeps 97.6% of the full cache's score and beats the gate trained to imitate KVzip+ by 7 points. It matches KVzip+ itself, which scores the cache by running the model again over the context. The KVzap-style gate loses most on multi-key retrieval and variable tracking, exactly where a dropped token cannot be recovered.
The gap holds across compression levels. Sweeping each gate's threshold on a smaller 195-sample slice:
| Gate | Cache evicted | RULER score |
|---|---|---|
| RAZOR | 70% | 86.8 |
| RAZOR | 76% | 86.4 |
| RAZOR | 82% | 83.8 |
| KVzap-style | 60% | 85.8 |
| KVzap-style | 71% | 82.5 |
| KVzap-style | 80% | 73.8 |
| KVzap-style | 86% | 60.8 |
The KVzap-style gate has to keep 40% of the cache to reach the score RAZOR holds while keeping 24%. Two RAZOR gates trained from different seeds land within half a point of each other at the same threshold (86.4 and 87.0).
What's next
Those runs are finished, and the full results are in our paper: RAZOR: learning what to forget in the KV cache.



