Back to Deep Learning Mind Map
中文·English
🧠 Deep LearningID: ssm-mamba

SSM & Mamba

SSM 与 Mamba
🎯Core Definition
State-space models (SSMs, e.g. S4/Mamba) frame sequence modeling as a linear time-invariant system: continuous form h˙(t)=Ah(t)+Bx(t)\dot{h}(t) = Ah(t) + Bx(t), y(t)=Ch(t)y(t) = Ch(t); ZOH (zero-order hold) discretization gives Aˉ=eAΔ\bar{A} = e^{A\Delta}, Bˉ=(eAΔI)A1B\bar{B} = (e^{A\Delta} - I)A^{-1}B, so inference is the linear recurrence ht=Aˉht1+Bˉxth_t = \bar{A}h_{t-1} + \bar{B}x_t, yt=Chty_t = Ch_t — an O(1)O(1) state update per step with no KV cache. When time-invariant (Aˉ,Bˉ,C\bar{A}, \bar{B}, C independent of the input) it unrolls into a global convolution y=Kˉxy = \bar{K} * x with Kˉ=(CBˉ,CAˉBˉ,)\bar{K} = (C\bar{B}, C\bar{A}\bar{B}, \ldots), enabling fully parallel training. The key of Mamba is the selective mechanism: Δt,Bt,Ct\Delta_t, B_t, C_t depend on the input xtx_t (e.g. Δt=softplus(WΔxt)\Delta_t = \mathrm{softplus}(W_\Delta x_t)), acting like gating to decide per-token whether to remember or ignore — the cost is losing the convolution form, replaced by parallel scanning (associative scan) in training. Complexity: self-attention is O(L2)O(L^2) in time and memory, Mamba is O(L)O(L) in sequence length, giving a clear edge on long sequences.
💡Use Cases
long-context modeling (50k+ tokens) and linear-time inference on edge devices; staple interview comparisons include Mamba vs Transformer (complexity, parallelism, long-range dependencies), Mamba vs LSTM (selectivity vs gating), and the SSM discretization derivation.
Key Problems Solved
Transformer attention grows quadratically (O(L2)O(L^2)), making long-context training/inference expensive; RNNs (LSTM) are O(L)O(L) but sequential and cannot be trained in parallel. Mamba keeps O(L)O(L) complexity via a linear recurrence, restores training parallelism via the parallel scan, and uses the selective mechanism to overcome the limited expressivity of fixed-parameter recurrences — reaching near-Transformer quality while greatly improving inference throughput and long-sequence memory.
🎯5 High-Frequency Exam Points
1
Write the discretized SSM recurrence ht=Aˉht1+Bˉxth_t = \bar{A}h_{t-1} + \bar{B}x_t and derive the continuous-to-discrete step (Aˉ=eAΔ\bar{A} = e^{A\Delta}, ZOH); what is the role of Δ\Delta?
2
Training parallelism: why is a time-invariant SSM equivalent to a global convolution y=Kˉxy = \bar{K} * x? After adding selectivity, how does the parallel scan (associative scan) restore parallel training?
3
What is the selective mechanism: why must Δt,Bt,Ct\Delta_t, B_t, C_t depend on the input xtx_t? How does it compare with LSTM gating (content-adaptive vs fixed parameters)?
4
Complexity comparison: self-attention is O(L2)O(L^2) in time and memory vs Mamba's O(L)O(L); what does this mean concretely for L=100kL = 100k long context?
5
Why are hybrid Transformer + Mamba architectures popular (Mamba blocks every few layers)? What are the potential weaknesses of pure Mamba?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "SSM & Mamba"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardGRUNext CardSGD & Momentum

🔗 More Deep Learning Knowledge Cards

Activation FunctionsAdam & AdamWAutograd Compute GraphBatch Normalization