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:
- 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.
- 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