Attention has two bottlenecks: the KV cache that decoding rereads at every step, and the N×N score matrix of training and prefill. MQA, GQA and MLA shrink the KV cache; FlashAttention cuts memory traffic with tiling and online softmax, and its output is identical to standard attention.
Linear attention, state space models (Mamba) and the gated delta rule compress history into a fixed-size state: memory stays flat as context grows, but capacity is limited by the state size. Hybrids keep a few attention layers for exact recall; Jamba's KV cache is 1/8 of Mixtral's.
DeepSeek-V4.1-Flash cuts the global KV cache to 890 bytes per token, about 1/4 of V4-Flash and 1/437 of DeepSeek-V1, with a causal encoder-decoder, cross-layer sharing in CSA2 and an FP4 main KV. This post explains the paper and rebuilds its numbers from the public configs.
MSA (MiniMax, 2026) adds an index branch to GQA that picks top-k KV blocks per group and attends exactly over only those. On a 109B MoE it matches full attention while cutting per-token attention compute 28.4× at 1M context. We verify the FLOPs figure and the coverage limits of block selection.
DeepSeek-V3.2 adds DeepSeek Sparse Attention to V3.1-Terminus by continued training: a lightning indexer picks 2048 tokens per query, so core attention drops from O(L²) to O(Lk). Then scaled-up GRPO and 1,800+ synthetic environments. I recompute the numbers and rebuild DSA in miniature.
NSA combines compressed global tokens, selected important blocks and local sliding windows. Its trainable, hardware-aligned design targets long-context speed without losing global information.
MiniMax-01 combines seven Lightning Attention layers with one softmax layer per eight, using a 456B-parameter MoE with 45.9B active parameters and reporting inference contexts up to four million tokens.
Differential Transformer computes two softmax attention maps and subtracts them to cancel shared noise. The paper reports improvements in language modeling, long-context retrieval and hallucination metrics.
FlashAttention-3 uses warp specialization to overlap GEMMs with softmax on Hopper and adds block-quantized FP8 for higher throughput, while retaining an exact FP16 path.
DeepSeek-V2 (DeepSeek-AI, 2024) is a 236B-parameter MoE model that activates 21B per token: Multi-head Latent Attention (MLA) shrinks the inference cache and DeepSeekMoE lowers training cost. This post rechecks 93.3%, 236B and 21B, and verifies MLA's absorption and decoupled RoPE numerically.
Mamba makes a state space model's Δ, B and C depend on the current token (selection) and runs it with a hardware-aware scan: linear cost in length, fixed-size state at inference. We recompute its parameters and Table 3, then compare LTI and selective SSMs on selective copying.
StreamingLLM (ICLR 2024) finds that language models dump much of their attention on the first few tokens, the attention sinks; evict them from a sliding-window KV cache and perplexity explodes. Keeping 4 initial tokens fixes it with no fine-tuning, but it does not extend the context.
FlashAttention-2 preserves exact attention while reducing non-matrix operations, increasing sequence parallelism and improving warp-level work partitioning for higher GPU utilization.
GQA lets groups of query heads share one key/value head, between multi-head (MHA) and multi-query attention (MQA); MHA checkpoints convert by mean-pooling heads plus about 5% extra pretraining. On T5-XXL it nears MHA quality at close to MQA speed. We check Table 1 and compute Llama 3's KV cache.
FlashAttention computes exact attention block by block in the GPU's on-chip SRAM, so the N×N score matrix never goes to GPU memory. HBM accesses fall from Θ(Nd+N²) to Θ(N²d²/M); BERT trains about 15% faster, GPT-2 3.0 to 3.5 times faster than HuggingFace. A breakdown of the paper.