Research direction IV · go/no-go test: failed, then passed with joint training · deciding test next · results updated 24 November 2026

Some layers need the whole past, some need none of it, and most only need the gist.

AMTR-KV (Adaptive Multi-Timescale Recurrent KV compression) is a research project on the memory a language model uses while it reads a long input. To look back at earlier tokens, a transformer stores a key vector and a value vector for every token in every layer. This store is the KV cache, and it grows with the input: Qwen3-8B needs 144 KiB per token, so one 128K-token document fills about 18 GiB, more than the model's own weights. All of it is read again for every token the model writes.

Most ways of shrinking the cache without retraining the model make a yes-or-no choice for each layer or attention head: keep its whole cache, or keep only a few tokens from the start plus a recent window and throw everything older away. AMTR-KV adds a third option. A layer can fold its old tokens into a small, fixed-size memory instead of keeping them or losing them. The model's weights stay frozen; only small adapters are trained. The project asks two things: does a third option beat the best two-option plan at the same total memory, and does a memory split into three parts with different time horizons beat a single memory of the same size?

Drop
Keep a few start tokens and the recent window
For layers whose attention rarely reaches far back. Everything older is freed.
Fold
Same, plus a small learned memory of the rest
For layers that need old context, but spread over many tokens. The old tokens are compressed, then freed.
Exact
Keep every token
For layers that look up specific far-back tokens, like a name or a number. Nothing is freed.
59%
of Qwen3-0.6B's 224 KV heads (133) need their old context, but spread thinly over many tokens: candidates to fold. It is 31–79% depending on the thresholds.
0.77 vs 0
how well two signals rank the 28 layers by the damage of dropping their old tokens (Spearman ρ): the project's headroom measure against attention entropy, a signal earlier methods use.
≈ 1%
of the score a per-input plan would get is lost by one fixed plan computed once (7% in the worst case). Which layers need what barely depends on the input.
52%
of the error left by an equally sized longer window that one small memory removes, layer by layer, once the input is 32 windows long (median of 6 layers). With inputs only 8 windows long, it was a tie.
0.23 nats
lower loss on the tokens that need long context (1.56 against 1.79) than the same bytes spent on a longer window, once the six folded layers are trained together. Trained one at a time, they tied, and the go/no-go test said no.
Status, 24 November 2026. Every experiment so far runs on one laptop, with Qwen3-0.6B-Base as the frozen model and inputs of 4K–8K tokens, so every number on this page is preliminary and small-scale: one training seed, 20 examples per task. The measurements of which layers need what are done. The go/no-go test for the fold, with its pass and fail rules written down before any of its results existed, has returned its verdict in two steps. With each layer's memory trained on its own, as first planned, folding six layers did no better than spending the same bytes on a longer window: a no-go, which stays on record. Follow-up tests were then fixed in advance, again before any of their results. The first trains the six folded layers together, and with that one change the same test passes (1.56 against 1.79 nats on the tokens that need long context). Both tests used a small 256-token window, so the follow-up that decides the project runs at a 2,048-token window on 32K-token inputs: if the fold fails there, it is declared dead and the paper becomes an analysis of which layers need what. A paper draft, Exact, Fold, or Drop: Allocating the KV Cache of Pretrained Transformers with Multi-Timescale Recurrent Memory, reports both verdicts. Larger models (Qwen3-1.7B, Llama-3.2-1B, then 8B models on rented GPUs) come only if the deciding test passes. None of the ingredients is new on its own, and the related-work section says exactly which parts might be.
What the results have already changed.
  • Train the folded layers together. Each memory was first trained to reproduce its own layer's output, with every other layer intact. With six layers folded at once, their small errors add up, and the go/no-go test failed. Fine-tuning the six memories together, so that the whole model's predictions match the original's, turned the result around. It is now a required step.
  • One small memory first, the bank second. Measured per byte, a single memory has done best on every layer tested; the three-horizon bank beats a single memory of the same total size, but only by 0.02. The deciding tests now use one memory stored at 16-bit precision (the bytes of 65 cached tokens), and the bank runs alongside.
  • Fold the right layers, not the least important ones. The first plan folded the layers that matter least. But those layers have almost nothing to win back: on layer 0, a trained memory did worse than simply dropping the old tokens. Hence three modes, with folding kept for layers whose old context matters but is spread out.
  • One fixed plan, not a new plan per conversation. Re-deciding the plan for every input was meant to be central. A fixed plan loses about 1% of what a per-input plan would get, so per-input planning is now an optional extra that has to prove itself.
  • A stricter bar and a fairer test. The first fold test, at short context, tied with spending the same bytes on a longer window. That setting favours the longer window by construction, so the go/no-go test runs at realistic ratios of input length to window, with each variant scored at its own memory cost.

Background

Where the memory goes, and what current methods do with it

Each layer of a transformer has several attention heads. For every new token, a head compares the token's query vector with the stored keys of all earlier tokens and returns a weighted average of their stored values. In models with grouped-query attention, such as Qwen3 [1], several query heads share one set of keys and values: Qwen3-0.6B has 16 query heads and 8 KV heads per layer, and the KV head is the unit that owns memory. Its cache costs 4 KiB per token per layer, so 112 KiB per token over 28 layers.

StreamingLLM [2] showed that a model keeps working if each head keeps just two things exactly. The first is a few tokens from the very start, which soak up a lot of attention for reasons that have little to do with their content (they are called attention sinks). The second is a window of the W most recent tokens. Every older token is evicted. That works for fluent text but loses anything the model needs from further back. The methods that came after mostly decide where to accept that loss:

  • Two-mode methods keep the full cache in some heads or layers and evict in the rest. DuoAttention and RazorAttention [3, 4] pick the heads once, offline; LightTransfer and Flux Attention [5, 6] pick layers for each input.
  • Fold methods keep a fixed-size summary of the evicted tokens in a recurrent state, the kind of memory a linear-attention layer uses. AHN [7] does this in every layer of a frozen model, with one state per head. Turnout [8], posted on 20 November 2026, switches individual layers of a reasoning model from full attention to such a state while it generates. MomentKV [9] keeps simple statistics of the evicted tokens with no training at all.

