On the Recall Scaling Laws in Mamba: A Theoretical and Mechanistic Study via Hashing

Yuval Koren, Itamar Zimerman, Assaf Ben-Kish, Raja Giryes, Lior Wolf · Submission to ICLR 2026 · Rejected

TL;DR

This paper reverse-engineers how Mamba models perform associative recall, revealing that they implicitly learn to function as similarity-preserving linear hash tables. By applying the Johnson-Lindenstrauss lemma, the authors derive "recall scaling laws" that precisely predict a model's memory capacity based on its state size, embedding dimension, and vocabulary size.

What Problem Does This Paper Address?

State Space Models (SSMs) like Mamba are designed to solve the "quadratic bottleneck" of Transformers by using a fixed-size recurrent state. While this makes them incredibly fast for long sequences, it introduces a new challenge: compression.

To remember a fact, the model must squeeze information into a finite-dimensional vector. Until now, we haven't had a clear understanding of the "circuitry" Mamba uses to do this, nor did we have a mathematical way to predict exactly how many facts a Mamba model of a certain size could remember before it started failing. The authors aim to bridge this gap between mechanistic interpretability (how it works) and theoretical scaling laws (how much it can hold).

Methods

The researchers employ a two-pronged approach:

  1. Mechanistic Interpretability: They "strip down" a Mamba model to its bare essentials—removing non-linearities, gating, and discretization—to find a minimal linear circuit that can still solve the Multi-Query Associative Recall (MQAR) task. They use "invariant operators" to prove that fully trained, complex Mamba models actually converge on this same internal algorithm.
  2. Theoretical Hashing Analysis: They identify a mathematical link between Mamba’s operations and similarity-preserving linear hashing. Specifically, they use the Johnson-Lindenstrauss (JL) lemma—a fundamental result in geometry about projecting high-dimensional data into lower dimensions with minimal distortion—to derive bounds on memory capacity.

Datasets

The study primarily uses Multi-Query Associative Recall (MQAR).

  • The Task: A model is given a sequence of key-value pairs (e.g., "Apple: 5, Banana: 2") followed by queries (e.g., "Apple?"). The model must retrieve the correct value.
  • Variations: The authors also introduce and test harder versions: MQAR with repeating keys (where the model must remember the last value assigned to a key) and MQAR with repeating queries.

Key Insights and Ideas

  • Mamba is a Distributed Hash Table: Instead of storing a fact in a single "slot," Mamba distributes the information across its entire state using linear projections that act as hash functions.
  • The Conv1D Layer is the "Writer": A surprising finding is that the 1D convolution layer in Mamba isn't just for local feature extraction; it acts as a "copy and shift" mechanism that aligns keys with their corresponding values so the SSM can "write" them into memory together.
  • The $DN$ Product Rule: The authors show that the total memory capacity is governed by the product of the embedding dimension ($D$) and the state dimension ($N$). Their derived scaling law, $DN = \Omega(N_f \log(V/\delta))$, shows that to remember more facts ($N_f$) or handle a larger vocabulary ($V$), you must scale $D$ or $N$ accordingly.
  • Depth is Additive: In multi-layer models, the "effective" state size is simply the sum of the state sizes across all layers ($N_{eff} = \Lambda N$). This explains why deeper models are significantly better at recall than single-layer models with the same total parameters.

Key Results

  • Predictive Accuracy: The theoretical scaling laws were found to be remarkably "tight." When plotting model accuracy against the predicted bounds, the transition from 0% to 100% accuracy happened almost exactly where the theory predicted.
  • Multi-Head Superiority: For Mamba-2, the authors found that only the Multi-Head Attention (MHA) pattern—where keys and queries are independent for each head—actually increases recall capacity. Other patterns like Multi-Query or Multi-Key do not provide the same scaling benefits.
  • Ablation Proof: Removing the Conv1D layer reduced MQAR accuracy to 0.00, confirming its critical role in the recall circuit.
  • Solving Repetition: While single-layer models fail at MQAR with repeating keys (they get confused between the old and new values), two-layer models can solve it perfectly by using the first layer to "read" the old value and the second layer to "subtract" it from the state.

Limitations and Future Work

  • Linear Simplification: The theoretical framework relies on a simplified linear version of Mamba. While experiments show this matches the full model well, the specific role of the gating branch (the "Selective" part of Selective SSMs) in recall remains theoretically unclear.
  • Synthetic vs. Natural Language: The study focuses on synthetic associative recall. While AR is highly correlated with language modeling performance, natural language involves more complex hierarchical structures that hashing alone might not fully explain.
  • Architecture Expansion: The authors suggest extending this "scaling law" approach to other modern architectures like xLSTM and RWKV to see if they follow similar hashing-based principles.

Summary updated

Abstract

Associative Recall (AR) is the cognitive ability to learn and retrieve links between items in memory. In NLP, AR is used as a benchmark for evaluating the in-context memory capacity of architectures such as Mamba, and has been found to strongly correlate with language modeling performance. This paper explores AR from the perspective of mechanistic interpretability, aiming to reverse-engineer the exact internal algorithm used by Mamba to perform recall. Our key insight is that Mamba performs recall by implicitly learning linear hash functions, and we identify the low-level circuit that enables this behavior. Building on these findings and inspired by theoretical tools in similarity-preserving hashing, such as the Johnson–Lindenstrauss (JL) lemma, we develop a theoretical framework for analyzing AR, which we term recall scaling laws. For example, given a model’s state, context length, and embedding dimensions, our theory predicts a lower bound on the largest vocabulary size that can be perfectly recalled in the AR task. Empirical results show that this bound is tight and predictive, offering insights into how AR capacity scales with vocabulary size, state size, embedding size, and model architecture.
BibTeX
@inproceedings{koren2026recall,
  author = {Yuval Koren and Itamar Zimerman and Assaf Ben-Kish and Raja Giryes and Lior Wolf},
  title = {{On the Recall Scaling Laws in Mamba: A Theoretical and Mechanistic Study via Hashing}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=4ZDfHcccsn},
}
Figure