Mamba Modulation: On the Length Generalization of Mamba

Peng Lu, Jerry Huang, Qiuhao Zeng, Xinyu Wang, Boxing Chen +2 more
9/23/2025
cs.LGcs.AIstat.ML

No official code found. Best implementation: gnepul-ace/mamba_modulation (4 stars, MIT, last commit 2025-11-04).

Abstract

The quadratic complexity of the attention mechanism in Transformer models has motivated the development of alternative architectures with sub-quadratic scaling, such as state-space models. Among these, Mamba has emerged as a leading architecture, achieving state-of-the-art results across a range of language modeling tasks. However, Mamba's performance significantly deteriorates when applied to contexts longer than those seen during pre-training, revealing a sharp sensitivity to context length extension. Through detailed analysis, we attribute this limitation to the out-of-distribution behaviour of its state-space dynamics, particularly within the parameterization of the state transition matrix $\mathbf{A}$. Unlike recent works which attribute this sensitivity to the vanished accumulation of discretization time steps, $\exp(-\sum_{t=1}^NΔ_t)$, we establish a connection between state convergence behavior as the input length approaches infinity and the spectrum of the transition matrix $\mathbf{A}$, offering a well-founded explanation of its role in length extension. Next, to overcome this challenge, we propose an approach that applies spectrum scaling to pre-trained Mamba models to enable robust long-context generalization by selectively modulating the spectrum of $\mathbf{A}$ matrices in each layer. We show that this can significantly improve performance in settings where simply modulating $Δ_t$ fails, validating our insights and providing avenues for better length generalization of state-space models with structured transition matrices.

View on arXivView PDF

Code Implementations(1)

MIT

Mamba Modulation: On the Length Generalization of Mamba Models

40Shell, PythonJun 10, 202511 months agoMIT
length-generalizationmamba-state-space-models

Similar Papers

Cite this paper

@article{lu2025mamba,
  title  = {Mamba Modulation: On the Length Generalization of Mamba},
  author = {Peng Lu and Jerry Huang and Qiuhao Zeng and Xinyu Wang and Boxing Chen and Philippe Langlais and Yufei Cui},
  year   = {2025},
  eprint = {2509.19633},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2509.19633v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2509.19633.svg)](https://codeofpaper.com/paper/2509.19633)

Discussion