Neural Scaling Laws
Power laws in loss versus parameters, data and compute, across modalities, and compute-optimal training.
A frontier training run happens once, at a price that rules out trial and error. Its model size, token count and final loss are nevertheless chosen in advance, by extrapolating from runs a thousand times cheaper. This lesson derives the compute bill of a transformer, solves a fitted loss surface for the best split between parameters and data, dissects why two landmark studies disagreed, and maps where scaling laws hold beyond text and where they bend.
What you’ll learn
- Derive from the FLOPs of a transformer's matrix products, together with the attention term it leaves out and when that term matters.
- Fit power laws with an irreducible floor, and solve under for the compute-optimal and .
- Explain why Kaplan et al. (2020) and Hoffmann et al. (2022) reached different allocations, and why the optimal tokens per parameter depend on how a fit was made.
- Describe scaling laws for images, video, games and transfer, and the ways laws fail: broken power laws, inverse scaling and hard-to-predict downstream tasks.
Power laws, measured
A scaling law summarizes many training runs with a power law. Kaplan et al. (2020) trained decoder-only transformers with 768 to 1.5 billion non-embedding parameters on WebText2, about 23 billion tokens of web text, and measured the test loss in nats per token. Whenever one resource was the bottleneck, the loss followed a power law in it:
The same study found regularities that make extrapolation possible:
- Shape barely matters. At fixed , changing the aspect ratio by a factor of 40 changed the loss only slightly.
- Overfitting is predictable. In their joint fit the penalty for limited data depends on , so a model 8 times larger needs only about 5 times more data to avoid it.
- Bigger models are more sample-efficient: they reach a given loss in fewer steps and with fewer tokens.
Hestness et al. (2017) had already seen power-law learning curves in translation, language modeling, image classification and speech recognition, and noticed that better architectures shifted the curves without changing their exponents.
Kaplan et al.'s compute law has exponent and no floor. By what factor must compute grow to halve the loss? Give of the factor.
Show the answer
6
Halving needs , so : a millionfold more compute. Small exponents are why scaling is expensive, and why measuring them is delicate: with or instead, the factor becomes or . An error of in an exponent moves such extrapolations tenfold or more.
Counting FLOPs
Scaling laws are stated in FLOPs, so the bill must be counted with care. Take a decoder-only transformer with layers of width , attention width and an MLP of width .
A weight matrix applied to one token's vector costs multiply-adds: 2 FLOPs per weight. Each layer holds attention weights () and MLP weights, so
Attention also does work that involves no weights. A query scores each key it can see ( FLOPs) and adds up the matching values (another ). Under a causal mask token sees keys, on average, which gives per layer:
Backpropagation through needs and : two products the size of the forward one. Attention's backward pass is likewise about twice its forward pass, so a training step costs three forward passes:
Divide the attention term by the weight term, using :
Attention adds little while the context is short compared with , which is why serves for most published models; past it dominates. The unembedding adds another FLOPs per token, a large share for small models with big vocabularies, and one that Kaplan et al. left out.
A model of width is trained with a context of tokens. By what percentage does attention raise the training FLOPs above per token?
Show the answer
16.7 %
. With a -token context it would be , and would badly undercount. GPT-3, with and a -token context, sits at .
The compute-optimal allocation
Kaplan et al. concluded that a growing budget should go mostly to parameters, and , with large models stopped far short of convergence. Hoffmann et al. (2022) attacked the same question three ways, with over 400 runs from 70 million to over 16 billion parameters:
| Approach | Method | in |
|---|---|---|
| each model size trained with 4 schedule lengths; at every FLOP count, keep the lowest loss reached by any run | |
| 9 budgets from to FLOPs; at each, vary , fit a parabola in and take its minimum | |
| fit to all runs by minimizing a Huber loss on |
Substitute and minimize over :
Multiply by and put back. At the optimum the two reducible terms stand in a fixed ratio:
Solve for , then :
Both reducible terms then fall at one rate, and the ratio of tokens to parameters drifts unless :
With the printed the ratio grows like , so the fit itself does not say "20 tokens per parameter" (the paper's own Approach 3 projections rise from 27 tokens per parameter at 1 billion parameters to 61 at 67 billion): that rule comes from Approaches 1 and 2 and from Chinchilla, 70 billion parameters on 1.4 trillion tokens. Besiroglu et al. (2024) refitted Approach 3 to data reconstructed from the paper's figures. They found the printed estimates inconsistent with the other two approaches and their confidence intervals implausibly narrow, traced this to a fitting optimizer that had stopped before converging and to rounding in the printed values, and obtained : about 20 tokens per parameter, almost constant.
With the printed exponents and , what is in ?
Show the answer
0.45
, close to the Hoffmann et al. report from unrounded values; the re-fit gives . Either way about half of each extra factor of compute goes to parameters and half to data, against Kaplan's .
Why the two studies disagreed
Kaplan et al. found , Hoffmann et al. about ; extrapolated to Chinchilla's budget, the first prescribes a model roughly ten times larger. The gap turned out to be methodological, and taking it apart shows how fragile fitted exponents are:
- Learning-rate schedules. Hoffmann et al. pointed out that Kaplan et al. read losses part-way through runs whose cosine schedule was set for a longer horizon. Such losses overstate what a shorter, fully decayed run reaches, which undervalues training on fewer tokens; they proposed this as the cause of the gap.
- What counts as a parameter. Kaplan et al. excluded embedding parameters, a large share of small models. Simulating Chinchilla-like training curves for Kaplan's range of model sizes and fitting in non-embedding parameters gives local exponents of to , close to Kaplan's (Pearce & Song, 2024).
- Compute, warmup and tuning. Porian et al. (2024) reproduced Kaplan's result ( in their setup) and removed the discrepancy one factor at a time: counting the last layer's FLOPs (), shortening a fixed warmup that was too long for small models (), and tuning the learning rate, batch size and AdamW at each model size (). Matching the learning-rate decay to each run's length, the explanation Hoffmann et al. offered, changed little ( to ): their tuned runs reproduced the Chinchilla law with a constant learning rate.
import numpy as np
def isoflop_minimum(N, L):
"""Approach 2: final losses L of models of sizes N, all trained with one budget C."""
c2, c1, _ = np.polyfit(np.log(N), L, deg=2) # parabola in log N
return np.exp(-c1 / (2 * c2)) # its vertex estimates N_opt(C)
def fit_exponent(C, N_opt):
"""N_opt = k * C**a is a straight line on log-log axes."""
a, log_k = np.polyfit(np.log(C), np.log(N_opt), deg=1)
return a, np.exp(log_k)
# n_opt = [isoflop_minimum(N_c, L_c) for N_c, L_c in runs_per_budget]
# a, k = fit_exponent(budgets, np.array(n_opt))The core of an IsoFLOP study. Everything that matters happens before this code runs: how and are counted, and whether every run was trained with hyperparameters suited to its size and length.
You fit from runs between and FLOPs, using one learning rate and warmup tuned for your largest model. What is the main risk?
- None: the exponent does not depend on hyperparameters
- The fit will be too noisy to give any exponent at all
- Runs of other sizes are handicapped by unsuitable hyperparameters, which shifts where each iso-FLOP minimum falls and biases
- The largest model will overfit, so comes out too small
Show the answer
C. Runs of other sizes are handicapped by unsuitable hyperparameters, which shifts where each iso-FLOP minimum falls and biases
A scaling law compares well-tuned runs. If small models get a learning rate or warmup that suits large ones, their losses are inflated by different amounts at different sizes, and the minima of the iso-FLOP curves move. Porian et al. traced much of Kaplan's exponent to exactly this kind of effect.
Beyond language, and where laws bend
| Setting | Finding | Source |
|---|---|---|
| Images, video, image↔text, math | loss is a power law plus a constant in compute, in every domain; , measured with Kaplan et al.'s methods (fixed 3,000-step warmup included) | Henighan et al., 2020 |
| Vision transformers | error against compute follows a double-saturating law ; bigger models are more sample-efficient | Zhai et al., 2022 |
| Board games (Hex, AlphaZero) | play at fixed compute degrades predictably with board size; each extra of training compute saves about of test-time search | Jones, 2021 |
| Transfer (text to Python) | pretraining is worth extra fine-tuning data : it multiplies the fine-tuning set | Hernandez et al., 2021 |
Laws also bend and break:
- Broken power laws. Many curves change slope. A smoothly broken power law, power-law segments joined smoothly, fits and extrapolates them better than a single power law, including double descent and late, sharp inflections such as those on arithmetic tasks (Caballero et al., 2023).
- Inverse scaling. On some tasks larger language models do worse. A public contest collected 11 such tasks and identified four causes: repeating memorized text instead of following instructions, imitating undesirable patterns in the data, latching onto an easy distractor task, and misleading few-shot examples. Some of these trends later reversed into U shapes (McKenzie et al., 2023).
- Downstream tasks. Loss falls smoothly, but accuracy is a nonlinear function of loss, so a single task can look flat and then jump. Whether such emergent abilities are real or created by all-or-nothing metrics is debated (Wei et al., 2022; Schaeffer et al., 2023). Averages over many tasks are more predictable: Gadre et al. (2024) linked perplexity to average top-1 error with a power law and predicted it for models trained with 20 times more compute than the runs used for the fit.
- Inference. A model that will serve many requests (on the order of a billion or more) should be trained smaller and longer than compute-optimal. In tests, quality kept improving up to 10,000 tokens per parameter, though fits made at ordinary ratios overestimated the gains at such extremes (Sardana et al., 2024).
Key takeaways
- Loss follows power laws in , and when the others are plentiful, best fitted with a floor, . Small exponents make scaling costly: halving the loss at exponent takes about times more compute.
- Training costs FLOPs per token: holds while , and the unembedding matters for small models.
- Minimizing at fixed balances and gives ; tokens per parameter stay constant only if . Chinchilla's 20 comes from Approaches 1 and 2 and the re-fitted Approach 3, not from the printed fit.
- Kaplan's versus Chinchilla's came from method: parameter and FLOP counting, warmup and per-size tuning at small scale.
- Similar laws hold for images, video, games and transfer, but curves can break, invert on specific tasks, and translate unpredictably into downstream accuracy.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
A transformer has width . At roughly what context length does the attention term of its training FLOPs equal the term?
- tokens
- tokens
- tokens
- tokens
Show the answer
C. tokens
The ratio is , which reaches at . Beyond that, a FLOP count of undercounts by more than half.
At the compute-optimal point of with , which statement holds?
- The model term equals the data term:
- , so the model term is times the data term
- , whatever the constants
Show the answer
B. , so the model term is times the data term
Setting with gives . Each term's elasticity balances, not its size; the terms are equal only if .
Hoffmann et al.'s printed parametric fit has and . What does it imply about the optimal tokens per parameter?
- A constant 20 at every budget
- It shrinks as compute grows, as Kaplan et al. found
- It is undefined, because the fit has no optimum
- It grows as compute grows, like : about 50 at FLOPs and 78 at
Show the answer
D. It grows as compute grows, like : about 50 at FLOPs and 78 at
, and makes it grow. The 20-tokens rule comes from Approaches 1 and 2 and from Chinchilla itself; Besiroglu et al.'s re-fit of Approach 3, with , recovers about 20.
Porian et al. (2024) reproduced Kaplan et al.'s allocation and then recovered Hoffmann et al.'s. Which change turned out not to be needed?
- Matching the learning-rate decay to each run's length
- Counting the last layer's FLOPs
- Shortening the warmup for small models
- Tuning the learning rate, batch size and AdamW at each model size
Show the answer
A. Matching the learning-rate decay to each run's length
Their fully tuned runs used a constant learning rate and still gave . Cosine decay lowers the loss, but the allocation came from FLOP counting, warmup and per-size tuning.
What is inverse scaling?
- Training loss rising as models grow
- Performance on a specific task getting worse as models grow, even as their overall loss improves
- Smaller models generalizing better because they overfit less
- Loss falling faster than any power law
Show the answer
B. Performance on a specific task getting worse as models grow, even as their overall loss improves
McKenzie et al. (2023) collected 11 tasks where bigger language models did worse, caused by things like distractor tasks and imitation of undesirable patterns in the data; some trends later turned U-shaped. Aggregate loss can improve while a particular behavior degrades.
Go deeper
- μP & Hyperparameter Transfer · Parameterizing width so the best learning rate stays put as models grow.
- Data Quality, Filtering & Mixtures · Deduplication, quality filters, data pruning and choosing a mixture.
- Where Scaling Laws Come From · Solvable models, phases of compute-optimal scaling and the superposition explanation.
Further reading
- J. Kaplan et al., "Scaling laws for neural language models," arXiv:2001.08361 (2020).
- J. Hoffmann et al., "Training compute-optimal large language models," NeurIPS (2022).
- T. Besiroglu, E. Erdil, M. Barnett & J. You, "Chinchilla scaling: A replication attempt," arXiv:2404.10102 (2024).
- T. Porian, M. Wortsman, J. Jitsev, L. Schmidt & Y. Carmon, "Resolving discrepancies in compute-optimal scaling of language models," NeurIPS (2024).
- T. Henighan et al., "Scaling laws for autoregressive generative modeling," arXiv:2010.14701 (2020).