Interpretable
Module 1.4 · ~2.5h

Training Dynamics & Scaling

Next-token prediction, scaling laws, emergence debates, and grokking.

You'll be able to
  • Interpret loss in nats/token and fit a power law to loss data
  • Compute Chinchilla-optimal data for a compute budget
  • Describe grokking and what it says about phase changes in training
Learn

One objective, ten thousand GPUs

You now know what a transformer block does. This module is about what happens when you run one for three months. The striking thing is how little the recipe changes: the objective that trains a 100M-parameter toy is the same objective that trains a frontier model. Only the budget moves.

That objective is next-token prediction. Take a document, feed it in, and at every position ask the model for a distribution over the next token. Because of the causal mask, position 5's prediction can't see token 6, so one forward pass over a 4,096-token document yields 4,096 independent training signals at once. Average their cross-entropy losses and you get the number everyone watches:

L=1Tt=1Tlogpθ(xtx<t)\mathcal{L} = -\frac{1}{T}\sum_{t=1}^{T} \log p_\theta(x_t \mid x_{<t})

Term by term: xtx_t is the token that actually came next, pθ(x<t)p_\theta(\cdot \mid x_{<t}) is the model's distribution given everything before it, and the log turns “probability I assigned to the truth” into an additive score. Units are nats per token. This is exactly the cross-entropy from Module 0.2, averaged over positions.

nats/token
The natural-log version of bits/token. Divide by ln20.693\ln 2 \approx 0.693 to get bits. A loss of 2.0 nats is 2.89 bits — the model is as uncertain as if it were picking uniformly among e2.07.4e^{2.0} \approx 7.4 equally good tokens.

Two warnings about comparing loss numbers across models. First, loss depends on the tokenizer: a model with a bigger vocabulary packs more text into each token, so its per-token loss is higher even at equal quality. (Bits-per-byte fixes this and is what careful papers report.) Second, loss depends on the evaluation corpus. “Loss 1.9” means nothing without both.

loss spikewarmupLR decaytokens seen (log) →loss
A real pretraining loss curve, stylized. Log-x, because all the interesting structure is in the early orders of magnitude. Warmup ramps the learning rate up over the first ~1% of steps; a cosine decay brings it down at the end, and that final decay alone is usually worth a few hundredths of a nat. Loss spikes happen; the standard response is to roll back a few thousand steps and skip the offending data.
Key idea
A pretraining run has no curriculum, no labels, and no notion of “helpful.” Every capability you will later find inside the model — grammar, arithmetic, theory of mind, refusal, deception — arrived because it lowered next-token surprise on text. That is the entire causal story of where the weights came from, and it is why interpretability is possible at all: the model is optimised, not designed, but it is optimised for something we can write down.
Learn

Scaling laws: buying loss with compute

Here is the result that turned deep learning into an industry. Plot loss against model size, or against data, or against compute, on log-log axes — and you get a straight line. Over seven orders of magnitude. Kaplan et al. found this in 2020, and it means you can train a set of small models, fit two numbers, and predict the loss of a model a thousand times bigger before you build it.

The modern form is Hoffmann et al.'s three-term fit, and it is worth reading slowly:

L(N,D)=Eirreducible+ANαtoo few params+BDβtoo little dataL(N, D) = \underbrace{E}_{\text{irreducible}} + \underbrace{\frac{A}{N^{\alpha}}}_{\text{too few params}} + \underbrace{\frac{B}{D^{\beta}}}_{\text{too little data}}

NN is parameters, DD is training tokens. EE is the entropy of natural language itself — the surprise no model can remove, because text is genuinely partly unpredictable. The other two terms are penalties: one for being too small to represent the structure, one for not having seen enough text to find it. Both decay as power laws, which is why they look linear on log-log axes and why progress feels smooth and expensive at the same time. Hoffmann's fitted values: E=1.69E = 1.69, A=406.4A = 406.4, B=410.7B = 410.7, α=0.34\alpha = 0.34, β=0.28\beta = 0.28.

Training compute is well approximated by C6NDC \approx 6ND FLOPs — roughly 2 FLOPs per parameter for the forward multiply-accumulate and 4 for the backward pass, at every token. So the real question a lab faces is not “how big?” but: given a fixed C, how should I split it between N and D?

Minimise LL subject to C=6NDC = 6ND and you get a clean answer:

NCβα+βC0.46,DCαα+βC0.54N^{*} \propto C^{\frac{\beta}{\alpha+\beta}} \approx C^{0.46}, \qquad D^{*} \propto C^{\frac{\alpha}{\alpha+\beta}} \approx C^{0.54}

