Scaling Laws II: Details & Methodology

A small model predicts a big one only if its settings carry over. In our toy network, the best learning rate under standard settings falls 45-fold from width 64 to width 2,048. Under muP it moves by at most 2-fold. Real scaling studies rest on fixes like this.

Pick a parameterization, then drag the width. Watch where the bottom of the curve lands, and what the small model's best rate costs the big one. Then we build the study piece by piece: muP, batch and learning-rate rules, the WSD cooldown, a robust fit, and repeated data.

You need a little Python and the power law from Lecture 9. We build the rest from zero.

Lecture 11 of Stanford CS336, Language Modeling from Scratch (Spring 2025, Percy Liang and Tatsunori Hashimoto). Previous: Lecture 10, Inference. The basics: Lecture 9, Scaling Laws. Next: Lecture 12, Evaluation.

Tune small, train wide

1,024

Illustrative toy that we ran in PyTorch. A ReLU network with 2 hidden layers learns a fixed random teacher with Adam: 300 steps of batch 128, 3 seeds, rates from 2−14 to 2−1 in half steps. muP follows Yang et al. (2022), Table 3, with base width 64. The loss is the mean of the last 30 steps.

Chapter 0

Tune Small, Predict Big

Run cheap models first, read the big run off them, and see the three places this breaks

You get one shot at a big training run. Before it, you can afford many small ones. A scaling study is that set of small runs, plus a fitted curve. It chooses the big run's size, data, learning rate and batch size, and predicts its loss. MiniCPM's authors call it a wind tunnel: test the shape small, then build it big.

Lecture 9 gave the curve. Loss falls as a power law in parameters N and tokens D, and an IsoFLOP sweep finds the best split of a compute budget. This lecture asks how that works in practice. Does the Chinchilla approach hold up? Can the study cost less? Should we build the model so that its settings scale cleanly?

Three things break a study. First, the best learning rate moves with model width, so a rate tuned small is wrong big. Second, Chinchilla's fit needs every point trained to its own end. A run planned for 40N tokens and stopped at 20N is still on a high learning rate, so its loss is too high. Third, a curve fitted to 30 noisy points can extrapolate far off.

The second break sets the price. To get m data sizes for each of m model sizes, a cosine schedule needs a separate run for every pair. The device lays out that grid.

Price a grid of runs

Each row is one model size. Each bar is the tokens a run consumes, in units of its size N. Change the number of sizes, then switch to WSD.

6 by 6

Illustrative accounting. Data sizes are 10N, 20N, up to m × 10N tokens, as in MiniCPM's grid. A WSD cooldown is 10% of its run's tokens; we ignore warmup.

With 6 sizes and lengths 10N to 60N, cosine runs cost 10 + 20 + … + 60 = 210N tokens per size. One WSD run to 60N plus six cooldowns of 10% costs 60 + 21 = 81N. That is 2.6 times less. At 12 by 12 the gap is 3.9 times.

Symptom: the big run lands far off the fitted curve.

Measure: leave the largest size out of the fit and predict it. Cerebras-GPT fitted its law on models up to 6.7B parameters; its 13B model landed within 0.5% of the prediction.

Fix: check the three breaks in order: the settings that drift, the points that were not trained to their end, and the fit.

The road

  1. Drift: one Adam step moves a wide layer more, so the best rate falls with width.
  2. muP rules: two conditions give an init rule and a learning-rate rule.
  3. Transfer: what a large replication found keeps or breaks the transfer.
  4. Batch: the best batch grows as the loss falls.
  5. Fit to C: DeepSeek fits learning rate and batch to compute.
  6. WSD: hold the rate, then cool down, and reuse the run.
  7. Fitting: a robust fit, and how fits fool you.
  8. Showcase: plan one big run with five published recipes.
  9. Repeats: what repeated epochs are worth.
  10. Field guide: the recipes, the code and the checks.
Why can you not use the checkpoints of one long cosine run as the points of a Chinchilla fit?

Chapter 1

Why the Best Learning Rate Moves with Width

Follow one Adam step through a layer, and watch the change grow with the number of inputs