Neither family asks which heads need their old tokens exactly, which can do without them, and which need them only in aggregate. To answer that, AMTR-KV measures two things for every KV head.

Headroom: does old context matter here? Full attention can be split exactly into two smaller attentions, one over the kept tokens (sinks and window) and one over the evicted tokens, mixed by a weight λ: the share of attention the kept tokens would get. Evicting sets that weight to 1, so the error it causes is (1 − λ) times the gap between the two outputs. Divided by the size of the full output, this is the head's headroom. It is how wrong window-only attention is, and therefore the most that any memory of the old tokens could put right. It can be computed exactly from one ordinary forward pass.

ofull  = λ · okept + (1 − λ) · oold          // exact for every query, every head
λ       = share of attention the kept tokens get  // sinks + window
headroom = (1 − λ) · ‖okept − oold‖ / ‖ofull‖     // the error of dropping, relative to the output

Concentration: could a summary stand in for the old tokens? If a head's attention on old tokens is spread over hundreds of them, as when it tracks the topic of a chapter, a fixed-size summary may be enough. If it lands on one or two specific tokens, as when it looks up a name mentioned once, the exact tokens are needed. Concentration is measured two ways: the largest share any single old token gets at the moment a needle-in-a-haystack question is asked (retrieval spikes are rare in ordinary text, so they have to be provoked), and how many old tokens the attention effectively covers on ordinary text.

Type A · low headroom

Drop

Window attention is already nearly exact: little attention reaches old tokens, or what it reaches says much the same as the window. Keep sinks and window, free the rest.

Type B · high headroom, spread out

Fold

Old context matters, but it is spread over many tokens. A recurrent memory can summarise it. Keep sinks and window, compress the rest into a small memory, free the old tokens. A borderline layer (B*) is a type-B layer with exactly one concentrated head.

Type C · high headroom, concentrated

Exact

The head retrieves specific distant tokens. No fixed-size summary can reproduce one particular old token, so it keeps its full cache. A layer counts as type C if two or more of its KV heads are.

The method in one picture

Three modes, chosen once under a memory budget

Each layer (or each KV head) gets one of the three modes. The choice is a small budgeting problem: every option has a memory cost and an expected quality loss, and the allocator starts from the cheapest plan and upgrades whichever layer buys back the most quality per byte, until the budget is spent. A two-mode method is the same allocator with the fold option removed, so comparing the two at the same total memory is a clean test of what the third mode adds.

ModeMemory per KV head, in cached-token equivalentsExpected loss
EXACTN, the whole input0
FOLD4 sinks + W + 385 for the memory (three 128 × 128 states in fp32, plus a running sum of the evicted keys)headroom × (1 − r), where r is the share of the error the memory recovers on that layer, measured
DROP4 sinks + Wheadroom

The main method computes the plan once, from scores averaged over a calibration set, for each memory budget. Re-scoring each new input at the end of its prompt is an optional refinement (hypothesis H3 below). The scorer only needs the last 64 queries of the prompt against all keys, and its layer ranking agrees with the full-sequence measurement at Spearman ρ = 0.97–0.99, so it works with fused attention kernels that never form the full attention matrix. The table shows the full three-memory bank; the tests so far found a single memory stored at 16-bit precision (65 token-equivalents) the most efficient per byte, so that is the variant the deciding tests use.

Findings so far · Qwen3-0.6B-Base · 4K–8K tokens · 21–24 November 2026

Most of the cache sits in the middle group, and at realistic proportions the fold wins layer by layer

Two kinds of measurement are in here. The first maps which layers and heads need what, with no training: profile every head on long WikiText documents and synthetic needle-in-a-haystack prompts, then drop each layer's old tokens in turn and measure how much the next-token loss rises (in nats; 0.01 nats is about a 1% rise in perplexity). The second trains the fold on single layers and compares it with cheaper alternatives, first on short inputs and then at realistic proportions. Unless stated otherwise, inputs are 4K tokens with 4 sinks and a 512-token window. The end-to-end go/no-go test has its own section below.

1 · Headroom predicts which layers get hurt; attention entropy doesn't

