TL;DR
State-of-the-art recurrent architectures like Mamba-2 suffer from severe performance drops when context lengths exceed their training length. This paper reveals that the culprit is "state overparameterization"—the model's internal memory state is so large relative to short training contexts that it never learns how to forget irrelevant past information. By establishing new scaling laws, the authors show that training on sufficiently long sequences forces Mamba-2 to learn how to forget, unlocking near-perfect information retrieval up to a 256K context length.
What Problem Does This Paper Address?
Transformers scale quadratically with sequence length, making long-context processing computationally expensive. Recurrent Neural Networks (RNNs) and State Space Models (SSMs) like Mamba and RWKV offer a promising alternative: they compress context into a fixed-size state, achieving constant per-token time and space complexity during inference.
However, these models suffer from a frustrating limitation: their performance degrades sharply once the context length exceeds the length they were trained on. The authors investigate why this length generalization failure happens. While Mamba has a built-in mathematical gating mechanism designed to "forget" older tokens to avoid memory overload, it fails to utilize it effectively in practice. This paper addresses the root cause of this inability to forget and outlines how to fix it.
Methods
- Memory Retention Analysis: The authors inspect the internal memory decay multiplier ($\alpha_t$) to track how strongly the model retains early tokens over time.
- Forgetting Interventions: To prove that over-retention causes the failure, they introduce two training-free interventions: Reduced Memory Retention and Insertion (RRI), which manually scales down retention and insertion forces, and a recurrent Sliding Window mechanism that mathematically discards tokens outside a specific window.
- Empirical Sweeps: They train multiple Mamba-2 models from scratch across six different model sizes and varying training lengths to map out the exact relationship between state size, training length, and long-context performance.
Datasets
- RedPajama: An open dataset used for pre-training models from scratch and evaluating standard language modeling perplexity across long token positions.
- Passkey Retrieval: A synthetic benchmark where the model must recall a specific 5-digit passkey hidden inside a massive block of repetitive, irrelevant text (e.g., "The grass is green. The sky is blue...").
Key Insights and Ideas
- State Overparameterization: When trained on short contexts, Mamba's fixed state size is excessively large relative to the total information it needs to hold. Because it can easily store everything without running out of space, the model minimizes training loss without ever needing to activate or learn its forgetting mechanism.
- Forgetting as an Overfitting Problem: As training progresses on short sequences, the model actually loses its initial ability to forget, choosing instead to over-retain all past tokens. This acts like a form of overfitting to short contexts.
- The Linear Forget Threshold: Forgetting isn't automatic; it must be forced. The authors discover a strict linear threshold ($T_{forget}$): a model will only learn to forget if the training context length exceeds its state capacity.
- Exponential Recall Scaling: While the threshold to start forgetting scales linearly, the maximum context length for accurate information retrieval ($T_{recall}$) scales exponentially with the state size. This shows that RNNs can retain specific high-value information far out into the horizon if trained correctly.
Key Results
- Standard Mamba-2 models show catastrophic loss spikes and zero passkey retrieval accuracy once context lengths cross into untrained territory (typically around 8K to 16K tokens).
- Artificially forcing the model to forget via RRI or Sliding Window interventions successfully mitigates the long-context performance collapse.
- The authors empirically derived the exact linear law for the minimum training length required to learn robust forgetting: $$T_{forget} = 5.172 \cdot N_S - 4.469$$ (where $N_S$ is the state size).
- By scaling the training length appropriately based on these insights, a 370M parameter Mamba-2 model achieved near-perfect passkey retrieval accuracy at a massive 256K context length, outperforming similarly sized Transformer models.
Limitations and Future Work
- The primary focus of the empirical evaluations and interventions is on Mamba-2, though the authors note that similar trends are observable in Mamba-1 and RWKV-6.
- The paper does not exhaustively test newer, non-gating-based recurrent architectures like xLSTM or Titans, which use different memory mechanisms entirely.
- Future work is needed to explore how these insights can guide optimal hyperparameter tuning and data scheduling (such as progressive context lengthening) during the pre-training of massive state-space models.
Summary updated