← Back to learning

Mamba × TTT · IRSTD

Write memory as a recurrence, then let the input decide what matters.

Mamba is about more than linear complexity. What gets written into the state, what is retained, and how is it read out?

About 20 min

Course chapters
Progress and notes stay in this browser.

Paper mechanism: from a continuous system to a discrete sequence

dh(t)/dt = A h(t) + B x(t)  y(t) = C h(t) + D x(t)
A̅ = exp(ΔA)  B̅ = [∫₀Δ exp(sA) ds] B
hₜ = A̅ₜ hₜ₋₁ + B̅ₜ xₜ  yₜ = Cₜ hₜ + D xₜ

h is compressed memory; A controls the dynamics, B writes, C reads, D is the input feedthrough term, and Δ sets the scale of one evolution step. Zero-order-hold discretization assumes a constant input within each sampling interval; when A is invertible, B̅ = A⁻¹(exp(ΔA) − I)B.

Mamba makes Δ, B, and C input-dependent, replacing fixed filtering with content-dependent selection. Not every parameter is generated token by token: A in the basic formulation remains a shared learned parameter. The ΔB input term commonly used in implementations is a simplification, not the exact general zero-order-hold solution.

Original sources: Mamba · COLM 2024 / arXiv 2023 ↗

Teaching demo: how long can a target impulse persist?

A = −1,B = C = 1,D = 0:
a = exp(−Δ),hₜ = a hₜ₋₁ + (1−a)xₜ

Increasing a retains the old state longer but writes the current impulse more weakly; decreasing a strengthens the new input while forgetting faster. An impulse may be a true target or defective-pixel noise, so longer memory is not automatically better or worse.

How can a recurrence still be parallelized?

(a₂,b₂) ∘ (a₁,b₁) = (a₂a₁, a₂b₁+b₂)

Each step is an affine transformation hₜ=aₜhₜ₋₁+bₜ. Composition is associative, enabling a parallel prefix scan. Input-dependent parameters cannot directly become a fixed convolution, making hardware-aware implementation crucial for efficiency.

With channel count and state dimension fixed, computation grows linearly with sequence length L. This does not mean independence from network width or guarantee that every CPU/GPU implementation is fast.

Mamba-2: why read about SSD?

Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality (ICML 2024) introduces SSD by using structured matrices to connect a class of SSMs with attention computation. It helps you see recurrence and blockwise matrix operations as different organizations of the same computation.

The title does not imply that arbitrary softmax Transformers and arbitrary SSMs are fully equivalent. Speedups in a language model's core layer do not directly translate into end-to-end IRSTD speedups: backpropagation, teacher forward passes, and the decoder can all become bottlenecks.

Original sources: Mamba-2 / SSD · ICML 2024 ↗

Pause and test your intuition

What happens when Δ increases in the scalar demo?

Connect this unit to your IRSTD work

Progress and notes stay in this browser.