This matters because it says which signal to allocate memory by. Headroom works without any training, and layers above the median headroom carry 82% of the total measured damage. The same quantity has been used before under other names (LightTransfer's “lazy ratio” is the attention share outside the window, and Switch Attention [18] scores layers by the unnormalised gap), so the measurement itself is not claimed as new. What is new is pairing it with concentration to separate “fold” from “keep”. The type-B layers alone carry about three quarters of the damage, which is why a two-option method has to choose between keeping them in full and losing it. Dropping a single layer's old tokens never broke needle retrieval except in layer 11 (88%), because retrieval is spread redundantly across layers, so needle accuracy only tells methods apart when many layers are compressed at once.

2 · Most KV heads are type B: old context matters, but spread out

The result holds as inputs get longer and windows wider. A wider window turns some type-B heads into type A, as it should (more of what they need is now in the window), but type B stays the largest group at the default thresholds. Every row below uses the same model and thresholds; the ranges cover the 3 × 3 threshold grid.

Input lengthWindowType A headsType B headsType C headsType B share (threshold range)Type B / B* layers
4K512751331659% (31–79%)18 of 28
4K1,024991111450% (18–69%)19 of 28
8K512661421663% (40–82%)22 of 28
8K1,024851231655% (28–77%)18 of 28
8K2,048111104946% (14–67%)16 of 28

Two caveats. The thresholds are a choice, and at the strictest headroom bar (0.2) type B drops to 31–41% of heads at 4K, behind type A. And “spread out” is measured imperfectly: attention on old tokens is diffuse almost everywhere in ordinary text (the median head spreads it over about 246 tokens), so type C is found from needle-question attention. Being diffuse does not guarantee that a memory can recover it; the measured recovery per layer, not the label, is what the allocator uses.

3 · Which heads need what barely depends on the input

Per-head headroom ranks the heads almost identically on two disjoint sets of documents (Spearman ρ = 0.994), on single documents (median 0.986, lowest 0.949), on prose versus needle questions (0.903) and for a 256-token versus a 1,024-token window (0.980). Across task types the layer ranking is just as stable for prose, needle retrieval and variable tracking (0.98–0.99), and least stable for aggregation tasks, which ask about many tokens at once (0.76–0.81). A single plan calibrated on prose, applied to every task, loses about 1% of the score a per-input plan would capture on average (at most 3.2%, or 7.3% with the cheap last-64-query scorer). Flux Attention reports a similarly high cross-task agreement (0.918) for its own layer choices [6]. So the main method uses one fixed plan, and per-input planning has to earn its place, most likely on aggregation.

4 · The first fold test: the memory beats dropping, but not a longer window

The fold was trained one layer at a time to reproduce that layer's full-attention output, and scored on held-out documents by the share of a reference method's error it removes. The pre-set bar for “worth its bytes” is 25%. Three cheaper ways to use the same memory serve as rivals: one memory state three times as wide (the same bytes as the three-state memory), MomentKV [9], and a single “mean token” that stands in for all evicted tokens (as in RazorAttention [4]). The last two need no training.

  1. The memory is worth having over nothing. On 17 of 18 type-B layers it removes 19–67% of plain drop's error, and on every type-B layer except layer 1 it beats both no-training baselines.
  2. It is not yet worth its bytes. Against a window lengthened by the memory's own 385 tokens, the median is −0.02: a tie. Only layer 12 clears the 25% bar. By the rule fixed in advance this would fail, but this run was planned as a check, not the decision, for the reasons in point 5.
  3. Three memories versus one wide one: no verdict. The three-state memory is ahead on 14 of 17 layers, but by only 0.02 on average (largest gap: layer 2, +0.31). At this input length the horizons can't separate (next figure); the rerun at realistic proportions is in section 6.
  4. Folding per KV head looks better than per layer. A third of type-B KV heads (44 of 136) clear the 25% bar on their own. That is why the go/no-go test falls back to deciding per KV head before declaring failure.
  5. Two smaller lessons. On layers 1 and 2 the gate that decides how much to trust the memory barely learns (its error in estimating λ is 0.117 and 0.083, against 0.02–0.04 elsewhere); until that is fixed, those layers are only ever dropped or kept. And the memory's readout should start from the average of the evicted values and learn a correction, rather than start from the window's output: with equal training that won on all 4 layers tested (gains of +0.08 to +0.32).

5 · Why that test favours the longer window

The first test used 4K-token inputs with a 512-token window, an input only 8 windows long. In deployment, a 128K-token input with a 4K window is 32 windows long. Short inputs tilt the test in five ways: few tokens have been evicted, so their attention sits just behind the window edge, where a few hundred extra exact tokens catch most of it; the memory's 385-token cost is +75% of a 512-token window but under +10% of a 4K one; the long-range memory never gets used (below); training was a smoke-test budget of 150 steps on 12 documents; and every variant was charged the same bytes instead of its own. Scoring by how well single layer outputs match also favours the window: end to end, MomentKV kept needle retrieval at 100% in a setting where the same bytes spent on a longer window did not.

6 · At realistic proportions, the memory beats a longer window, one layer at a time

The rerun uses 8K-token books from PG-19 [27] with a 256-token window, so the input is 32 windows long, like a 128K-token input with a 4K window. Each memory is trained until its validation error stops improving (300 steps on 16 books; the error changed by at most 1% over the last 50 steps) and is charged its own bytes. The table gives the share of the error left by an equally sized longer window that each variant removes on held-out books, for the six type-B layers the go/no-go test uses. Each cell has two numbers because a memory can be stored at two precisions: at 32-bit (fp32) it costs twice the bytes of 16-bit (bf16), so its rival window gets twice the extra tokens. One memory costs 129 / 65 tokens, two cost 257 / 129, three cost 385 / 193, and MomentKV 130 / 65. The mean token costs about 2 tokens either way, so it has one number.

LayerOne memoryTwo memoriesThree memories (the bank)MomentKV (no training)Mean token (no training)
12+0.68 / +0.71+0.65 / +0.70+0.61 / +0.68+0.06 / +0.14+0.14
26+0.40 / +0.47+0.27 / +0.40+0.16 / +0.35−0.01 / +0.10+0.15
25+0.29 / +0.37+0.16 / +0.30+0.02 / +0.24−0.09 / +0.02+0.09
24+0.12 / +0.20−0.04 / +0.12−0.17 / +0.05−0.17 / −0.06+0.03
14+0.54 / +0.57+0.50 / +0.56+0.45 / +0.54−0.05 / +0.02+0.06
8+0.54 / +0.59+0.48 / +0.56+0.41 / +0.53−0.05 / +0.06+0.09
  1. The bar is cleared. One memory removes a median 47% of the remaining error (52% stored in bf16) and clears 25% on 5 of the 6 layers; only layer 24 falls short. The two no-training baselines stay at 15% or below. That fits the explanation above: the short-context test was stacked against the fold.
  2. Fewer memories are better per byte. On every layer one memory beats two, and two beat three, each against its own equal-bytes window. Against one memory with the same total bytes (keys three times as wide), the three-horizon bank is ahead on all 6 layers, but by only 0.02 on average (H2 below).
  3. Still one layer at a time. These scores compare a single layer's output with the rest of the model intact. Whether the gain survives when six layers are folded at once, measured on what the whole model predicts, is what the go/no-go test checks.

The go/no-go test · rules fixed 23–24 November 2026, before any of its results · verdict 24 November 2026

The test that decides whether the fold is worth its bytes

The project rests on one claim: on type-B layers, the fold does better than spending the same bytes on a longer window. If it doesn't, there is no reason for a third mode, and the work stops there. So that claim gets a go/no-go test whose rules were written down before any of its results existed, and the short-context run above is explicitly excluded from the decision.

1

realistic proportions

Inputs are 32 windows long, the ratio of a 128K-token input to a 4K window: 8K-token books from PG-19 [27] with a 256-token window. A 16K-token run with a 512-token window was the first choice but needed more memory than the laptop has; it moves to a larger machine as the confirmation.

2

no tuning on the deciding data

Adapters train on PG-19 training books. Every choice (which variant to report, which heads to fold, any threshold) is made on validation books 0–49. The decision uses test books 50–99 and synthetic tasks with fixed seeds, on which nothing is tuned.

3

trained until it stops improving

300 steps on 16 books, with the validation loss logged every 50 steps. If a curve hasn't flattened, training gets more books or more steps.

4

each variant at its own cost

One memory, two memories and the three-memory bank each pay their own bytes (129, 257 and 385 cached-token equivalents with fp32 states; half that with bf16), and each is compared with drop given exactly that many extra window tokens, on the same examples.

5

end-to-end tasks, not layer outputs

The deciding measures are needle retrieval (one key, several keys, several values) and a multi-turn task, counted only where full attention scores at least 0.8 and plain drop clearly falls short, plus the next-token loss on held-out books restricted to tokens whose prediction depends on long context (LongPPL [25]). Variable tracking and common-word counting are reported but never decide, because the base model scores too low on them even with full attention.

6

what “beats” means

On at least one deciding measure, the lower end of a 95% bootstrap interval for (fold − equal-bytes drop) must be above zero: 10,000 resamples of 20 examples per task, resampling whole examples or documents, never single tokens. The other measure must be no worse than a small margin (0.05 in exact-match accuracy, or 0.01 nats of loss). With three or more seeds, the spread across seeds replaces the bootstrap.

7

layers first, then KV heads

Decided on six type-B layers first (12, 26, 25, 24, 14, 8). If that fails, it is tried per KV head before giving up: fold only the heads whose validation recovery is positive, and drop the rest at the same total bytes.

8

the kill rule

The fold claim is dead if every memory variant, with fp32 and with bf16 costs, fails to beat equal-bytes drop on these tasks at both granularities. Then the work stops and the result is reported before anything else is built. The verdict goes into a file that every later job checks before it runs.

One power caveat was also written down in advance: with 20 examples per task and scores near the ceiling, a zero difference in needle accuracy means “inconclusive”, not “equal”. The long-context loss, measured over many tokens in each of 20 documents, carries most of the statistical power.

The first verdict: no-go

The six layers were folded at once, each with the memory trained on its own layer, and compared with the same six layers given a longer window instead. The rule for which tasks count left two deciding measures. The needle tasks dropped out because they barely move: with no memory at all, plain drop on these six layers still finds every needle (accuracy 1.00 with one key and with several). Retrieval in this model does not depend on these layers. What dropping them does damage is the loss on tokens that need long context, which rises from 0.70 nats with full attention to 1.85, while the loss over all tokens rises only from 2.77 to 2.83. Ordinary perplexity barely notices. So the test came down to that long-context loss and the multi-turn task (0.99 with full attention, 0.91 with plain drop).

  1. Every memory variant helps the multi-turn task a little (0.96 against 0.90–0.91), but none beats the longer window on long-context loss. The single memory, charged at 16-bit size, ties with a window 65 tokens longer (+0.006 nats, 95% interval −0.10 to +0.09); every other variant loses, by up to 0.30 nats. No variant meets the rule, at either precision, so the verdict is no-go. It was confirmed on 24 November and stays in the paper.
  2. The per-KV-head fallback changed nothing. It picks the variant and the heads on validation books. Its pick, one bf16 memory, had positive recovery on all 48 heads, so it folded all of them and reproduced the layer result exactly. In secondary runs that do not count toward the decision, folding only the heads with positive recovery and dropping the rest closed most of the loss gap for the two-memory bank (1.62 against 1.60 for its equal-bytes window, down from 1.78). That is a hint for later, not a result.
  3. What the verdict covers, and why it may have failed. Qwen3-0.6B, 8K-token inputs, a 256-token window, six layers, memories trained one layer at a time, one seed, 20 examples per task. Two explanations fit. A 256-token window is small, so even a few dozen extra window tokens buy back the tokens just past its edge, where much of what long-context tokens need sits (385 extra tokens alone cut that loss from 1.85 to 1.47). And memories trained one layer at a time have never seen each other's errors, which add up when six layers are folded together. The follow-ups test each explanation separately.

The follow-ups, fixed before any of their results

The project's rules said to stop and report, and the verdict was confirmed. Four follow-up tests were then written down, again before any of their results. Each keeps the same data splits, the same statistics and the equal-bytes rival, and has exactly one deciding configuration, chosen in advance; every result goes into the paper, pass or fail.

Follow-up 1 · same setting

Train the folded layers together

Starting from the per-layer memories, all six are fine-tuned at once so that the folded model's next-token predictions match the full model's; the model itself stays frozen (200 steps, about 4 hours and 17 GB on the laptop). Validation books picked this recipe (long-context loss 1.77 → 1.42) before the test books were touched. On the test books: 1.56 against 1.79 for the equal-bytes window, a gain of 0.23 nats (95% interval 0.13 to 0.31), with the multi-turn task no worse (+0.025, interval −0.04 to +0.09). It also beats a window 193 tokens longer (1.61), three times its bytes; only 385 extra tokens do better (1.47). Training had levelled off: validation loss changed by 0.03% over the last 25 steps.

Passed · confirmed 24 November
Follow-up 2 · same setting

Window and memory as one budget

Given a fixed number of extra bytes per KV head, is it better to spend all of them on the window, or to keep 65 for a memory? Deciding at 385 extra tokens: a 576-token window plus one memory against a 641-token window, with the memory retrained for the wider window. The tokens that count as needing long context are picked with the original 256-token window for both sides, so both are scored on the same tokens.

Next on the laptop
Follow-up 3 · decides the project

A realistic window

A 2,048-token window on 32K-token inputs, where one bf16 memory is 3% of the window's bytes rather than 25%. The six layers are re-chosen on validation books and the memories trained together; 50 examples per task and at least 40 test books. Deciding: one memory against a window 65 tokens longer. If it fails, the fold is declared dead and the paper becomes an analysis of headroom and layer types, with the fold reported as a negative result. If it passes, the first no-go is reported as “folding pays only when the memory is small next to the window”.

Handed off · layer selection on an 8 GB RTX 3070 Ti; joint training on a 48 GB Mac or one rented GPU (≈ $10–25)
Follow-up 4 · reported alongside

Very long inputs

Qwen3-0.6B stretched to 128K tokens with YaRN, the extension Qwen recommends, with a 4,096-token window and 64K and 128K inputs, on a 48 GB Mac. A validity check comes first: the stretched model must actually use its long context (loss past 32K no worse than at 16–32K, needle accuracy at least 0.8), or the test is reported as invalid and nothing is concluded from it. Joint training at 32K does not fit on a Mac, so the memories are trained one layer at a time, a stated limitation.

Not started

Also fixed in advance, none of them deciding: an out-of-domain check, because the jointly trained memories learn from PG-19 books and are tested on other PG-19 books while the longer window needs no training (does the gain survive on Wikipedia text? running now); the three-memory bank trained jointly in the same setting (running); folding only the KV heads with positive validation recovery; and a memory split into two independent halves at the same bytes. One accounting note: in the first test, memories charged at 16-bit size were read out at 32-bit, which slightly favours the fold. That test failed anyway, and every follow-up rounds the memory to 16-bit before reading it.

Inside a folded layer

Three Gated DeltaNet-2 memories per KV head, each with its own horizon

A folded layer still attends exactly over its sinks and its window. Every token that leaves the window is written into a bank of three small memories. When a new token arrives, a router decides how much to read from each memory, and a gate decides how much the memory's answer should count against the window's.

What one memory is

Each memory is a 128 × 128 matrix, the recurrent state of a linear-attention layer (Gated DeltaNet deep-dive · Atlas node). Writing a token into it takes three steps: let everything fade a little (decay), erase what the matrix currently returns for the token's key, and write the token's value under that key. The erase-then-write step is the delta rule of Gated DeltaNet [10]; Gated DeltaNet-2 [11] gives the decay, the erase and the write their own strengths, per channel. The same kind of memory runs inside linear-attention models such as Qwen3-Next and Kimi Linear [12]. Reading the memory with a query returns a blend of the values whose keys match it.

Built from the cache alone

The fold happens after the prompt has been read, and by then the model's internal activations are gone. So the memory has to be built from the cached keys and values alone. That works because of a property of RoPE, the rotary position encoding Qwen3 uses: it rotates each key by an angle set by its position, and a rotation can be undone exactly. The memory therefore stores position-free keys, and recency comes only from the decay. Keys pass through a small learned map (initialised to do nothing) and are scaled to unit length, which keeps the delta-rule update stable. When a layer is folded, one pass over its old tokens builds the bank, a cost that is small next to reading the prompt, and those cache entries are freed. After that, each token that leaves the window is written as it goes.

Three horizons, set relative to the window

With one memory per head, a single decay rate has to keep old facts and also keep up with recent content, and it can't do both. The bank gives each job its own memory. A memory's horizon is roughly how many tokens it takes for a stored token to fade, and each memory's horizon is confined to a band. The bands are set relative to the window, because the bank only ever sees tokens that are already W tokens old: “recent” means just behind the window. (An earlier draft used fixed horizons of 2–10, 10–100 and 100–10,000 tokens, which would have made the fast memory remember about ten tokens past the window edge, duplicating the window.)

Recent-past memory · horizon W/4 to W

What just left the window

Keeps continuity across the window's edge. Writes densely and erases strongly, so it is mostly overwritten.

Mid-range memory · horizon W to 8W

The current section or topic

Moderate writes that depend on the input.

Long-range memory · horizon 8W to 106 tokens

Facts that hold for the whole input

Names, entities, instructions. Writes are sparse and surprise-gated: a token is written only to the extent the memory couldn't already predict its value, and a penalty keeps writes rare.

q̃       = the query, RoPE undone, unit length
um      = SmT q̃                                  // what memory m returns; m = recent, mid, long
r       = softmax(Wr [q̃; log nold; LSEkept])         // router: how much to read from each memory
ôold    = mean of old values + Wo Σm rm cm RMSNorm(um)  // estimate of attention over the old tokens
λ̂       = σ(LSEkept − ζ̂)                          // gate: the share of attention the kept tokens would get
output  = λ̂ · okept + (1 − λ̂) · ôold               // the exact split, with the old part estimated

The gate follows from the exact split above. The attention kernel already returns LSEkept, the log of the total unnormalised attention weight on the kept tokens; ζ̂ is a small network's estimate of the same quantity for the old tokens, from how many there are and how well the query matches their running mean key. During training the true λ is known, so the gate is supervised directly. Two weightings, two jobs: the router picks which horizon to read, and the gate decides how much old memory to use at all. Each memory's output is normalised and given a learned scale, because slow memories build up larger values and would otherwise drown out the others [21]. The learned correction Wo starts at zero, so an untrained fold is exactly the mean-token baseline and training can only move away from a known point.

Training, with the model frozen

Stage 1 runs on a laptop, one layer at a time: record each layer's inputs from the frozen model, then fit that layer's adapter (the key and value maps, gates, router, scales and correction) so its output matches the full-attention output, plus a loss on the gate's estimate of λ and a sparsity penalty on long-range writes. Nothing is backpropagated through the model. A trick makes this fast: query t reads the memory as it was when token t − W was written, so the whole thing is a standard causal Gated DeltaNet pass with the queries shifted by W, and the three memories run in one batched call. Stage 1b handles the fact that folding an early layer changes the inputs of every later one: with several layers folded together, it fine-tunes only their memories so that the model's next-token predictions match the full model's. The go/no-go test showed this step is not optional (see above). At 8K tokens it fits on the laptop (17 GB, about four hours for 200 steps); at 32K it needs a 48 GB machine or a rented GPU. The version tested so far folds one fixed set of six layers. The original plan trains on random sets of folded layers, the “train once for any layout” idea from Jet-Nemotron [13] (Jet-Nemotron deep-dive), so that one set of memories serves every budget.

Known ways this can fail, with a countermeasure for each: in hybrids of window attention and a linear memory, the memory often ends up ignored [19, 20], so training uses small windows, supervises the gate and tracks how much the memory is used; the bank can collapse onto one memory, so the router's spread is monitored and a light balancing loss is ready; and the slow memory can dominate by size, which the normalisation handles.

Why a bank, and not one bigger memory

Three memories fed the same keys with different decay rates add time resolution, not capacity: each can still hold only about 128 clearly separate associations. What makes them store different things is their write policy, above all the surprise-gated long-range memory, so that has to be shown to matter in an ablation. And Gated DeltaNet-2 already decays each channel at its own rate, which spreads many horizons across one memory. So the honest rival is not a smaller single memory but one memory with the same total bytes, its keys three times as wide. If it ties with the bank, the multi-horizon claim is dropped.

What it saves

ModelKV cache per token, all layersOne exact layer at 128K tokensOne folded layer (4K window, three fp32 memories)
Qwen3-0.6B (28 layers, 8 KV heads of 128 dims)112 KiB512 MiB≈ 17.5 MiB (16 window + 1.5 memory)
Qwen3-8B (36 layers, 8 KV heads of 128 dims)144 KiB512 MiB≈ 17.5 MiB (16 window + 1.5 memory)

One 128 × 128 memory in fp32 takes as many bytes as 128 cached tokens of one KV head in bf16, so the three-memory bank is worth 384 tokens (385 with the running key sum). Every comparison on this page is at equal total bytes: drop baselines get a window that much longer, and single-memory baselines get keys three times as wide. Reading the three memories at each step costs about as much as reading 384 more window tokens, roughly 10% on top of a 4K window. The fold saves nothing while the prompt is being read: layers kept exact still pay the usual quadratic cost there. This is cache compression for long inputs, not a replacement for models trained as hybrids.

Hypotheses

Six hypotheses, each with the result that would kill it

The paper stands on H1 and H2. H3 started as central and has been demoted by the data. Each is tagged with where it stands on 24 November 2026; “single layers” means scored one layer at a time, “end to end” means on what the whole model predicts.

H1

The fold makes type-B layers cheap (go/no-go)

(a) On type-B layers, the bank beats drop with the same bytes, the mean token and MomentKV. (b) Three modes beat the best two-mode plan at the same total bytes: the headline accuracy-versus-memory chart. Killed if the fold recovers under about 25% on type-B layers, or the three-mode curve is within noise of the two-mode one.

Mixed · end to end: no-go with memories trained one layer at a time, a pass with them trained together; single layers clear the 25% bar on 5 of 6. The realistic-window test decides
H2

Several horizons beat one memory

Three banded memories beat (a) one memory with the same total bytes and (b) three memories with unconstrained decay rates. Killed if the single wide memory ties with the bank (then drop the bank), or unconstrained ties with banded (then drop the bands).

Weak support, single layers only · the bank beats one memory of equal size on 6 of 6 layers, by 0.02; per byte, one small memory does best. Not yet tested end to end
H3

Re-planning per input helps (secondary)

Re-scoring each input beats the fixed plan at the same budget. Killed if layer scores agree across tasks at ρ ≥ 0.9 and per-input plans score within noise of the fixed one.

Evidence against · the fixed plan loses ≈ 1%; aggregation (ρ 0.76–0.81) is the remaining candidate
H4

Gated DeltaNet-2 beats Gated DeltaNet inside the bank

At equal bytes. A stability guard taken from the GDN-2 code makes the erase almost uniform across channels in the slow memories, so in practice this tests whether per-channel writes and decay help. Killed if there is no gain; then use the simpler Gated DeltaNet.

Not started
H5

The gate should know the window's attention mass

A gate that uses LSEkept beats one that sees only the query. Killed if there is no gain.

Early · same output error, but a better estimate of λ (error 0.031 vs 0.047); kept as an ablation, not a headline
H6

Whole layers are good enough

Choosing modes per layer comes within a small margin of choosing them per KV head at equal memory, and is simpler to serve. Killed if per-head choice is clearly better; then it becomes the main method.

Early sign against · 32% of type-B KV heads clear the bar on their own; in exploratory runs, dropping a few heads closed most of the end-to-end gap

Staged plan

Measure first, build the fold second, rent GPUs last

Each phase has a condition that must be met before the next one starts. As of 24 November 2026, Phases 0, 0.5 and 1 are done, and Phase 2's go/no-go test has its verdict: no-go with memories trained one layer at a time, a pass with the folded layers trained together. The test at a realistic window decides.

Phase 0 · done

Infrastructure

Undoing RoPE exactly, the exact split of attention into kept and old parts, chunked Gated DeltaNet and Gated DeltaNet-2 in pure PyTorch (with GDN-2's stability guard reproduced and tested in double precision), the three-memory bank, and per-layer patching of a frozen model. 36 tests pass.

Phase 0.5 · done

Overlap check

Turnout read in full, AHN's public code read, and a literature check of multi-memory linear attention, before building on top.

Phase 1 · done

Which heads need what

Headroom, concentration and the damage of dropping each layer, at windows of 256 to 2,048 tokens on 4K and 8K inputs; stability across documents and tasks.

to move on: type B must not be nearly empty · passed: 59% of KV heads, 18 of 28 layers
Phase 2 · running

The fold, then three modes versus two

The go/no-go test above (H1a): no-go with per-layer training, then a pass with joint training. Next come window and memory as one budget, the deciding realistic-window test and very long inputs, then the fold ladder (one memory, one wide memory, unconstrained bank, banded bank) and the headline budget sweep with and without the fold option (H1b, H2, H4, H5). If the deciding test passes, a small-scale paper package follows: every baseline reimplemented, a second model size (Qwen3-1.7B) and family (Llama-3.2-1B), ablations and figures, so that the large run is a matter of changing the model name.

to move on: the realistic-window test must pass; if it fails, the fold is declared dead and the paper reports the analysis
Phase 3 · next

Per-input plans and multi-turn chat

How much the fixed plan loses against per-input re-planning, at equal budget (H3). Multi-turn tasks where a later question needs something an earlier fold summarised: folding for good, versus moving the old tokens to CPU memory so a layer can be restored.

to move on: keep or drop per-input planning
Phase 3.5 · later

Rented GPUs, only for what a laptop can't do

8B adapters at 32K tokens, end-to-end training across layers, evaluation at 64K–128K (RULER [24], LongBench v2 [28], SCBench [26], HELMET [29]), CUDA-only baselines, fused kernels and throughput. About 350–600 H100-hours in the lean plan.

each spend item: go or no-go after the laptop phases pass
Phase 4 · later

Scale and systems

Qwen3-8B and Llama-3.1-8B-Instruct; fused kernels for the bank; serving many requests at once when each has a different cache layout.

to finish: real throughput, latency and peak memory against every baseline

Risks

Ten ways it could go wrong

Turnout covers it

If Turnout's router, retrained to switch at the end of the prompt, does as well, the allocation half of the claim weakens. That is why prompt-time Turnout is a baseline. The bank (H2) is the part Turnout doesn't touch.

The fold doesn't pay for its bytes

With memories trained one layer at a time and a 256-token window, it didn't: the go/no-go test said no-go. Trained together, it passed. The realistic-window test decides; if the fold fails there, the project becomes an analysis paper.

The gain is just fitting the books

The jointly trained memories learn from PG-19 books and are tested on other PG-19 books, while a longer window needs no training at all. A check on Wikipedia text, fixed in advance, tests whether the gain survives a change of domain. It is running.

One wide memory matches the bank

Per-channel decay may already give one memory enough horizons. Then the bank goes, and the paper rests on the three-mode plan with a single memory.

More memories, no more capacity

Unless the write policies make the memories store different things, three of them hold no more than one. The surprise-gated long-range memory has to be shown to matter.

The readout goes wrong

The slow memory dominates through its size, or the router collapses onto one memory. Both are monitored; normalisation and a balancing loss are the fixes.

Folding can't be undone

In a long chat, a later question may need an exact token that an earlier fold summarised. No fixed-size memory can return it exactly. Moving the old tokens to CPU memory restores them, at a bandwidth cost.

Peak memory while reading the prompt

The plan is applied once the prompt is read, so peak memory during reading is still the full cache. Bounding it needs decisions during chunked prefill, as CAKE does [23].

Errors compound across layers

Folding an early layer changes every later layer's input, which layer-by-layer training never sees. This happened: it is the likeliest reason the first go/no-go test failed. Training the folded layers together fixed most of it at 8K tokens on a laptop; at 32K it needs a 48 GB machine or a rented GPU.

Serving and kernels

Layers keep caches of very different sizes, and paged-attention allocators need a block table per layer; deciding whole layers, not heads, makes this easier. Gated DeltaNet-2 kernels are new, and the bank needs a batched three-memory pass that reads straight from a paged cache.

What would make the paper convincing

Window-only attention fails by an exactly computable amount. Together with how concentrated the lost attention is, that amount sorts heads into three kinds: those that can drop their past, those that need it exactly, and a large middle group that needs it only in aggregate. Two-mode compression must keep the middle group exact; folding it into recurrent memory should buy a better trade-off between accuracy and memory.
— the central hypothesis
  • Three modes beat the strongest two-mode methods and uniform folding on accuracy against total KV bytes, on retrieval tasks, long-context loss and multi-turn chat, at small scale and at 8B.
  • Every comparison is at equal bytes, including the memory's own, and every baseline gets the same sinks, windows and accounting.
  • The bank beats one memory of the same size where it should, on long inputs, or the claim is dropped.
  • The decision rules are fixed before the results, nothing is tuned on the data that decides, and negative results are reported alongside gains.

Limitations

The fold saves nothing while the prompt is read, and peak memory then is still the full cache. When most long-range attention is concentrated (type C), AMTR-KV reduces to a two-mode plan and offers no gain, so its benefit depends on the share of type-B heads, which varies with the model and the window. So far every result uses one training seed and 20 examples per task, and the only end-to-end pass comes from one small model with a 256-token window. Small-scale baselines are reimplementations and may differ from the originals in detail. Timing on a laptop says nothing about speed on a GPU server, so throughput is measured only at large scale, with fused kernels.

How it relates to the other directions. Direction I asks whether a recurrent state can replace attention inside a model trained from scratch; QUANTA uses Gated DeltaNet-2 as a mixer in a ternary-weight lesion study; MnemoRoute uses a recurrent state one level up, as an agent's memory across turns. AMTR-KV retrofits recurrent memory into a pretrained transformer that is left unchanged, and asks where in its cache the exact old tokens can be replaced. No hypotheses or results are shared between the four.

References

The project's code and paper draft are in a private repository for now.

  1. Yang, A. et al. (2025). Qwen3 Technical Report. arxiv.org/abs/2505.09388
  2. Xiao, G. et al. (2023). Efficient Streaming Language Models with Attention Sinks (StreamingLLM). arxiv.org/abs/2309.17453
  3. Xiao, G. et al. (2024). DuoAttention: Efficient Long-Context LLM Inference with Retrieval and Streaming Heads. arxiv.org/abs/2410.10819
  4. Tang, H. et al. (2024). RazorAttention: Efficient KV Cache Compression Through Retrieval Heads. arxiv.org/abs/2407.15891
  5. Zhang, X. et al. (2024). LightTransfer: Your Long-Context LLM is Secretly a Hybrid Model with Effortless Adaptation. arxiv.org/abs/2410.13846
  6. Qiu, Q. et al. (2026). Flux Attention: Context-Aware Hybrid Attention for Efficient LLMs Inference. arxiv.org/abs/2604.07394
  7. Fang, Y. et al. (2025). Artificial Hippocampus Networks for Efficient Long-Context Modeling (AHN). arxiv.org/abs/2510.07318
  8. Kuzina, A. et al. (2026). Turnout: Adaptive Attention Switching for Efficient Reasoning. arxiv.org/abs/2611.27500
  9. Li, Y., Li, B. & Lan, T. (2026). MomentKV: Closing the Directional Gap in KV Cache Eviction for Long-Context Inference. arxiv.org/abs/2606.01563
  10. Yang, S., Kautz, J. & Hatamizadeh, A. (2025). Gated Delta Networks: Improving Mamba2 with Delta Rule. ICLR 2025. arxiv.org/abs/2412.06464
  11. Hatamizadeh, A., Choi, Y. & Kautz, J. (2026). Gated DeltaNet-2: Decoupling Erase and Write in Linear Attention. arxiv.org/abs/2605.22791
  12. Kimi Team (2025). Kimi Linear: An Expressive, Efficient Attention Architecture. arxiv.org/abs/2510.26692
  13. Gu, Y. et al. (2025). Jet-Nemotron: Efficient Language Model with Post Neural Architecture Search. arxiv.org/abs/2508.15884
  14. Du, J. et al. (2025). MoM: Linear Sequence Modeling with Mixture-of-Memories. arxiv.org/abs/2502.13685
  15. Guo, H. et al. (2025). Log-Linear Attention. arxiv.org/abs/2506.04761
  16. Sun, Y. et al. (2023). Retentive Network: A Successor to Transformer for Large Language Models (RetNet). arxiv.org/abs/2307.08621
  17. Hwang, H. S. et al. (2026). Multi-State Linear Attention with Generalized Second-Order Routing (MERLIN). arxiv.org/abs/2610.37645
  18. Zhao, Y. et al. (2026). Switch Attention: Towards Dynamic and Fine-grained Hybrid Transformers. arxiv.org/abs/2603.26380
  19. Benfeghoul, M. et al. (2025). Untangling Component Imbalance in Hybrid Linear Attention Conversion Methods. arxiv.org/abs/2510.05901
  20. Cabannes, L. et al. (2025). Short Window Attention Enables Long-Term Memorization (SWAX). arxiv.org/abs/2509.24552
  21. Gangavarapu, T., Tabak, G. & Schaefer, C. (2026). Muir: Linear Attention with Sensitivity-Allocated Gating and Matched-Filter Readout. arxiv.org/abs/2611.08376
  22. Li, Y. et al. (2024). SnapKV: LLM Knows What You are Looking for Before Generation. arxiv.org/abs/2404.14469
  23. Qin, Z. et al. (2025). CAKE: Cascading and Adaptive KV Cache Eviction with Layer Preferences. arxiv.org/abs/2503.12491
  24. Hsieh, C.-P. et al. (2024). RULER: What's the Real Context Size of Your Long-Context Language Models? arxiv.org/abs/2404.06654
  25. Fang, L. et al. (2024). What is Wrong with Perplexity for Long-context Language Modeling? (LongPPL). arxiv.org/abs/2410.23771
  26. Li, Y. et al. (2024). SCBench: A KV Cache-Centric Analysis of Long-Context Methods. arxiv.org/abs/2412.10319
  27. Rae, J. W. et al. (2019). Compressive Transformers for Long-Range Sequence Modelling (the PG-19 books). arxiv.org/abs/1911.05507
  28. Bai, Y. et al. (2024). LongBench v2: Towards Deeper Understanding and Reasoning on Realistic Long-context Multitasks. arxiv.org/abs/2412.15204
  29. Yen, H. et al. (2024). HELMET: How to Evaluate Long-Context Language Models Effectively and Thoroughly. arxiv.org/abs/2410.02694