Both exponents are near 12\tfrac{1}{2}: when your budget goes up 100×, you should make the model ~10× bigger and train it on ~10× more data. Kaplan's 2020 analysis had said to grow the model much faster than the data, and the field believed it — GPT-3 is 175B parameters trained on only 300B tokens. Hoffmann's team showed the earlier fit was distorted by a learning-rate schedule that wasn't re-tuned for each run length, then proved the point by training Chinchilla: 70B parameters, 1.4T tokens, same compute as the 280B-parameter Gopher, and better on essentially everything.

Key idea
A model that is too big for its data budget is wasting compute, not just money. The IsoFLOP panel in the explorer below makes this visceral: at fixed compute, loss as a function of model size is a U-curve with a genuine bottom, and GPT-3 sat well up the left wall of it.
“20 tokens per parameter” — with an asterisk
The famous rule of thumb comes from Hoffmann's first two estimation approaches, which both give NC0.5N^* \propto C^{0.5} and therefore a constant token/param ratio. The third approach — the parametric fit above, and the one the explorer uses — has αβ\alpha \neq \beta, so its implied ratio drifts upward with scale (about 90 tokens/param at 102410^{24} FLOPs). The three approaches genuinely disagree; Besiroglu et al. (2024) re-fit the parametric model to the paper's own data, argue the published constants are inconsistent with the other two approaches, and land closer to ~20. Treat the exact numbers as contested and the shape as solid.

One more twist: compute-optimal is optimal for training. If you are going to serve a model to millions of users, inference cost scales with NN and not with DD, so it pays to “overtrain” a small model far past the Chinchilla point. Llama 3 8B saw ~15T tokens — nearly 2,000 tokens per parameter, two orders of magnitude past compute-optimal. That is a deliberate, rational choice, not a mistake.

Safety tie-in
Scaling laws are the reason the field can forecast at all. Loss is predictable years out; that predictability is what responsible-scaling policies and pre-deployment eval schedules are built on. But loss is not the thing we care about. Nobody has a scaling law for “will it help with a bioweapon” or “will it deceive an evaluator.” The gap between a smooth, forecastable loss curve and jumpy, hard-to-forecast capabilities is precisely the gap that makes evals hard — and the next section is about why that gap exists.
Learn

Phase changes: emergence, grokking, double descent

If loss falls this smoothly, why does everyone talk about abilities appearing “suddenly”? Three different phenomena get tangled together here, and pulling them apart is the point of this section.

1. Emergence (contested). Wei et al. (2022) showed benchmark after benchmark where accuracy sits at chance across several model sizes and then shoots up. Schaeffer et al. (2023) replied: look at your metric. Exact-match accuracy on a 5-digit arithmetic problem is a threshold applied to a smoothly improving per-token probability — get each of five digits right with probability pp and your score is p5p^5, which stays invisible until pp is already high. Swap in a continuous metric (token edit distance, log-probability of the answer) and many “emergent” curves straighten out. The honest position: some apparent emergence is a metric artifact; whether all of it is remains open.

2. Grokking (real, and mechanistically understood). Power et al. (2022) trained small transformers on modular arithmetic and found something odd: the model reaches 100% training accuracy quickly, sits at chance on held-out data for tens of thousands more steps, and then — long after the training loss stopped moving — generalises, abruptly.

Nanda et al. (2023) opened the model up and explained it. The network learns to do (a+b)modp(a + b) \bmod p by embedding numbers on circles at a handful of frequencies and applying trigonometric identities — a genuinely elegant algorithm. Crucially, that algorithm is not built abruptly. Three phases overlap:

memorisation
Fast. The model stores the training pairs in a lookup-table-like circuit. Train accuracy hits 100%; test accuracy stays at chance.
circuit formation
Slow and hidden. Under weight decay, the generalising Fourier circuit grows while the memorising circuit is still doing the work. Accuracy curves show nothing at all here — but progress measures that read the internals (restricted loss, excluded loss) move smoothly the whole time.
cleanup
Fast. Weight decay deletes the now-redundant memorisation circuit. Weight norm drops, test accuracy snaps to 100%, and it looks from outside like a phase change.
Key idea
Grokking is a measurement discontinuity, not a learning discontinuity. The mechanism developed gradually; the behaviour we were watching was a lagging, thresholded readout of it. This is the single best argument in the course for why interpretability earns its keep: internal progress measures saw the transition coming and the loss curve did not.

3. Double descent (real, still surprising). Classical statistics says test error is U-shaped in model size: too small underfits, too big overfits. Nakkiran et al. (2019) showed that if you keep going past the interpolation threshold — the size at which the model can fit the training set exactly — test error falls again, often below the classical sweet spot. The same shape shows up in epochs (train longer, get worse, then better) and in sample count (more data can transiently hurt). Modern LLMs live far out on the second descent, which is one reason “overfitting” intuitions from a statistics course mislead here.

