Abstract
Recent advancements in recurrent architectures, such as Mamba and RWKV, have showcased strong language capabilities. Unlike transformer-based models, these architectures encode all contextual information into a fixed-size state, leading to great inference efficiency. However, this approach can cause information interference, where different token data conflicts, resulting in performance degradation and incoherent outputs beyond a certain context length. To prevent this, most RNNs incorporate mechanisms designed to "forget" earlier tokens. In this paper, we reveal that Mamba-based models struggle to effectively forget earlier tokens even with built-in forgetting mechanisms. We demonstrate that this issue stems from training on contexts that are too short for the state size, enabling the model to perform well without needing to learn how to forget. Then, we show that the minimum training length required for the model to learn forgetting scales linearly with the state size, and the maximum context length for accurate retrieval of a 5-digit passkey scales exponentially with the state size, indicating that the model retains some information beyond the point where forgetting begins. These findings highlight a critical limitation in current RNN architectures and provide valuable insights for improving long-context modeling. Our work suggests that future RNN designs must account for the interplay between state size, training length, and forgetting mechanisms to achieve robust performance in long-context tasks.
The Challenge of Long-Context Recurrent Architectures
Recurrent Neural Networks (RNNs) like Mamba and RWKV represent a promising frontier for long-context artificial intelligence. Unlike Transformers, which suffer from quadratic scaling of memory requirements relative to sequence length, RNNs maintain a constant-size recurrent state. This efficiency, however, often comes with a trade-off: performance typically collapses once a sequence exceeds the length seen during training.
This research investigates the root cause of this "performance cliff." While modern RNNs theoretically possess "forgetting mechanisms"—decay factors intended to discard stale information—the authors discover that Mamba models fail to utilize them effectively. Instead of managing memory dynamically, these models suffer from "information interference," where residual data from early tokens conflicts with new inputs, leading to incoherent outputs and a sharp rise in perplexity.
Mechanistic Analysis and Scaling Laws
To diagnose this failure, the researchers employed a mechanistic approach to evaluate Mamba-2:
- Retention Analysis: They examined the "memory retention strength" ($\alpha_t$) across individual heads to determine if the model was actively decaying old information.
- State Interventions: They tested whether manual "forced forgetting" could restore performance. This involved Reduced Memory Retention and Insertion (RRI)—scaling down state updates—and implementing a Sliding Window state to mathematically purge tokens outside a specific window.
- Scaling Law Discovery: By training multiple Mamba-2 variants from scratch, varying state size ($N_S$) and training length ($T_{train}$), they sought the mathematical relationship governing memory capacity and the emergence of forgetting behavior.
The "Stuffed" State and the Linear Forget Threshold
The core finding is the "Stuffed" State Hypothesis. If a model is trained only on short sequences relative to its state size, it never encounters a "full" memory. Consequently, it never learns to prioritize or discard information. Like a traveler who never learns to pack efficiently because their suitcase is oversized for a weekend trip, the model simply "stuffs" every token into its state. When faced with a truly long sequence, the state becomes over-saturated, leading to catastrophic interference.
The researchers identified a critical forget threshold ($T_{forget}$). A model only learns to manage its memory if its training length exceeds this threshold, which scales linearly with the state size. Specifically, they established the empirical formula: $T_{forget} \approx 5.17 \cdot N_S - 4.47$.
Empirical Findings
The study utilized the RedPajama-V2 dataset for language modeling and a synthetic Passkey Retrieval task to test long-range memory. The results highlight a stark performance drop-off: standard Mamba-2 models achieve near-perfect retrieval up to their 8K training length but fail almost immediately thereafter.
Despite this limitation, the state's potential capacity is immense. The maximum context length for accurate passkey retrieval scales exponentially with state size. By continuing pre-training on longer sequences to force the model to learn forgetting, a 370M Mamba-2 model achieved near-perfect retrieval on a 256K context, outperforming similarly sized Transformers.
Discussion and Future Directions
The findings suggest that "state overparameterization" is a primary obstacle to long-context generalization in RNNs. While manual interventions like RRI can mitigate the issue, the most robust solution is ensuring training lengths are sufficient to trigger the learning of forgetting mechanisms.
Future work should explore architectural modifications that incentivize forgetting during training, potentially decoupling the state's capacity from the training length requirement. This would allow RNNs to fulfill their promise as efficient, truly long-context models without the prohibitive cost of training on massive sequences.
Summary updated