Take one layer. It multiplies an input vector h by a weight matrix W and passes the result on. Call the number of inputs n, the layer's width (its fan-in). Train it with Adam, the optimizer nearly every language model uses.

On its first step, Adam moves every weight by the learning rate, with the sign of its gradient. It divides each gradient by its own running size, so tiny and huge gradients give the same step. So the step does not shrink when the layer gets wider.

For one example, the gradient of W is an outer product: the error at each output times each input. So every weight in a row moves by the learning rate, with the sign of its input. Now feed the same h through the moved weights. Every input adds its size in the same direction. Nothing cancels.

Take one Adam step

Each bar is one output's change after a single step at learning rate 0.001. The yellow band is the change at width 64. Drag the width, then switch to muP.

256

Computed live on one random input with unit-normal entries. Adam's first step is exactly the rate times the sign of the gradient.

The change of output i after one step is Δhi. The learning rate is η. Input j is hj, and there are n inputs.

Say it aloud

Delta h-i equals eta times the sum over j of the size of h-j, which is about eta times n times the average size of h.

Δhi
delta h-i how much output i changes after one Adam step, fed the same input.
η
eta the learning rate: how far Adam moves each weight on its first step.
Σj
the sum over j add one term for each of the n inputs.
|hj|
the size of h-j input j without its sign.
n
n the width: the number of inputs to the layer.
E|h|
the average size of h about 0.80 for unit-normal inputs (the square root of 2 over pi).
In plain words

Add up the sizes of all n inputs and multiply by eta. Every output moves by that much. Double the width n and the change Delta h-i doubles.

With numbers

Take eta = 0.001 and unit-normal inputs. At n = 256: 0.001 × 256 × 0.80 = 0.20. At n = 4,096: 3.27, sixteen times more. To keep 0.20 at width 4,096, eta must drop sixteen-fold to 0.0000625.

So under standard settings the best learning rate falls about as fast as the width grows. In the hero toy it fell from 2−8 at width 64 to 2−13.5 at width 2,048. That is 45 times lower for 32 times the width. Tune at width 64 and copy the rate to width 2,048: the loss is 0.714 instead of the 0.615 it could reach.

Symptom: the learning rate that trained the small model makes the big one spike or diverge.

Measure: after one step, log the change of each layer's output relative to its size, at two widths.

Fix: scale hidden learning rates by 1 / width (muP, Chapter 2), or refit the rate at each scale (Chapter 5).

A layer goes from 512 inputs to 2,048. With Adam and the same learning rate, how much bigger is the change in each output after one step?

Chapter 2

muP: Two Conditions, Two Rules

Demand that activations and their updates keep their size at every width, and read off the init and the learning rate

muP, the maximal update parameterization from Greg Yang's Tensor Programs work, fixes the drift with two demands. The lecture derives them for a deep linear network. Layer l computes hl = Wl hl−1, with nl−1 inputs (fan-in) and nl outputs (fan-out).

A1: at initialization, each activation stays about size 1. A2: after one gradient step, each activation's change is also about size 1. We write "about size 1" as Θ(1): it neither grows nor shrinks with width.

A1 sets σl, the spread of the random starting weights. A random matrix with spread σ stretches a vector by at most about σ(√nl−1 + √nl). Choose σ so that the output's entries keep size 1:

Say it aloud

Sigma-l is of order one over root n-l-minus-one, times the smaller of one and root of n-l over n-l-minus-one.

σl
sigma-l the standard deviation of layer l's random starting weights.
Θ( )
of order up to a constant that does not change with width.
1 / √nl−1
one over root fan-in the usual starting scale: nl−1 is the number of inputs.
min(1, √(nl / nl−1))
the smaller of one and root fan-out over fan-in 1 unless the layer narrows.
In plain words

Start from one over the square root of the fan-in. If the layer narrows, shrink it again by the square root of outputs over inputs.

With numbers

A square layer, 4,096 by 4,096: sigma = 1 / 64 = 0.0156, the usual init. A layer from 16,384 down to 4,096: 1 / 128 × 0.5 = 0.0039.

