Sitemap

How AI Finally Killed Quadratic Attention: NSA, Mamba-3, and the Architectures Making Million-Token Context 11× Cheaper in 2026

21 min readJun 8, 2026

--

Press enter or click to view image in full size
The 2026 thesis in one figure. Left: despite being sparse, DeepSeek’s NSA beats full attention on average across general, long-context, and reasoning benchmarks. Right: at 64k tokens it is several times faster in every phase, decode, forward, and backward. Source: Yuan et al., NSA (ACL 2025 Best Paper).
Press enter or click to view image in full size
The trick that underpins the whole family: a linear-attention/SSM layer can be computed two equivalent ways, a parallel “chunkwise” form for fast training (intra-chunk, Qintra) that passes a single fixed-size state S between chunks (inter-chunk, Qinter) for constant-memory recurrent inference. That duality is what makes these models both trainable at scale and cheap to decode. Source: Efficient Attention Mechanisms for LLMs, survey (2025).
Press enter or click to view image in full size
MLA (left) compresses each token’s keys and values into one small latent vector, the only thing cached, then reconstructs per-head K/V on the fly. A small “decoupled RoPE” component carries position separately. Source: DeepSeek-V3 technical report.
Press enter or click to view image in full size
NSA replaces one dense attention with three parallel branches: compression (a coarse, summarized view of the whole context), selection (full-resolution attention on the few blocks that matter most), and a sliding window (recent local tokens). A learned gate blends them per token. Source: Yuan et al., 2025.
Press enter or click to view image in full size
NSA’s kernel is group-centric: it loads all query heads sharing a KV group together (outer loop), fetches only the selected sparse KV blocks (inner loop), and computes on fast SRAM (green) instead of HBM (blue). Hardware-alignment is what turns “fewer tokens” into actual wall-clock speedup. Source: Yuan et al., 2025.
Press enter or click to view image in full size
NSA vs a FlashAttention-2 kernel across context lengths: the speedup widens as sequences grow, because the selected token budget stays roughly fixed while full attention keeps paying O(L²). Source: Yuan et al., 2025.
Press enter or click to view image in full size
MoBA routes each query to its top-k most relevant blocks of the KV cache, like MoE routing to expert FFNs, while causally masking the future. It’s the long-context attention backend behind Moonshot’s Kimi models. Source: Lu et al., MoBA, 2025.
Press enter or click to view image in full size
DeepSeek-V3.2-Exp (DSA) vs V3.1-Terminus (full attention): benchmark parity. MMLU-Pro held at 85.0; AIME 2025 actually rose 88.4 → 89.3. The efficiency was effectively free. Source: DeepSeek official announcement.
Press enter or click to view image in full size
The DSA dividend: DeepSeek’s own price comparison, more than 50% off across input and output tokens, effective the day V3.2-Exp shipped. Source: DeepSeek API docs.
Press enter or click to view image in full size
MiniMax-01’s needle-in-a-haystack retrieval stays near-perfect out to a 4-million-token context, trained at 1M and extrapolated to 4M, roughly 20–32× the window of GPT-4o or Claude 3.5 Sonnet at the time. Source: MiniMax-Text-01 model card.
Press enter or click to view image in full size
Gated DeltaNet fuses Mamba-2-style gating (fast forgetting) with the delta rule (precise, targeted updates), then offers hybrid variants (H1, H2) that add a sprinkle of sliding-window attention for recall. Source: NVIDIA Gated DeltaNet.
Press enter or click to view image in full size
Mamba’s selective SSM: input-dependent parameters let the model decide what to keep, and a hardware-aware scan keeps the state in fast SRAM. Linear-time training, constant-memory decode, no KV cache. Source: Gu & Dao, Mamba.
Press enter or click to view image in full size
The headline result: Mamba-3 matches Mamba-2’s perplexity at half the state size, so the same quality at half the decode latency. The MIMO variant pushes the Pareto frontier further still. Source: Mamba-3 (ICLR 2026).
Press enter or click to view image in full size
NVIDIA’s Nemotron-H hybrids (mostly Mamba-2, ~1 attention layer per 11–12) sit on a better accuracy-vs-throughput frontier than pure transformers: the 47B is 2.9× faster than Qwen-2.5–72B at long context. Source: NVIDIA Nemotron-H.
Press enter or click to view image in full size
DeepSeek-V4-Pro’s official performance chart. The real story isn’t a magic memory, it’s a disciplined hybrid attention design delivering frontier scores at a fraction of V3.2’s inference cost. Source: DeepSeek-V4-Pro model card.
Even models built explicitly for long context fade as the window grows: RULER accuracy for the LargeWorldModel family (trained from 128K up to 1M) slides downward with sequence length, and the shorter-trained variants drop off first, the visible gap between a model’s advertised window and its usable one. Source: Hsieh et al., RULER.
Press enter or click to view image in full size
The canonical needle-in-a-haystack heatmap (Gemini 1.5), here across text, audio, and video out to ~10M tokens. Green is a hit, and it looks like a solved problem, which is exactly why benchmarks like RULER, which test multi-hop and aggregation, matter: real comprehension lags simple retrieval badly. Source: Gemini 1.5 technical report.

--

--

Abdullah Grewal
Abdullah Grewal

Written by Abdullah Grewal

Caffeine-fueled tech maestro, equally at home, building intelligent AI, machine learning, NLP models, and crafting seamless web applications.