Stuffed Mamba: Oversized States Lead to the Inability to Forget

Yingfa Chen, Xinrong Zhang, Shengding Hu, Xu Han, Zhiyuan Liu, Maosong Sun

TL;DR

Recurrent architectures like Mamba are designed to handle long sequences efficiently, but they often crash when the context exceeds their training length. This paper reveals the culprit: state overparameterization. Because the model's internal memory (state) is often too large relative to its training sequences, it never learns to "forget" old information, leading to catastrophic memory interference in long-context scenarios.

What Problem Does This Paper Address?

Modern Large Language Models (LLMs) are moving toward massive context windows, but the standard Transformer architecture struggles with this because its computational cost grows quadratically with sequence length. Recurrent Neural Networks (RNNs) like Mamba and RWKV offer a solution: they compress context into a fixed-size state, keeping costs constant per token.

However, these RNNs suffer from a "length generalization" failure. Even if a model is theoretically capable of processing infinite text, its performance degrades sharply once it passes the length of the sequences it saw during training. The authors investigate why these models—which have built-in "forgetting" gates—fail to use them effectively, resulting in a "Stuffed Mamba" that tries to remember everything until its memory overflows and produces gibberish.

Methods

The researchers conducted a deep dive into Mamba-2, analyzing its internal mechanics and training dynamics:

  • State Inspection: They monitored the "memory retention strength" ($\alpha_t$) and the variance of the recurrent states across different layers.
  • Interventions: They tested whether forcing the model to forget—either by manually scaling down retention or using a sliding window approach—could fix the performance drop.
  • Controlled Training: They trained multiple Mamba-2 models from scratch, varying both the state size ($N_S$) and the training length ($T_{train}$) to find the mathematical relationship between memory capacity and the ability to learn forgetting.
  • Passkey Retrieval: They used the "needle-in-a-haystack" passkey task to measure exactly how much information the model could accurately recall.

Datasets

  • RedPajama-V2: A massive open-source dataset used for pre-training and evaluating language modeling loss.
  • Passkey Retrieval Task: A synthetic benchmark where a 5-digit code is hidden inside a long sequence of irrelevant text (e.g., "The grass is green..."). The model must recall the code at the end.

Key Insights and Ideas

  • The "Forgetting" Paradox: Mamba has the math to forget, but it doesn't want to. If the training sequences are short enough to fit entirely within the model's state, the model minimizes loss by simply storing everything. It never encounters the "memory pressure" needed to learn that old tokens should be discarded.
  • Linear Scaling of the Forget Threshold: The authors discovered a linear law: the minimum training length required for a model to learn robust forgetting scales linearly with its state size ($T_{forget} \approx 5.17 \cdot N_S$). If you have a bigger state, you must train on longer sequences to avoid length generalization failure.
  • Exponential Recall Capacity: While the threshold to start forgetting is linear, the model's ability to retrieve specific facts (like a passkey) scales exponentially with the state size. This suggests that RNNs have a massive untapped potential for long-context retrieval if trained correctly.
  • Variance Explosion: When a model that hasn't learned to forget encounters a sequence longer than its training length, the variance of its internal state explodes. A few "outlier channels" become overloaded, causing the entire model to fail.

Key Results

The paper provides empirical proof that the "stuffing" issue is the primary bottleneck for Mamba's long-context performance:

  • Generalization Failure: A Mamba-2 370M model trained on 8K tokens showed near-zero accuracy on passkey retrieval once the context reached 16K, regardless of where the passkey was hidden.
  • Successful Scaling: By increasing the training length beyond the "forget threshold," the authors showed that a 370M Mamba-2 could achieve near-perfect retrieval on a 256K context, significantly outperforming similarly sized Transformers.
  • Linear Relationship: They established the formula $T_{forget} = 5.172 \cdot N_S - 4.469$, providing a practical guide for researchers on how long their training sequences need to be based on their model's architecture.
Passkey retrieval accuracy heatmap showing how a model trained on short contexts (8K) fails to retrieve information as the context length increases, even for very recent tokens.

Limitations and Future Work

While the paper focuses heavily on Mamba-2, the authors note that other RNNs like RWKV-6 and Mamba-1 show similar symptoms, though the severity varies based on state size.

A key limitation is the computational cost: training large models (like the 780M parameter version) on extremely long sequences (128K+) to reach their forget threshold requires significant resources. Future work could explore training-free methods to induce forgetting or architectural changes that force the model to manage its memory more efficiently from the start, rather than relying solely on long-context training data.

Summary updated

BibTeX
@inproceedings{chen2025stuffed,
  author = {Yingfa Chen and Xinrong Zhang and Shengding Hu and Xu Han and Zhiyuan Liu and Maosong Sun},
  title = {{Stuffed Mamba: Oversized States Lead to the Inability to Forget}},
  booktitle = {COLM},
  year = {2025},
  url = {https://openreview.net/forum?id=CdRauNXD1w},
}
Figure