Understand large language models,from first principles to the frontier
Follow a learning path from Transformers to training, inference, and agents. Check the math in runnable Python labs and trace each method back to its sources in the paper explainers.
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.
Attention Residuals (AttnRes) is Kimi's March 2026 fix for residual connections: it swaps the fixed weight-1 sum over earlier layers for softmax attention over their outputs. This post reviews the paper, recomputes its numbers and tests the idea on a small model.
GDPO is NVIDIA's January 2026 fix for multi-reward RL. GRPO sums the rewards before normalizing, which can collapse different reward combinations into one advantage; GDPO normalizes each reward first. This post re-enumerates the paper's counts and flags claims that do not check out.
mHC (Manifold-Constrained Hyper-Connections) is DeepSeek's fix for hyper-connections: Sinkhorn-Knopp turns the residual mixing matrix into a doubly stochastic one, keeping multi-layer gain bounded, for a reported 6.7% extra training time. This post reviews it and checks the math in code.
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.