A2 sets the learning rate. One Adam step moves each output by the rate times the sum of nl−1 input sizes (Chapter 1). To keep that Θ(1), the rate of layer l, ηl, must shrink with the fan-in:

Say it aloud

Eta-l is of order one over n-l-minus-one, for Adam.

ηl
eta-l the learning rate of layer l.
Θ( )
of order up to a constant: the base rate, tuned once.
1 / nl−1
one over fan-in double the inputs, halve the rate.
(Adam)
for Adam with plain SGD the rule is nl / nl−1 instead.
In plain words

Tune one base rate on a small model. For a hidden layer m times wider, divide eta-l by m.

With numbers

Cerebras-GPT tuned a width-256 base model to a rate of 0.006. Its 2.7B model has width 2,560, so m = 10: hidden rate 0.0006, init spread 0.08 / √10 = 0.0253, and output logits multiplied by 1/10.

In a Transformer, three things change (Yang et al., Table 3). Hidden matrices get a rate in proportion to 1 / width. The output layer starts with variance 1 / fan-in², or you divide its logits by the width multiplier. Attention scores divide by d, not √d.

Widen a Cerebras-GPT model

Each row is one kind of weight, on log scales. Drag the width, then switch to SP.

2,560

Base values from the Cerebras-GPT appendix (Dey et al., 2023): width 256, rate 0.006, spread 0.08. SP rates from its Table 1. We drop two depth terms.

Symptom: early in training, the output logits grow with width (Yang et al. show it under SP).

Measure: the RMS logit after a few steps, at two widths.

Fix: divide the logits by the width multiplier, or start the output layer with variance 1 / fan-in².

Under muP with Adam, a hidden layer goes from width 512 to width 4,096. What happens to its learning rate?

Chapter 3

Does the Transfer Hold? A Replication

Sweep the base rate at three widths and see which modern parts keep the best rate in place

The derivation used a linear network and plain gradient steps. Real language models have nonlinear blocks, normalization gains, weight decay and new optimizers. The lecture asks which of these break muP, using a replication by Lucas Lingle (2024).

Lingle trained Transformers of width 128, 512 and 2,048, from 4.7M to 1.2B non-embedding parameters. Each width swept the base learning rate α over 2−10, 2−8, 2−6, 2−4 and 2−2. In the baseline muP model, the best α was 2−6 at all three widths. Yet each model is 4 times wider and 16 times larger than the last.

Break the transfer

Each curve is one width; the dot is its best rate. The yellow line is the smallest model's best rate. Pick a change to the model.

Real numbers: validation losses from Lingle, "An Empirical Study of µP Learning Rate Transfer" (2024), Table 4. We draw losses above 4.4 at the top edge and label them.

The verdicts, from the same table. SwiGLU, squared ReLU, multi-query attention, a zero-initialized query, a cosine schedule, and batches 4 times smaller or larger all kept the transfer. Trainable RMSNorm gains, the standard 1/√d attention scale, decoupled weight decay and the Lion optimizer broke it.

Take weight decay at 0.1. The width-128 model's best α is 2−8 (loss 3.679). The width-2,048 model's best is 2−6 (loss 2.502). Copy 2−8 to the big model and it reaches 2.535: 0.033 worse, a 1.3% loss. Lingle's heuristic: leave weight decay out of the proxy and add it to the target only. The lecture calls strong weight decay maybe the only significant muP failure.

The case studies agree. Cerebras-GPT tuned a 40M-parameter muP proxy and used one rate, 0.006, from 111M to 2.7B parameters. Its standard models needed 0.0006 at 111M and 0.0002 at 2.7B. Its muP models sat 0.04% (one standard deviation) off their scaling law; the standard ones sat 0.66% off. MiniCPM found its best base rate stayed near 0.01 from 0.04B to 0.5B, and checked it at 2.1B.

Symptom: the proxy's best rate is not the target's best rate.

Measure: sweep α at two proxy widths before you trust the transfer.

Fix: remove the norm gains, which Lingle found also hurt the largest models. Divide attention by d, and keep decoupled weight decay out of the proxy.