Careful
None of this licenses the reverse inference. “Capabilities can appear abruptly” is not the same claim as “capabilities will keep appearing abruptly at frontier scale.” Grokking is observed in tiny models on algorithmic tasks with heavy weight decay and no data diversity; frontier pretraining has none of those properties. Take the mechanism seriously and the extrapolation carefully.
Explore

Feel it: the frontier and the phase change

Two toys. The first is the Chinchilla loss surface with real fitted constants — every number it shows you is what the 2022 paper's parametric model actually predicts, including the historical models it was fit against. The second replays a grokking run so you can watch the two accuracy curves come apart and snap back together.

Scaling-law explorer
Chinchilla's fitted loss surface, live. Move parameters N and training tokens D; the compute budget C ≈ 6ND follows. The curve is the compute-optimal frontier — the best loss any model can reach at that budget.
L = E + A/N^α + B/D^β
E = 1.69 · A = 406.4 · B = 410.7
α = 0.34 · β = 0.28
22.53451e181e201e221e241e26E = 1.69 (irreducible)loss (nats/token, log)training compute C (FLOPs, log) →IsoFLOP slice at C = 5.9e23: loss vs model sizeN* = 32B1.932.17model size N (log) →
N = 70B params, D = 1.4T tokens (20.0 tokens/param) → C = 5.9e23 FLOPs, loss 1.937 nats.
At that budget the optimum is N* = 32B / D* = 3.0T (93 tokens/param) for loss 1.930 — you are leaving 0.007 nats on the table.
Grokking: memorisation → generalisation
One-layer transformer, modular addition mod 113, heavy weight decay. Press play and watch the two accuracy curves come apart for an order of magnitude of training, then slam back together.
0%25%50%75%100%1e11e21e31e41e5MemorisationCircuitCleanupGrokkedtraining step (log) →
train accuracytest accuracyweight norm (normalised)
Step 100,000 · train acc 100.0% · test acc 100.0% · Grokked. The model now runs a clean, general algorithm — Fourier components and trig identities — that Nanda et al. reverse-engineered head-on.

Things to try: (1) Load the GPT-3 preset, note the loss, then hit Snap to optimal — same compute, and you see the ~0.05 nats that the 2020 recipe left on the table; now do the same for Chinchilla and see how close it already is. (2) Load Llama 3 8B and look at the IsoFLOP panel: the orange dot sits way down the left wall, and the readout shows a large loss gap — that gap is the price paid, on purpose, for a model that is cheap to serve. (3) In the grokking widget, scrub to step 5,000 and read the phase blurb: train accuracy has been pinned at 100% for thousands of steps and test accuracy is still at chance. Ask yourself what an eval run at that moment would have concluded, and how you would have known better.

Practice

Problem set

The first three are ten minutes each with a calculator and they make the quiz easy. Problem 4 is the classic: watch a model grok with your own eyes. Budget an evening for it.

1.Fit a power law from two pointspencil & paper

You train a family of models to convergence on the same enormous corpus, so the data term is negligible and LE+A/NαL \approx E + A/N^{\alpha}. You have already estimated E=1.69E = 1.69 and subtracted it. The remaining reducible loss is:

N = 1e8 → 0.774 nats
N = 1e10 → 0.162 nats

Find α\alpha and AA. Then predict the reducible loss at N=1012N = 10^{12}, and say what fraction of the total loss it would be.

2.Spend $10M of computepencil & paper

Your budget is C=1024C = 10^{24} FLOPs. Using C6NDC \approx 6ND:

(a) Use the “20 tokens per parameter” rule of thumb to get NN and DD. (b) Now use the parametric optimum, N=1.345(C/6)0.4516N^* = 1.345\,(C/6)^{0.4516}. (c) The two answers differ by more than 3×. Which one would you actually trust, and why?

3.Read a loss numberpencil & paper

Model A reports validation loss 2.40 nats/token; model B reports 2.30. (a) Convert both to perplexity and to bits/token. (b) By what factor is B more confident in the true next token, on average? (c) Your colleague says “that's only a 4% improvement, who cares.” Give the strongest counterargument, and then the strongest reason to be suspicious of the comparison anyway.

4.Watch a model grokcode

Train a one-layer transformer (dmodel=128d_{model}=128, 4 heads, no LayerNorm needed) on (a+b)mod113(a + b) \bmod 113. Use all 1132=12,769113^2 = 12{,}769 pairs, a 30% train split, full-batch AdamW, learning rate 1e-3, and weight decay 1.0. Log train and test accuracy every 100 steps for 25,000 steps and plot both on a log-x axis.

Success check: train accuracy passes 99% within ~1,000 steps, test accuracy stays under 5% for at least 5,000 steps after that, and then crosses 90%. Then ablate: rerun with weight decay 0 and report what happens.

5.Fit the Chinchilla form yourselfcode

