MemTensor's Stable GDN-2 Fixes a Hidden Memory Explosion Crashing Long-Context AI Training
A linear-attention variant hits exponential state blowup on long contexts; symmetric erasure plus decay-regulated residual writes restore stability.
Takeaways
- Stable GDN-2 fixes recurrent state explosion in Gated DeltaNet-2 through symmetric erasure.
- GDN-2's asymmetric erase operator is non-normal, allowing state to grow exponentially even without new writes.
- 3 of 8 pretraining runs crashed with NaN losses at 64K context; surviving runs saw state entries hit 10^36.
- Fix splits erase gate into square-root factors; adds decay-regulated residual write, bounding state growth to O(√T).
- 128K RULER score jumps from 4.82 to 11.62 in recurrent setting; hybrid downstream accuracy improves 0.62 points.
- Chunkwise parallel training preserved; no public code or weights released with the paper.
Linear-attention models compress prior tokens into a fixed-size recurrent state, avoiding the growing key-value cache used by standard transformers. Gated DeltaNet-2 (GDN-2) expanded that design with channel-wise control over memory erasure and writing. During 64K-token training, however, some models produced NaN losses, while surviving runs recorded state values above 1036. Researchers from MemTensor and several universities traced the instability to GDN-2’s asymmetric erase operation and proposed Stable GDN-2, a bounded replacement that retains chunkwise parallel training.
An erase step that amplifies memory
Earlier architectures such as Gated DeltaNet and Kimi Delta Attention use the same key vector to read old content and write its correction. This alignment keeps the erase operation non-expansive: it may preserve or reduce the state norm, but it cannot increase it.
GDN-2 applies the erase gate differently. It reads memory along the gated key b ⊙ k, then writes the modification along the ungated key k. When those vectors are not collinear, the resulting erase matrix is non-normal. In plain terms, its eigenvalues can appear stable even while the matrix stretches some input directions.
For a single erase step, the authors derive the exact operator norm and prove that it exceeds 1 whenever the gated and ungated keys are not collinear. These token-level gains can compound. Their Corollary 3.2 constructs a valid sequence with one write at the first token and no later writes, yet the state norm continues growing exponentially.
- Three of eight recurrent and hybrid pretraining runs failed with NaN losses.
- One surviving run reached a maximum absolute state entry of 3.157 × 1036.
- That value remains within FP32 range, but exponential growth leaves little margin before overflow.
Symmetry puts a ceiling on growth
Stable GDN-2 splits the erase gate into two square-root factors and applies one on each side of the outer product. With u = √b ⊙ k, the erase operator becomes I − uuT. This matrix is symmetric, and the authors prove that its spectral norm is at most 1. Without new writes, the recurrent state therefore cannot be amplified by the transition.
Symmetric erasure also weakens writing when a channel’s erase gate approaches zero because the erase and write paths share u. Stable GDN-2 compensates with a residual write along k − u, scaled by √(1 − d2), where d is the channel’s decay. Channels with stronger decay receive more residual write capacity, while channels preserving existing state receive less.
The combined update gives the state’s Frobenius norm an O(√T) upper bound under bounded value vectors and a zero initial state. This replaces GDN-2’s possible exponential growth with a bound that increases sublinearly with sequence length.
The revised recurrence remains compatible with the chunkwise parallel algorithm used by GDN and Kimi Delta Attention. Its residual term depends only on known inputs and fits into the existing lower-triangular solve, preserving the method’s asymptotic training complexity and comparable per-chunk throughput.
Retrieval improves, with trade-offs
The researchers pretrained models with roughly 1.6 billion parameters on 64K-token sequences from ProLong. Their comparisons covered GDN-2, Kimi Delta Attention, D-Clip, and β-Guard. They evaluated a fully recurrent architecture and a hybrid containing one full-attention layer for every three linear-attention layers.
| Evaluation | Setting | Stable GDN-2 | Comparison |
|---|---|---|---|
| RULER average | Recurrent, 128K | 11.62 | GDN-2: 4.82 |
| RULER average | Hybrid, 128K | 8.78 | β-Guard: 10.52 |
| WikiText perplexity | Recurrent, 64K | 7.759 | KDA: 7.677 |
| Zero-shot reasoning | Recurrent | 50.39% | Matches GDN-2 |
| Zero-shot reasoning | Hybrid | 50.53% | GDN-2: 49.91% |
Higher scores are better for RULER and zero-shot reasoning; lower perplexity is better. On the RULER benchmark, Stable GDN-2 gains 6.80 points over GDN-2 in the recurrent 128K setting. β-Guard leads the hybrid 128K comparison by 1.74 points, while Kimi Delta Attention retains a small perplexity advantage across 8K through 64K windows.
Stable GDN-2 shows its largest task-specific gains on Variable Tracking, scoring 31.88 at 32K and 17.80 at 64K while most baselines remain near zero. The zero-shot average covers PIQA, HellaSwag, WinoGrande, ARC-Easy, ARC-Challenge, OpenBookQA, SocialIQA, BoolQ, and LAMBADA.
Implementation checks before adoption
Ablations indicate that both stabilization components contribute. In the paper’s ablation setting, the full model scores 25.43 on RULER. Removing the residual write lowers the score to 22.22, while removing decay regulation lowers it to 13.53 and also reduces short-task accuracy.
The paper does not provide code or model weights, so adopters must translate the recurrence and chunkwise derivation into their own kernels. The mathematical change is local, but production implementations should verify that recurrent and chunkwise outputs agree, especially under mixed-precision training.
- Track each layer’s maximum absolute state value and state norm during training.
- Alert on sustained state growth before the loss becomes non-finite.
- Test long sequences directly, since shorter runs may not expose compounding amplification.
- Compare sequential and chunkwise implementations on identical inputs.
- Measure retrieval, perplexity, and short-task accuracy because the reported methods trade performance across those evaluations.
For teams training delta-rule architectures at 64K tokens or beyond, the central diagnostic is concrete: stable loss curves do not guarantee bounded recurrent states. Direct state monitoring can expose the failure earlier, while symmetric erasure removes the amplification mechanism identified in GDN-2.