In Lingle's table, which change broke learning-rate transfer?

Chapter 4

The Best Batch Grows as Loss Falls

Average enough examples to see a gradient that shrinks as training goes on

muP keeps the learning rate in place across width. The batch size still needs a rule. A batch's gradient is an average of per-example gradients. Each one is the true gradient plus noise, and averaging B of them shrinks the noise by √B.

Past some size, more examples barely sharpen the direction, so the extra compute buys little. Below it, steps are noisy and you waste steps. McCandlish and colleagues named the turning point the gradient noise scale. It is the batch where the noise of the average about equals the gradient itself.

Name the parts. The true gradient is G. Each example's gradient differs from G; the total of those variances, over all coordinates, is tr(Σ). The batch average of B examples has noise tr(Σ) / B. Set that equal to |G|²:

Say it aloud

B-noise equals the trace of Sigma divided by the length of G, squared.

Bnoise
B-noise the gradient noise scale: the batch size where noise and signal are about equal.
tr(Σ)
the trace of Sigma how much single-example gradients scatter: the variance of each coordinate, added up.
|G|²
the length of G, squared the true gradient's strength, the average over all data.
In plain words

Measure how much single-example gradients scatter, tr Sigma. Divide by the true gradient's squared length, G squared. A batch of B-noise examples sees the direction about as clearly as it is noisy.

With numbers

With made-up numbers: tr Sigma = 400 and G squared = 0.01 give B-noise = 40,000 examples. Later, the gradient's length halves, so G squared = 0.0025, and B-noise = 160,000. Half the slope needs four times the batch.

That is why the best batch grows as the loss falls. Near the bottom the true slope is small, but single examples still disagree. You need more of them to see the slope. Kaplan et al. measured the critical batch as 2.1 × 108 / L4.8 tokens: it doubles for every 13% drop in loss.

Average a noisy batch

Faint teal arrows are single-example gradients. The yellow arrow is the true gradient; the pink arrow is the batch average. Switch to late training, then raise the batch.

4

Illustrative 2-D toy computed live: each example's gradient is the true gradient plus unit Gaussian noise. We average the angle error over 400 batches.

MiniCPM measured this on 9M, 30M and 170M models, each with 6 batch sizes. It fitted bs = 1.21 × 109 / L6.24 tokens, with L the loss on C4. At L = 3.5 that is 487,000 tokens; at L = 2.5 it is 3.98 million. MiniCPM-2.4B trained with 3.93 million.

Symptom: doubling the batch barely cuts the number of steps to a target loss.

Measure: steps to that loss at batch B and 2B.

Fix: you are above the critical batch for this loss. Keep the batch, or grow it later, as the loss falls.

Late in training the true gradient's length falls by 3 while single-example scatter stays the same. What happens to the gradient noise scale?

Chapter 5

DeepSeek: Fit the Settings to Compute

Skip muP, sweep batch and learning rate at small budgets, and fit both as power laws in compute

DeepSeek LLM (2024) took the other road: standard parameterization, and fit the settings directly. A grid search at 1017 FLOPs showed a wide flat basin: many batch and rate pairs gave nearly the same loss. So the team trained models from 1017 to 2 × 1019 FLOPs and kept every run within 0.25% of the best loss as near-optimal. Then it fitted power laws through them.

Call the compute budget in FLOPs C. The best learning rate is ηopt and the best batch, in tokens, is Bopt:

Say it aloud

Eta-opt equals 0.3118 times C to the minus 0.125; B-opt equals 0.2920 times C to the 0.3271.

ηopt
eta-opt the best peak learning rate for this budget.
C
C the training compute in FLOPs.
−0.1250
to the minus 0.125 the rate falls slowly: 1,000 times the compute gives 0.42 times the rate.
Bopt
B-opt the best batch size, in tokens.
0.3271
to the 0.3271 the batch grows: 1,000 times the compute gives 9.6 times the batch.
In plain words

Take the budget C. Raise it to minus 0.125 and multiply by 0.3118: that is the rate eta-opt. Raise C to 0.3271 and multiply by 0.292: that is the batch B-opt in tokens.

With numbers

