Mamba: Selective State Space Model
Autoregressive2023 · Carnegie Mellon & Together AI (Gu & Dao)Linear-time sequence modeling with input-selective recurrent state spaces
Intuition & Key Idea
ELI5 GuideWhy this model was invented and how it transforms generation
"Processes millions of words in linear time and fixed memory by continuously filtering incoming data like an audio equalizer instead of saving every past word."
A person listening to a lecture who updates a concise set of running mental notes, rather than recording every word and re-reading the entire transcript every sentence.
Compute scales linearly with document length instead of quadratic O(N²).
State size never grows; no exploding KV cache on 100k+ tokens.
Executes associative prefix scan directly in fast GPU SRAM.
Ingests massive books and codebases without memory crashes.
1. Input-Dependent Parameter Discretization (Δ, B, C)
Feed single new token x_t. Compute timescale Δ_t, input matrix B_t, and output matrix C_t via linear projection.
Calculated instantly for single input vector without loading past sequence context.
GPU Memory Hierarchy & HBM Traffic for this Step
HBM ↔ SRAM on-chipParameters kept in on-chip registers
Active Tensor Dimensions & Memory Shapes
Solves the fundamental memory and compute scaling limits of Transformers: scales linearly O(T) with context length rather than quadratically O(T²), maintaining throughput on 100k+ token sequences where standard Transformers run out of VRAM.
Training Objective:Next-Token Cross-Entropy Loss via Parallel Associative Scan: L = -∑ log P_θ(x_t | x_<t)
Inference Bottleneck:O(1) memory footprint and O(1) compute per step (Zero KV Cache)
Foundational & Breakthrough Papers for Mamba: Selective State Space Model
Mamba: Linear-Time Sequence Modeling with Selective State Spaces
Albert Gu (CMU), Tri Dao (Together AI)
Efficiently Modeling Long Sequences with Structured State Spaces (S4)
Albert Gu, Karan Goel, Christopher Ré (Stanford)