Introduction
A language model can keep what it has read in two ways. Softmax attention keeps it exactly: the keys and values of every past token stay in a cache, and any of them can be read back by content. A recurrence such as Gated DeltaNet [1] or Mamba keeps it compressed, in a state whose size does not depend on the length of the sequence. At inference the exact kind is the expensive kind, and the question of this task is how to spend a fixed per-sequence inference-state budget: which layers keep exact memory, how wide that memory is, and what the remaining layers do, so that the model is good at language modelling and at recalling what it has read.
The field has converged on hybrids, but not on one rule. Samba interleaves recurrent layers with sliding-window attention [2]; Jamba places one attention layer among several Mamba layers [3]; Nemotron-H mixes Mamba-2, attention and MLP sub-layers [4]; Falcon-H1 and Hymba put attention and recurrence side by side inside every layer [5, 6]; Gemma 3, SWAN-GPT and gpt-oss mix local and global attention [7, 8, 9]; and Kimi Linear and the Qwen3-Next layout use three linear-attention layers per full-attention layer [10]. As we read it, a systematic analysis of hybrid linear attention [11] reports that language-modelling loss is fairly insensitive to the linear-to-full ratio while recall improves with more full attention. So the ratio, the width of each exact layer and the kind of compressed layer interact, and the budget couples them: a byte of KV cache spent in one layer is a byte that cannot be spent in another.
Two facts about this task's setup shape the answer. First, the budget is metered in bytes, so a grouped-query attention layer with few KV heads is much cheaper than a full multi-head one, and a Gated DeltaNet layer is almost free. Second, the parameter count is capped as well, so any widening of one component must be paid for elsewhere.
Method
Our composition is one periodic rule over depth, one MLP choice and one learning rate. We describe the two kinds of layer, the rule that places them, and what the budget accounting says about the result.
Compressed layers: value-rich delta memory
Eight of the twelve layers are Gated DeltaNet [1]. Each value head keeps a matrix state updated by the gated delta rule,
with L2-normalised, a write strength and a decay
, both per value head. The state is
an associative memory: the delta rule overwrites the value stored under a key rather than adding to it.
We read this as saying that the scarce resource of the compressed layer is the number of associations
it can hold, and we spend extra capacity on values. Our layers use key width , so
key heads, and num_v_heads value heads of width : each query and key
head is shared by two consecutive value heads, each with its own and . This doubles
the state of the layer relative to the default of six value heads.
# Where exact and compressed memory go, by what each byte buys:
#
# * Compressed (8 layers): Gated DeltaNet with twice as many
# value as key heads -- the delta state is an associative
# memory, so its scarce resource is stored associations,
# i.e. value capacity, at the key width (128) where delta
# addressing saturates.
# * Exact (4 layers, every third, including the last): gated
# grouped-query softmax attention with 256-wide heads.
# Recall is address-matching, so the KV budget is spent on
# key dimensionality (few wide KV heads) rather than on
# many narrow heads duplicating content. Partial rotary
# (a quarter of each head, slow base) keeps most of every
# head content-addressed, which extrapolates past theExact layers: few wide heads, mostly content-addressed
Every third layer is causal softmax attention over the whole prefix with query heads of width and KV heads, so each KV head serves three query heads. Recall is a matching problem between a query and the key of the right past token; we spend the KV budget on key dimensionality (few wide heads) rather than on many narrow heads that would store overlapping content. Three options of the fixed attention module complete the layer:
- RMS normalisation of and per head, with a learned gain, before the rotary embedding.
- Partial rotary embedding. Only the first dimensions of each head are rotated, at base ; the remaining 192 dimensions carry no position at all. Most of each head is therefore matched on content alone, which is what we want to keep working past the training context.
- An elementwise output gate, , one gate per output channel, following gated attention [12]. A head can close its own output instead of having to place its softmax mass somewhere.
q_dim = num_heads * self.head_dim
kv_dim = self.num_kv_heads * self.head_dim
self.q_proj = nn.Linear(hidden_size, q_dim, bias=bias)
self.k_proj = nn.Linear(hidden_size, kv_dim, bias=bias)
self.v_proj = nn.Linear(hidden_size, kv_dim, bias=bias)
self.o_proj = nn.Linear(q_dim, hidden_size, bias=bias)
rot_dim = (self.head_dim if rope_fraction is None
else int(self.head_dim * rope_fraction))
self.rotary = (RotaryEmbedding(dim=rot_dim, base=rope_theta)
if rope else None)
if output_gate == 'elementwise':
self.g_proj = nn.Linear(hidden_size, q_dim, bias=bias)
elif output_gate == 'headwise':
self.g_proj = nn.Linear(hidden_size, num_heads, bias=bias)The rule over depth
With layers indexed ,
so the exact layers sit at and the last layer is one of them. No layer is more than two layers from an exact read. Our reasoning is that an induction-style circuit (match in one layer, copy in the next) can then form at every depth, and that the final exact layer can copy retrieved content almost directly to the output.
Every layer, of either kind, has a SwiGLU MLP of hidden width 2048. At width 768 this is parameter-identical to the default GELU MLP of width 3072, since , so the change costs no parameter budget.
# * SwiGLU MLPs everywhere (parameter-identical to the GELU
# default at this width, strictly better in our runs).
#
# No layer is more than two steps from an exact read, so
# induction-style circuits (match in one layer, copy in the
# next) can form at every depth, and the final exact layer can
# copy retrieved content almost directly to the output. Pure
# sliding-window and pure thin-KV full-attention stacks, and
# within-layer parallel/shared-projection hybrids, were all
# worse in controlled runs at this scale; sequential separation
# of the two memory kinds is what works. mlp = {"act": "swiglu", "hidden": 2048}
if (layer_idx + 1) % 3:
return {"mixer": "gdn", "head_dim": 128, "num_v_heads": 12,
"mlp": mlp}
return {"mixer": "attn", "num_heads": 6, "head_dim": 256,
"num_kv_heads": 2, "qk_norm": "rms",
"output_gate": "elementwise", "rope_theta": 10000000.0,
"rope_fraction": 0.25, "mlp": mlp}Where the budget goes
The task meters the state of each layer by a fixed formula. An attention layer keeps bf16 keys and values for every position it sees, bytes; a Gated DeltaNet layer keeps its fp32 state plus three bf16 short-convolution caches,
independent of .
if m == "gdn":
hd = spec["head_dim"]
heads = hidden_size // hd
if "num_v_heads" not in spec and "expand_v" not in spec:
return heads * hd * hd * 4 + 3 * (HYBRID_CONV_SIZE - 1) * hidden_size * 2
hv = spec.get("num_v_heads", heads)
dv = int(hd * spec.get("expand_v", 1.0))
return hv * hd * dv * 4 + (HYBRID_CONV_SIZE - 1) * (2 * hidden_size + hv * dv) * 2For our exact layers , which is 2048 bytes per token, against 3072 for a default twelve-head full-attention layer: each exact layer costs two thirds of a default full-attention layer, and the four together cost of one. The task's docstring puts a default full-attention layer at 96 MiB at the metering length and the cap at 316.6 MiB, about such layers. Our Gated DeltaNet layers each keep bytes, about 0.77 MiB, so the eight of them are a rounding error next to the exact layers. Our own check during development reported 262 MiB of the 316.6 MiB cap and 151,361,472 parameters against the cap of 151,785,048, which agrees with the formula. In short, almost the entire state budget buys four wide-key exact layers, and the compressed layers are made richer at a negligible cost in state.
The learning rate
The training recipe exposes only the peak learning rate, whose default is 6e-4. We set it to 1.5e-3. Our development runs (below) found the default far from the optimum on both stacks on which we compared it with a higher rate, with a higher rate of 2e-3 better at the training length but worse on longer sequences; 1.5e-3 is the compromise between the two.
Results
| Method | ① | ② | ③ | ④ | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Validation loss ↓ | WikiText-2 perplexity ↓ | LAMBADA perplexity ↓ | Validation loss, 16k window ↓ | Tail loss, 16k window ↓ | WikiText-2 loss, 16k window ↓ | SQuAD answer score ↑ | S-NIAH-1 answer NLL ↓ | S-NIAH-2 answer NLL ↓ | S-NIAH-1 answer NLL, 16k ↓ | S-NIAH-2 answer NLL, 16k ↓ | Relative prefill time ↓ | |
| Muse Wonder Full | 3.233 | 28.80 | 39.05 | 3.302 | 3.424 | 3.429 | 27.78 | 1.086 | 0.871 | 1.790 | 3.579 | 1.190 |
| All attention | 3.492 | 40.93 | 47.65 | 5.331 | 6.657 | 5.889 | 19.67 | 4.814 | 5.039 | 11.00 | 11.35 | 0.999 |
| Samba | 3.401 | 36.35 | 44.61 | 3.345 | 3.340 | 3.535 | 22.45 | 4.404 | 5.129 | 7.062 | 7.598 | 0.566 |
| Jamba | 3.418 | 38.59 | 42.68 | 3.364 | 3.357 | 3.580 | 17.73 | 3.367 | 3.639 | 5.085 | 5.288 | 0.666 |
| All Gated DeltaNet | 3.434 | 40.82 | 44.73 | 3.382 | 3.372 | 3.659 | 12.67 | 3.153 | 5.105 | 4.668 | 7.407 | 0.640 |
| Qwen3-Next | 3.393 | 36.92 | 43.07 | 3.608 | 4.133 | 3.916 | 22.69 | 2.143 | 2.585 | 7.114 | 4.624 | 0.735 |
| Gemma 3 | 3.433 | 38.52 | 45.27 | 3.407 | 3.430 | 3.624 | 19.77 | 3.415 | 3.054 | 6.550 | 7.671 | 0.496 |
| SWAN-GPT | 3.503 | 45.62 | 48.49 | 3.451 | 3.444 | 3.784 | 17.79 | 6.593 | 6.114 | 7.126 | 7.121 | 0.561 |
| iRoPE, without QK norm | 3.473 | 39.75 | 46.92 | 3.566 | 3.763 | 3.624 | 22.99 | 2.505 | 2.476 | 3.130 | 3.220 | 0.527 |
| All sliding-window attention | 3.486 | 40.86 | 47.47 | 3.429 | 3.421 | 3.655 | 19.14 | 4.931 | 5.137 | 7.227 | 7.902 | 0.514 |
| Nemotron-H | 3.373 | 35.35 | 43.04 | 3.446 | 3.648 | 3.515 | 22.39 | 2.005 | 2.562 | 6.151 | 6.200 | 0.703 |
| Falcon-H1 | 3.380 | 35.72 | 43.75 | 3.630 | 3.868 | 3.852 | 23.46 | 1.294 | 2.340 | 4.706 | 5.744 | 1.021 |
| Samba, Mamba-1 | 3.350 | 34.49 | 42.50 | 3.293 | 3.285 | 3.479 | 25.23 | 4.313 | 4.628 | 7.169 | 7.426 | 0.594 |
| Jamba, Mamba-1 | 3.394 | 37.20 | 43.81 | 3.514 | 3.718 | 3.663 | 21.85 | 2.740 | 2.665 | 7.356 | 7.275 | 0.656 |
| Qwen3-Next, gated attention | 3.334 | 32.96 | 41.75 | 3.349 | 3.419 | 3.526 | 26.51 | 3.803 | 2.042 | 4.495 | 2.836 | 1.083 |
| iRoPE | 3.514 | 41.58 | 48.52 | 3.549 | 3.670 | 3.686 | 22.22 | 1.501 | 1.670 | 2.523 | 2.345 | 0.563 |
| gpt-oss | 3.465 | 40.08 | 47.32 | 3.853 | 4.213 | 4.137 | 21.78 | 3.374 | 3.692 | 7.751 | 8.232 | 0.678 |
| Hymba | 3.335 | 34.44 | 40.83 | 3.293 | 3.303 | 3.500 | 22.86 | 4.803 | 5.220 | 7.800 | 8.092 | 2.191 |
- ① 124M FineWeb pretraining · 4k training context · validation, WikiText-2 and LAMBADA
- ② Same checkpoint · 16k-window validation / WikiText-2
- ③ SQuAD completion + four near/far RULER needle-recall measures, far needles at 16k
- ④ Measured inference cost · 16k prefill vs an all-attention stack, fused kernels, quality guard
Pretrain. The composition is ahead of every published baseline on all three metrics: a validation loss of 3.233 against 3.334 for Qwen3 gated [12], perplexity A of 28.80 against 32.96 (Qwen3 gated [12]), and perplexity B of 39.05 against 40.83 (Hymba [6]). The starter, all sliding-window attention, has a validation loss of 3.486.
Long-ctx. The picture is mixed. On long-sequence loss A we are ahead of every baseline, 3.429 against 3.479 (Samba-M1 [2]). On the long-sequence loss we reach 3.302, behind two baselines, Samba-M1 [2] at 3.293 and Hymba at 3.293. On the tail loss we reach 3.424, behind seven baselines, among them the sliding-window-and-recurrence interleaves (Samba at 3.340, Samba-M1 [2] at 3.285), the all-Gated-DeltaNet stack at 3.372, and even the all-sliding-window starter at 3.421.
Recall. On recall the composition leads on four of the five metrics: answer accuracy of 27.78 against 26.51 (Qwen3 gated [12]), retrieval NLL 1 of 1.086 against 1.294 (Falcon-H1 [5]), retrieval NLL 2 of 0.871 against 1.670 (Llama 4 qk), and long retrieval NLL 1 of 1.790 against 2.523 (Llama 4 qk). On long retrieval NLL 2 it reaches 3.579, behind three baselines: Llama 4 qk at 2.345, the Qwen3-Next gated layout at 2.836 and Llama 4 iRoPE at 3.220.
Prefill. Our relative prefill time is 1.190. Lower is better, and every baseline except Hymba (2.191) is cheaper, including the over-budget all-attention reference (0.999) and the Qwen3-Next gated layout (1.083). The best is Gemma 3 [7] at 0.496.
Against the layout we borrow from. Our per-layer options are those of the Qwen3-Next gated baseline, so it is the most direct comparison. Against it we are better on every other metric, among them validation loss (3.233 against 3.334), on the long-sequence loss (3.302 against 3.349) and on answer accuracy (27.78 against 26.51), slightly worse on the tail loss (3.424 against 3.419), worse on long retrieval NLL 2, and slower to prefill. We read that pattern as the combined effect of a fourth exact layer (more exact reads, more attention compute), SwiGLU MLPs and a higher learning rate, but we have no measurement that separates them on these settings.
How we got here
The composition was narrowed by about two dozen head-to-head training runs in a reduced development setting: the same data source, schedule shape and model width, but 200M training tokens at a smaller batch for screens and 600M tokens for confirmations. The numbers below are our development measurements, as they appear in the trace, in validation cross-entropy at the training length unless stated otherwise.
- Budget accounting came first. Before any run we tabulated parameters and state for every baseline. Two observations from that table guided everything else: grouped-query attention with two KV heads makes a full-attention layer cost a sixth of a multi-head one, and the parameter cap equals the parameter count of the largest baseline, the Qwen3-Next gated layout, while most other baselines leave 8 to 18% of it unused.
- Reading. We read the systematic hybrid study [11] (recall improves sharply with more full attention, ratios of 3:1 to 6:1 recommended), Kimi Linear's 3:1 design [10], SWAN-GPT's argument for local rotary attention as an extrapolation aid [8], Samba's bounded-window rotary [2] and the Gated DeltaNet ablation that prefers key width 128 [1]. Among our hypotheses were that thinly spread exact memory might beat concentrated exact memory, that within-layer parallel hybrids might beat sequential ones, and that the default learning rate might be too low for these stacks.
- The first screening proxy was flawed. At the full batch size a short screen gave only 300 optimizer steps, and the models had not yet formed the circuits that recall needs. We restarted the screens at a quarter of the batch, so that each screen took 1600 steps.
- First screen. The all-sliding-window starter reached 4.307, and the simple stacks built on default Gated DeltaNet layers (all Gated DeltaNet, a Samba-style interleave with a window, and three Gated DeltaNet layers to one position-free attention layer) reached 4.065 to 4.079, a gain of about 0.24 nats from the recurrence alone. Our reproduction of the Qwen3-Next gated layout reached 3.983, and our own first layout (a four-layer period of Gated DeltaNet, a 1024-token window, Gated DeltaNet, and one full-attention layer) 3.977. A pure grouped-query full-attention stack learned slowly (4.371) and collapsed on longer sequences (5.492), which ended the idea of spreading thin exact memory across every layer. A Hymba-style parallel layout reached 4.078 and trained more slowly, and we dropped within-layer parallel hybrids.
- Our own mixer was a clear negative result. We wrote and contract-tested a custom mixer, DeltaWindow, which shares one set of projections between an exact sliding window and a delta memory that is written only after a token leaves the window. At the same parameter count as the all-Gated-DeltaNet stack (4.072) it reached 4.286, and 4.207 without the delayed write. Our diagnosis was that the convolved, L2-normalised projections suited to delta memory are the wrong tensors for softmax attention, and that sharing them makes the two kinds of memory interfere. This is why the final method uses only the fixed mixers, and why its comment states that sequential separation of the two memory kinds is what works.
- Single-factor ablations. Replacing the sliding-window layers of our first layout with Gated DeltaNet layers (and narrowing its MLP to fit the parameter cap) improved the training-length loss (3.939) but worsened the longer-sequence loss (4.189 against 4.141). A 2:1 ratio with the Qwen3-Next options reached 3.970 against 3.983 for 3:1, a small difference. SwiGLU in place of GELU at equal parameters gave 3.923 against 3.983. Raising the learning rate to 1.2e-3 on the Qwen3-Next reproduction gave 3.847 against 3.983, the largest single gain we found. Our end-of-run summary also credits the gated 256-wide attention and the doubled value heads with about 0.08 and 0.07 nats respectively.
- Choosing the head width and the learning rate. A 2:1 variant with twelve 128-wide heads in the exact layers reached 3.814 at 1.2e-3. Its 600M-token confirmations gave 3.517 at the training length and 3.754 on longer sequences at 1.2e-3, and 3.494 and 3.806 at 2e-3: the higher rate fit better and extrapolated worse. We set 1.5e-3 between them, a choice that a compute-optimal learning-rate scaling rule also supported. In the last pair of screens the 256-wide variant reached 3.795 and 3.945 against 3.797 and 3.988 for the 128-wide one (the former at 1.2e-3, the latter at 1.5e-3), and it also had the best long-distance accuracy on our own synthetic associative-recall probe; we chose it for the longer-sequence number.
- Confirmation and robustness. The exact submitted composition, trained for 600M tokens at 1.5e-3, reached 3.503 at the training length and 3.734 on longer sequences, and its loss did not rise on still longer sequences (3.724, against 3.727). A screen with a second training seed at 1.5e-3 (3.788 and 3.936) differed by less than 0.01 from the first seed's screen at 1.2e-3, and replacing one Gated DeltaNet layer with a sliding-window layer came out level or slightly worse (3.802 and 3.959), so we kept the simpler rule.
- Two long-context mechanisms rejected late. Llama 4-style attention-temperature scaling on the exact layers was neutral (3.785 and 3.936). Learned attention sinks trained about 2.2 times more slowly through their dense-mask path, and we stopped that run on cost before it finished.
We timed inference against the Qwen3-Next gated baseline in development: our decode step was a little slower (1155 against 1048 microseconds per token in our probe, 902 for all Gated DeltaNet), and our one prefill timing was level with that baseline's. We did not optimise prefill cost further, and Prefill shows that we should have.
Limitations
- Prefill cost is the price of the fourth exact layer. Our relative prefill time on Prefill is higher than every baseline's except Hymba's. Four full-attention layers with a query width of , twice the model width, are more prefill compute than the three of the Qwen3-Next layout or the local layers of the cheapest baselines. The method trades inference speed for quality and recall; our single development prefill timing put us level with the Qwen3-Next gated baseline, which the measured result on Prefill does not bear out.
- Long-sequence tail loss is weak. On the tail loss of Long-ctx seven baselines are ahead of us, including the starter. Our own ablation pointed the same way: replacing the local-window layers of an earlier layout with Gated DeltaNet layers hurt longer sequences. Our final rule has no local layers, and a single-layer replacement we tried tied rather than helped, so we do not know which placement of local memory would fix this.
- Much of the gain may be the learning rate. The single largest development gain came from raising the learning rate, which is a recipe change the task allows rather than a decision about where memory lives. In our screens at 1.2e-3, the Qwen3-Next gated layout with SwiGLU at its own 3:1 ratio reached 3.804, against 3.795 for our 2:1 composition; at 6e-4 the 2:1 and 3:1 versions without SwiGLU reached 3.970 and 3.983. The part of our improvement that comes from the ratio is therefore about one hundredth of a nat in development, which is the size of the seed noise we measured.
- The per-layer options are borrowed. The attention options (wide heads, two KV heads, RMS normalisation of queries and keys, partial rotary at base , elementwise gate) and the doubled value heads are those of the Qwen3-Next gated baseline. Our contribution is the ratio, the parameter-matched SwiGLU and the learning rate, together with the evidence for them.
- The rule is tied to twelve layers. It places attention wherever and never consults the depth, so "the last layer is exact" holds only when the depth is a multiple of three.
- Development evidence is reduced-scale and mostly single-seed. Our screens used a quarter of the batch and a fraction of the training tokens, and only one configuration was repeated with a second seed. Differences of one or two hundredths of a nat between the leading variants are not resolved by that evidence.
References
- Songlin Yang, Jan Kautz, Ali Hatamizadeh (2025). Gated Delta Networks: Improving Mamba2 with Delta Rule. ICLR.
- Liliang Ren, Yang Liu, Yadong Lu et al. (2025). Samba: Simple Hybrid State Space Models for Efficient Unlimited Context Language Modeling. ICLR.
- Opher Lieber, Barak Lenz, Hofit Bata et al. (2024). Jamba: A Hybrid Transformer-Mamba Language Model.
- NVIDIA, Aaron Blakeman, Aarti Basant et al. (2025). Nemotron-H: A Family of Accurate and Efficient Hybrid Mamba-Transformer Models.
- Jingwei Zuo, Maksim Velikanov, Ilyas Chahed et al. (2025). Falcon-H1: A Family of Hybrid-Head Language Models Redefining Efficiency and Performance.
- Xin Dong, Yonggan Fu, Shizhe Diao et al. (2025). Hymba: A Hybrid-head Architecture for Small Language Models. ICLR.
- Gemma Team, Aishwarya Kamath, Johan Ferret et al. (2025). Gemma 3 Technical Report.
- Krishna C. Puvvada, Faisal Ladhak, Santiago Akle Serrano et al. (2025). SWAN-GPT: An Efficient and Scalable Approach for Long-Context Language Modeling.
- OpenAI, Sandhini Agarwal, Lama Ahmad et al. (2025). gpt-oss-120b & gpt-oss-20b Model Card.
- Kimi Team, Yu Zhang, Zongyu Lin et al. (2025). Kimi Linear: An Expressive, Efficient Attention Architecture.
- Dustin Wang, Rui-Jie Zhu, Steven Abreu et al. (2025). A Systematic Analysis of Hybrid Linear Attention.
- Zihan Qiu, Zekun Wang, Bo Zheng et al. (2025). Gated Attention for Large Language Models: Non-linearity, Sparsity, and Attention-Sink-Free. NeurIPS.