Topic 3 of 6 · 5 min read
Chinchilla and compute-optimal training
Goal: Given a compute budget, choose a model size and token count and explain when overtraining a smaller model is the better deal.
For a fixed training budget, loss is lowest when parameters and tokens grow together, at roughly 20 training tokens per parameter; but if the model will be served a lot, a smaller model trained on more tokens is often the cheaper choice overall.
Check yourself · 1 of 3
What does compute-optimal training mean in the Chinchilla paper?
Why it matters
Early large models were big and under-trained. The Chinchilla paper (Hoffmann et al., 2022) trained a 70B model on 1.4T tokens with the same compute as the 280B Gopher model, which saw about 300B tokens, and the smaller model won on most benchmarks. Spending the budget on tokens beat spending it on parameters.
How to choose
Combine two facts. Compute is C = 6 * N * D. The compute-optimal ratio is D = 20 * N. Substitute: C = 120 * N^2, so N = sqrt(C / 120).
import math
C = 1e23 # FLOPs
N = math.sqrt(C / 120) # about 2.9e10 parameters
D = 20 * N # about 5.8e11 tokens
print(f"{N:.2e} params, {D:.2e} tokens")
That answer minimises training loss for 1e23 FLOPs. It ignores what happens after training.
Training cost is only half the bill
A model is trained once and served many times. Inference costs about 2N FLOPs per generated token, so a smaller model is cheaper for every request. If a model will answer billions of requests, it pays to train a smaller model well past 20 tokens per parameter. LLaMA (2023) trained a 7B model on 1T tokens, about 140 tokens per parameter, so that users could run it cheaply.
| Goal | Choice |
|---|---|
| Lowest loss for one training budget, no serving | About 20 tokens per parameter |
| Cheapest model to serve at a target quality | Smaller model, many more tokens |
| Little data available | Smaller model, since extra parameters will overfit |
Before and after
Weak: "We have budget for 1e23 FLOPs, so train the biggest model we can fit."
Better: "A 29B model on 580B tokens is compute-optimal. Since we expect heavy use, we will compare it with a 13B model on 1.3T tokens, which costs a little more to train and about half as much per request."
What goes wrong
- Treating 20 as a law of nature; the fitted ratio depends on data quality and architecture.
- Ignoring inference when choosing size.
- Repeating the same data many epochs and counting repeats as fresh tokens.
Examples
The 70B beats the 280B
Chinchilla and Gopher used about the same training compute. Gopher had 280B parameters and saw about 300B tokens; Chinchilla had 70B and saw 1.4T. The smaller model was ahead on most tasks and was four times cheaper to serve.
When to overtrain
A product expects 5 billion requests a month. A compute-optimal 30B model saves training compute but costs more on every request than an 8B model trained on 2T tokens. The extra training is paid once; the saving repeats with every request.
Key points
- Chinchilla found that parameters and tokens should grow together, at about 20 tokens per parameter for a fixed compute budget.
- Combining C = 6ND with D = 20N gives N = sqrt(C / 120).
- Inference costs about 2N FLOPs per token, so smaller models are cheaper at every request.
- Overtraining a small model on many more tokens trades extra training cost for lower serving cost.
- The ratio of 20 is a fitted value that depends on data and setup, not a constant of nature.
Common mistakes
- Reading 20 tokens per parameter as a law that every model must obey.
- Choosing model size from the training budget alone, ignoring serving cost.
- Counting repeated epochs of the same data as new tokens.
- Scaling parameters while holding tokens fixed and expecting Chinchilla-style gains.
Check yourself · 2 of 3
A budget is 1e23 FLOPs and you want the compute-optimal size. Which is closest?
Check yourself · 3 of 3
A team expects to serve a model to millions of users. Why might it train a 7B model on 1T tokens rather than a compute-optimal larger one?
Practice items, not counted towards your mastery.
Start here
- Scaling Laws for Neural Language Models (opens in a new tab)PaperFree
Shows test loss following power laws in parameters, data and compute, with the fitted exponents and the 6ND compute estimate.
- Training Compute-Optimal Large Language Models (Chinchilla) (opens in a new tab)PaperFree
The 70B model trained on 1.4T tokens that beat a 280B model at equal compute, and the rule of about 20 tokens per parameter.
- How to Scale Your Model (Google DeepMind scaling book) (opens in a new tab)BookFree
A free, practical text on FLOPs, memory and communication limits when training and serving large models.
More for this topic
- LLaMA: Open and Efficient Foundation Language Models (opens in a new tab)PaperFree
Open models trained on far more tokens than compute-optimal, built to be cheap to run.