Manuscript Offprint

arXiv:2610.19709

Beyond State Capacity: Why Retrieval Breaks in Mamba

Nir Yarden, Amit Ben-Artzy, Roy Schwartz

ABSTRACT

Mamba models underperform Transformers on in-context retrieval. This gap is usually attributed to Mamba's fixed-size recurrent state, which loses information as the context grows. We challenge this assumption by focusing on query-first retrieval, a setup in which the query precedes the context and state capacity should not be the binding constraint. We show that even in this setting Mamba lags substantially behind Transformers, despite its selection mechanism, which was designed to distinguish relevant content from distractors. We then demonstrate that the Mamba selection gates have sufficient control over the state updates to influence the model output: intervening on specific gates alone can swing accuracy between extremes. However, as gates are input-dependent, they require the incoming token's representation to encode its relevance to the query. We therefore probe token representations across layers, and find that the relevance signal emerges only gradually with model depth, and that the gates begin to reflect it only several layers deeper. Crucially, we find that gates in retrieval-critical layers are not yet aligned with relevance. The selection mechanism is thus expressive enough to solve the task, but it commonly operates on a relevance signal that has not yet arrived. Mamba's retrieval bottleneck therefore extends beyond state capacity: even when capacity is sufficient, the delayed emergence of relevance information across depth often prevents successful retrieval.

1 INTRODUCTION

The Transformer architecture (Vaswani et al., 2017) has dominated the large language model landscape for nearly a decade. Concurrently, the research community has actively sought sub-quadratic alternatives with competitive performance (Katharopoulos et al., 2020; Gu et al., 2021), with Mamba state-space models (Gu & Dao, 2024; Dao & Gu, 2024; Lahoti et al., 2026) emerging as a leading contender. Mamba's limitations in long-context retrieval are established in the literature, with prior work largely attributing them to its fixed-size state capacity: as the state saturates, it inevitably decays and loses information (Jelassi et al., 2024; Waleffe et al., 2024; Arora et al., 2024; Wen et al., 2025).

State saturation provides a natural explanation for Mamba's retrieval failures when the model is forced to store the entire sequence under limited state capacity before discovering what information will be queried. Providing the query upfront removes this pressure: the model can, in principle, identify the relevant information as it processes the context and retain only the compact target information. Much like a human skimming a phonebook for a specific entry, a selective recurrent model should use its input-dependent gates to filter out irrelevant distractors—precisely the behavior Mamba's selection mechanism is intended to support. Yet empirical findings show that Mamba's retrieval accuracy remains poor even when the query is provided before the context, falling well behind Transformers (Waleffe et al., 2024). Thus, although state saturation provides an important explanation for Mamba's retrieval failures, the poor performance in this setting points to additional factors at play, motivating us to examine whether Mamba's selection mechanism can reliably identify and retain relevant information.

To uncover the root cause of this failure, we work backward from the output to trace where Mamba's information flow breaks down (fig. 1). First, we construct a controlled setting using a query-first key-value retrieval task—concretely, a synthetic phonebook in which the model must return the value paired with a queried key, embedded among many distractor entries. We find that simply prepending a relevance flag to the target entry drastically improves Mamba's accuracy. The flag explicitly signals the entry's relevance instead of relying on contextual deduction. We can therefore localize the bottleneck by comparing information flow between the flagged and unflagged variations. Specifically, we track the recurrent states to determine when the target information is retained, and analyze the selection mechanism's gates ( Δ\Delta) to assess how effectively they distinguish target tokens from distractors. Next, we probe the target entry token's representations to measure how deeply its contextual relevance is encoded and how rapidly this signal reflects upon the selection gates. To measure the gates' exact control over performance, we patch gate values between the variants and inject oracle gate spikes at critical tokens.

Ultimately, we find that the selection gates strictly govern retrieval accuracy: trivial modifications to these gates can dramatically restore or destroy Mamba's output. This demonstrates that the selection mechanism is capable of effective state updates, provided its gates are well-calibrated. The problem, however, is that the gates are often miscalibrated: long-range contextual information requires many layers to mix into a token's representation and then reflect upon its gates. Empirically, critical state updates tend to occur before the token's relevance is adequately indicated in the selection mechanism. These findings reveal that limited state capacity alone does not fully account for Mamba's retrieval difficulty, and point to selection gate calibration—shaped by both architectural design and training—as a critical factor in addressing it.

