Introduction
We study the sequence mixer in a GPT-style language model when its memory is a recurrent state of fixed size. The mixer must process a prefix in linear time, carry only bounded state between calls, and still preserve information that matters much later. A state that is too small loses associations; a state that is too diffuse cannot give any one association a reliable read. The fixed parameter budget adds a second constraint: capacity assigned to the mixer is capacity taken from the rest of the stack.
The starting point is linear attention, which replaces the quadratic attention matrix with an associative summary of keys and values [1]. Gated linear attention adds input-dependent retention [2], while delta-style rules write a correction to a state prediction [3]. More recent gated delta work makes the erase and write controls distinct [4]. Other fixed-state families use state-space recurrences [5, 6] or distribute capacity across memories [7]. These directions leave a practical design choice open: should every layer receive the same matrix state, or should the fixed state budget follow the hierarchy of the model?
We propose two-scale gated delta memory (TSDM). We keep the gated delta update, but allocate more matrix capacity to later layers. The first layers use more, smaller heads; the later layers use fewer, wider heads. This preserves the total state while giving the upper part of the residual stack room for slower, higher-capacity associations. The result is a single causal recurrence per layer, with no cross-layer memory path and no sequence-length-dependent state.
Method
State allocation across depth
The submitted mixer has eight layers, key width , value width , and the head schedule . For layer with heads, the per-head dimensions are
The state held by that layer therefore has
scalars. The early layers use eight heads and the later layers four, so a later layer's matrix state is twice as large. Because the schedule has four layers of each kind, this is a reallocation of the fixed state budget rather than an increase in it. The model keeps the parameter count in the allowed shell with an MLP width of .
n_layer = 8
key_dim = 1024
value_dim = 768
v_short_conv = False
owns_read_out = True
mlp_hidden = 3906
head_k_dim = 256
head_schedule = (8, 8, 8, 8, 4, 4, 4, 4)
@staticmethod
def train_recipe():
return {'lr': 0.0048, 'init_std_mult': {'attn_in': 0.3194, 'attn_out': 0.3194}}This schedule is a capacity decision, not a hard-coded timescale. Each layer still learns its own
decay from its input. The shell supplies the query, key and value projections. We retain its short
convolutions for queries and keys but set v_short_conv = False, so values enter the recurrent
update without that local filter.
Gated delta state update
Let be the layer input and let be the projected streams after the fixed shell. The mixer constructs three controls from :
Here is the learned dt_bias, is the learned per-head A_log after exponentiation,
and the products are broadcast over each head's key channels. Thus is a
positive, input-dependent retention factor, while and are separate sigmoid
controls supplied to the gated delta update. Inside the kernel, queries and keys are L2-normalized
before they read and write the state.
def __init__(self, hidden_size, state_budget, layer_idx=0):
super().__init__()
self.hidden_size = hidden_size
self.state_budget = state_budget
self.num_heads = self.head_schedule[layer_idx]
K, V = self.key_dim, self.value_dim
self.head_k_dim = K // self.num_heads
self.head_v_dim = V // self.num_heads
self.f_proj_0 = nn.Linear(hidden_size, self.head_v_dim, bias=False)
self.f_proj_1 = nn.Linear(self.head_v_dim, K, bias=False)
self.b_proj = nn.Linear(hidden_size, K, bias=False)
self.w_proj = nn.Linear(hidden_size, V, bias=False)
self.A_log = nn.Parameter(torch.log(torch.empty(self.num_heads, dtype=torch.float32).uniform_(1, 16)))
self.A_log._no_weight_decay = True
dt = torch.exp(torch.rand(K, dtype=torch.float32) * (math.log(0.1) - math.log(0.001))
+ math.log(0.001)).clamp(min=1e-4)
self.dt_bias = nn.Parameter(dt + torch.log(-torch.expm1(-dt)))
self.dt_bias._no_weight_decay = True
self.g_proj_0 = nn.Linear(hidden_size, self.head_v_dim, bias=False)
self.g_proj_1 = nn.Linear(self.head_v_dim, V, bias=True)
self.o_norm = FusedRMSNormGated(self.head_v_dim, activation='swish', eps=1e-5)For each head, chunk_gdn2 applies the gated delta recurrence to the carried matrix state and
returns a readout:
where bars denote the kernel's L2-normalized queries and keys. The call supplies the carried matrix state together with the current queries, keys, values, decay, erase, and write controls. The returned matrix state carries the mixer's recurrent prefix information; the shell separately carries the fixed-size query and key convolution caches.
def forward(self, q, k, v, x, state=None, return_state=False):
dk, dv = self.head_k_dim, self.head_v_dim
g = F.softplus(self.f_proj_1(self.f_proj_0(x)).float() + self.dt_bias)
b = self.b_proj(x).sigmoid()
w = self.w_proj(x).sigmoid()
q, k, g, b = (rearrange(t, '... (h d) -> ... h d', d=dk) for t in (q, k, g, b))
v = rearrange(v, '... (h d) -> ... h d', d=dv)
w = rearrange(w, '... (h d) -> ... h d', d=dv)
g = -self.A_log.float().exp().unsqueeze(-1) * g
o, s = chunk_gdn2(q=q, k=k, v=v, g=g, b=b, w=w,
initial_state=state[0] if state is not None else None,
output_final_state=return_state, use_qk_l2norm_in_kernel=True)
gg = rearrange(self.g_proj_1(self.g_proj_0(x)), '... (h d) -> ... h d', d=dv)
o = self.o_norm(o, gg)
return rearrange(o, 'b t h d -> b t (h d)'), ((s,) if return_state else None)The mixer owns its readout. A second pair of projections produces from , and the returned head outputs are transformed as
This keeps the recurrent state focused on the associative memory while allowing the current layer input to gate how strongly that memory enters the residual stream. The output is then flattened from heads back to the fixed value width.
Results
| Method | ① | ② | ③ | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Validation loss ↓ | WikiText-2 perplexity ↓ | LAMBADA perplexity ↓ | Long-window validation loss ↓ | Long-window tail loss ↓ | Long-window WikiText-2 loss ↓ | SQuAD answer accuracy ↑ | RULER S-NIAH-2 NLL ↓ | RULER S-NIAH-3 NLL ↓ | NIAH-1 NLL ↓ | NIAH-1 16k ↓ | |
| Kimi K3.1 Pro | 3.287 | 31.67 | 39.15 | 3.232 | 3.223 | 3.396 | 21.18 | 4.321 | 2.970 | 1.678 | 4.069 |
| Linear Transformer | 3.976 | 86.42 | 68.01 | 6.423 | 8.181 | 6.288 | 3.820 | 8.257 | 5.434 | 8.202 | 10.47 |
| GLA | 3.407 | 41.98 | 44.39 | 3.358 | 3.348 | 3.698 | 14.18 | 6.065 | 4.208 | 6.600 | 7.210 |
| Gated Slot Attention | 3.406 | 41.27 | 44.65 | 3.354 | 3.342 | 3.681 | 11.33 | 4.791 | 3.983 | 3.076 | 5.355 |
| Mixture-of-Memories | 3.369 | 36.95 | 41.88 | 3.318 | 3.308 | 3.560 | 14.14 | 4.432 | 3.137 | 3.881 | 6.364 |
| Gated DeltaNet | 3.314 | 33.19 | 40.80 | 3.260 | 3.253 | 3.443 | 17.53 | 4.616 | 2.873 | 1.611 | 4.315 |
| Gated DeltaNet-2 | 3.283 | 31.63 | 39.76 | 3.230 | 3.223 | 3.392 | 19.81 | 4.613 | 2.886 | 2.981 | 5.777 |
| Kimi Delta Attention | 3.290 | 32.47 | 40.64 | 3.236 | 3.227 | 3.416 | 19.40 | 4.379 | 2.671 | 1.968 | 4.780 |
| Comba | 3.296 | 32.13 | 40.09 | 3.243 | 3.235 | 3.410 | 19.64 | 4.320 | 2.488 | 1.808 | 2.811 |
| RWKV-7 | 3.296 | 33.48 | 40.83 | 3.244 | 3.235 | 3.455 | 16.49 | 4.734 | 3.291 | 2.062 | 5.083 |
| Mamba-2 | 3.301 | 36.73 | 42.22 | 3.250 | 3.239 | 3.564 | 13.67 | 5.939 | 4.079 | 4.690 | 7.259 |
| Mamba-3 | 3.300 | 34.02 | 42.16 | 3.248 | 3.243 | 3.480 | 17.36 | 5.562 | 3.583 | 4.238 | 7.385 |
| OmegaNet | 3.402 | 39.14 | 44.87 | 3.349 | 3.339 | 3.612 | 13.34 | 5.282 | 3.307 | 2.775 | 3.648 |
| In-Place TTT | 3.400 | 40.49 | 42.25 | 3.372 | 3.407 | 4.204 | 13.64 | 5.262 | 3.684 | 8.899 | 14.51 |
| IP-TTCD | 3.443 | 46.75 | 43.61 | 6.330 | 12.14 | 4.212 | 13.14 | 6.414 | 4.665 | 6.838 | 14.92 |
| TTT-Linear | 3.416 | 39.08 | 44.01 | 3.477 | 3.657 | 3.687 | 13.34 | 6.012 | 4.065 | 2.107 | 5.414 |
| MesaNet | 3.379 | 36.09 | 44.55 | 3.326 | 3.317 | 3.526 | 16.09 | 4.184 | 2.871 | 2.603 | 5.960 |
| Mamba-3 MIMO | 3.273 | 32.60 | 40.48 | 3.220 | 3.212 | 3.430 | 18.23 | 4.299 | 2.774 | 3.820 | 6.731 |
- ① 124M FineWeb pretraining · 4k context · validation, WikiText-2 and LAMBADA
- ② Same checkpoint · 16k-window validation / WikiText-2
- ③ Same checkpoint · SQuAD completion + RULER needle recall at 4k and 16k
The results table reports all per-setting means. On Pretrain, TSDM has LAMBADA perplexity 39.15 versus the strongest published baseline's 39.54 (GDN-2, half batch). Its validation loss is 3.287 versus 3.271 from GDN-2, half batch, and its WikiText-2 perplexity is 31.67 versus 30.79 from GDN-2, half batch. The advantage is therefore concentrated in transfer rather than every short-context loss.
On Long-ctx, our long-context validation loss is 3.232, tail loss is 3.223, and WikiText-2 loss is 3.396. Each is higher than the corresponding best published value, 3.218, 3.212, and 3.364, respectively. This is a competitive result without a uniform lead on the long-context losses.
On Recall, TSDM reaches recall accuracy 21.18, above the best published baseline value 19.81 from Gated DeltaNet-2 [4]. The NIAH-2 and NIAH-3 negative-log-likelihood measures tell a different story: our values are 4.321 and 2.970, while the best published values are 3.894 and 2.488. Recall accuracy and likelihood therefore disagree about where the allocation helps.
How we got here
We began by comparing the fixed shell and recurrent references. The initial hypothesis was that a local cache could reconstruct recent patterns, leaving a global delta state to store only the residual. We implemented a strictly causal local predictor, a residual target for the delta state, and a local reconstruction objective. Early development comparisons supported that complementarity, and they also showed that channel-wise gates were better than one scalar gate.
The longer comparisons changed the decision. Detaching the local target was worse, and landmark caches traded some middle-distance recall for denser local quality. Dynamic confidence and projection-decoupled shrinkage underperformed static shrinkage, while learned coefficients collapsed toward zero. A phase-separated pre-write read was also dropped after its language-model comparisons were consistently weaker. These failures moved us toward a simpler raw gated delta memory with more capacity per layer.
The decisive structural experiment varied depth while holding the total state and parameter budgets fixed. Fewer layers made larger global matrices possible; the final choice was a smooth two-scale allocation rather than a single uniform geometry. The trace records the motivation as a hierarchical memory hypothesis: lower layers learn faster, local structure, while upper layers can use larger states for slower associations. We then compared the two-scale candidate with a symmetric delta update intended to reduce oblique amplification. That alternative was rejected by the longer comparison, leaving the standard GDN2 update plus the depth allocation in the submitted file.
Limitations
TSDM is not uniformly best. It trails the strongest published baseline on the validation and WikiText-2 measures of Pretrain, on all three long-context losses in Long-ctx, and on all four likelihood measures in Recall. Its clearest table-level strengths are LAMBADA perplexity on Pretrain and recall accuracy on Recall.
The schedule encodes a structural assumption that later layers benefit from larger associative matrices. The trace supports that assumption for this run, but it does not establish an optimal allocation for another parameter budget, corpus, or model width. A uniform head geometry, a local cache, or a different depth could be preferable elsewhere.
The state stores a learned summary rather than exact tokens. The four-head late layers trade the number of independent subspaces for per-head capacity. TSDM therefore has no guarantee of retrieving every distant association, even though its state size is constant and its recurrence can continue beyond the training context.
Finally, the submitted implementation relies on the chunk_gdn2 kernel and on the surrounding
shell's projection and convolution contract. The method is consequently a design for this fixed
interface; portability to another kernel or a different state accounting rule remains untested.
References
- Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas et al. (2020). Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention. ICML.
- Songlin Yang, Bailin Wang, Yikang Shen et al. (2024). Gated Linear Attention Transformers with Hardware-Efficient Training. ICML.
- Songlin Yang, Jan Kautz, Ali Hatamizadeh (2025). Gated Delta Networks: Improving Mamba2 with Delta Rule. ICLR.
- Ali Hatamizadeh, Yejin Choi, Jan Kautz (2026). Gated DeltaNet-2: Decoupling Erase and Write in Linear Attention. NeurIPS.
- Tri Dao, Albert Gu (2024). Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality. ICML.
- Aakash Lahoti, Kevin Y. Li, Berlin Chen et al. (2026). Mamba-3: Improved Sequence Modeling using State Space Principles. ICLR.
- Jusen Du, Weigao Sun, Disen Lan et al. (2026). MoM: Linear Sequence Modeling with Mixture-of-Memories. ICLR.
- Yu Zhang, Songlin Yang, Ruijie Zhu et al. (2024). Gated Slot Attention for Efficient Linear-Time Sequence Modeling. NeurIPS.
- Kimi Team, Yu Zhang, Zongyu Lin et al. (2025). Kimi Linear: An Expressive, Efficient Attention Architecture.
- Jiaxi Hu, Yongqi Pan, Jusen Du et al. (2025). Comba: Improving Bilinear RNNs with Closed-loop Control.
- Bo Peng, Ruichong Zhang, Daniel Goldstein et al. (2025). RWKV-7 "Goose" with Expressive Dynamic State Evolution. COLM.
- Ali Behrouz, Zeman Li, Praneeth Kacham et al. (2026). ATLAS: Learning to Optimally Memorize the Context at Test Time. ICML.
- Guhao Feng, Shengjie Luo, Kai Hua et al. (2026). In-Place Test-Time Training. ICLR.
- Zixuan Wang, Xingyu Dang, Rui-Jie Zhu et al. (2026). Learning What to Remember: Test-Time Training via Context Distillation.
- Yu Sun, Xinhao Li, Karan Dalal et al. (2025). Learning to (Learn at Test Time): RNNs with Expressive Hidden States. ICML.
- Johannes von Oswald, Nino Scherrer, Seijin Kobayashi et al. (2026). MesaNet: Sequence Modeling by Locally Optimal Test-Time Training. ICLR.