What Mamba-2 is
Mamba-2 (Dao and Gu, 2024) simplifies Mamba's state update until its scan becomes exactly a masked, attention-like matrix product. The paper calls the correspondence state space duality (SSD): the same layer can run as a recurrence, carrying a state token by token, or as a quadratic matrix product over the tokens like attention, and its algorithm mixes the two. The abstract reports the new layer 2–8 times faster than Mamba's selective scan while staying competitive with Transformers in language modelling.
The page records Mamba-2 130M, every third of its 24 layers, on the Mamba tab's three prompts. Each layer has 24 heads of 64 channels. The recorded model continues the repeated phrase with “ fox” and the two-names prompt with “ Mary”.
One decay per head
Mamba gives each channel 16 decay rates. Mamba-2 gives each head one scalar , shared by its 64 channels and all 128 entries of its state. A head's state is then a 64 × 128 matrix, decayed as a whole and updated by an outer product:
is the head's 64 channels, and are 128-dimensional, and is one step size per token and head. The A box lists every head's rate, and the Δ box this head's step sizes with the share of the state that survives each step: a large writes token strongly and forgets more of what came before.
The matrix form
Unrolled over the sequence, the update is one matrix per head:
This is causal linear attention with as queries, as keys and as values, multiplied elementwise by a decay mask . Because the decay is a scalar, it factors out of the sum over state entries, which Mamba's per-entry decay does not. The card's three views show the factors: C·Bᵀ is the same for every head, since all heads share one and ; Decay L is the head's mask, between 0 and 1 and falling with distance at a pace set by each ; and M = L ∘ C·Bᵀ·Δ is their product, the weight that multiplies each 64-dimensional .
With this is the linear attention of Katharopoulos et al. (2020); with a fixed it is RetNet's retention (the RetNet tab). Mamba-2's mask depends on the input through : a learned forget gate.
Chunks
The SSD algorithm splits the sequence into chunks, 256 tokens in this model. Inside a chunk it computes as dense matrix products, the operation GPUs run fastest; between chunks it passes only each head's 64 × 128 state, as the recurrence does. The cost stays linear in length, with most of the work in matrix multiplications.
These prompts fit in one chunk, so the recorder also ran the scan with chunks of 4 tokens to exercise the passing of states. The matrix drawn on the card agrees with the normal run to and with the 4-token chunks to .
Where it came from
Mamba (2023, the Mamba tab) introduced the selective scan; Mamba-2 traded per-entry decay for a scalar to gain the matrix form and a larger state, 128 entries here against Mamba's 16. Linear-attention work reached the same family from the other side: gated linear attention (Yang et al., 2023) learns a data-dependent decay on a linear-attention state, and Gated DeltaNet (Yang et al., 2024) combines a Mamba-2-style gate with a delta-rule update. Qwen3-Next uses Gated DeltaNet in three of every four layers (the Gated tab), and the Linear tab shows RWKV-7.
Papers
- Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality Mamba-2 and state space duality: scalar decay per head, the matrix form M = L ∘ CBᵀ, and the chunked algorithm.
- Mamba: Linear-Time Sequence Modeling with Selective State Spaces The selective scan Mamba-2 simplifies (the Mamba tab).
- Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention Linear attention and its recurrent form, the L = 1 case of the SSD matrix.
- Retentive Network: A Successor to Transformer for Large Language Models Retention, linear attention with a fixed decay per head: SSD with a constant mask rate (the RetNet tab).
- Gated Linear Attention Transformers with Hardware-Efficient Training Data-dependent decay on a linear-attention state, a parallel route to the same family.
- Gated Delta Networks: Improving Mamba2 with Delta Rule Mamba-2's gate combined with a delta-rule update, the linear layer of Qwen3-Next (the Gated tab).