DeepSeek 7B: 30 layers, width 4,096, sequence 4,096. Its compute per token is 4.23 × 1010 FLOPs, times 2 trillion tokens: C = 8.46 × 1022. The formula gives eta-opt = 4.25 × 10−4 and B-opt = 9.2 million tokens. DeepSeek used 4.2 × 10−4 and 2,304 × 4,096 = 9.4 million.

Read the settings off compute

Two log-log plots: rate and batch against compute. The yellow band is where DeepSeek fitted. Stars are the 7B and 67B models as trained. Drag the budget.

8.5e22

Formulas and the 7B and 67B settings from DeepSeek LLM (Bi et al., 2024), Equation 1 and Table 2. The compute of each star is our estimate from their formula for M times 2 trillion tokens.

Two more details carry over. DeepSeek measures model size as non-embedding FLOPs per token, M, which counts attention. For small models, 6N misses it by up to 50%. Its IsoFLOP fit, over 8 budgets from 1017 to 3 × 1020, predicted the 7B and 67B losses from 1,000 times less compute. Cleaner data moved compute toward model size: the model exponent rose from 0.450 to 0.578.

Symptom: the extrapolated rate lands outside the stable range at full scale.

Measure: how far is the target from the fitted range? DeepSeek fitted up to 2 × 1019 and trained 67B at about 1024: 50,000 times more.

Fix: validate at an intermediate budget (DeepSeek checked 1020) and choose inside the wide near-optimal band. The lecture calls the rate fit "a bit questionable".

You multiply DeepSeek's budget by 1,000. What do the fits say?

Chapter 6

WSD: Hold the Rate, Then Cool Down

Split the schedule into warmup, a long flat stretch and a short decay, and reuse the flat stretch for every data size

A cosine schedule ties its shape to the end of training. Plan 80N tokens and stop at 40N, and the rate is still halfway up, so the loss is too high. That is why Chinchilla's fit costs a grid of runs. MiniCPM's warmup-stable-decay schedule, WSD, cuts the tie.

Name the steps. The warmup ends at step W, the flat stretch at step T, and training at step S. The peak rate is η, and f is a decay that falls from 1:

Say it aloud

The WSD rate at step s is eta times s over W before W. It is eta from W to T, and f of s minus T, times eta, from T to S.

WSD(s)
the WSD rate at step s the learning rate the optimizer uses at step s.
η · s / W
eta times s over W warmup: the rate climbs in a straight line to the peak eta at step W.
η
eta the stable stage: the peak rate, held flat until step T.
f(s − T) · η
f of s minus T, times eta the decay: f starts at 1 and falls toward 0 by the last step S.
In plain words

Climb to eta by step W. Hold eta until step T. Then multiply eta by a falling f until step S. To get a model for a new length, restart from the checkpoint at the new T and decay again.

With numbers

MiniCPM's decay runs for 10% of the tokens: hold to 40N, decay to 44N. Its final run decayed exponentially, halving the rate every 5,000 steps (20B tokens). DeepSeek's version is two steps: the rate drops to 31.6% of peak at 80% of the tokens and to 10% at 90%.

Cool down a run

Purple is the learning rate, pink the loss, over the tokens of one run. Choose a schedule, shorten the decay, and turn on the branches.

10% of tokens

Illustrative toy loss, not fitted to any paper: loss = 2.0 + 0.2 × (area under the rate + 0.02)−0.2 + 0.3 × a lagged copy of the rate. It reproduces the shape MiniCPM reports: a flat plateau, then a sharp drop in the decay.

The saving grows with the grid. With m data sizes per model, cosine runs cost 1 + 2 + … + m = m(m + 1) / 2 units of the shortest run. WSD costs one run of m units plus cooldowns of 10% each: m + 0.1 × m(m + 1) / 2. For m = 20 that is 210 against 41, five times less.

Why does the loss drop so fast in the decay? MiniCPM tracked the weights. The largest updates happen at the high rate, while the loss barely moves. In the decay, updates shrink and the loss falls quickly. A high rate bounces across a valley; cooling lets it settle to the floor.

