C.W.K.
Stream
Lesson 03 of 05 · published

How SSMs Differ from Attention

~14 min · ssm-vs-attention, memory, compression

Level 0Observer
0 XP0/50 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

Two fundamentally different memory models

Attention and SSMs aren't "two algorithms for the same operation". They're two genuinely different ways to handle sequence memory. The clearest way to see it: attention is a database, SSMs are a stream summary.

An attention layer at position i pulls explicit per-token weights against every prior token's value. The full n×n attention matrix is the database — every cell is a direct connection between two tokens, and the model can route information from any past token to the current one if it wants. An SSM at position i has access only to the current input x_i and the current state h_i. The state h_i is whatever survived being squeezed through the recurrence; there is no path back to a specific token at position j<i.

The strength side

SSMs win on resource consumption. Constant memory at inference. Linear compute. No KV-cache to grow. Tractable on consumer hardware at sequence lengths where Transformers OOM. For workloads where most of the relevant information is captured in the state — streaming inference over audio, time-series forecasting, long-form text where the bulk content is what matters — this is fantastic.

The weakness side

SSMs lose on tasks that need precise retrieval of specific past tokens. Show an SSM a long passage and then ask "what was the third number in the second paragraph?" — pure SSMs systematically fail. The information was there, but the recurrence's job is summarization, not indexing. The 2025 NeurIPS paper "Achilles' Heel of Mamba" made this rigorous: pure SSMs have provable failure modes on associative recall that Transformers don't share, and these failure modes can't be patched with more data — they're structural.

This is the core trade. If you ever find yourself comparing an SSM to a Transformer on a single benchmark and asking which one is "better", you're asking the wrong question. The right question is: does my workload care about exact recall over the full window, or about steady summarization at low cost?

External links

Exercise

Run a small associative-recall test yourself. Generate synthetic data of the form "key1=val1 key2=val2 ... keyN=valN. What is val of key3?" with N up to 256. Train a small Transformer (≤10M params) and a small Mamba (similar size) on this task. The Transformer should approach 100% accuracy easily; the Mamba will plateau well below it as N grows. This is the recall gap, in your own hands.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.