Figure

Figure 1: Mechanistic overview of query-first retrieval in Mamba Guided by the design principles behind Mamba's architecture, we trace the flow of information across the layer and token-sequence axes, examining under a magnifying glass the mechanisms involved at query-first retrieval in Mamba, in search of the source of its degraded performance. Specifically, we zoom in on the following processes: (a) As token representations are mixed across layers, a relevance signal is encoded. (b) The selection gate responds to this signal by 'opening and closing', selectively writing relevant content to state while suppressing distractors. (c) The recurrent state stores the target information while being repeatedly updated, which requires protecting it from decay. (d) Finally, the target information is extracted from the state to generate the output token.

References (41)

  • Understanding intermediate layers using linear classifier probes, 2017
  • Zoology: Measuring and Improving Recall in Efficient Language Models
  • Yonatan Belinkov. Probing Classifiers: Promises, Shortcomings, and Advances. Comput. Linguistics, 48(1):207–219, 2022. URL https://doi.org/10.1162/coli_a_00422. (opens the publisher in a new tab)
  • DeciMamba: Exploring the Length Extrapolation Potential of Mamba
  • Understanding the Skill Gap in Recurrent Models: The Role of the Gather-and-Aggregate Mechanism
  • Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality
  • Hymba: A Hybrid-head Architecture for Small Language Models
  • Zamba: A Compact 7B SSM Hybrid Model
  • Mamba: Linear-Time Sequence Modeling with Selective State Spaces
  • Efficiently Modeling Long Sequences with Structured State Spaces
  • How to use and interpret activation patching
  • A Comparative Analysis of Contextual Representation Flow in State-Space and Transformer Architectures
  • Repeat After Me: Transformers are Better than State Space Models at Copying
  • Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
  • SentencePiece: A simple and language independent subword tokenizer and detokenizer for Neural Text Processing
  • Mamba-3: Improved Sequence Modeling using State Space Principles
  • Jamba: Hybrid Transformer-Mamba Language Models
  • In-context Learning and Induction Heads
  • In-Context Retrieval-Augmented Language Models
  • Probing the Probing Paradigm: Does Probing Accuracy Entail Task Relevance? CoRR, abs/2005.00719, 2020 (opens arXiv in a new tab)
  • Linear Transformers Are Secretly Fast Weight Programmers
  • BERT Rediscovers the Classical NLP Pipeline
  • The unreasonable effectiveness of the forget gate
  • Attention is All you Need
  • Investigating Gender Bias in Language Models Using Causal Mediation Analysis
  • An Empirical Study of Mamba-based Language Models (opens arXiv in a new tab)
  • Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 Small
  • RNNs are not Transformers (Yet): The Key Bottleneck on In-Context Retrieval
  • Gated Delta Networks: Improving Mamba2 with Delta Rule
  • LongMamba: Enhancing Mamba's Long-Context Capabilities via Training-Free Receptive Field Enlargement
  • Context-Selective State Space Models: Feedback is All You Need
  • I am interested in the phone number I asked for
  • (followed by a whitespace) to the target entry within the phonebook. The profession-book dataset—used exclusively in section 4.2—uses a nearly identical template structure, but replaces phone numbers with professions sampled uniformly at random from a closed set of 20 categories (e.g
  • The weights are provided in a Megatron checkpoint format, which we remap to the official mamba_ssm library structure
  • The model is a 7.3B-parameter Mamba-2 model instruction-tuned for code generation
  • 10 individual digit tokens, and a trailing newline token. This consistent tokenization enables clear alignment between target and distractor entries, as well as distinct separation between name and digit tokens. Prepending the word
  • one for model inference and state extraction, and the other for training the probes
  • Correctness is determined by generating 20 new tokens (top_k = 1), extracting a 10-digit sequence via regular expression, and comparing the extracted sequence against the ground truth
  • Each sample is evaluated in both its flagged and unflagged variants to collect and align the corresponding internal activations
  • During model forward passes, we capture the hidden representations corresponding to the final digit token of each phone number entry in the phonebook
  • During model forward passes, we capture the gate vectors produced by the selection mechanism corresponding to the final digit token of each phone number entry in the phonebook