Symptom: WSD branch points sit above a cosine run of the same length.

Measure: the decay fraction. MiniCPM found 10% of the tokens enough and 2.5% too short.

Fix: decay for about 10% of the tokens; DeepSeek's 80 / 10 / 10 split matched cosine at the end.

How does WSD make a Chinchilla grid cheaper?

Chapter 7

Fit the Law Without Fooling Yourself

Fit five numbers robustly in log space, then see how one bad run or a little noise moves the answer

Chinchilla's third method fits L(N, D) = E + A / Nα + B / Dβ to all trained points at once. MiniCPM made it its main method (Lecture 9 covers the IsoFLOP alternative).

Run i has Ni parameters, Di tokens and an observed loss Li. The law predicts L̂. We measure the miss with a Huber loss, quadratic for small misses and linear for large ones, with switch point δ:

Say it aloud

Minimize, over E, A, B, alpha and beta, the sum over runs i of Huber-delta of log L-hat of N-i and D-i, minus log L-i.

minE,A,B,α,β
minimize over E, A, B, alpha and beta search the five numbers of the law for the smallest total.
Σi
the sum over runs i one term for each trained run.
Huberδ
Huber-delta r²/2 when the miss r is at most δ; δ(|r| − δ/2) beyond. Chinchilla used δ = 0.001.
log L̂(Ni, Di)
log L-hat of N-i and D-i the log of the loss the law predicts for run i.
log Li
log L-i the log of run i's measured loss. A log difference is a relative miss.
In plain words

For each run, take log predicted loss minus log observed loss. Square small misses; count misses past delta only in proportion. Add over the runs. Search E, A, B, alpha and beta for the smallest sum, from many starts.

With numbers

A diverged run sits 25% too high: r = log 1.25 = 0.223. Squared, it adds 0.0249 to the sum. Huber with delta = 0.001 adds 0.000223, 112 times less pull on the fit.

Fit 28 runs, then extrapolate

Dots are toy runs at four budgets. Pink curves are your fit; yellow curves, the true law. Add a diverged run, then switch the loss.

0.5%

Illustrative toy computed live. Our true law: E 1.82, A 482, B 2,085, α 0.35, β 0.37; budgets 1018 to 3 × 1019 FLOPs, 7 sizes each. The fit grids α and β, then solves E, A and B by least squares.

One diverged run, fitted by least squares, swings the extrapolated tokens per parameter from about 16 to hundreds. Even clean runs move it: at 1% noise, the first six seeds gave 9.5 to 57 tokens per parameter at 1023, against a true 16.5. And methods differ: Chinchilla's three approaches put the model-size exponent at 0.50, 0.49 and 0.46.

The fit must also converge and report honest error bars. Besiroglu et al. (2024) rebuilt Chinchilla's data from its figure and refitted. The published numbers fit the data poorly, partly from rounding, and the reported intervals were implausibly narrow. The Chinchilla authors traced it to an optimizer that stopped early.

The refit gives about 25.6 tokens per parameter, close to the 20 Chinchilla trained with. Rounding alone moves answers. Put the rounded numbers through the allocation formula at Gopher's 5.76 × 1023 FLOPs and you get 32B parameters; the paper reported 40B.

Symptom: the fitted exponents jump when you add or drop one run.

Measure: refit with each run left out, or on bootstrap resamples, and report the spread.

Fix: Huber in log space, many starting points, run the optimizer to convergence, and hold out the largest budget as a test.

Why did Chinchilla fit with a Huber loss on log losses rather than least squares on raw losses?

Chapter 8

Showcase: Plan the Big Run

Give five published recipes the same budget and compare the models they ask for

Every recipe in this lecture ends in the same decision: for budget C, how many parameters and how many tokens? Here are five published answers on one dial. Cerebras-GPT trained at Chinchilla's 20 tokens per parameter. Chinchilla's own fitted law, with its rounded numbers, asks for more data as the budget grows. MiniCPM's joint fit found 192 tokens per parameter on average. DeepSeek's IsoFLOP fit and Llama 3's fit give their own curves.

