cs.LGMar 12, 2026

Probing Length Generalization in Mamba via Image Reconstruction

Authors: Jan Rathjens, Robin Schiewer, Laurenz Wiskott, Anand Subramoney

Organizations: Institute for Neural Computation, Faculty of Computer Science, Ruhr University Bochum, Bochum, Germany · CITEC, Bielefeld University, Bielefeld, Germany · Department of Computer Science, Royal Holloway, University of London, Egham, UK

Abstract

Mamba has attracted widespread interest as a general-purpose sequence model due to its low computational complexity and competitive performance relative to transformers. However, its performance can degrade when inference sequence lengths exceed those seen during training. We study this phenomenon using a controlled vision task in which Mamba reconstructs images from sequences of image patches. By analyzing reconstructions at different stages of sequence processing, we reveal that Mamba qualitatively adapts its behavior to the distribution of sequence lengths encountered during training, resulting in strategies that fail to generalize beyond this range. To support our analysis, we introduce a length-adaptive variant of Mamba that improves performance across training sequence lengths. Our results provide an intuitive perspective on length generalization in Mamba and suggest directions for improving the architecture.

Figures & tables

Explore similar work

CardsList
  1. Mamba with Hierarchical Memory: Solving Representation Bottleneck in Long Sequence Modeling

    Aug 3, 2026Qinwen Wang, Jieping Luo, Aoxiang Qin +5Long-Context RetrievalMemory-Augmented Neural Networks

  2. Length Generalization Needs Proper Regularization

    Oct 3, 2026Pavlo Vasylenko, Matthias Lindemann, André F. T. Martins +1Length GeneralizationNeural Network Generalization

  3. Separators in Enhancing Autoregressive Pretraining for Vision Mamba

    Mar 4, 2026Hanpeng Liu, Zidan Wang, Shuoxi Zhang +2Visual Autoregressive ModelsVisual SSMs