How Frontier AI Models Are Trained, End to End
A one-hour, 18-chapter explainer in four parts, following one frontier training run from the raw web to a reasoning assistant: the data (Common Crawl, the FineWeb filters, MinHash deduplication, quality classifiers, mixtures, tokens), the recipe (scaling laws, mixture-of-experts architectures, AdamW and Muon, learning-rate schedules, FP8 and FP4 numbers, loss spikes), scaling out (memory, data / tensor / pipeline / expert parallelism, failures and checkpoints) and post-training (supervised fine-tuning, preferences and DPO, reinforcement learning with verifiable rewards, agentic RL, evaluation). It describes the field as of October 2026.
Every chart is a real run, in miniature, on the 4-core CPU that rendered the
video: the FineWeb recipe run on 10,498 pages of Common Crawl's September 2026
crawl, MinHash deduplication of the 8,457 pages that survive the same filters
out of 169,783 more, FineWeb-Edu's classifier, a 25-run IsoFLOP
scaling-law sweep, AdamW vs Muon, cosine vs warmup-stable-decay, a learning-rate
stability sweep with and without QK-norm, three mixture-of-experts load-balancing
runs, the singular values of a real gradient going through Newton–Schulz, FP8 /
FP4 quantization of GPT-2's real activations, a real chat template, and a
GRPO run with a verifiable reward. Frontier numbers come from the labs' own
reports and are cited below. Schematics are labeled schematic, illustrative
examples illustrative.
Every chapter also works its key formula through with numbers, on screen,
one line at a time: formula → the values substituted → the result. Most use
real numbers (Llama 3.1 405B's 6ND, the Chinchilla optimum derived by calculus,
Adam's step on two gradients, five Newton–Schulz iterations, one FP8 number
decoded bit by bit, an NVFP4 block of GPT-2's activations, the QK-norm bound,
ZeRO's memory formulas, the Young–Daly checkpoint interval, the per-token SFT
loss under two real models, GRPO's advantages for a real group of eight
answers); the rest are labeled illustrative. See
Worked examples for the full list.
Contents
- 1One of the largest computations ever run2 min
- 2Part 1: The raw web2 min
- 3Filtering: the FineWeb recipe2 min
- 4Deduplication with MinHash2 min
- 5Quality, mixtures, and tokens3 min
- 6Part 2: How big? Scaling laws4 min
- 7Architecture and mixture of experts5 min
- 8The optimizer: AdamW and Muon5 min
- 9Learning-rate schedules3 min
- 10Fewer bits: FP8 and FP45 min
- 11Loss spikes and stability4 min
- 12Part 3: Memory and data parallelism3 min
- 13Tensor, pipeline, expert parallelism4 min
- 14Keeping the run alive3 min
- 15Part 4: Supervised fine-tuning3 min
- 16Learning from preferences4 min
- 17Reinforcement learning and reasoning7 min
- 18The whole pipeline2 min
Also on this page: Lecture · Notes and sources · Build the film.
Lecture
The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film.
1One of the largest computations ever run2 min
You ask a question, and a moment later the answer starts streaming back, one token at a time. The model writing it is the result of one of the largest computations people have ever run.
Here is every notable AI model with a published estimate of its training compute, placed by release date and by how many arithmetic operations it took to train, on a logarithmic scale. GPT-2, in 2019: about ten to the twenty-one operations. GPT-3, a year later: more than a hundred times that. GPT-4: about seventy times more again.
The largest runs of 2025 and 2026 are estimated at ten to the twenty-six operations and beyond. At the frontier, training compute has been growing almost five times, every single year.
And so that none of this is a cartoon: every experiment in this video was actually run, in miniature, on the four-core computer that rendered it. All of our training runs together took less than ten to the fifteen operations, roughly a hundred billion times less than a frontier run. The scale is different. The ideas are the same.
This video follows one of those training runs from end to end. It starts with a crawl of the public web, which is filtered, deduplicated and mixed into a dataset of tens of trillions of tokens. Pretraining teaches a network to predict the next token of that text, with the work spread across tens of thousands of GPUs for months. Post-training then turns that raw text predictor into something that follows instructions and reasons, and the result is the assistant.
We'll go in four parts: the data, the training recipe, scaling it out across a cluster, and post-training. Along the way, we'll look at what the labs have actually published about how they do it, as of October 2026.
What it establishes: An answer streams back token by token (schematic). How much compute notable models used to train, and how fast the frontier grows. Every experiment in the video is a real run, about 10¹¹× smaller. The pipeline map: web → clean data → pretraining → GPU cluster → post-training → assistant. Four-part roadmap.; Real data on screen: Epoch AI's compute estimates for notable models since 2012: GPT-2 ≈ 10²¹, GPT-3 > 100× that, GPT-4 ≈ 70× more; Llama 3.1 405B, Grok 4 and GPT-6 Astra circled. A least-squares frontier trend of ×4.8 per year (45 frontier models since 2018). All of this video's pretraining runs together: 6.6 × 10¹⁴ FLOPs, ~10¹¹× below 10²⁶.
2Part 1: The raw web2 min
Almost every large language model starts from the same place: Common Crawl, a non-profit that crawls the web every month or two and gives the result away. Its September 2026 crawl alone holds 2.17 billion web pages, a hundred and six terabytes compressed, split into a hundred thousand files. Each square here is one of them. For this video, we downloaded eight of them, plus the first four hundred megabytes of the raw HTML behind the first.
Here's one page from the very first file: a blog post with a recipe for savory custard.
This is what the crawler actually stored: more than two thousand lines of HTML. Scripts, style sheets, menus, links, metadata. And the recipe itself? All of it sits on a single line: number 436. Ninety-eight kilobytes of HTML, for three kilobytes of text: about three percent.
Across the first ten thousand pages of that file, it's the same story: 1.65 gigabytes of HTML become thirty-seven megabytes of text. Pulling out the main text is a step of its own. Common Crawl ships an extracted version, but the FineWeb team found that re-extracting from the raw HTML, with a library called Trafilatura, leaves out more menus and boilerplate, and trains better models. Here's our recipe page both ways. Common Crawl's version keeps the comments, the cookbook ads, and a hundred-line blog archive. Over all the pages that survive our filters, it's twice as long. And the web is multilingual: in this sample, only four pages in ten are in English. Frontier models train on many languages; here, like the original FineWeb, we'll keep English.
What it establishes: Part 1. Almost everyone starts from Common Crawl (a crawler following links; schematic); one crawl is 100,000 files. A crawled page is mostly markup. Extracting the main text is its own step, and Trafilatura (as in FineWeb) keeps less boilerplate than Common Crawl's own WET text. The web is multilingual; we keep English.; Real data on screen: CC-MAIN-2026-39: 2.17B pages, 106 TiB, 100,000 files (one square each); the 8 WET files and 400 MB of WARC we downloaded are circled. A real recipe-blog page: 2,296 lines of HTML with the whole post on line 436; 97.8 KB of HTML → 3.3 KB of text. The 10,498 pages of the WARC: 1.65 GB of HTML → 37 MB of text, drawn as areas. The same recipe page as Common Crawl's WET text (8.7 KB, 195 lines: menu, 4 comments, cookbook ads, a 103-line blog archive) vs Trafilatura (3.3 KB, the recipe); over all 1,363 surviving pages WET text is 2.0× as long. fastText language shares (English 42%).
3Filtering: the FineWeb recipe2 min
Next, filtering. We took the exact recipe behind FineWeb, Hugging Face's open web dataset of fifteen trillion tokens, and ran their own code on those ten thousand pages. Here's how many pages survive each step.
First, a blocklist of four and a half million domains removes adult sites, malware and spam. Pages with no extractable text go next, like this one, which does nothing but redirect your browser. Then a language classifier keeps only pages that are confidently English: about a third of what's left.
These rules are blunt. This page, a programming puzzle full of code, was thrown out. Here is the arithmetic. It passes six of Gopher's seven tests: enough words, a normal word length, few hashes, bullets or trailing dots, and plenty of ordinary words like the, and, of. But of its 2,756 words, only 2,037 contain a letter: 73.9 percent, under the 80 percent threshold. The rest are quotes, brackets and numbers from its code. At web scale that's an acceptable trade: losing some good pages costs far less than training on bad ones.
In the end, thirteen percent of the pages survive, holding about a third of a percent of the original bytes. FineWeb ran this, plus deduplication, over ninety-six crawls, and ended up with fifteen trillion tokens.
What it establishes: The FineWeb recipe run stage by stage with FineWeb's own code (datatrove): URL blocklist, extractable text, English (fastText > 0.65), Gopher repetition, Gopher quality, C4 line rules, FineWeb's three rules. The rules are blunt (one false positive shown).; Real data on screen: Pages surviving each stage, 10,498 → 1,363. Real rejected pages: a redirect-only page, a forum index, a login form, spun ad copy with template braces, a course-handbook menu. A programming puzzle dropped by mistake (gopher_below_alpha_threshold). 13% of pages and about a third of a percent of the bytes survive. Quoted: 4.56M blocked domains; FineWeb = 96 crawls → 15T tokens.
4Deduplication with MinHash2 min
The web is full of copies: mirrored sites, templates, boilerplate pages. Training on the same text over and over wastes compute and encourages memorization. Here's the biggest cluster of near-duplicates in our eight files: forty-one pages announcing that some domain name is for sale.
To measure how alike two pages are, cut each one into overlapping five-word shingles. The Jaccard similarity is the number of shingles they share, divided by the number of distinct shingles in either. For these two pages, it's 0.78.
But comparing every page with every other is hopeless. Billions of pages means billions of billions of pairs. MinHash gets around this with a beautiful trick. Run every shingle of a page through a random hash function, and keep only the smallest value. Two pages get the same minimum exactly when the smallest-hashed shingle of the two pages combined is one they share, which happens with probability equal to their Jaccard similarity. Repeat with 112 different hash functions, and each page gets a short fingerprint. For our two pages, 86 of the 112 minimums agree: an estimate of 0.77.
Then, instead of comparing fingerprints, hash them. Cut the 112 numbers into 14 bands of eight. Pages that match on all eight numbers of any band land in the same bucket, and become candidates. The chance of that, as a function of similarity, is this S-curve: pages that are eighty percent alike are caught ninety-two percent of the time; pages that are half alike, about five percent.
In our eight files, deduplication removed about three percent of the pages that survived filtering, in 114 clusters: domain-for-sale pages, access-denied pages, default web-hosting pages. Across a hundred crawls, the same pages turn up again and again, so the stakes are much higher, and FineWeb found a surprise. Deduplicating across all the crawls threw away ninety percent of the oldest ones, and what remained trained worse models. So FineWeb deduplicates each crawl separately.
What it establishes: Why copies hurt (wasted compute, memorization). 5-word shingles and Jaccard similarity. MinHash: P(minima match) = J, so 112 minima are a fingerprint. LSH banding (14 × 8) and its S-curve 1 − (1 − s⁸)¹⁴. Deduplicate each crawl separately, not globally.; Real data on screen: The biggest cluster in the 8 WET files: 41 "[domain] is for sale" pages. Two GoDaddy for-sale pages: shingle Venn counts, J = 0.78; 86 of 112 minima agree (estimate 0.77). P(0.8) = 92%, P(0.5) ≈ 5%. 8,457 → 8,208 pages (after the filters), ≈ 3% removed in 114 clusters (for-sale 41, access-denied 24, default hosting 7). Quoted: FineWeb's cross-crawl dedup removed 90% of the oldest crawls and trained worse models.
5Quality, mixtures, and tokens3 min
Hand-written rules catch obvious junk, but they can't tell whether a page is worth learning from. For that, labs use models. FineWeb-Edu asked Llama 3 70B to grade half a million pages for educational value, from zero to five, trained a small, fast classifier to imitate those grades, and ran it over all fifteen trillion tokens. Then it kept the pages scoring three or more.
We ran that same classifier on four hundred random pages that survived our filters. Most score low: shops, services, local news. Keeping three and up, as FineWeb-Edu does, leaves just seven percent. The top scorer looks like this, and a typical low scorer like this.
At full scale, FineWeb-Edu kept a similar eight percent of FineWeb, 1.3 trillion tokens, and models trained on it matched older datasets on knowledge benchmarks with ten times fewer tokens. Since then, the trend is to rewrite rather than throw away. NVIDIA's Nemotron-CC used a language model to rephrase web pages, producing almost two trillion synthetic tokens. Moonshot rephrased Kimi K2's knowledge data, and a factual-recall score rose from 24 to 29 percent. And AI2's OLMo 3 repeats its best data up to seven times, instead of drawing a hard line.
Then the data is mixed. Llama 3's recipe was about half general knowledge, a quarter math and reasoning, seventeen percent code, and eight percent other languages. And in the last stretch of training, the mix shifts toward the very best data. Annealing Llama 3's 8-billion-parameter model this way raised its score on grade-school math problems by twenty-four percent.
The finished datasets are enormous: around fifteen trillion tokens for Llama 3, DeepSeek-V3 and Kimi K2; twenty-eight and a half trillion for GLM-5; thirty-three trillion for DeepSeek-V4, released in April 2026; thirty-six trillion for Qwen3. Last, the text becomes tokens. A tokenizer, trained with byte-pair encoding, breaks text into frequent pieces; frontier tokenizers have between 128 and 260 thousand of them. We trained a small one, with 2,048, and used it to encode 168 million tokens of FineWeb-Edu: the fuel for the training runs in the next part.
How does byte-pair encoding choose its pieces? Start from single bytes, and count every adjacent pair in the training text. In our 57 million words, the most common pair is a space followed by t: six million times. Merge it into one token, recount, and repeat: space-a, then h-e, i-n, r-e. At the sixth merge, space-t plus h-e makes space-the. Recounting the pairs ourselves gives exactly the merges our tokenizer learned. After two thousand merges, 'the cat sat on the mat', twenty-two bytes, becomes eight tokens.
What it establishes: Model-based filtering, animated: an LLM grades pages, a 110M-parameter classifier imitates it, scores the crawl, keep ≥ 3 (grades illustrative). Keep the best and rewrite the rest (four panels). Data mixtures and annealing. How big datasets are. BPE tokenizers.; Real data on screen: FineWeb-Edu's own classifier on 400 random pages of our 1,363 survivors: scores 0–5 (55 / 253 / 63 / 25 / 4 / 0), 7% score ≥ 3, the top page (3.8) and a typical low one. Our 2,048-token BPE splitting a real sentence; 168M tokens of FineWeb-Edu for the pretraining runs. Quoted: 500,000 graded pages, 6,000 H100 hours; FineWeb-Edu kept 8% (1.3T tokens); Nemotron-CC 1.9T synthetic tokens; Kimi K2 SimpleQA 23.8% → 28.9%; OLMo 3 repeats data ≤ 7×; Llama 3 mix 50/25/17/8%, +24% GSM8K from annealing; Llama 3 15.6T, DeepSeek-V3 14.8T, Kimi K2 15.5T, GLM-5 28.5T, DeepSeek-V4 33T, Qwen3 36T tokens; vocabularies of 128K–260K.
6Part 2: How big? Scaling laws4 min
Before training anything, a lab has to decide how big the model should be. The budget is compute, and there's a simple rule for it: training costs about six times the number of parameters, times the number of tokens. Two operations per parameter per token on the forward pass, a multiply and an add, and about four more on the backward pass. So a fixed budget is a fixed area: you can spend it on a big model trained on fewer tokens, or a small model trained on many. Which is better?
Check the rule on a real model. Llama 3.1's largest version has 405 billion parameters, so every token costs six times that: 2.4 trillion operations. It was trained on 15.6 trillion tokens. Multiply, and the whole run comes to 3.8 times ten to the twenty-five operations. Epoch AI's independent estimate of that run: the same, 3.8 times ten to the twenty-five.
The way to find out is an experiment, so we ran one. Pick a compute budget, and train models of several sizes, each on exactly the number of tokens the budget allows. Plot final loss against model size, and you get a valley: too small a model can't hold what it sees, too large a model doesn't get to see enough. Repeat at four budgets, twenty-five runs in all, and fit a parabola to each valley floor. The best size grows with the budget, as a power law, with an exponent of about three quarters. That's close to what OpenAI found in 2020 with small models. The much larger study we'll see next found about one half, and later work traced the gap to details of how very small models like ours are measured and tuned.
In 2022, DeepMind's Chinchilla paper did this with more than four hundred models, up to sixteen billion parameters, and fitted a formula for the loss as a function of model size and data. Here is the landscape it describes, with the coefficients as corrected by a 2024 replication; darker means lower loss. Each yellow line is a fixed compute budget. Along each one there's a best point, and together they trace this path: grow parameters and tokens together, about twenty tokens for every parameter. By that measure, GPT-3 had been trained on far too little data, and the 70-billion parameter Chinchilla, trained on 1.4 trillion tokens, beat a model four times its size.
The formula also tells you how to split any budget. Since C is six N D, the number of tokens is C over six N, so the loss becomes a function of the model size alone. Set its derivative to zero, and the best size turns out to be a power of the budget: C to the beta over alpha plus beta. With the corrected coefficients, that exponent is 0.51, so model size and data should grow at almost the same rate. Now plug in Chinchilla's own budget, 5.76 times ten to the twenty-three operations. The formula asks for 72 billion parameters and 1.3 trillion tokens, about eighteen tokens per parameter. DeepMind trained Chinchilla with 70 billion parameters on 1.4 trillion tokens.
But nobody actually stops at twenty. Llama 3's team used the same kind of IsoFLOP experiment, up to ten to the twenty-two operations, to choose the size of their 405-billion-parameter model, and then trained their small models far longer: the 8-billion-parameter Llama 3 saw fifteen trillion tokens, almost nineteen hundred per parameter, and it kept improving. The reason is cost after training: a smaller model trained for longer is much cheaper to run for millions of people. Frontier mixtures of experts land in between, at hundreds to over a thousand tokens per active parameter.
What it establishes: Part 2. C ≈ 6ND (2 operations forward + 4 backward); a fixed budget is a fixed area. IsoFLOP valleys and parabola fits; the compute-optimal N is a power law in C. Chinchilla's loss landscape and ≈ 20 tokens per parameter. Why everyone overtrains (cheaper inference).; Real data on screen: Our IsoFLOP sweep: 25 real runs at 10¹², 3×10¹², 10¹³ and 3×10¹³ FLOPs, final validation loss vs model size, parabolas through each valley floor: optimal size 25K, 75K, 174K, 340K parameters, N_opt ∝ C^0.76 (close to Kaplan et al.'s 0.73 at small scale; Chinchilla found ≈ 0.5). A heat map of the Chinchilla loss formula with Besiroglu et al.'s 2024 re-estimate of its coefficients (E 1.82, A 482, B 2,085, α 0.348, β 0.366; the formula, not data). Tokens per (active) parameter: 20 (Chinchilla), 39 (Llama 3.1 405B), 400 (DeepSeek-V3), 1,636 (Qwen3-235B), 1,875 (Llama 3 8B). Quoted: 400+ Chinchilla runs, 70M–16B parameters; GPT-3 175B on 300B tokens; Chinchilla 70B on 1.4T beat the 280B Gopher; Llama 3 IsoFLOPs up to 10²².
7Architecture and mixture of experts5 min
What gets trained? Still a transformer: the same basic blueprint as GPT-2, which our earlier video took apart piece by piece. But nearly every component has been refined: a simpler normalization, rotary position embeddings, gated MLPs, attention that shares or compresses its keys and values to save memory, and normalization of the queries and keys for stability. Our pocket models use the first three, and QK-norm gets an experiment of its own later on.
The biggest architectural change of the last two years is the mixture of experts. In a standard transformer, every token passes through the whole MLP in every layer. A mixture-of-experts layer replaces that one MLP with many smaller ones, the experts, and a small router that scores them for each token and sends the token to only the top few. So the number of parameters grows with the number of experts, while the computation per token grows only with the number chosen.
In symbols: the router turns the token's vector into one score per expert, with a softmax. Keep the top two, rescale their scores to sum to one, and add up those experts' outputs. With the scores we just saw, 0.38 and 0.31 become 0.55 and 0.45. And the saving is plain arithmetic. DeepSeek-V3 has 671 billion parameters, but each token passes through 37 billion of them, so training costs six times 37 billion operations per token, not six times 671 billion: eighteen times less.
Frontier open models push this hard. DeepSeek-V3 has 256 experts per layer and uses eight of them, plus one shared expert that every token visits: 671 billion parameters in total, but only 37 billion doing work for any one token. Kimi K2 has 384 experts and passes a trillion parameters. And Kimi K3, from July 2026, picks sixteen of 896, for 2.8 trillion parameters. Experts keep getting more numerous, and the fraction used per token keeps shrinking, now around three to five percent.
But routers have a failure mode. Experts that get more tokens improve faster and get chosen even more: the rich get richer. Here are three real runs of our pocket mixture of experts, eight experts, two per token. Watch the share of tokens each expert receives as training goes. With no balancing, the busiest expert ends up with three times its fair share, while another gets almost nothing. The classic fix is an extra loss term that penalizes uneven routing. DeepSeek-V3 used a gentler trick: a bias added to each expert's score, only for choosing experts, nudged up after every step if the expert was underused and down if it was overused, with no extra loss term competing with learning. Here, it balances almost perfectly. In our tiny runs, the auxiliary loss still finished with a slightly lower loss; in DeepSeek's experiments, at billions of parameters, the bias came out ahead.
Here's the arithmetic behind the two fixes. The auxiliary loss multiplies, for each expert, the share of tokens it gets, f, by the average probability the router gives it, P, and adds them up. If every expert gets an eighth, the total is exactly one, its minimum. Plug in our unbalanced run's real shares, taking P close to f, and it's 1.84; training with the loss brought it to 1.07. DeepSeek's bias never touches the loss. After every step, each expert's bias moves by 0.001 toward balance: up if it got fewer tokens than average, down if it got more. By the end of our run, the naturally popular experts carried biases near minus 0.3 and the neglected ones near plus 0.3: just enough to even out the choices.
A few other shifts are reshaping the blueprint, mostly to make long contexts and inference cheaper. Sparse attention lets each token look at only its most relevant earlier tokens. Hybrid models replace three of every four attention layers with cheaper linear-time layers. Multi-token prediction adds heads that guess several tokens ahead, both as extra training signal and to speed up generation. And context windows of a million tokens are now common, reached in stages near the end of training.
What it establishes: The GPT-2 blueprint, refined: RMSNorm, RoPE, SwiGLU, grouped-query or latent attention, QK-norm, no biases. Mixture of experts: a router, top-k, parameters vs compute per token (schematic). Frontier MoEs keep getting sparser. Load balancing: rich-get-richer, an auxiliary loss, DeepSeek-V3's bias. Sparse attention, hybrid linear attention, multi-token prediction, 1M-token context (four schematic panels).; Real data on screen: Three real pocket MoE runs (8 experts, top-2; no balancing / auxiliary loss / bias): the share of tokens each expert gets in the last layer, animated over 487 steps; busiest expert 3.0× / 1.3× / 1.1× its fair share (one expert under 1% without balancing); final validation loss 4.876 / 4.820 / 4.868 (the auxiliary loss is ahead in these tiny runs; DeepSeek found the bias ahead at scale). Quoted: DeepSeek-V3 8 of 256 experts + 1 shared, 671B total / 37B active; Kimi K2 8 of 384, 1.04T / 32B; Kimi K3 16 of 896, 2.8T; sparse attention over the top 2,048 tokens; 3 linear layers per full-attention layer.
8The optimizer: AdamW and Muon5 min
Next, the optimizer: the rule that turns each gradient into an update. Plain gradient descent steps straight downhill, and in a long, narrow valley it zigzags across the steep walls while creeping along the floor. Adam fixes this one coordinate at a time: it keeps running averages of each parameter's gradient and squared gradient, and divides one by the square root of the other, so every coordinate moves at a similar speed. With decoupled weight decay, AdamW has been the default for most of a decade.
Here's Adam in equations. It keeps a running average of the gradient, m, and of the squared gradient, v. The step is m divided by the square root of v, after a correction for the averages starting at zero. Run it on two parameters: one with gradients around four, one with gradients a hundred times smaller. The averages differ by a factor of a hundred, but their ratio doesn't: after three steps both parameters move by 0.974 learning rates. AdamW adds one more term, shrinking every weight slightly, kept separate from the gradient step.
A newer optimizer, Muon, treats each weight matrix as a whole. A matrix's gradient can be broken into directions, its singular vectors, each with a size. Here are the sizes for a real gradient from one of our pocket models, on a log scale. A handful of directions dominate: the top five, out of 128, carry about two thirds of it, while a typical direction is some fifty times smaller than the largest. Muon keeps the directions but sets every size to one: each direction gets an equal step.
Computing that exactly would need a singular value decomposition, which is slow on GPUs. Muon's trick is a polynomial. Multiplying a matrix by itself in this pattern applies the same polynomial to every singular value at once, and the coefficients are chosen so that five rounds push every value toward one. Here are the real singular values of our gradient, scaled below one, going through five iterations: small ones are lifted fast, any that overshoot are pulled back, and all of them end up between about 0.6 and 1.2.
Here is that arithmetic for three of them. Take a singular value of 0.03. One application of the polynomial is mostly the first term: 3.4445 times 0.03, minus a tiny cubic correction, gives 0.103. Apply it again: 0.35, then 1.01. A value that starts at 0.9 overshoots and oscillates instead. But after five rounds, all three sit between 0.68 and 1.12. They aren't exactly one, and they don't need to be: roughly equal steps in every direction is the whole point.
Does it help? Here's our pocket model trained twice on the same data, once with AdamW and once with Muon, each with the better of the learning rates we tried in short test runs. Muon pulls ahead early and stays ahead. While the learning rate is held at its peak, Muon reaches any given loss with less than two thirds of the tokens AdamW needs. At the end, both learning rates are lowered and both losses drop, which is the subject of the next chapter. Muon finishes at 3.61, AdamW at 3.80.
Muon began in 2024 as a trick for a community speedrun of small GPT models. In 2025, Moonshot showed it scales, needing about half the training compute of AdamW, and trained the trillion-parameter Kimi K2 with it. By 2026, Zhipu's GLM models, DeepSeek-V4 and Kimi K3 all use Muon variants. One caveat: a careful 2025 benchmark found the speed-up shrinks as models grow, from 1.4 times at a hundred million parameters to 1.1 times at 1.2 billion. Our tiny model's 1.6 fits that trend, though our tuning was far lighter. Optimizer gains are real, but they're hard to measure at scale.
What it establishes: Gradient descent zigzags while Adam normalizes each coordinate (computed on ½(25x² + y²)); AdamW. Muon: G = UΣVᵀ → UVᵀ, so every direction takes an equal step; a Newton–Schulz polynomial replaces the SVD. AdamW vs Muon, compared while the learning rate is at its peak. Adoption timeline; a speed-up that shrinks with scale.; Real data on screen: Singular values of a real gradient (a 336 × 128 MLP matrix of a pocket model): the top 5 of 128 directions hold 65% of it, the median is 1/47 of the largest; through 5 Newton–Schulz iterations of p(σ) = 3.4445σ − 4.7750σ³ + 2.0315σ⁵ every value ends in 0.6–1.2. AdamW vs Muon on the same ≈ 1M-parameter model and 12M tokens: at the peak learning rate Muon reaches each of AdamW's losses with 55–66% of the tokens (63% at the end of the stable phase); final 3.80 vs 3.61. Speed-ups: ours ≈ 1.6× (lightly tuned) next to Wen et al.'s 1.4× at 0.1B and 1.1× at 1.2B. Quoted: Moonlight ≈ half the FLOPs; Kimi K2 (MuonClip, 1T); GLM-4.5, DeepSeek-V4, Kimi K3.
9Learning-rate schedules3 min
The learning rate sets how big each step is, and how it changes over the run matters a lot. Runs begin with a short warmup, ramping up from near zero, because big steps on a freshly initialized network can blow it up. Then the rate decays. The classic choice is half a cosine wave, falling from the peak to a tenth of it. Cosine has a catch: you must choose the length of the run in advance. Stop halfway, and the rate was never brought down: at t equals half of T, p is 0.474, the cosine is 0.083, and the rate is still 59 percent of its peak. The alternative is warmup, stable, decay: hold the peak for most of the run, and decay only in the last fifth.
Here are both schedules on one of our pocket models, with the same data. During the stable phase, WSD's loss lags slightly behind. Then its decay begins, and the loss drops off a cliff, finishing below cosine. Larger published comparisons usually find the two about level. And the stable phase can be reused: branch off and decay early, here at forty and sixty percent of the way, and each branch is a finished model for that budget. Our half-length branch even beat a separate half-length cosine run. One long run gives you a model at every budget.
Why does the loss fall so suddenly? One picture: late in training, the loss landscape looks like a river valley, with steep walls and a slowly descending floor. At a high learning rate, the optimizer bounces between the walls while drifting downstream. Lower the rate, and it settles onto the valley floor, revealing progress it had already made.
Frontier runs use variations of both. DeepSeek-V3 held its peak learning rate for ten trillion tokens, then decayed over the next four. Llama 3 used cosine, annealed to zero over its last forty million tokens, and averaged checkpoints. Kimi K3 fitted scaling laws for both schedules and chose cosine. And the batch size usually grows as training goes, from a few million tokens per step to tens of millions.
What it establishes: Warmup; cosine decay vs warmup–stable–decay (WSD); cosine fixes the run length in advance (stop at 50% and the rate is still at 59% of peak). WSD's loss lags, then drops in the cooldown; cooldown branches give a model at every budget. The river-valley picture (computed toy). Real schedules from the labs' reports; batch sizes grow.; Real data on screen: Schedule shapes from the training code's own lr_factor. Cosine vs WSD on one pocket model (L3 d96, 5M tokens): WSD lags slightly during the stable phase, then finishes at 4.18 vs cosine's 4.30; WSD cooldown branches from 40% and 60%; the half-length branch (4.59) beats a separate half-length cosine run (4.87). Charts drawn from the reports: DeepSeek-V3 (peak to 10T tokens, cosine to 10% over 4.3T, two low-LR stages), Llama 3 405B (cosine, annealed to 0 over the last 40M tokens), Kimi K3 (chose cosine over WSD), Llama 3's batch 4M → 8M → 16M tokens.
10Fewer bits: FP8 and FP45 min
Every number in a training run is stored in a fixed number of bits, and that choice is one of the biggest levers on speed. Use half as many bits, and a chip can do roughly twice as many multiplications per second, while moving half as much memory. An H100 does about a thousand trillion operations per second in sixteen-bit bfloat, and twice that in eight-bit. A Blackwell Ultra chip does fifteen thousand trillion in four-bit.
A floating-point number has three parts: a sign, an exponent that sets its scale, and a mantissa that sets its precision within that scale. Ordinary thirty-two-bit floats have eight exponent bits and twenty-three mantissa bits. Bfloat16 keeps all eight exponent bits but only seven of mantissa: the same range, less precision. It's the workhorse of training today. The eight-bit format called E4M3 has four exponent bits and three of mantissa, and four-bit E2M1 has just two exponent bits and one mantissa bit.
Here is every positive number each format can represent, on a log scale. FP8 has a hundred and twenty-six of them, from about two thousandths up to 448. FP4 has seven: one half, one, one and a half, two, three, four and six. That's all.
Decoding one is simple arithmetic. In E4M3, the value is two to the exponent minus seven, times one plus the mantissa over eight. Take the bits 0, 0111, 011: the exponent is seven, so two to the zero; the mantissa is three, so the value is 1.375. The largest pattern, 0, 1111, 110, is two to the eighth times 1.75: 448. FP4 works the same way with a bias of one: its largest value, 0, 11, 1, is four times 1.5, which is six.
Because the range is so small, low-precision numbers are stored with a scale factor: divide by the scale, round, and multiply back. The question is how many numbers share one scale. Here is a real tensor: the residual stream of GPT-2 after six blocks, for one sentence. Forty-five tokens by 768 channels. A typical entry is about one. But a few channels are enormous: this one reaches almost 2,900 at the first token. Such massive activations show up in many transformers.
Now store it in FP4 with a single scale for the whole tensor. The outlier sets the scale, and every ordinary value rounds to zero: 99.99 percent of the tensor simply vanishes. Give every block of sixteen numbers its own scale, as NVIDIA's NVFP4 format does, and the picture comes back. Each value is still rounded coarsely, here with about twelve percent error, but the information survives.
Zooming in on one token, the word Paris: each block of sixteen values gets its own scale, stored in eight bits, so a large value only coarsens its own block, not the whole tensor.
Here's one block, step by step: sixteen real values from the Paris token. First, one scale for the whole tensor, so its largest value fits: 2,883, over 448 times 6, is 1.072. Then the block's own scale: its largest value is 8.84; divided by 6 and by 1.072 that's 1.374, rounded to the nearest FP8 number, the 1.375 we just decoded. Divide every value by the combined scale, round to the nearest FP4 value, and multiply back. The block's largest value, 8.84, becomes exactly 6 and comes back almost perfectly; 5.11 lands at 3.47, rounds to 3, and comes back as 4.42. Over the block, the error is 9.6 percent.
FP8, with its four exponent bits, is more forgiving: on this same tensor, even a single scale gives under three percent error. Labs still scale finely, for safety. DeepSeek-V3 was trained in FP8 with a separate scale for every 128 values, adding up partial sums in full precision every 128 products, and in tests against sixteen-bit training its loss stayed within a quarter of a percent. And in 2026, NVIDIA pretrained Nemotron 3 Ultra, a 550-billion-parameter model, on twenty trillion tokens in NVFP4, keeping the most sensitive layers in higher precision and using tricks like random rotations and stochastic rounding to tame the outliers.
What it establishes: Fewer bits → more FLOP/s and less memory. Sign / exponent / mantissa in FP32, BF16, FP8 E4M3 and FP4 E2M1. Every value each format can hold. Scale factors and how many numbers share one. Outliers (massive activations) and block scaling (NVFP4). FP8 and NVFP4 at frontier scale.; Real data on screen: Every positive E4M3 value (126, from 2⁻⁹ to 448) and E2M1 value (0.5, 1, 1.5, 2, 3, 4, 6). GPT-2 small's real residual stream after 6 blocks (45 tokens × 768 channels): channel 447 reaches ≈ 2,900 at the first token, a typical entry ≈ 1.2. FP4 with one scale flushes 99.99% of values to zero; NVFP4 (blocks of 16) keeps them at ≈ 12% error. " Paris" (first 64 channels) before and after NVFP4. Quoted: dense PFLOP/s: H100 BF16 0.989, FP8 1.979; B300 FP8 5, NVFP4 15. DeepSeek-V3 FP8 (1 × 128 tiles, within 0.25% of BF16); Nemotron 3 Ultra, 550B on 20T tokens in NVFP4.
11Loss spikes and stability4 min
Big runs are fragile. The loss can suddenly spike, and sometimes it never recovers. Google's PaLM saw about twenty spikes during training, even with gradient clipping; the fix was to restart from a checkpoint about a hundred steps earlier and skip a few hundred batches of data. Meta's OPT needed more than thirty-five manual restarts. And labs still hit this in 2026: NVIDIA's Nemotron 3 Ultra report describes two divergences, one traced to gradients being summed in sixteen-bit instead of thirty-two-bit.
Many instabilities can be reproduced in miniature. Researchers at Google showed in 2023 that small models trained at high learning rates fail in the same ways big ones do. So we trained twelve pocket models: six learning rates, each with standard attention and with a fix called QK-norm. These runs are short, so nothing blows up outright. But look at the shape. From 0.003 to 0.03, the QK-norm model's loss barely moves, while the standard model's climbs. QK-norm makes training far less sensitive to the learning rate, for a small cost at the best setting.
What's going on inside? Here is the largest attention score each model produced, the dot product of a query and a key, against the learning rate. In the standard model it explodes: about nine at the gentlest rate, over a hundred at 0.01, and ten thousand at 0.1. A softmax over scores that large is one-hot, and in longer runs, this is what Wortsman and colleagues saw right before the loss diverged. QK-norm normalizes every query and key vector before the dot product, and the largest score stays below ten at every learning rate.
Why does normalizing cap the scores? A dot product can never exceed the product of the two lengths: that's the Cauchy-Schwarz inequality. RMS normalization divides each 32-dimensional query and key by its root-mean-square, which sets its length to root 32. So the score, q dot k over root d, can be at most root 32, about 5.66, unless the learned gains grow. Our gentlest run peaked at 4.8, under the bound. Even at the highest learning rate, with grown gains, it reached only 9.1, while without normalization the score hit ten thousand. And a softmax over scores like that is brutal. Two scores 45 apart get weights in the ratio e to the minus 45, about three in ten to the twenty: the output is one-hot, and its gradient, p times one minus p, is zero.
QK-norm is now standard in many open models. Alongside it: a small z-loss that keeps the output logits from drifting, gradient clipping, warmup and careful initialization. Moonshot's MuonClip rescales the query and key weights whenever an attention score passes a hundred, and Kimi K2 trained on fifteen and a half trillion tokens with zero loss spikes. And new failure modes keep appearing: in 2026, DeepSeek-V4 traced spikes to outliers in its mixture of experts, and added activation clamping and an emergency re-routing mode that switches on after a spike.
What it establishes: Loss spikes in big runs, and PaLM's rollback-and-skip fix (illustrative curve). The same instabilities show up in small models at high learning rates. The mechanism: attention scores grow and the softmax goes one-hot. QK-norm. The toolbox: z-loss, clipping, warmup, initialization, MuonClip, DeepSeek-V4's clamping and re-routing.; Real data on screen: 12 real pocket runs (800K tokens each; none diverged): final loss vs peak learning rate (3×10⁻⁴ … 10⁻¹), standard vs QK-norm. From 0.003 to 0.03 QK-norm's loss stays at 5.87 while standard attention's rises 5.78 → 5.98 (QK-norm costs a little at the best rate). Largest attention score q·k/√d vs learning rate: 9, 13, 23, 112, 917, 10,045 for standard attention, ≤ 9.1 with QK-norm. Quoted: PaLM ≈ 20 spikes (restart ~100 steps back, skip 200–500 batches); OPT-175B 35+ restarts; Nemotron 3 Ultra 2 divergences; MuonClip caps scores at 100, zero spikes over 15.5T tokens.
12Part 3: Memory and data parallelism3 min
Let's count what a training run has to keep in memory. For every parameter: the weight itself, in sixteen-bit, two bytes. Its gradient: two more. Then the optimizer's state: a full-precision master copy of the weight, four bytes, and Adam's two running averages, four bytes each. Sixteen bytes per parameter.
For a 405-billion-parameter model like Llama 3.1, that's six and a half terabytes. An H100 has eighty gigabytes; even the newest Blackwell Ultra has 288. So just holding the training state takes eighty-one H100s, before counting the activations: the intermediate values saved during the forward pass for use in the backward pass, which for long sequences can be even larger. They're often thrown away and recomputed when needed, trading compute for memory.
So the work has to be split across many GPUs, and there are several ways to split it. The simplest is data parallelism: every GPU holds a full copy of the model and processes a different slice of each batch. Each computes its own gradient, and then they must all agree on the average before taking a step together.
That averaging is called an all-reduce, and the standard algorithm passes messages around a ring. Each GPU's gradient is cut into chunks; here, four GPUs with four numbers each. Every GPU needs to end up with the sum.
In each step, every GPU sends one chunk to its neighbor, which adds it to its own. After three steps, each GPU holds one chunk of the complete sum. Three more steps pass the finished chunks around the ring, and now every GPU has the whole sum. Each one sent only about twice the size of its gradient, no matter how many GPUs are in the ring.
But in plain data parallelism, every GPU still stores all sixteen bytes per parameter. ZeRO, and PyTorch's FSDP, shard that state instead. For a 7.5-billion-parameter model on sixty-four GPUs, replicated state is sixteen bytes times 7.5 billion: 120 gigabytes on every GPU. Split the twelve bytes of optimizer state sixty-four ways: four times 7.5, plus twelve times 7.5 over sixty-four, is 31.4. Shard the gradients too: 16.6. Shard the weights themselves, gathering each layer just before it's needed: sixteen times 7.5 over sixty-four, under two gigabytes. The price is more communication: about one and a half times that of plain data parallelism.
What it establishes: Part 3. Training state = 16 bytes per parameter; activations and recomputation. Data parallelism. Ring all-reduce: reduce-scatter + all-gather, 2(N−1)/N per GPU. ZeRO-1/2/3 and FSDP shard the state for ~1.5× the communication.; Real data on screen: Llama 3.1 405B × 16 bytes = 6.48 TB = 81 H100s just to hold the state; H100 80 GB, B200 192 GB, B300 288 GB. An exact ring all-reduce over 4 GPUs × 4 chunks, ending at [22, 20, 20, 18]. ZeRO for a 7.5B model on 64 GPUs: 120 → 31.4 → 16.6 → 1.9 GB per GPU.
13Tensor, pipeline, expert parallelism4 min
Data parallelism still runs every layer in full on every GPU. When a single layer is too big, you split the layer itself. That's tensor parallelism. Take a matrix multiplication. Cut the weight matrix into columns, and each GPU computes its own slice of the output, with no communication at all. Feed those slices into the next matrix, cut into rows, and each GPU produces a partial sum. One all-reduce adds them up.
NVIDIA's Megatron-LM arranged a whole transformer layer this way, with just two all-reduces in the forward pass and two in the backward. But they happen in every layer, on the critical path, so tensor parallelism is kept inside one server, where eight GPUs are joined by NVLink at 450 gigabytes per second in each direction. Between servers, a network card manages about 50: nine times slower.
To spread a model across servers, cut it by depth instead: pipeline parallelism. The first GPU holds the first quarter of the layers, the next GPU the next quarter, and so on. Only activations pass between stages, so slower links are fine. But a naive pipeline is mostly idle. While one stage works, the others wait: three quarters of the time is bubble.
The fix is to cut each batch into micro-batches and keep the pipeline full. With eight micro-batches, the bubble shrinks to p minus one, over m plus p minus one: about a quarter. Cleverer schedules push it further. Zero-bubble pipelines split the backward pass in two and use one half to fill the gaps, and DeepSeek's DualPipe feeds micro-batches in from both ends at once, hiding communication behind computation.
Mixture-of-experts models add expert parallelism. Each GPU holds different experts, and every token must travel to the GPUs holding its chosen experts, and back again: an all-to-all exchange in every MoE layer. And for very long sequences, context parallelism splits the sequence itself across GPUs.
Real runs combine all of these. Llama 3.1, the 405-billion-parameter model, trained on 16,384 H100s arranged as a grid: tensor parallel across the eight GPUs inside each server, a sixteen-stage pipeline across sixteen servers, and a hundred and twenty-eight copies of that pipeline doing data parallelism. Each GPU sustained about 400 teraflops: roughly forty percent of its peak, which is typical. DeepSeek-V3 took a different shape, on 2,048 export-limited H800s: no tensor parallelism at all, a sixteen-stage DualPipe pipeline, and experts spread across 64 GPUs on eight nodes.
Now the arithmetic of a real run. An H100 peaks at 989 trillion operations per second; Llama 3.1's GPUs sustained about 400 trillion, forty percent, a figure called model FLOPs utilization. So training takes six N D divided by the cluster's speed: 3.8 times ten to the twenty-five, over sixteen thousand GPUs times 400 trillion. That's 5.8 million seconds: sixty-seven days, or 26 million GPU-hours. Meta reports 30.8 million, so this one line gets within fifteen percent. One step, sixteen million tokens, takes about six seconds. In that time each GPU must average its gradients with its 127 copies. It holds 3.2 billion parameters, 6.3 gigabytes of gradients; a ring sends about twice that, and at fifty gigabytes per second it takes a quarter of a second, hidden behind the backward pass.
What it establishes: Tensor parallelism: split by columns (no communication), then by rows (one all-reduce); Megatron-LM's two all-reduces each way, kept inside NVLink. Pipeline parallelism: the bubble, micro-batches, (p−1)/(m+p−1), Zero Bubble, DualPipe. Expert parallelism (all-to-all) and context parallelism (schematic). How real runs combine them.; Real data on screen: A worked [1 2] · W₁ (2 × 4) · W₂ (4 × 2) split across 2 GPUs, giving [12 19] both ways. NVLink 450 GB/s vs ~50 GB/s between servers (≈ 9×). Exact pipeline timelines from a dependency simulator (4 stages, backward = 2× forward): idle 75% with 1 batch, 27% with 8 micro-batches. Llama 3.1 405B: 16,384 H100s = TP 8 × PP 16 × DP 128, ≈ 400 TFLOP/s per GPU (41% MFU). DeepSeek-V3: 2,048 H800s, no TP, 16-stage DualPipe, experts over 64 GPUs on 8 nodes.
14Keeping the run alive3 min
A run like this lasts weeks or months, and keeping it alive is a job in itself, because the more GPUs you use, the more often something breaks. Meta measured this across its research clusters: an eight-GPU job ran, on average, forty-eight days between failures. A thousand-GPU job: about eight hours. Failures scale with the number of parts, so at sixteen thousand GPUs you'd expect one every couple of hours, and at a hundred thousand, about every quarter of an hour.
And that's what Llama 3 saw. In one fifty-four-day stretch of training on 16,384 GPUs, the job was interrupted 466 times: once every two point eight hours. About four fifths of the unexpected stops traced to hardware, mostly the GPUs themselves and their memory.
So the training state is checkpointed regularly. When a GPU dies, the job restarts from the last checkpoint on healthy machines, and only the work since then is lost. Doing this well is the difference between a run that spends nine tenths of its time training and one that doesn't. Llama 3 stayed above ninety percent. Google kept redundant copies of Gemini's state in memory, so recovery took seconds, and raised the share of useful time from eighty-five to ninety-seven percent.
How often should you save? Saving takes time, delta, every tau minutes. But with a failure every M minutes, each failure throws away, on average, half an interval of work. Add the two, set the derivative to zero, and the best interval is the square root of two delta M. With Llama 3's failure every 2.8 hours and a checkpoint that takes one minute, save every eighteen minutes and lose eleven percent, split evenly between the two costs. Make checkpoints take ten seconds, from memory, and the best interval drops to seven and a half minutes, losing four and a half percent: one reason Google kept copies of Gemini's state in memory.
Some failures are silent: a chip that keeps running but computes slightly wrong numbers. At Gemini's scale, Google expected such silent data corruption every week or two, and caught it by replaying steps. Even the power grid notices: when sixteen thousand GPUs pause at the same moment, Meta saw the power draw swing by tens of megawatts.
What it establishes: More GPUs mean more failures. What interrupted Llama 3. Checkpoint, fail, restart; goodput. Silent data corruption; the power grid notices.; Real data on screen: Meta's measured mean time to failure: 48 days at 8 GPUs, 7.9 h at 1,024; projected 1.8 h at 16,384 and 14 min at 131,072. Llama 3: 466 interruptions in 54 days on 16,384 GPUs, one every 2.8 h (tick positions illustrative). Causes of the 419 unexpected ones: faulty GPU 30.1%, HBM3 17.2%, software 12.9%, network 8.4%, host maintenance 7.6%, SRAM 4.5%, GPU system processor 4.1%. Over 90% of time spent training (Llama 3); 85% → 97% (Gemini).
15Part 4: Supervised fine-tuning3 min
After pretraining, we have a base model: a superb document completer, but not an assistant. Ask the base version of Qwen3's smallest model where the Eiffel Tower is, and it decides it's reading a quiz. It writes the multiple-choice options, the answer key, and then the next question. The same model after post-training simply answers.
The first step is supervised fine-tuning. Conversations are written out as a single stream of tokens, with special tokens marking who is speaking. Here is Qwen3's actual format: a start marker, the speaker's role, the message, and an end marker. The assistant's turn even begins with a thinking block, empty here because thinking was switched off.
Training is the same next-token prediction as before, with one change: the loss is only counted on the assistant's tokens. The model isn't learning to predict what users say. It's learning how the assistant replies.
Here is that loss on real numbers. For each of the assistant's tokens, take minus the log of the probability the model gave it. Qwen3's base model, in grey, finds most of the answer easy, but pays heavily for the first word, at 7.3, for 'in', at 4.5, and for the end-of-turn marker it has never seen, at 12.9. Averaged over these twelve tokens, its loss is 2.12. The same model after post-training, in green, averages 0.52. Its biggest cost is 'in', at 3.6, because it would have said 'located in'. Fine-tuning is exactly the pressure that pushes these numbers down.
Where do the conversations come from? Early on, from people: OpenAI's InstructGPT used about thirteen thousand demonstrations written by contractors. The LIMA paper showed that a thousand carefully chosen examples go a long way, because the knowledge is already there from pretraining. Today most of the data is generated by stronger models and then filtered: Allen AI's Tülu 3 mix has 939 thousand prompts, and OLMo 3's reasoning set has 2.3 million, about forty-five billion tokens. This kind of imitation is powerful. DeepSeek distilled R1's reasoning into a 32-billion-parameter Qwen model with fine-tuning alone, and it scored 72.6 percent on the AIME 2024 math competition, far above the 47 percent that reinforcement learning reached directly on the same base.
What it establishes: Part 4. A base model completes documents; it is not an assistant. Chat template: one token stream with role and special tokens (here an empty think block). SFT = next-token loss on the assistant's tokens only. Where SFT data comes from; distillation.; Real data on screen: Real greedy answers to "Where is the Eiffel Tower?": Qwen3-0.6B-Base writes a quiz ("A. Paris / B. London …", the answer key, the next question); Qwen3-0.6B answers "Paris, France". Qwen3's real chat format for a 3-turn conversation (44 tokens), prompt tokens masked out of the loss. Quoted: InstructGPT ≈ 13,000 demonstrations; LIMA 1,000; Tülu 3 939,344 prompts; OLMo 3 Think ≈ 2.3M prompts, ≈ 45B tokens; R1 distilled into Qwen2.5-32B scores 72.6% on AIME 2024 vs 47.0% for RL.
16Learning from preferences4 min
Imitation only goes so far. For many qualities, it's far easier to judge an answer than to write a perfect one. So the next stage learns from comparisons: show a person two responses to the same prompt, and ask which one is better.
Those choices train a reward model: a copy of the language model whose output is a single number, a score. It's trained so that the probability a person prefers answer A over answer B is the sigmoid of the difference between their scores. That's the Bradley-Terry model, from 1952.
Here's one comparison with numbers. Say the reward model scores answer A at 1.3 and answer B at 0.4. Then it predicts that a person prefers A with probability sigma of 0.9: 71 percent. The loss is minus the log of that probability, 0.34. Its slope with respect to A's score is minus 0.29, and with respect to B's, plus 0.29: each step raises A's score and lowers B's by the same amount. Once a pair is ranked confidently, say with a gap of 3, the loss and the push both shrink to 0.05: the training effort goes to the comparisons the model still gets wrong. And only the gap matters: add ten to every score, and nothing changes.
Then comes reinforcement learning. The model writes answers, the reward model scores them, and the model is nudged toward the answers that score higher, with one constraint: a penalty for drifting too far from the fine-tuned model it started from, measured by the KL divergence. This is RLHF, reinforcement learning from human feedback: the recipe behind InstructGPT and the first ChatGPT.
The leash matters, because the reward model is only a proxy for what people want. Here's a simulation. Each candidate answer has a true quality, and the reward model sees that quality plus some error. Pick the best of n answers by the reward model's score. At first, true quality climbs. But push harder, and you start selecting the answers whose errors were biggest: the proxy reward keeps rising while the true quality falls. That's Goodhart's law, and OpenAI measured exactly this shape with real reward models in 2022.
In 2023, Direct Preference Optimization showed you can skip the reward model and the RL loop altogether. A bit of algebra turns the same objective into a simple loss on each pair: raise the probability of the preferred answer, relative to the reference model, and lower the rejected one. DPO and its variants are now standard in open post-training pipelines. And the comparisons don't have to come from people: with constitutional AI, a model judges responses against a written list of principles.
Here's DPO on one pair. Each log-probability is a sum over the answer's tokens: the same per-token numbers as in fine-tuning. Compared with the reference model, the policy has raised the log-probability of the preferred answer by 2, and lowered the rejected one by 1. Times beta, 0.1, those are implicit rewards: 0.2, and minus 0.1. Their gap, 0.3, goes into the same Bradley-Terry loss as the reward model: minus log sigma of 0.3, which is 0.554. Every pair starts at log 2, 0.693, because at step zero the policy is the reference. And notice: the rejected answer is still the more likely one, in absolute terms. DPO doesn't care. Only the ratios to the reference count.
What it establishes: Judging is easier than writing: pairwise comparisons (illustrative). Reward model and Bradley–Terry, P = σ(r_A − r_B). RLHF: maximize reward minus β·KL to the reference (schematic). Goodhart: over-optimizing a proxy. DPO (no reward model, no RL loop); Constitutional AI.; Real data on screen: A best-of-n simulation (true quality g ~ N(0, 1); the reward model sees g plus heavy-tailed error), against √KL: the proxy reward keeps rising while true quality peaks at n ≈ 35, then falls below half its peak.
17Reinforcement learning and reasoning7 min
The biggest change in post-training since 2024 is reinforcement learning on problems whose answers can be checked automatically. A math problem has a final answer; code has tests. The reward is simply one if the answer is right, and zero if it isn't. There's no learned reward model for the policy to fool.
Here's the most popular algorithm for this, GRPO, run for real on a miniature. We pretrained a pocket model on three-digit additions, where four in ten of the examples were written by someone who always forgets to carry. So the model learned two habits: the right answer, and the carry-dropping mistake.
Give it a problem, 478 plus 356, and sample a group of eight answers. Only one is right: 834. Five drop both carries, 724, and two drop one of them. Each answer gets a reward: one or zero. GRPO's key idea is to grade each answer against its own group: subtract the group's average reward, and divide by the spread. Better than average gets a positive advantage; worse gets a negative one. Then every token of each answer is pushed up or down in probability according to its advantage. No critic network, no reward model: just a group of samples and a checker.
Here are those numbers, worked out. The rewards are a single one and seven zeros, so the mean is one eighth: 0.125. The spread, the sample standard deviation, is the square root of an eighth: 0.354. So the right answer gets 0.875 divided by 0.354: plus 2.47. Each wrong one gets minus 0.35. The advantages always sum to zero: probability pushed up in one place is pushed down somewhere else. And their size depends on how rare the outcome was. One success in eight earns plus 2.47; one failure in eight costs minus 2.47. And when all eight agree, the spread is zero, and so is every advantage.
GRPO's full objective adds one safeguard, borrowed from PPO. Rho is the ratio of a token's probability now to its probability when the answers were sampled, and it's clipped to within twenty percent of one. Take a token of the right answer, advantage plus 2.47, whose probability has already risen by thirty percent: rho is 1.3. Unclipped, the objective would be 3.21; clipped at 1.2 it's 2.96, and the minimum takes the clipped value. That value no longer depends on the weights, so its gradient is zero: this token has been pushed enough for this batch. Likewise a wrong answer's token already down to 0.6 of its old probability: the minimum is the clipped minus 0.28, and the push stops. In our toy, each batch is used for one step only, so rho is exactly one, and the gradient is simply the advantage times the gradient of the log-probability.
Repeat that over thousands of problems. Pass at one, the chance that a single sample is right, climbs from about sixty percent to nearly a hundred. But look at pass at eight, the chance that at least one of eight samples is right. It barely moves: it was already near the top. In this toy, reinforcement learning didn't teach the model anything new. It made it reliable at what it could already sometimes do. Whether that also holds at the frontier is debated: a 2025 study found the same pattern in large models, while others find that prolonged RL discovers genuinely new strategies.
And notice what happens late in training: most groups are all correct, like our 478 plus 356, which now gets eight out of eight. Every advantage is zero, and those groups teach nothing. Refinements like DAPO's dynamic sampling filter them out, alongside other tweaks to the clipping and to how the loss is averaged.
Back to pass at eight: why did it barely move? If each sample is right with probability p, all k samples fail with probability one minus p, to the k. At the start, the average sample was right 61 percent of the time. If every problem were average, pass at eight would be one minus 0.39 to the eighth: 99.95 percent. The measured 98.8 is a little lower, because failures cluster on the hard problems, like 478 plus 356, where one sample in eight was right. There, pass at eight is one minus seven eighths to the eighth: 66 percent. RL raised p on exactly those problems, and pass at one followed. Pass at eight was already near its ceiling.
At frontier scale, this is how reasoning models are made. DeepSeek-R1-Zero applied it directly to a base model, with just two rewards: is the answer correct, and is the format right? Its score on the AIME 2024 math competition rose from 15.6 percent to 71. Its answers grew from hundreds of tokens to thousands, as it learned on its own to re-check its work. In one transcript it stops and writes: wait, wait. Wait. That's an aha moment I can flag here.
Today's frontier RL goes further: long, multi-step tasks with tools, in sandboxes. Fixing real software issues, driving a terminal, browsing the web. DeepSeek-V3.2 synthesized more than eighteen hundred environments, and spent over ten percent of its pretraining compute on post-training. Generating those long rollouts dominates the cost: in OLMo 3's runs, the learner spent three quarters of its time waiting for data. So generation and training run on separate GPUs, asynchronously, with fresh weights streamed to the generators as training goes.
And reinforcement learning finds loopholes. If a test can be gamed, a model will eventually game it, like a prime checker that simply memorizes the test cases. Anthropic reported in 2025 that models which learned to cheat in real coding environments generalized to broader bad behavior. Building environments that can't be gamed is now a central part of the job.
What it establishes: RL with verifiable rewards (final answers, unit tests; reward 1 or 0). GRPO: sample a group, advantage = (r − mean)/std, no critic or reward model. RL raises pass@1 but not pass@k (debated at scale); groups where every answer agrees carry no signal (DAPO). DeepSeek-R1-Zero. Agentic RL with sandboxes and asynchronous rollouts (schematic). Reward hacking (illustrative).; Real data on screen: A real miniature: a 3-layer pocket model with 334,944 parameters, pretrained on 384,000 three-digit additions, 40% of them with every carry dropped (347+285 = 0632 vs 0522). Its real group of 8 answers to 478+356: one 834 (A = +2.47), five 724, two 824 (A = −0.35). On held-out problems over 120 GRPO steps (32 prompts × 8): pass@1 goes from 61% to 97% while pass@8 stays flat near the top (99% → 100%); groups where all 8 agree pass 50%; at the end, 834 eight times out of eight. Quoted: R1-Zero AIME 2024 15.6% → 71.0%, the "aha moment" line; DeepSeek-V3.2 > 1,800 environments and > 10% of pretraining compute; OLMo 3's learner waits for rollouts 75% of the time.
18The whole pipeline2 min
Before release, the model is evaluated: on hard benchmarks in science, math and coding, on long agentic tasks, and on safety tests, all written up in a system card. Benchmarks are a moving target: they saturate, and they leak into training data. In February 2026, OpenAI stopped reporting the popular SWE-bench Verified because of contamination.
So here is the whole pipeline. Billions of crawled pages, filtered and deduplicated down to tens of trillions of tokens. A recipe chosen with scaling laws, today usually a sparse mixture of experts, trained with Muon or AdamW in eight- or even four-bit arithmetic. Tens of thousands of GPUs, coordinated by four kinds of parallelism, and kept alive through failures every few hours. Then fine-tuning, preferences and reinforcement learning, which now takes a substantial share of the compute. And finally, the assistant.
And our pocket versions? The largest model we trained had about three million parameters, against up to 2.8 trillion at the frontier. All of our training runs together took less than ten to the fifteen operations; the largest frontier run is estimated at around ten to the twenty-seven. Four CPU cores, against a hundred thousand GPUs. Yet the curves have the same shapes.
Almost everything in this video comes from open-weight labs and open-source projects; the leading closed labs publish very little about how their models are trained. But the shape of the pipeline has been stable for years: get the data right, choose the size with scaling laws, keep the run stable across thousands of machines, and then teach the model with feedback. And more of it is open than ever. AI2's OLMo 3 releases every dataset and checkpoint; nanochat trains a GPT-2-grade chat model for under a hundred dollars; Hugging Face's playbooks write down the hard-won lessons. If you want to know how these models are made, you can run the whole thing yourself, at whatever scale you have.
What it establishes: Evaluation before release (capability benchmarks, safety tests, system card; contamination). The whole pipeline in one picture. Pocket scale vs frontier scale. The four lessons, recapped with mini-charts. Most of what is known comes from open-weight labs; open end-to-end projects.; Real data on screen: Read from the cached runs: largest pocket model 2.9M parameters (the 8-expert MoE) vs up to 2.8T (Kimi K3); 30M tokens in one run vs 33T (DeepSeek-V4); all pocket training 6.6 × 10¹⁴ vs ~10²⁷ FLOPs; 4 CPU cores vs 100,000+ GPUs. Recap charts redrawn from the funnel, IsoFLOP, stability and RL data. Quoted: OpenAI stopped reporting SWE-bench Verified (Feb 2026); pipeline notes (13% of pages survive, 15–36T tokens, 10²⁵–10²⁷ FLOPs, 10⁴–10⁵ GPUs).
Notes and sources
Sources
Fact-check notes and sources
Status: as of October 8, 2026. Closed labs (OpenAI, Anthropic, Google DeepMind, xAI) publish almost
nothing about how their models are trained; the recipes on screen come from open-weight labs' reports.
Numbers marked real run were computed for this video by compute.py; everything else is quoted.
Part 1 – The data
- Common Crawl CC-MAIN-2026-39 (September 2026): 2.17 billion pages, 105.92 TiB compressed, 100,000 WARC / WAT / WET files each (crawl statistics page, https://data.commoncrawl.org/crawl-data/CC-MAIN-2026-39/index.html). We downloaded WET files 0, 12500, …, 87500 (8 files, 169,783 pages) and the first 400 MiB of WARC file 0 (10,498 HTML responses). The WARC is the raw twin of the first WET file.
- FineWeb: Penedo et al., The FineWeb Datasets: Decanting the Web for the Finest Text Data at Scale
(NeurIPS 2024, arXiv 2406.17557) and the FineWeb blog. Pipeline as in
datatrove/examples/fineweb.py: URL filter → Trafilatura(favour_precision) → fastText language ID (English, > 0.65) → Gopher repetition → Gopher quality → C4 (without the terminal-punctuation rule) → FineWeb rules → per-dump MinHash (5-grams, 14 × 8). 15T tokens from 96 dumps at release. WET text "keeps too much boilerplate" and trained worse models. Global dedup of 2013-48 removed ~94% of tokens and the kept data was "actually worse". Filters run here are datatrove's own code (v0.10.1, defaults;LanguageFilter(languages=["en"])because current datatrove keeps every language by default). Note: datatrove's defaults differ slightly from the papers in two places (FineWeb's duplicated-line character ratio is 0.01 in code vs 0.1 in the paper; the C4 filter's sentence/word minimums are 5/3 in code vs 3/5 in C4) – the video uses the code. - URL blocklist: 4,558,939 domains and 19,586 URLs in datatrove's integrated list (measured by counting).
- Gopher rules: Rae et al. 2021 (arXiv 2112.11446), Table A1 and Sec. A.1.1. C4: Raffel et al. 2020.
- MinHash LSH: Broder 1997; banding P(s) = 1 − (1 − s^r)^b. Our implementation uses FineWeb's parameters (5-grams, 14 bands × 8 rows) with a SplitMix64 hash family; estimates checked against exact Jaccard (mean error < 10⁻⁴ on 300 random pairs).
- FineWeb-Edu: Llama-3-70B-Instruct annotated 500k samples (0–5); classifier on Snowflake-arctic-embed-m
trained on 450k; threshold 3 keeps 1.3T tokens (removes 92%); 6,000 H100 GPU-hours to score 15T tokens;
matches C4/Dolma MMLU "with 10x fewer tokens". Classifier:
HuggingFaceFW/fineweb-edu-classifier(run here). - Nemotron-CC: Su et al. 2024 (arXiv 2412.02595): 6.3T tokens = 4.4T real + 1.9T synthetic (rephrasing and QA generation with Mistral NeMo 12B).
- Kimi K2 rephrasing: Kimi K2 report (arXiv 2507.20534): SimpleQA 23.76 (raw, 10 epochs) → 28.94 (10 rephrasings, 1 epoch).
- OLMo 3: Ai2, OLMo 3 (arXiv 2512.13961): quality-aware upsampling capped at 7×; Dolma 3 mix 5.93T; Dolmino mid-training 100B tokens; Think SFT 2,268,468 prompts for the 7B and 2,253,916 for the 32B (~45B tokens); "our learner spends 75% of the time waiting for data" in RL.
- Llama 3: Llama Team, The Llama 3 Herd of Models (arXiv 2407.21783): mix ≈ 50% general knowledge, 25% math and reasoning, 17% code, 8% multilingual; 15.6T tokens (405B); annealing raised Llama 3 8B GSM8K by 24.0% and MATH by 6.4%; IsoFLOP experiments up to 10²² FLOPs predicted 402B parameters on 16.55T tokens; 16,384 H100s with TP 8 × CP 1 × PP 16 × DP 128, ~400 TFLOPs/GPU, 41% BF16 MFU (Table 4); 466 job interruptions in 54 days, 419 unexpected, ~78% attributed to hardware (Table 5; the video shows the percentages as printed. Note the paper's "Faulty GPU" row is internally inconsistent: 148 of 419 is 35.3%, but 30.1% is printed; every other row matches count / 419); power swings "on the order of tens of megawatts"; > 90% effective training time.
- Tokens per model: DeepSeek-V3 14.8T (arXiv 2412.19437); Kimi K2 15.5T; Qwen3 36T (arXiv 2505.09388); GLM-5 28.5T (arXiv 2602.15763); DeepSeek-V4-Pro 33T (arXiv 2606.19348, April 2026).
- Tokenizers: GPT-2 50,257; Llama 3 128,256; Gemma 3 262,208; Qwen3 151,669; gpt-oss 201,088.
Ours: byte-level BPE, 2,048 tokens, trained with Hugging Face
tokenizerson FineWeb-Edu (karpathy/fineweb-edu-100b-shuffle, shards 0–1); 168.2M training tokens, 2.97 bytes per token.
Part 2 – The recipe
- C ≈ 6ND: Kaplan et al. 2020 (arXiv 2001.08361). Our FLOP count adds attention (6 · layers · seq · d / 2 per token) to 6N on the matrices each token multiplies through (body + unembedding).
- Chinchilla: Hoffmann et al. 2022 (arXiv 2203.15556): > 400 models, 70M–16B parameters, 5–500B tokens; parametric fit L = E + A/N^α + B/D^β; ≈ 20 tokens per parameter. The heat map and the worked optimum use Besiroglu et al.'s re-estimate (Epoch AI, Chinchilla Scaling: A replication attempt, arXiv 2404.10102, Table 1: E 1.8172, A 482.01, B 2085.43, α 0.3478, β 0.3658), not the published Eq. 10 values (E 1.69, A 406.4, B 410.7, α 0.34, β 0.28): with the rounded published values the formula's optimum is ≈ 70–90 tokens per parameter, inconsistent with the paper's own Approaches 1–2 and with Chinchilla itself; the re-estimate gives 72B parameters on 1.33T tokens (18 per parameter) at Chinchilla's budget of 5.76 × 10²³ FLOPs; Chinchilla 70B on 1.4T tokens beat Gopher 280B. GPT-3: 175B parameters, 300B tokens (Brown et al. 2020).
- Overtraining: Llama 3 8B trained on 15T tokens (Meta blog, Apr 2024) = 1,875 tokens per parameter; tokens per active parameter: DeepSeek-V3 ≈ 400, Qwen3-235B-A22B ≈ 1,640 (arithmetic).
- Architectures: DeepSeek-V3: 671B total / 37B active, 256 routed + 1 shared experts, top-8, auxiliary- loss-free balancing with bias speed γ = 0.001 (arXiv 2412.19437, and Wang et al. arXiv 2408.15664). Kimi K2: 1.04T / 32.6B, 384 experts, top-8, MuonClip with τ = 100, "zero loss spike" over 15.5T tokens. Kimi K3: 2.8T total, 16 of 896 experts, ~3:1 linear (KDA) to full attention, chose cosine over WSD (arXiv 2607.24653, July 2026). Qwen3.5-397B-A17B: 15 × (3 Gated DeltaNet + 1 gated attention). DeepSeek-V3.2 sparse attention: top-2048 tokens per query (arXiv 2512.02556).
- Muon: K. Jordan et al., https://kellerjordan.github.io/posts/muon/ and
KellerJordan/Muon(quintic Newton–Schulz, coefficients (3.4445, −4.7750, 2.0315), 5 steps). Moonlight (Liu et al., arXiv 2502.16982): update RMS matched to AdamW (0.2·√max(A, B)), "only requires about 52% training FLOPs". GLM-4.5/5, DeepSeek-V4 (Muon with AdamW for embeddings, head and norms), Kimi K3 (per-head Muon) use Muon variants. Wen et al., Fantastic Pretraining Optimizers and Where to Find Them (arXiv 2509.02046): speedup 1.4× at 0.1B, 1.1× at 1.2B. - Schedules: WSD: MiniCPM (arXiv 2404.06395); Hägele et al. 2024 (arXiv 2405.18392); river valley: Wen et al. 2024 (arXiv 2410.05192). DeepSeek-V3: 2.2e-4 constant to 10T tokens, cosine decay over 4.3T; batch 3,072 → 15,360 sequences. Llama 3 405B: cosine; last 40M tokens annealed to 0; Polyak averaging.
- Precision: OCP MX spec (32-element blocks, E8M0 scales); FP8 formats (Micikevicius et al. 2022). DeepSeek-V3: FP8 with 1 × 128 activation tiles and 128 × 128 weight blocks, FP32 promotion every 128 elements, relative loss error < 0.25% vs BF16. NVFP4: NVIDIA, Pretraining LLMs with NVFP4 (arXiv 2509.25149): 16-element blocks with E4M3 scales + FP32 tensor scale, random Hadamard transforms, stochastic rounding. Nemotron 3 Ultra (arXiv 2606.15007): 550B total / 55B active, 20T tokens, pretrained in NVFP4 with the final ~15% of layers in higher precision; two divergences, the first traced to BF16 gradient accumulation. Throughput: H100 SXM 989 TFLOP/s BF16 and 1,979 FP8 dense; B300 15 PFLOP/s NVFP4 dense (NVIDIA datasheets / Blackwell Ultra blog).
- Stability: PaLM (Chowdhery et al. 2022): ~20 spikes; restart ~100 steps earlier and skip 200–500 batches; z-loss 10⁻⁴·log²Z. OPT-175B (Zhang et al. 2022): 35+ manual restarts. Wortsman et al., Small-scale proxies for large-scale Transformer training instabilities (arXiv 2309.14322). QK-norm: Dehghani et al. 2023; used by Qwen3, OLMo 2/3, GLM-4.5. DeepSeek-V4: SwiGLU clamping and "Anticipatory Routing" after a detected spike.
Part 3 – Scaling out
- 16 bytes per parameter, ZeRO stages and the 7.5B / 64-GPU example (120 → 31.4 → 16.6 → 1.9 GB): Rajbhandari et al., ZeRO (arXiv 1910.02054). Ring all-reduce: 2(N−1)/N × size per GPU.
- Tensor parallelism: Shoeybi et al., Megatron-LM (arXiv 1909.08053): two all-reduces forward, two backward per layer. NVLink4 on H100: 900 GB/s total (450 GB/s each way); ConnectX-7 400 Gb/s ≈ 50 GB/s.
- Pipelines: bubble (p−1)/(m+p−1) (Narayanan et al. 2021); timelines on screen are computed by an exact
dependency simulator in
s13_parallelism.py. Zero Bubble (Qi et al., arXiv 2401.10241); DualPipe (deepseek-ai/DualPipe). DeepSeek-V3: 2,048 H800s, PP 16 (DualPipe), EP 64 across 8 nodes, ZeRO-1, no TP. - Reliability: Kokolis et al. (Meta), Revisiting Reliability in Large-Scale Machine Learning Research Clusters (arXiv 2410.21680): MTTF 47.7 days at 8 GPUs, 7.9 h at 1,024; projected 1.8 h at 16,384 and 0.23 h at 131,072. Gemini Team 2023 (arXiv 2312.11805): redundant in-memory copies raised goodput 85% → 97%; silent data corruption expected "every week or two".
Part 4 – Post-training
- Chat template: Qwen3-0.6B's tokenizer, rendered with
apply_chat_template(real tokens). Base vs chat outputs: Qwen3-0.6B-Base and Qwen3-0.6B, greedy, 48 new tokens (real outputs). - SFT data: InstructGPT (Ouyang et al. 2022) ~13k demonstrations; LIMA (Zhou et al. 2023) 1,000 examples; Tülu 3 (Lambert et al., arXiv 2411.15124) 939,344 prompts; OLMo 3 Think SFT 2,268,468 prompts. DeepSeek-R1-Distill-Qwen-32B 72.6% AIME 2024 vs 47.0% for RL on Qwen-32B-Base (R1 paper v1, Table 6).
- Preferences: Bradley & Terry 1952; InstructGPT RLHF with KL penalty; DPO (Rafailov et al., arXiv 2305.18290); Constitutional AI (Bai et al., arXiv 2212.08073); reward-model overoptimization (Gao, Schulman & Hilton, arXiv 2210.10760). The Goodhart plot is our own best-of-n simulation (heavy-tailed proxy error, Student-t with 3 degrees of freedom), plotted against √KL with KL = log n − (n−1)/n.
- RLVR: GRPO (DeepSeekMath, arXiv 2402.03300); DeepSeek-R1 (arXiv 2501.12948): R1-Zero AIME 2024 pass@1 15.6% → 71.0% (v1; 77.9% in the Nature 2025 version), the "aha moment" quote; DAPO (arXiv 2503.14476): clip-higher, dynamic sampling, token-level loss; Yue et al., Does Reinforcement Learning Really Incentivize Reasoning Capacity in LLMs Beyond the Base Model? (arXiv 2504.13837); ProRL (arXiv 2505.24864). DeepSeek-V3.2: post-training budget > 10% of pretraining, > 1,800 synthesized environments. Reward hacking: MacDiarmid et al., Natural Emergent Misalignment from Reward Hacking in Production RL (Anthropic, arXiv 2511.18397). The prime-checker code is illustrative.
- Evaluation: OpenAI stopped reporting SWE-bench Verified on Feb 23, 2026, citing contamination (https://openai.com/index/why-we-no-longer-evaluate-swe-bench-verified/).
Context
- Training compute data: Epoch AI, Data on AI models (CC BY 4.0), https://epoch.ai/data/ai-models,
notable_ai_models.csvretrieved Oct 8, 2026. Values are Epoch's estimates, not lab disclosures; e.g. GPT-6 Astra (Sep 2026) 1e27 FLOP ("Likely"; OpenAI said only that it was its largest run and the first pretrained on more than 100,000 GPUs at its Stargate site in Texas, Fortune, Sep 3, 2026), Grok 4 5e26 ("Speculative"), Llama 3.1-405B 3.8e25 ("Confident"). The ×4.8/year line is a least-squares fit to Epoch's "frontier" models since 2018 (Epoch's own estimate: 4–5×/year). - Open end-to-end projects: Karpathy,
nanochat(GPT-2-grade model for ~$48–100 on one 8×H100 node); Ai2 OLMo 3 (all data, code and checkpoints); Hugging Face, The Smol Training Playbook (2025) and The Ultra-Scale Playbook (2025).
What is computed and built
Each chapter has a beat that evaluates its central formula with numbers, line by line. Numbers come from the
cached runs, from compute.py's math item, or from the cited reports, and each one stated in the narration is
asserted at render time. Illustrative inputs are labeled on screen.
| # | Formula on screen | Numbers |
|---|---|---|
| 3 | Gopher quality rules, one by one | A real programming-puzzle page the funnel removed, with datatrove's own statistics: passes 6 of 7 rules; fails "words containing a letter ≥ 80%": 2,037 / 2,756 = 73.9%. |
| 4 | J(A, B) = |A ∩ B| / |A ∪ B|; P(minima match) = J; 1 − (1 − s⁸)¹⁴ | Two real for-sale pages: J = 0.78, 86 / 112 minima agree (0.77); P(0.8) = 92%, P(0.5) ≈ 5%. |
| 5 | BPE: count adjacent pairs, merge the most frequent, repeat | Recounted over the tokenizer's real training text (56.6M words, 660,950 distinct): ␣t 6,071,917 → ␣a, he, in, re, ␣the, on, er (8 merges, matching the trained tokenizer); "the cat sat on the mat": 22 bytes → 8 tokens. |
| 6 | C = 6ND; L(N) = E + A N^−α + B (6N/C)^β, dL/dN = 0 ⇒ N_opt = G (C/6)^(β/(α+β)) | Llama 3.1 405B: 6 × 405×10⁹ × 15.6×10¹² = 3.79×10²⁵ (Epoch AI: 3.8×10²⁵). Chinchilla's budget 5.76×10²³: β/(α+β) = 0.513, G = 0.120 → N = 72B, D = 1.33T, 18 tokens per parameter. |
| 7 | g_i = s_i / Σ_TopK s_j; y = Σ g_i E_i(x); L_aux = α E Σ f_i P_i; b_i ← b_i + γ sign(f̄ − f_i) | Router scores 0.38, 0.31 → weights 0.55, 0.45 (illustrative). DeepSeek-V3: 6 × 37B vs 6 × 671B per token, 18× less. Our MoE runs' real loads: E Σ f_i² = 1.84 unbalanced, 1.07 with the auxiliary loss (minimum 1); final biases about ±0.3 at γ = 0.001. |
| 8 | Adam's m̂, v̂, m̂/√v̂ (β₁ 0.9, β₂ 0.95); p(σ) = 3.4445σ − 4.7750σ³ + 2.0315σ⁵ | Gradients 4, 5, 3 and 0.04, 0.05, 0.03 give identical steps 1.000, 0.997, 0.974. p(0.03) = 0.103; σ₀ = 0.9, 0.3, 0.03 through 5 iterations all end between 0.68 and 1.12. |
| 9 | Cosine: η = η_min + ½(η_max − η_min)(1 + cos πp); WSD | At T/2 with 5% warmup: p = 0.474, cos(0.474π) = 0.083, η = 0.587 η_max (η_min = 0.1 η_max). |
| 10 | E4M3: x = (−1)^s 2^(e−7)(1 + m/8); E2M1: 2^(e−1)(1 + m/2); NVFP4 two-level scales | 0 0111 011 = 1.375; 448 and 6 are the largest values. 16 real values of GPT-2's residual stream at " Paris": s_tensor = 2883 / (448 × 6) = 1.072, block scale 1.374 → 1.375 (E4M3), each value divided, rounded to FP4, multiplied back: 9.6% error. |
| 11 | |q·k| ≤ |q||k| (Cauchy–Schwarz); QK-norm makes |q̂| = √d, so |q̂·k̂|/√d ≤ √d with unit gains | Head dimension 32: bound √32 = 5.66; measured 4.8 at learning rate 3×10⁻⁴, at most 9.1 once the learned gains grow; 10,045 without QK-norm. Two scores 45 apart (illustrative): softmax = (1, 2.9×10⁻²⁰), and the gradient p(1 − p) ≈ 0. |
| 12 | ZeRO: 16Ψ, 4Ψ + 12Ψ/N, 2Ψ + 14Ψ/N, 16Ψ/N | Ψ = 7.5B, N = 64: 120 / 31.4 / 16.6 / 1.9 GB per GPU (ZeRO-1: 30 + 1.41). |
| 13 | MFU = achieved / peak; T = 6ND / (n_GPU × FLOP/s); ring all-reduce 2(N−1)/N | Llama 3.1 405B on 16,384 H100s at 400 TFLOP/s: MFU 40%, 5.8×10⁶ s ≈ 67 days = 26.3M GPU-hours (Meta reports 30.84M); 5.9 s per 16M-token step; 6.3 GB of gradients per GPU, 12.6 GB moved per all-reduce. |
| 14 | waste(τ) = δ/τ + τ/2M ⇒ τ* = √(2δM) (Young–Daly) | M = 2.8 h (Llama 3: 466 stops in 54 days). δ = 1 min: τ* = 18.3 min, 10.9% lost; δ = 10 s: 7.5 min, 4.5% (write times illustrative). |
| 15 | L_SFT = −(1/|A|) Σ_{t∈A} log p(x_t | x_<t) | The real assistant tokens of the example conversation, scored by Qwen3-0.6B-Base and Qwen3-0.6B: mean 2.12 vs 0.52 nats. |
| 16 | P(A ≻ B) = σ(r_A − r_B); L = −log σ(r_A − r_B); L_DPO = −log σ(β[log-ratio_w − log-ratio_l]) | r = 1.3, 0.4: σ(0.9) = 0.711, L = 0.341, ∂L/∂r_A = −0.289 (gap 3: 0.049, slope −0.047). DPO, β = 0.1, log-ratios +2.0 and −1.0: σ(0.30) = 0.574, L = 0.554; every pair starts at log 2 = 0.693 (illustrative). |
| 17 | A_i = (r_i − mean) / std; PPO/GRPO clip min(ρA, clip(ρ, 0.8, 1.2) A); pass@k = 1 − (1 − p)^k | The real group for 478 + 356: mean 0.125, std √0.125 = 0.354, A = +2.47 and −0.35, ΣA = 0; 4 of 8 right → ±0.94, all 8 → 0. ρ = 1.3: min(3.21, 2.96) = 2.96; ρ = 0.6, A = −0.35: −0.28 (clipped, no gradient). pass@8 at p̄ = 0.61: 99.95% if every problem were average vs 98.8% measured; p̂ = 1/8 → 66%. |
Method notes (so the charts are not over-read)
- Pocket runs are tiny and lightly tuned: 51K–2.9M parameters in total, at most 30M tokens, one seed each, learning rates from short test runs (AdamW 3.5×10⁻³·(128/d)^¼, Muon 6×10⁻³). Differences of a few hundredths in loss are within run-to-run noise.
- IsoFLOP fits: a parabola in log N through the 5 runs around each budget's minimum (with every run, the 10¹² fit is dragged to the edge of the sweep). N counts the matrices each token multiplies through (body + unembedding), not the input embedding. Our exponent (0.76) is close to Kaplan et al. 2020 (0.73) and above Chinchilla (≈ 0.5); Pearce & Song 2024 (arXiv 2406.12907) and Porian et al. 2024 (arXiv 2406.19146) trace such gaps to parameter counting, last-layer cost, warmup and tuning at small scale.
- AdamW vs Muon is compared while both runs hold their peak learning rate (the WSD stable phase): Muon only reaches AdamW's final loss during its own cooldown (at 82% of the tokens), which would mix two effects.
- Schedules: one 0.5M-parameter model. WSD's lead here (0.12 at full length, 0.28 at half length) is larger than in published comparisons, which find the two about level (Hägele et al. 2024).
- Stability: 800K tokens per run, gradient clipping at 1.0 (never reached), no run diverged. The "largest attention score" is the maximum pre-softmax q·k/√d over all layers and heads on the training batch, probed every 10 steps.
- MoE loads: the share of top-2 routing slots each expert receives in the last layer, averaged over the final 20 logs (100 steps).
- WET vs Trafilatura: the same records (WET file 0 is the text twin of WARC file 0); a WET line counts as kept when it appears verbatim as a line of Trafilatura's output.
What is computed and builtReal footage (compute.py)
| Item | What | Used in |
|---|---|---|
funnel |
The first 400 MiB of WARC file 0 of CC-MAIN-2026-39 (10,498 HTML responses) through the whole FineWeb recipe with datatrove's own filters: URL blocklist → Trafilatura → fastText English > 0.65 → Gopher repetition → Gopher quality → C4 → FineWeb rules. Per-stage counts and bytes, rejection reasons, example pages, language counts; the 1,363 survivors go on to edu. |
2, 3, 5 |
corpus |
WET files 0, 12,500, …, 87,500 (8 of 100,000; 169,783 pages of Common Crawl's own text extraction) through the same filters from the URL stage on, in 4 processes. | 4 |
wet |
Common Crawl's own extracted text (WET file 0, the text twin of the WARC the funnel read) for all 1,363 surviving pages: total bytes vs Trafilatura's, and the recipe page line by line, marked kept / boilerplate. | 2 |
dedup |
MinHash LSH over that corpus with FineWeb's settings: 5-word shingles, 14 bands × 8 rows = 112 hashes (SplitMix64 hash family). Cluster sizes, pages from the biggest clusters, estimated vs exact Jaccard for one pair from each of the 40 biggest clusters. | 4 |
edu |
HuggingFaceFW/fineweb-edu-classifier on 400 seeded-random survivors of funnel (first 512 tokens). |
5 |
tokenizer |
Byte-level BPE with 2,048 tokens (including a <|doc|> separator), trained with Hugging Face tokenizers on 60,000 FineWeb-Edu documents (karpathy/fineweb-edu-100b-shuffle, shards 0–1). Everything except 2,000 held-out documents is encoded to uint16 (168.2M training tokens, 2.97 bytes per token). |
5; the text of every pocket run |
sweeps |
Every pretraining run below in one pool: 25 + 2 + 5 + 12 + 3 = 47 runs (≈ 16 CPU-hours), longest first, four single-threaded runs side by side. Each run is cached on its own in runs/<name>.json, so an interrupted sweep resumes. |
6–9, 11; 1 and 18 total their FLOPs |
isoflop |
PocketGPT (explainer/lm/pocket.py: RMSNorm, RoPE, SwiGLU, no biases; vocabulary 2,048, context 256, batch 16). Budgets of 10¹² (7 sizes), 3×10¹² (7), 10¹³ (6) and 3×10¹³ (5) FLOPs over (layers, width) from (1, 12) to (5, 160), chosen so each budget's valley has two walls: 25 runs. Each trains on budget ÷ (6N + attention) tokens with AdamW and a cosine schedule, peak learning rate 3.5×10⁻³·(128/d)^¼. |
6 |
optim |
AdamW (3.5×10⁻³) vs Muon (6×10⁻³; AdamW for embeddings, norms and the output layer) on L4 d128 (≈ 1M parameters), 12M tokens, WSD with a 30% cooldown, same seed and batches. | 8 |
schedule |
L3 d96 (≈ 0.5M parameters), 5M tokens: cosine and WSD (20% cooldown) at full length, WSD at 50% and 75% length (the cooldown branches, starting at 40% and 60%), cosine at 50%: 5 runs. | 9 |
stability |
L4 d128, 800,000 tokens per run, peak learning rates 3×10⁻⁴, 10⁻³, 3×10⁻³, 10⁻², 3×10⁻², 10⁻¹, without and with QK-norm: 12 runs. The largest attention logit is probed every 10 steps. | 11 |
moe |
L4 d128 with 8 experts per layer, top-2, 2M tokens. Balancing: none / Switch-style auxiliary loss / DeepSeek-V3 bias; per-expert load logged every 5 steps: 3 runs. | 7 |
muon_svd |
An L4 d128 pocket model trained for 400 steps (1.6M tokens), then one real gradient of blocks.2.mlp.up.weight (336 × 128): its singular values, those of the AdamW update, and those after each of 5 Newton–Schulz iterations (3.4445, −4.7750, 2.0315). |
8 |
precision |
GPT-2 small's residual stream after 6 blocks on a 45-token paragraph (45 × 768), rounded to the nearest representable value under BF16, FP8 per tensor, FP8 1 × 128 tiles, MXFP8, FP4 per tensor, MXFP4 (32-element blocks, E8M0 scales) and NVFP4 (16-element blocks, E4M3 scales + an FP32 tensor scale). | 10 |
chat |
Qwen/Qwen3-0.6B's chat template on a 3-message conversation (token pieces, IDs, prompt length for the loss mask), and greedy answers to "Where is the Eiffel Tower?" from Qwen3-0.6B-Base (plain text) and Qwen3-0.6B (chat template, thinking off), fp32 on CPU. |
15 |
toy_rl |
A 3-layer, width-96 PocketGPT over 13 characters, pretrained for 3,000 AdamW steps × 128 three-digit additions in which 40% of the answers drop every carry (loss on answer tokens only). Then GRPO: 120 steps × 32 prompts × 8 samples, reward = exact answer. Every 10 steps: pass@1, pass@8 and greedy accuracy on 400 held-out problems, and the group for 478 + 356 at steps 0 and 120. | 17 |
goodhart |
A best-of-n simulation with no model: n from 1 to ≈ 20,000 (log-spaced); true quality g ~ N(0, 1), proxy g + 0.6·t₃; KL = log n − (n−1)/n. | 16 |
epoch |
Epoch AI's Data on AI models (notable_ai_models.csv, CC BY 4.0): every model with a training-compute estimate. |
1 |
Scenes never train or run a model; they load() the cached JSON/NPZ in
.cache/frontier/ (Hook and Outro also total the per-run files in runs/).
Measured numbers the narration states are asserted against the data at render
time (e.g. assert agree == 86 in Dedup, assert (right, wrong) == (834, 724)
in RL), so a rerun that disagrees with the script fails loudly instead of
silently contradicting the voice-over.
Chapter notes
| # | Scene | What it establishes | Real data on screen |
|---|---|---|---|
| 1 | Hook |
An answer streams back token by token (schematic). How much compute notable models used to train, and how fast the frontier grows. Every experiment in the video is a real run, about 10¹¹× smaller. The pipeline map: web → clean data → pretraining → GPU cluster → post-training → assistant. Four-part roadmap. | Epoch AI's compute estimates for notable models since 2012: GPT-2 ≈ 10²¹, GPT-3 > 100× that, GPT-4 ≈ 70× more; Llama 3.1 405B, Grok 4 and GPT-6 Astra circled. A least-squares frontier trend of ×4.8 per year (45 frontier models since 2018). All of this video's pretraining runs together: 6.6 × 10¹⁴ FLOPs, ~10¹¹× below 10²⁶. |
| 2 | RawWeb |
Part 1. Almost everyone starts from Common Crawl (a crawler following links; schematic); one crawl is 100,000 files. A crawled page is mostly markup. Extracting the main text is its own step, and Trafilatura (as in FineWeb) keeps less boilerplate than Common Crawl's own WET text. The web is multilingual; we keep English. | CC-MAIN-2026-39: 2.17B pages, 106 TiB, 100,000 files (one square each); the 8 WET files and 400 MB of WARC we downloaded are circled. A real recipe-blog page: 2,296 lines of HTML with the whole post on line 436; 97.8 KB of HTML → 3.3 KB of text. The 10,498 pages of the WARC: 1.65 GB of HTML → 37 MB of text, drawn as areas. The same recipe page as Common Crawl's WET text (8.7 KB, 195 lines: menu, 4 comments, cookbook ads, a 103-line blog archive) vs Trafilatura (3.3 KB, the recipe); over all 1,363 surviving pages WET text is 2.0× as long. fastText language shares (English 42%). |
| 3 | Filtering |
The FineWeb recipe run stage by stage with FineWeb's own code (datatrove): URL blocklist, extractable text, English (fastText > 0.65), Gopher repetition, Gopher quality, C4 line rules, FineWeb's three rules. The rules are blunt (one false positive shown). | Pages surviving each stage, 10,498 → 1,363. Real rejected pages: a redirect-only page, a forum index, a login form, spun ad copy with template braces, a course-handbook menu. A programming puzzle dropped by mistake (gopher_below_alpha_threshold). 13% of pages and about a third of a percent of the bytes survive. Quoted: 4.56M blocked domains; FineWeb = 96 crawls → 15T tokens. |
| 4 | Dedup |
Why copies hurt (wasted compute, memorization). 5-word shingles and Jaccard similarity. MinHash: P(minima match) = J, so 112 minima are a fingerprint. LSH banding (14 × 8) and its S-curve 1 − (1 − s⁸)¹⁴. Deduplicate each crawl separately, not globally. | The biggest cluster in the 8 WET files: 41 "[domain] is for sale" pages. Two GoDaddy for-sale pages: shingle Venn counts, J = 0.78; 86 of 112 minima agree (estimate 0.77). P(0.8) = 92%, P(0.5) ≈ 5%. 8,457 → 8,208 pages (after the filters), ≈ 3% removed in 114 clusters (for-sale 41, access-denied 24, default hosting 7). Quoted: FineWeb's cross-crawl dedup removed 90% of the oldest crawls and trained worse models. |
| 5 | Quality |
Model-based filtering, animated: an LLM grades pages, a 110M-parameter classifier imitates it, scores the crawl, keep ≥ 3 (grades illustrative). Keep the best and rewrite the rest (four panels). Data mixtures and annealing. How big datasets are. BPE tokenizers. | FineWeb-Edu's own classifier on 400 random pages of our 1,363 survivors: scores 0–5 (55 / 253 / 63 / 25 / 4 / 0), 7% score ≥ 3, the top page (3.8) and a typical low one. Our 2,048-token BPE splitting a real sentence; 168M tokens of FineWeb-Edu for the pretraining runs. Quoted: 500,000 graded pages, 6,000 H100 hours; FineWeb-Edu kept 8% (1.3T tokens); Nemotron-CC 1.9T synthetic tokens; Kimi K2 SimpleQA 23.8% → 28.9%; OLMo 3 repeats data ≤ 7×; Llama 3 mix 50/25/17/8%, +24% GSM8K from annealing; Llama 3 15.6T, DeepSeek-V3 14.8T, Kimi K2 15.5T, GLM-5 28.5T, DeepSeek-V4 33T, Qwen3 36T tokens; vocabularies of 128K–260K. |
| 6 | ScalingLaws |
Part 2. C ≈ 6ND (2 operations forward + 4 backward); a fixed budget is a fixed area. IsoFLOP valleys and parabola fits; the compute-optimal N is a power law in C. Chinchilla's loss landscape and ≈ 20 tokens per parameter. Why everyone overtrains (cheaper inference). | Our IsoFLOP sweep: 25 real runs at 10¹², 3×10¹², 10¹³ and 3×10¹³ FLOPs, final validation loss vs model size, parabolas through each valley floor: optimal size 25K, 75K, 174K, 340K parameters, N_opt ∝ C^0.76 (close to Kaplan et al.'s 0.73 at small scale; Chinchilla found ≈ 0.5). A heat map of the Chinchilla loss formula with Besiroglu et al.'s 2024 re-estimate of its coefficients (E 1.82, A 482, B 2,085, α 0.348, β 0.366; the formula, not data). Tokens per (active) parameter: 20 (Chinchilla), 39 (Llama 3.1 405B), 400 (DeepSeek-V3), 1,636 (Qwen3-235B), 1,875 (Llama 3 8B). Quoted: 400+ Chinchilla runs, 70M–16B parameters; GPT-3 175B on 300B tokens; Chinchilla 70B on 1.4T beat the 280B Gopher; Llama 3 IsoFLOPs up to 10²². |
| 7 | Architecture |
The GPT-2 blueprint, refined: RMSNorm, RoPE, SwiGLU, grouped-query or latent attention, QK-norm, no biases. Mixture of experts: a router, top-k, parameters vs compute per token (schematic). Frontier MoEs keep getting sparser. Load balancing: rich-get-richer, an auxiliary loss, DeepSeek-V3's bias. Sparse attention, hybrid linear attention, multi-token prediction, 1M-token context (four schematic panels). | Three real pocket MoE runs (8 experts, top-2; no balancing / auxiliary loss / bias): the share of tokens each expert gets in the last layer, animated over 487 steps; busiest expert 3.0× / 1.3× / 1.1× its fair share (one expert under 1% without balancing); final validation loss 4.876 / 4.820 / 4.868 (the auxiliary loss is ahead in these tiny runs; DeepSeek found the bias ahead at scale). Quoted: DeepSeek-V3 8 of 256 experts + 1 shared, 671B total / 37B active; Kimi K2 8 of 384, 1.04T / 32B; Kimi K3 16 of 896, 2.8T; sparse attention over the top 2,048 tokens; 3 linear layers per full-attention layer. |
| 8 | Optimizer |
Gradient descent zigzags while Adam normalizes each coordinate (computed on ½(25x² + y²)); AdamW. Muon: G = UΣVᵀ → UVᵀ, so every direction takes an equal step; a Newton–Schulz polynomial replaces the SVD. AdamW vs Muon, compared while the learning rate is at its peak. Adoption timeline; a speed-up that shrinks with scale. | Singular values of a real gradient (a 336 × 128 MLP matrix of a pocket model): the top 5 of 128 directions hold 65% of it, the median is 1/47 of the largest; through 5 Newton–Schulz iterations of p(σ) = 3.4445σ − 4.7750σ³ + 2.0315σ⁵ every value ends in 0.6–1.2. AdamW vs Muon on the same ≈ 1M-parameter model and 12M tokens: at the peak learning rate Muon reaches each of AdamW's losses with 55–66% of the tokens (63% at the end of the stable phase); final 3.80 vs 3.61. Speed-ups: ours ≈ 1.6× (lightly tuned) next to Wen et al.'s 1.4× at 0.1B and 1.1× at 1.2B. Quoted: Moonlight ≈ half the FLOPs; Kimi K2 (MuonClip, 1T); GLM-4.5, DeepSeek-V4, Kimi K3. |
| 9 | Schedule |
Warmup; cosine decay vs warmup–stable–decay (WSD); cosine fixes the run length in advance (stop at 50% and the rate is still at 59% of peak). WSD's loss lags, then drops in the cooldown; cooldown branches give a model at every budget. The river-valley picture (computed toy). Real schedules from the labs' reports; batch sizes grow. | Schedule shapes from the training code's own lr_factor. Cosine vs WSD on one pocket model (L3 d96, 5M tokens): WSD lags slightly during the stable phase, then finishes at 4.18 vs cosine's 4.30; WSD cooldown branches from 40% and 60%; the half-length branch (4.59) beats a separate half-length cosine run (4.87). Charts drawn from the reports: DeepSeek-V3 (peak to 10T tokens, cosine to 10% over 4.3T, two low-LR stages), Llama 3 405B (cosine, annealed to 0 over the last 40M tokens), Kimi K3 (chose cosine over WSD), Llama 3's batch 4M → 8M → 16M tokens. |
| 10 | Precision |
Fewer bits → more FLOP/s and less memory. Sign / exponent / mantissa in FP32, BF16, FP8 E4M3 and FP4 E2M1. Every value each format can hold. Scale factors and how many numbers share one. Outliers (massive activations) and block scaling (NVFP4). FP8 and NVFP4 at frontier scale. | Every positive E4M3 value (126, from 2⁻⁹ to 448) and E2M1 value (0.5, 1, 1.5, 2, 3, 4, 6). GPT-2 small's real residual stream after 6 blocks (45 tokens × 768 channels): channel 447 reaches ≈ 2,900 at the first token, a typical entry ≈ 1.2. FP4 with one scale flushes 99.99% of values to zero; NVFP4 (blocks of 16) keeps them at ≈ 12% error. " Paris" (first 64 channels) before and after NVFP4. Quoted: dense PFLOP/s: H100 BF16 0.989, FP8 1.979; B300 FP8 5, NVFP4 15. DeepSeek-V3 FP8 (1 × 128 tiles, within 0.25% of BF16); Nemotron 3 Ultra, 550B on 20T tokens in NVFP4. |
| 11 | Stability |
Loss spikes in big runs, and PaLM's rollback-and-skip fix (illustrative curve). The same instabilities show up in small models at high learning rates. The mechanism: attention scores grow and the softmax goes one-hot. QK-norm. The toolbox: z-loss, clipping, warmup, initialization, MuonClip, DeepSeek-V4's clamping and re-routing. | 12 real pocket runs (800K tokens each; none diverged): final loss vs peak learning rate (3×10⁻⁴ … 10⁻¹), standard vs QK-norm. From 0.003 to 0.03 QK-norm's loss stays at 5.87 while standard attention's rises 5.78 → 5.98 (QK-norm costs a little at the best rate). Largest attention score q·k/√d vs learning rate: 9, 13, 23, 112, 917, 10,045 for standard attention, ≤ 9.1 with QK-norm. Quoted: PaLM ≈ 20 spikes (restart ~100 steps back, skip 200–500 batches); OPT-175B 35+ restarts; Nemotron 3 Ultra 2 divergences; MuonClip caps scores at 100, zero spikes over 15.5T tokens. |
| 12 | Memory |
Part 3. Training state = 16 bytes per parameter; activations and recomputation. Data parallelism. Ring all-reduce: reduce-scatter + all-gather, 2(N−1)/N per GPU. ZeRO-1/2/3 and FSDP shard the state for ~1.5× the communication. | Llama 3.1 405B × 16 bytes = 6.48 TB = 81 H100s just to hold the state; H100 80 GB, B200 192 GB, B300 288 GB. An exact ring all-reduce over 4 GPUs × 4 chunks, ending at [22, 20, 20, 18]. ZeRO for a 7.5B model on 64 GPUs: 120 → 31.4 → 16.6 → 1.9 GB per GPU. |
| 13 | Parallelism |
Tensor parallelism: split by columns (no communication), then by rows (one all-reduce); Megatron-LM's two all-reduces each way, kept inside NVLink. Pipeline parallelism: the bubble, micro-batches, (p−1)/(m+p−1), Zero Bubble, DualPipe. Expert parallelism (all-to-all) and context parallelism (schematic). How real runs combine them. | A worked [1 2] · W₁ (2 × 4) · W₂ (4 × 2) split across 2 GPUs, giving [12 19] both ways. NVLink 450 GB/s vs ~50 GB/s between servers (≈ 9×). Exact pipeline timelines from a dependency simulator (4 stages, backward = 2× forward): idle 75% with 1 batch, 27% with 8 micro-batches. Llama 3.1 405B: 16,384 H100s = TP 8 × PP 16 × DP 128, ≈ 400 TFLOP/s per GPU (41% MFU). DeepSeek-V3: 2,048 H800s, no TP, 16-stage DualPipe, experts over 64 GPUs on 8 nodes. |
| 14 | Operations |
More GPUs mean more failures. What interrupted Llama 3. Checkpoint, fail, restart; goodput. Silent data corruption; the power grid notices. | Meta's measured mean time to failure: 48 days at 8 GPUs, 7.9 h at 1,024; projected 1.8 h at 16,384 and 14 min at 131,072. Llama 3: 466 interruptions in 54 days on 16,384 GPUs, one every 2.8 h (tick positions illustrative). Causes of the 419 unexpected ones: faulty GPU 30.1%, HBM3 17.2%, software 12.9%, network 8.4%, host maintenance 7.6%, SRAM 4.5%, GPU system processor 4.1%. Over 90% of time spent training (Llama 3); 85% → 97% (Gemini). |
| 15 | SFT |
Part 4. A base model completes documents; it is not an assistant. Chat template: one token stream with role and special tokens (here an empty think block). SFT = next-token loss on the assistant's tokens only. Where SFT data comes from; distillation. | Real greedy answers to "Where is the Eiffel Tower?": Qwen3-0.6B-Base writes a quiz ("A. Paris / B. London …", the answer key, the next question); Qwen3-0.6B answers "Paris, France". Qwen3's real chat format for a 3-turn conversation (44 tokens), prompt tokens masked out of the loss. Quoted: InstructGPT ≈ 13,000 demonstrations; LIMA 1,000; Tülu 3 939,344 prompts; OLMo 3 Think ≈ 2.3M prompts, ≈ 45B tokens; R1 distilled into Qwen2.5-32B scores 72.6% on AIME 2024 vs 47.0% for RL. |
| 16 | Preferences |
Judging is easier than writing: pairwise comparisons (illustrative). Reward model and Bradley–Terry, P = σ(r_A − r_B). RLHF: maximize reward minus β·KL to the reference (schematic). Goodhart: over-optimizing a proxy. DPO (no reward model, no RL loop); Constitutional AI. | A best-of-n simulation (true quality g ~ N(0, 1); the reward model sees g plus heavy-tailed error), against √KL: the proxy reward keeps rising while true quality peaks at n ≈ 35, then falls below half its peak. |
| 17 | RL |
RL with verifiable rewards (final answers, unit tests; reward 1 or 0). GRPO: sample a group, advantage = (r − mean)/std, no critic or reward model. RL raises pass@1 but not pass@k (debated at scale); groups where every answer agrees carry no signal (DAPO). DeepSeek-R1-Zero. Agentic RL with sandboxes and asynchronous rollouts (schematic). Reward hacking (illustrative). | A real miniature: a 3-layer pocket model with 334,944 parameters, pretrained on 384,000 three-digit additions, 40% of them with every carry dropped (347+285 = 0632 vs 0522). Its real group of 8 answers to 478+356: one 834 (A = +2.47), five 724, two 824 (A = −0.35). On held-out problems over 120 GRPO steps (32 prompts × 8): pass@1 goes from 61% to 97% while pass@8 stays flat near the top (99% → 100%); groups where all 8 agree pass 50%; at the end, 834 eight times out of eight. Quoted: R1-Zero AIME 2024 15.6% → 71.0%, the "aha moment" line; DeepSeek-V3.2 > 1,800 environments and > 10% of pretraining compute; OLMo 3's learner waits for rollouts 75% of the time. |
| 18 | Outro |
Evaluation before release (capability benchmarks, safety tests, system card; contamination). The whole pipeline in one picture. Pocket scale vs frontier scale. The four lessons, recapped with mini-charts. Most of what is known comes from open-weight labs; open end-to-end projects. | Read from the cached runs: largest pocket model 2.9M parameters (the 8-expert MoE) vs up to 2.8T (Kimi K3); 30M tokens in one run vs 33T (DeepSeek-V4); all pocket training 6.6 × 10¹⁴ vs ~10²⁷ FLOPs; 4 CPU cores vs 100,000+ GPUs. Recap charts redrawn from the funnel, IsoFLOP, stability and RL data. Quoted: OpenAI stopped reporting SWE-bench Verified (Feb 2026); pipeline notes (13% of pages survive, 15–36T tokens, 10²⁵–10²⁷ FLOPs, 10⁴–10⁵ GPUs). |
The visual languageColor legend (consistent across every scene)
| Concept | Color |
|---|---|
| raw web pages, HTML | grey |
| text that survives filtering | teal |
| removed by a filter; wrong answers; negative advantage | red |
| near-duplicates, MinHash | orange |
| quality scores; reward models | gold |
| model size N; weights | blue |
| training tokens D; forward pass; activations | green |
| compute C, FLOPs | yellow |
| learning rate | pale gold |
| AdamW / Muon | light blue / pink |
| experts | lilac |
| sign / exponent / mantissa bits | red / green / blue |
| gradients; backward pass | orange |
| optimizer state | lilac |
| communication between GPUs | yellow |
| pipeline bubble (idle) | dark grey |
| correct answers, positive advantage, assistant tokens | green |
Build the film
python -m videos.ml.frontier.compute # the film's numbers, into .cache/frontier
python tools/build.py frontier # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py frontier Hook # one chapter, silent, with a contact sheet
Scenes: videos/ml/frontier. Setup: see the course page. Source of these notes: the README and the scenes' narration.