Try 3.8 × 1025 FLOPs, Llama 3's budget. Llama 3's own fit asks for 16.55 trillion tokens; Meta reports 402B parameters, and trained 405B. Then try a budget far outside each fitted range and watch the recipes spread.

Plan one run, five recipes

Top: parameters against compute for each recipe, log-log; the band is the recipe's fitted range. Bottom: tokens per parameter. Pick a recipe and drag the budget.

1.0e23

Real formulas, computed live with C = 6ND where a recipe gives only one of N and D. We convert DeepSeek's M with N ≈ M / 6, which ignores attention. Llama 3 uses D = 0.299 C0.537, the fitted line in its Figure 3. At 3.8 × 1025 it gives 16.3T tokens and 389B parameters; the text reports 16.55T and 402B. The text's rounded 0.29 and 0.53 would give only 10.5T.

At 1023 FLOPs the answers range from about 9B to 33B parameters, a 3.5-fold spread on one budget. The two fixed ratios bracket them: 20 and 192 tokens per parameter. The lecture's view: recent models train far past 20, and the fitted ratio depends on data, architecture and recipe, so measure it for yours.

Chapter 9

When the Tokens Run Out

Count what a repeated epoch is worth, and see where repeats stop paying

Every recipe so far assumes fresh tokens. When the good data runs out, you repeat it. Muennighoff et al. (2023) ran 400 models, up to 9B parameters and 900B tokens, to price a repeat. Their headline: up to 4 epochs, repeated data is almost as good as new. After that the value fades, and around 40 epochs more compute is worthless.

They model it with effective data: the number of fresh tokens that would give the same loss. Call the unique tokens U and the number of repeats R (epochs minus 1). Each repeat is worth less than the one before, at a rate set by a fitted constant R*:

Say it aloud

D-prime equals U plus U times R-star times one minus e to the minus R over R-star.

D′
D-prime effective tokens: the fresh data that would do as much.
U
U unique tokens in the corpus: the first epoch.
R*
R-star a fitted constant, 15.4: roughly where repeated tokens have lost a large part of their value.
e−R / R*
e to the minus R over R-star how much value is left after R repeats; R is epochs minus 1.
In plain words

The first pass counts in full: U. The repeats add U times R-star times one minus e to the minus R over R-star. For a few repeats that is close to U times R, as good as fresh. It can never pass U times R-star.

With numbers

U = 100B tokens, 4 epochs, so R = 3: D-prime = 100 + 100 × 15.4 × (1 − e−0.195) = 100 + 273 = 373B, 93% of the 400B processed. At 16 epochs: 1,059B of 1,600B, 66%. The ceiling is 100 × 16.4 = 1,640B.

Price a repeated epoch

The grey line counts every repeat as fresh; the yellow line is the ceiling. The pink curve is the effective tokens, and the bar shows what the next epoch is worth. Drag the epochs.

4 epochs
100B

Formula and R* = 15.4 from Muennighoff et al. (2023), Equation 5 and Appendix A. The next epoch's worth is the exact gain in D′ from one more pass, divided by U.

Parameters get the same treatment, with a faster fade (R* = 5.3 for parameters beyond what the data supports). So with fixed data, the paper advises a smaller model trained for more epochs than a fresh-data law suggests, not a larger one.

Symptom: past a few dozen epochs, the loss rises midway through training.

Measure: held-out loss after each epoch. The paper's law underestimates the loss of such failing runs, for example at 44 epochs.

Fix: stay near 4 epochs on the main corpus. The paper's other options: add code data, or relax quality filters.

You have 2 trillion unique tokens and train for 8 epochs. About how many effective tokens is that?

Chapter 10

Field Guide

Keep the recipes, the code and the checks for your own scaling study

A scaling study predicts a big run from small ones, and three things decide if it works. Settings must carry over: muP holds the learning rate in place across width, or you fit rate and batch to compute. Every point must finish its run: WSD reuses one stable run and pays only for short cooldowns. The fit must be robust and checked: Huber in log space, many starts, a held-out budget. When data runs short, count repeats as effective tokens.

