Mamba: Linear-Time Sequence Modeling with Selective State Spaces
Gu & Dao in Architectures
Linear-time sequence models that finally match Transformers on language
Mamba: Linear-Time Sequence Modeling with Selective State Spaces
Fast recurrent models could not choose what to remember
Linear-time and parallelizable, but their dynamics are fixed for every input. They cannot decide to ignore filler or focus on a key token.
Make the step size and input and output projections functions of the current token. The model can now reset, skip or keep state based on content.
Selection gives recurrence the content-awareness attention gets for free.
Input-dependent parameters, computed in fast memory

B, C and the step size Δ are projected from each input, so the state update is content-aware. The expanded state lives only in GPU SRAM, never in HBM.
A recurrence whose dynamics depend on the input
The step Δt is computed from xt: a large step resets the state to focus on the current token, a small one preserves context.
- Aˉt
- State transition, discretized with step Δt
- Bˉt
- How much of the current input enters the state
- Ct
- Readout of the state, also chosen per token
- Δt
- Learned step size: the selection gate
Three ideas make selective SSMs fast
- 1
Kernel fusion
Load parameters into SRAM, discretize and run the recurrence there, and write only outputs back to HBM.
- 2
Parallel scan
Input-dependence rules out convolutions, so a work-efficient parallel scan computes the recurrence in linear time.
- 3
Recompute in backward
Intermediate states are recomputed rather than stored, matching the memory of a FlashAttention Transformer.
One uniform block replaces attention and the MLP

The H3 block and the gated MLP merge into a single Mamba block, stacked uniformly. No attention layers and no separate MLP blocks.
Matches a Transformer twice its size
Average over LAMBADA, HellaSwag, PIQA, ARC-E, ARC-C and WinoGrande (%), Table 3.
Open questions after Mamba
Continuous signals trade off
Selection helps discrete data like text and DNA, but can hurt continuous signals such as audio waveforms.
Scale tested to 3B
Language results stop near 3B parameters; whether the edge holds at frontier scale was open.
Why it matters
- Input-dependent state space parameters let recurrent models select what to keep, as attention does.
- A hardware-aware scan makes selection fast, with linear scaling in sequence length.
- Mamba layers now appear in hybrid models alongside attention.
152 upvotes on Hugging Face 9 slides, 2 min
1 Dec 2023