Summary (Overview)
- This paper reverse-engineers the internal algorithm used by Mamba models to perform Associative Recall (AR) and Multi-Query Associative Recall (MQAR), identifying that Mamba implicitly learns linear hash functions via a similarity-preserving mechanism.
- The authors develop a theoretical framework called "Recall Scaling Laws" that predicts the embedding dimension and state dimension required for perfect recall given vocabulary size and number of facts .
- The key theoretical result shows that high-probability recall requires model dimensions satisfying — the state memory scales linearly in the number of facts and logarithmically in vocabulary size.
- The framework extends to multi-layer models (where depth multiplies effective state size) and multi-head SSM patterns (where MHA improves recall but MQA/MKA degrade it).
- Extensive empirical validation confirms the theoretical predictions across linear and full nonlinear Mamba models, with accuracy collapsing onto predicted one-dimensional scaling curves.
Introduction and Theoretical Foundation
Background
Transformers suffer from linear memory growth during decoding due to key-value caching. Recent architectures like Mamba [1], RWKV [2], and other linear RNNs use a fixed-size recurrent state, enabling constant memory complexity. However, this fixed-size state imposes inherent information compression limitations.
The paper addresses a core question: How does the fixed-size state of Mamba limit its recall capabilities, and what is the exact scaling relationship?
Theoretical Foundations
The analysis leverages two key theoretical tools:
-
Johnson–Lindenstrauss (JL) Lemma: States that points in a high-dimensional space can be embedded into a lower-dimensional space while approximately preserving pairwise distances. Formally, for a set of points, an embedding into with preserves distances up to factor with high probability.
-
Mechanistic Interpretability: The approach of reverse-engineering neural networks by identifying specific "circuits" — compact computational units within the network that implement identifiable algorithms.
The MQAR Task
The Multi-Query Associative Recall task partitions vocabulary into key vocabulary and value vocabulary , each of size . A prompt contains:
- Context: non-repeating key-value pairs
- Query section: query tokens (duplicates of context keys) plus padding
The model must retrieve the value corresponding to each query key .
Mamba Architecture
The Mamba block operates as (simplified):
with the SSM update:
Methodology
Minimal Model and Simplified SSM
The authors construct a simplified single-layer Mamba with gating, discretization, nonlinearities, biases, and normalization removed. Without discretization and with , the SSM becomes:
The Ladder of Theoretical Guarantees
The paper establishes four levels of recall guarantees:
| Level | Guarantee | Dimension Requirement | Type |
|---|---|---|---|
| 1 | Exact recall (worst-case) | Non-compressive (Thm. 3.1) | |
| 2 | Exact recall (worst-case) | Hash-based (Lem. 4.1) | |
| 3 | High-probability recall | Mean-case (Thm. 4.2) | |
| 4 | Lower bound (necessity) | Information-theoretic (Lem. 4.5) |
Mechanistic Interpretability Validation
The authors define invariant operators that are robust to orthogonal transformations of weights:
The model output becomes:
where are input token pairs.
Hidden State as Hash Table
The ideal non-compressive circuit stores facts as an outer product:
This is a table where entries are 1 where facts exist. The compressive version uses:
with compressed tokens , , .
Empirical Validation / Results
Key Theoretical Results
Theorem 3.1 (Perfect non-compressive recall): A single-layer simplified Mamba with , , perfectly solves MQAR (recall probability = 1).
Theorem 3.2 (Efficient compressive recall): With , , , a single-layer Mamba solves the task with high probability.
Theorem 4.2 (Trained model recall scaling laws):
Remark 4.3 (Unified form):
where for AR and for MQAR.
Theorem 4.6 (Multi-layer):
Theorem 4.7 (Multi-head): Given fixed :
Empirical Findings
Figure 1 results — Accuracy grids show:
- Theoretical predictions (column b) closely align with trained linear models (column c)
- Full nonlinear models (column d) match linear models, confirming simplification preserves core recall behavior
- All columns exhibit the predicted inverse – tradeoff
Figure 4 results — Scaling curves:
- Accuracy collapses onto one-dimensional curves of the form
- The scaling variable is where
- Full nonlinear Mamba fits with , indicating improved performance under the same scaling law
Multi-layer results (Figure 5):
- Recall accuracy depends only on effective state size
- Accuracy collapses onto a single curve independent of depth
Multi-head results (Figure 6):
- MHA improves recall by increasing effective state size
- MQA and MKA are weaker due to shared-value compression across heads
- MVA matches the single-head baseline
Mechanistic Validation
- Hidden state inversion (Figure 3): Projecting the hidden state back to vocabulary space reveals , confirming a compression-decompression scheme
- Conv1D as copy-shift: and , verified empirically
- Ablation: Removing Conv1D causes complete failure of recall
Theoretical and Practical Implications
Theoretical Implications
-
Optimality of scaling: The upper bound is matched by an information-theoretic lower bound , establishing that Mamba's recall capacity is essentially optimal for fixed-state recurrent models.
-
Hash-table interpretation: The paper provides strong evidence that Mamba learns similarity-preserving linear hash functions, connecting neural network behavior to classical data structures.
-
Multi-head design guidance: The result that MQA/MKA degrade recall while MHA improves it provides theoretical justification for architectural choices in Mamba-2.
Practical Implications
- Model sizing: Given a target vocabulary size and number of facts, practitioners can predict required dimensions for reliable recall
- Architecture selection: MVA is validated as the stronger multi-head design when controlling for parameter count, consistent with real-world perplexity results
- Diagnostic tool: The scaling laws provide a principled way to evaluate whether a model is memory-limited or has other bottlenecks
Connection to Language Modeling
The trends in Thm. 4.7 are consistent with perplexity ablations for full Mamba-2 (Dao & Gu, 2024): MQA and MKA both yield worse perplexity than MVA, matching the finding that shared-value compression degrades recall. This suggests the analysis captures tradeoffs observed in real-world NLP tasks.
Conclusion
Main Takeaways
- Mamba performs associative recall by implicitly learning linear hash functions, verified through mechanistic interpretability
- The required state memory scales as — linear in facts, logarithmic in vocabulary
- The theoretical framework accurately predicts recall probability across model configurations
- Multi-layer models benefit through effective state size ; multi-head patterns have distinct recall characteristics
Future Directions
- Extend analysis to other architectures: xLSTM, RWKV, DeltaNet
- Investigate how architectural modifications impact recall capabilities
- Characterize the theoretical role of the gating branch in recall (currently unclear)
- Detailed investigation of why full models achieve (improved performance under same scaling law)
Limitations
- Analysis relies on simplified models; the full contribution of each Mamba component (e.g., gating) is not fully characterized
- The heuristic determination of for nonlinear models requires further theoretical justification
Related papers
- Do Tool Calls Execute as Intended? Measuring and Repairing Intent-Execution Correspondence in LLM Agents
Tool calls are silently altered by execution-path hops in 12% of production shell invocations, and the IntAct repair protocol recovers 79.2% of resulting failures.
- The Winner's Curse in LLM Self-Improvement Loops: Selection Noise, Lock-in, and Acceptance Rules
Self-improving LLM loops on small reused evaluation sets inflate reported gains by 13–20 points, with most proposals after the first rewrite being harmful.
- Fault-tolerant foundation models
Fault-hardened language models become more error-resilient as they scale, unlike fault-blind models, suggesting they learn good error-correcting codes that may enable energy-efficient inference on faulty hardware.