RecipeSettings across scaleScheduleSize and dataResult
Cerebras-GPT (2023)muP: one rate, 0.006, from 111M to 2.7Blinear or cosine decayChinchilla's 20 tokens per parameter13B within 0.5% of the predicted loss
MiniCPM (2024)muP (width and depth), fixed aspect ratio; batch from loss: 1.21 × 109 / L6.24WSD, decay about 10%Chinchilla methods 1 and 3192 tokens per parameter on average
DeepSeek LLM (2024)no muP; rate and batch fitted to computemulti-step 80 / 10 / 10IsoFLOP (method 2) in M, FLOPs per token7B and 67B losses predicted from 1,000 times less compute
Llama 3 (2024)not detailednot detailed hereIsoFLOP, parabola minima, 6 × 1018 to 1022402B on 16.55T tokens, about 41 per parameter
Hunyuan-Large (2024)not detailednot detailed hereIsoFLOP on active parameters of a mixture of experts58.1B active on 5.6T, about 96 per active parameter

The core, as code: muP parameter groups for Adam, the WSD schedule, and the Huber objective in log space.

python
import math, numpy as np, torch

def mup_groups(model, base_lr, width, base_width=256):
    """Adam param groups: hidden and output matrices get lr / m (Yang et al. 2022, Table 3)."""
    m = width / base_width
    hidden = [p for n, p in model.named_parameters() if p.ndim == 2 and "embed" not in n]
    other  = [p for n, p in model.named_parameters() if not (p.ndim == 2 and "embed" not in n)]
    return [{"params": hidden, "lr": base_lr / m},    # width-scaled
            {"params": other,  "lr": base_lr}]        # embeddings, biases, gains
# also: init hidden weights with std 1/sqrt(fan_in), divide logits by m, attention by d (not sqrt d)

def wsd(step, total, peak, warmup=0.01, decay=0.10):
    """Warmup-stable-decay. Restart from the stable checkpoint to get another length."""
    W, T = int(warmup * total), int((1 - decay) * total)
    if step < W: return peak * (step + 1) / W
    if step < T: return peak
    return peak * (1 - (step - T) / (total - T))          # linear decay to 0

def huber(r, delta=1e-3):
    a = np.abs(r)
    return np.where(a <= delta, 0.5 * r * r, delta * (a - 0.5 * delta))

def objective(theta, N, D, L):
    a, b, e, alpha, beta = theta                         # A, B, E = exp(a), exp(b), exp(e)
    log_pred = np.logaddexp.reduce([a - alpha * np.log(N), b - beta * np.log(D), e * np.ones_like(N)])
    return huber(log_pred - np.log(L)).sum()           # minimize with L-BFGS from a grid of starts

def effective_tokens(U, epochs, R_star=15.4):
    R = epochs - 1                                       # repeats after the first pass
    return U + U * R_star * (1 - math.exp(-R / R_star))

assert abs(effective_tokens(100e9, 4) / 1e9 - 372.6) < 0.1

The log-sum-exp form keeps A, B and E positive, as in Chinchilla's appendix. We ran the last line: 100B unique tokens for 4 epochs are worth 372.6B fresh ones.

The checks, in order: does the best rate stay put at two proxy widths? Is every point cooled down? Does the fit predict a held-out budget? How far past the fitted range is the target?

The lecture also points to Gadre et al. (2024), who estimate Chinchilla-style curves another way: the loss penalty from training past the compute-optimal point stays stable across scale. And loss is not the goal. Whether a lower loss buys better answers downstream is the subject of Lecture 12.

Keep going

Read next

The habit. Before you trust a small run's verdict, ask three things: does the setting carry over to the big width, was the point cooled down, and how far past the fitted range is the target?
Which pairing of problem and fix is right?

Now teach it: press Present or Teach. Explain why one Adam step moves a wide layer more, how muP's two rules fix it, and how WSD turns a grid of runs into one. Then go back to the sweep, choose SP, and predict where the width-2,048 minimum lands before you drag there.

Scaling Laws II: Details & Methodology · Stanford CS336, Lecture 11
Next: Evaluation · The basics: Scaling Laws · Course site · Back to Gleams