Scaling laws and compute-optimal training
Power laws, FLOPs ≈ 6ND, Chinchilla's 20 tokens per parameter, and over-training
Scaling laws turned model building from craft into planning: given a compute budget you can predict the loss, choose the model size and the number of training tokens, and estimate the GPU bill before launching a run. They explain why GPT-3 was built, why Chinchilla showed it was mis-sized, why Llama 3 8B saw 15 trillion tokens, and why the field pivoted toward post-training and test-time compute (8.6 Reasoning models and test-time compute). The 6ND rule here also underlies every cost estimate in 7.10 Efficient inference: KV cache, GQA, FlashAttention, speculative decoding, quantization and 4.12 Compute, hardware and scale basics.
You'll be able to
- State the Kaplan power laws and what they imply about sample efficiency and extrapolation
- Derive the FLOPs ≈ 6ND rule and estimate GPU-days for a training run
- Reproduce the Chinchilla result D ≈ 20N from the fitted loss function and apply it to a budget
- Explain inference-aware over-training, data constraints and the emergence debate
Key ideas
- Loss follows power laws in parameters, data and compute over many orders of magnitude; architecture details matter far less than scale.
- Training compute ≈ 6ND FLOPs: 2N for the forward pass and 4N for the backward pass per token.
- Chinchilla's fitted law L = E + A/N^α + B/D^β gives compute-optimal D ≈ 20N: grow parameters and tokens together.
Show 4 more key ideas
- Gopher (280B, 300B tokens) was under-trained; Chinchilla (70B, 1.4T tokens) beat it at the same compute.
- Inference cost scales with N, so heavily used models are over-trained far past Chinchilla (Llama 3 8B: ≈1,900 tokens per parameter).
- High-quality data is the binding constraint; ~4 epochs of repetition is nearly free, beyond that returns fall.
- Apparent emergence is partly a metric artifact; smooth metrics improve predictably, but discrete thresholds still matter in practice.
Suggested path through this lesson
Loss is predictable
In 2020 Kaplan et al. trained hundreds of decoder models and found that test loss follows smooth power laws in each of three resources, as long as the other two are not bottlenecks:
with non-embedding parameters, training tokens, compute, and exponents around , , — straight lines on log–log plots spanning seven orders of magnitude. Architecture details (depth vs width, number of heads) mattered far less than scale. Two consequences changed how labs plan: a bigger model is more sample-efficient (it reaches a given loss with fewer tokens), and you can extrapolate the loss of a run that costs millions from runs that cost thousands.
Counting compute: why FLOPs ≈ 6ND
Every weight in a matrix multiplication does one multiply and one add per token in the forward pass: FLOPs per token for parameters (7.4 Inside the block: residuals, LayerNorm, FFN and embeddings). The backward pass computes two gradients per weight — one with respect to the layer input (to keep propagating, 4.4 Backpropagation, fully derived) and one with respect to the weight itself — so it costs about . Total: FLOPs per token, or
Attention scores add roughly per token for context length , negligible when and significant for very long contexts (7.12 Beyond vanilla attention: state space models, long context and hybrids). Example: GPT-3, B, B → FLOPs. On an H100 sustaining an effective 400 TFLOP/s (about 40% of its bf16 peak), that is seconds ≈ 9,100 GPU-days — three months on 100 GPUs.
Chinchilla: the right size for a budget
Kaplan's fits suggested spending extra compute mostly on parameters, and labs built models like Gopher (280B parameters, 300B tokens). Hoffmann et al. (2022) redid the experiment with learning-rate schedules matched to each run's length and fitted a joint law:
is the irreducible entropy of text (1.9 Information theory: entropy, cross-entropy and KL divergence); the other two terms are the penalties for finite model size and finite data. Minimizing subject to gives and with : parameters and tokens should grow together, and the optimal ratio is roughly
Gopher, at about one token per parameter, was badly under-trained. Chinchilla, a 70B model trained on 1.4T tokens with about the same compute, beat it across the board.
Worked example. Budget FLOPs. With : , so — a 29B-parameter model trained on about 580B tokens. For : B and B tokens. The llm-calculator demo does this for any budget.
Inference changes the answer
Chinchilla optimizes training loss per training FLOP. But a deployed model is run billions of times, and inference cost scales with , not . If you expect heavy usage, it pays to train a smaller model on far more tokens than Chinchilla suggests — losing a little quality per training FLOP but gaining it back many times over at inference. Llama 3 8B was trained on 15T tokens, about 1,900 tokens per parameter (≈95× the Chinchilla ratio); such "over-trained" small models are now the norm, and their loss keeps falling with more data, just more slowly.
Data: the binding constraint
Tokens are not free. Estimates of the stock of high-quality public text run to a few hundred trillion tokens, and frontier training sets already use tens of trillions. Muennighoff et al. (2023) showed that repeating data for up to about four epochs costs almost nothing, after which returns diminish fast; beyond that, labs lean on filtering and deduplication (quality beats quantity), code and multilingual data, and synthetic data generated or rewritten by models — with care, since training on model outputs can narrow the distribution.
Emergence, or metric artifacts?
Wei et al. (2022) catalogued abilities (arithmetic, multi-step reasoning) that appear "suddenly" at some scale. Schaeffer et al. (2023) showed much of the suddenness comes from discontinuous metrics: exact-match accuracy jumps from 0 to 1 while the underlying per-token log-likelihood improves smoothly. The current view is that capability under smooth metrics is predictable, but thresholds on discrete tasks are real for users — a model either produces valid JSON for a tool call or it does not (10.2 Tool use and function calling).
Scaling in 2026
Pretraining scale still helps, but each 10× of compute buys less than it did, and the frontier added two new axes: post-training with reinforcement learning on verifiable tasks (8.3 Alignment: RLHF, PPO, DPO, GRPO and Constitutional AI, 8.6 Reasoning models and test-time compute), and test-time compute — letting the model think longer at inference, which has its own scaling curves (8.6 Reasoning models and test-time compute). Distillation moves frontier capability into small models, and mixture-of-experts (7.11 Mixture of Experts) decouples parameters from per-token compute, so "parameters" alone no longer predicts cost or quality.
| quantity | formula / rule | example |
|---|---|---|
| training FLOPs | GPT-3: | |
| compute-optimal tokens | 70B model → 1.4T tokens | |
| GPU-days | at 400 TFLOP/s → 2,900 GPU-days | |
| over-training ratio | vs 20 | Llama 3 8B: ≈1,900 |
Where this shows up later
- Parameter counting (7.4 Inside the block: residuals, LayerNorm, FFN and embeddings) and the 6ND rule are the inputs to every budgeting decision in this phase; the hardware side is 4.12 Compute, hardware and scale basics.
- Over-training small models for cheap inference connects to the KV-cache and quantization economics of 7.10 Efficient inference: KV cache, GQA, FlashAttention, speculative decoding, quantization.
- Test-time compute and RL post-training are the new scaling axes — 8.6 Reasoning models and test-time compute, 8.3 Alignment: RLHF, PPO, DPO, GRPO and Constitutional AI; deciding whether scale "emerged" a capability is an evaluation question — 8.7 Evaluating LLMs.
Common pitfalls (4)
- Using 2ND (forward only) as the training cost — the backward pass triples it.
- Treating Chinchilla's ratio as a law of nature: it optimizes training loss per training FLOP and ignores inference cost and data limits.
- Comparing models by parameter count alone when one is a mixture-of-experts or far more over-trained than the other.
- Quoting peak FLOP/s for cost estimates; real utilization is typically 30–50% of peak.
Recap: all 7 key points
- Loss follows power laws in parameters, data and compute over many orders of magnitude; architecture details matter far less than scale.
- Training compute ≈ 6ND FLOPs: 2N for the forward pass and 4N for the backward pass per token.
- Chinchilla's fitted law L = E + A/N^α + B/D^β gives compute-optimal D ≈ 20N: grow parameters and tokens together.
- Gopher (280B, 300B tokens) was under-trained; Chinchilla (70B, 1.4T tokens) beat it at the same compute.
- Inference cost scales with N, so heavily used models are over-trained far past Chinchilla (Llama 3 8B: ≈1,900 tokens per parameter).
- High-quality data is the binding constraint; ~4 epochs of repetition is nearly free, beyond that returns fall.
- Apparent emergence is partly a metric artifact; smooth metrics improve predictably, but discrete thresholds still matter in practice.
Watch
How a researcher who scaled models thinks about scale, structure and what to leave to compute.
Read
Try it live
Interactive demo
runs in your browserExercises
- Size a model for a budget
For budgets of , and FLOPs, compute the Chinchilla-optimal and , then the GPU-days on an H100 at 400 TFLOP/s effective. Expected: roughly (0.29B, 5.8B tokens, 0.3 GPU-days), (2.9B, 58B, 29 GPU-days), (29B, 580B, 2,900 GPU-days).
- Your own scaling law
Using the mini scaling study from 7.8 Build GPT from scratch (nanoGPT walkthrough) (or TinyStories), fit to three or more model sizes trained on the same tokens. Expected: a reasonable fit with between 0.1 and 0.5, and a prediction for a fourth size you then train to check.
- Over-training economics
Suppose a model will answer requests of 1,000 tokens each. Compare total FLOPs (training + inference, using per generated token) for a Chinchilla-optimal 29B model trained on 580B tokens versus an 8B model trained on 4T tokens. Expected: the small over-trained model wins by a wide margin — then argue when it would not.
Quiz
Flashcards
These cards are now in your spaced-repetition queue. Review all due cards →