Generate 40 synthetic (N,D,L)(N, D, L) triples from L=E+A/Nα+B/DβL = E + A/N^\alpha + B/D^\beta with the published constants, over N[108,1011]N \in [10^8, 10^{11}] and D[109,1012]D \in [10^9, 10^{12}], and add 1% Gaussian noise to LL. Now recover all five constants with scipy.optimize.minimize.

Success check: fit in log-space — logL\log L against logsumexp\mathrm{logsumexp} of the three terms — with a Huber loss, as the paper does, and recover α,β\alpha, \beta to within ±0.02. Then rerun the fit using only models with N<109N < 10^{9} and report how far the extrapolation to N=1011N = 10^{11} drifts.

6.Read a replication attemptexplore

Read Epoch AI's “Chinchilla Scaling: A replication attempt” (the blog version is enough). Then write three sentences: what exactly did they find inconsistent, what corrected token/parameter ratio do they land on, and which parts of the original Chinchilla paper survive the critique untouched?

Bonus: reconstruct their central figure yourself — plot the approach-3 parametric model's predicted optimal ratio against compute, using the explorer's readouts, and show that it disagrees with approaches 1 and 2 at every scale.

0 of 6 problems marked done
Check

Check yourself

1.
In L(N,D)=E+A/Nα+B/DβL(N,D) = E + A/N^\alpha + B/D^\beta, what does EE represent?
2.
You have a fixed compute budget and are choosing a model size. What shape does loss trace as you vary NN at fixed C=6NDC = 6ND?
3.
Llama 3 8B was trained on ~15T tokens — roughly 1,900 tokens per parameter, far past compute-optimal. The best explanation is:
4.
During grokking's “circuit formation” phase, the train and test accuracy curves are both flat. What is actually happening?
5.
Schaeffer et al. (2023) argue many “emergent abilities” are a mirage. Their core mechanism is:
6.
Model A reports loss 1.95 with a 32k-token vocabulary; model B reports 2.10 with a 128k-token vocabulary, on the same text. What can you conclude?
7.
What is the strongest safety-relevant lesson from the grokking result?
Answer all 7 questions to submit.
Submit your answers to complete this check.
Go deeper

Go deeper

Two scaling papers, one grokking paper you should read closely, and the debate literature that keeps you honest about all three.

EssentialTraining Compute-Optimal Large Language Models (Chinchilla)paper
Hoffmann, Borgeaud, Mensch, et al. (DeepMind) · 2022 · 1h (skim)
Read the abstract, then Figure 2 and Figure 3 — the IsoFLOP curves are the whole argument and you have just played with them. Skim §3 for the three estimation approaches; note where they disagree (that disagreement is the subject of the Epoch replication below). Skip the downstream-evaluation tables.
EssentialScaling Laws for Neural Language Modelspaper
Kaplan, McCandlish, Henighan, et al. (OpenAI) · 2020 · 1h
Read §1–3. The figures are the point: straight lines over seven orders of magnitude. Read it as a historical document — its allocation recommendation was superseded by Chinchilla, and understanding *why* (learning-rate schedules not re-tuned per run length) is more instructive than the recommendation itself.
EssentialProgress measures for grokking via mechanistic interpretabilitypaper
Nanda, Chan, Lieberum, Smith & Steinhardt · 2023 · 2h
The best short demonstration in the field that interpretability answers questions behaviour cannot. Read §1–4 carefully: the reverse-engineered Fourier/trig algorithm, then the restricted and excluded losses, then the three-phase story. §5 onward is worth a skim. This is also your first full worked example of the interp method you'll use for the rest of the course.
Grokking: Generalization Beyond Overfitting on Small Algorithmic Datasetspaper
Power, Burda, Edwards, Babuschkin & Misra · 2022 · 30 min
The original observation. Short. Read it for the phenomenon and the ablations (especially weight decay), then go to Nanda et al. for the explanation — reading them in that order lets you feel how unexplained the result was for a year.
Are Emergent Abilities of Large Language Models a Mirage?paper
Schaeffer, Miranda & Koyejo · 2023 · 45 min
Read alongside Wei et al. below — this pair is the whole emergence debate in two sittings. Focus on Figure 3 and §3: the same model outputs, scored two ways, produce a smooth curve or a cliff. Then ask yourself which metric your own evals use.
Emergent Abilities of Large Language Modelspaper
Wei, Tay, Bommasani, et al. · 2022 · 45 min
The claim under dispute. Read the figures and §2–3; skip the discussion of possible explanations, which has aged less well. Hold it in tension with Schaeffer et al. rather than picking a side — the resolution is still genuinely open.
Chinchilla Scaling: A replication attemptpaper
Besiroglu, Erdil, Barnett & You (Epoch AI) · 2024 · 30 min
Short and unusually clear about its own uncertainty. Read it for the discipline it models: extract the data from someone else's figures, re-fit, and say plainly where the numbers don't hold up. The blog version at epoch.ai is the faster read if you only want the argument.