Search

Search papers and lessons

Compute-Optimal Training

Level 4 · 10 min read

For a fixed compute budget, a language model reaches its lowest loss when its parameter count and its training tokens grow together, at roughly 20 tokens per parameter.

On this page

  • Colour = topic mix
  • Probability
  • Calculus
  • Discrete math
  • Pre-training
  • Losses & regularization
  • Neural network basics
  • Sign in to see your progress

TL;DR

Training a language model costs compute, and that compute is roughly the number of parameters times the number of training tokens. For a fixed budget you have to choose the split: a huge model seen briefly, or a smaller model seen for longer. Compute-optimal training picks the split that gives the lowest loss for that budget.

The answer from the 2022 Chinchilla study is that parameters and tokens should grow together, in roughly equal proportion, which works out to about 20 training tokens for every parameter. Many large models before it had been trained with far too many parameters for the data they saw.

Where you'll see it: in planning how big a language model should be before a training run, in deciding how many tokens to collect, and in choosing a smaller model trained longer when inference cost matters more than training cost.

Intuition

A fixed amount of work to split

Think of a fixed budget of study hours before an exam. You can read one very dense textbook once, or a shorter book many times. Which gives the better score depends on how much knowledge the reader can hold and how much material there is to learn from. If you only ever reread the short book, you stop learning from it. If you own a huge book but study for only an hour, most of it stays unread.

Training a Transformer has the same shape. The model has parameters, which are its capacity to store patterns. It sees tokens, which are the material. Each parameter-token pair costs a fixed amount of arithmetic, so the total compute is the product of the two. Given a fixed product, making one factor large forces the other to be small.

The question this lesson answers is which pair is the best use of the budget. The scaling laws lesson shows that loss falls as a power law in each resource separately. Compute-optimal training combines those power laws with the fixed product and asks where the combined loss is smallest.

99.51010.51111.51212.51.81.922.12.22.32.4log10 of parameter countloss
  • fixed budget (schematic)
Schematic only, not measured data. At a fixed compute budget the loss is a U-shaped function of model size. The lowest point is the compute-optimal size; both smaller and larger models do worse.

The math

Definition: Compute-optimal training
For a training compute budget CC measured in floating-point operations, choose a parameter count NN and a token count DD so that the loss L(N,D)L(N, D) is as small as possible, subject to the budget constraint C≈6NDC \approx 6 N D.

The budget constraint

For a dense transformer, one training pass costs about two floating-point operations per parameter for the forward pass and about four for the backward pass, for each token. Together that is about six operations per parameter per token:

C≈6ND.C \approx 6 N D.

This is the only link between the two choices. Fix CC and each choice of NN determines DD:

D=C6N.D = \frac{C}{6N}.

The loss model

The 2022 study fitted a loss that depends on both resources, with an irreducible floor EE and two terms that fall as the model or the data grow:

L(N,D)≈E+ANα+BDβ.L(N, D) \approx E + \frac{A}{N^{\alpha}} + \frac{B}{D^{\beta}}.

Here EE, AA, BB, α\alpha and β\beta are fitted constants. The floor EE is the entropy of the text itself, which no model can beat. The exponents α\alpha and β\beta say how fast each term shrinks. The 2022 paper's own fit gave α\alpha near 0.340.34 and β\beta near 0.280.28, close to each other but not equal. Treat the fitted values as those of one study on one dataset, not universal numbers.

Finding the best split

Substitute D=C/(6N)D = C/(6N) into the loss. Since 1/Dβ=(6N/C)β1/D^{\beta} = (6N/C)^{\beta},

L(N)=E+AN−α+B(6C)βNβ.L(N) = E + A N^{-\alpha} + B \left(\frac{6}{C}\right)^{\beta} N^{\beta}.

Set the derivative with respect to NN to zero:

−αAN−α−1+βB(6C)βNβ−1=0.-\alpha A N^{-\alpha - 1} + \beta B \left(\frac{6}{C}\right)^{\beta} N^{\beta - 1} = 0.

Rearranging gives Nα+β∝CβN^{\alpha + \beta} \propto C^{\beta}, so

Nopt∝Cβ/(α+β),Dopt=C6Nopt∝Cα/(α+β).N_{\text{opt}} \propto C^{\beta / (\alpha + \beta)}, \qquad D_{\text{opt}} = \frac{C}{6 N_{\text{opt}}} \propto C^{\alpha / (\alpha + \beta)}.

The two exponents add to one, so the two resources always share the extra compute between them. If α=β\alpha = \beta, both NoptN_{\text{opt}} and DoptD_{\text{opt}} scale as C1/2C^{1/2}. With the fitted values above the exponents are about 0.450.45 for NoptN_{\text{opt}} and 0.550.55 for DoptD_{\text{opt}}, so "equal split" is a close approximation: the Chinchilla result is that both grow at roughly the same rate, not that one dominates.

What the ratio looks like

Dividing the two optimal values gives the tokens per parameter at the optimum:

DoptNopt=C/(6Nopt)Nopt=C6Nopt2.\frac{D_{\text{opt}}}{N_{\text{opt}}} = \frac{C/(6N_{\text{opt}})}{N_{\text{opt}}} = \frac{C}{6 N_{\text{opt}}^2}.

When α=β\alpha = \beta this ratio is constant in CC, so the same tokens-per-parameter number applies at every budget. The study found that this ratio is about 20 across the budgets it tested, and the worked examples below use α=β\alpha = \beta with a ratio of exactly 20 as a clean approximation.

Worked examples

Example
The budget of a 70-billion-parameter model

Suppose the budget is C=5.76×1023C = 5.76 \times 10^{23} floating-point operations, and we use the rule D=20ND = 20 N.

  1. Write the budget in terms of NN: C=6ND=6N(20N)=120N2C = 6 N D = 6 N (20 N) = 120 N^2.
  2. Solve for NN: N2=C/120=5.76×1023/120=4.8×1021N^2 = C / 120 = 5.76 \times 10^{23} / 120 = 4.8 \times 10^{21}.
  3. Take the square root: N=4.8×1021≈6.9×1010N = \sqrt{4.8 \times 10^{21}} \approx 6.9 \times 10^{10}, about 70 billion parameters.
  4. Get the tokens: D=20N≈1.4×1012D = 20 N \approx 1.4 \times 10^{12}, about 1.4 trillion tokens.
  5. Check: 6×6.9×1010×1.4×1012≈5.8×10236 \times 6.9 \times 10^{10} \times 1.4 \times 10^{12} \approx 5.8 \times 10^{23}, which matches the budget.

Interpretation: with this budget the best model is about 70 billion parameters trained on about 1.4 trillion tokens. A model four times larger on the same budget would see only about a quarter as many tokens, and the study found that such a model does worse.

Example
Ten times the budget

Start from the same 70-billion-parameter, 1.4-trillion-token point and multiply the budget by 10. Use α=β\alpha = \beta, so both quantities scale as the square root of the budget.

  1. The scale factor for each quantity is 10≈3.16\sqrt{10} \approx 3.16.
  2. New parameters: 70 billion×3.16≈221 billion70 \text{ billion} \times 3.16 \approx 221 \text{ billion}.
  3. New tokens: 1.4 trillion×3.16≈4.4 trillion1.4 \text{ trillion} \times 3.16 \approx 4.4 \text{ trillion}.
  4. Check the ratio: 4.4 trillion/221 billion≈204.4 \text{ trillion} / 221 \text{ billion} \approx 20, the same tokens per parameter as before.
  5. Check the budget: 6×2.21×1011×4.4×1012≈5.8×10246 \times 2.21 \times 10^{11} \times 4.4 \times 10^{12} \approx 5.8 \times 10^{24}, which is ten times 5.76×10235.76 \times 10^{23}.

Interpretation: when the budget grows, both the model and the data must grow, and at the same rate. Adding parameters alone, or adding data alone, leaves the other term as the bottleneck.

Example
A smaller model for a deployed product

Compare two ways to spend the same budget of 5.76×10235.76 \times 10^{23} operations. Model A is the compute-optimal 70 billion parameters with 1.4 trillion tokens. Model B is a smaller 7 billion parameters.

  1. For Model B, the budget gives D=C/(6N)=5.76×1023/(6×7×109)≈1.4×1013D = C / (6 N) = 5.76 \times 10^{23} / (6 \times 7 \times 10^9) \approx 1.4 \times 10^{13}, which is 14 trillion tokens.
  2. Model B is ten times smaller than Model A and sees ten times more data. Against the 20-tokens-per-parameter rule for its own size (140 billion tokens), it is trained on about 100 times more.
  3. Inference cost is set by parameter count. Each query on Model B costs about a tenth of a query on Model A.

Interpretation: if the model will serve millions of queries, the total cost is dominated by inference, and a smaller model trained longer can be the better product even though it is not the lowest-loss model for the training budget alone. Compute-optimal training answers the training question, not the whole cost question.

Tradeoffs and failure modes

The rule is a training-budget rule. It does not account for what happens after training, and it assumes the fitted constants apply to your data and architecture.

SituationWhat goes wrongBetter choice
Model will serve a huge number of queriesThe compute-optimal model is expensive to run at inferenceTrain a smaller model on more tokens, accepting higher training cost for lower serving cost
Tokens are scarce or expensive to collectThe 20-tokens-per-parameter rule asks for more data than existsRepeat data carefully, filter for quality, or accept a smaller model
Data quality varies across the corpusFitted constants from one corpus can overstate gains on a noisier oneRefit on a small pilot run with your own mix
Fitting the schedule with a fixed learning-rate decayComparing models at intermediate points can misleadLet each run finish its own schedule before comparing
Extrapolating the rule to a very different architectureThe exponents and the constant of 20 depend on setupMeasure the ratio on your architecture at a few small scales first

History

In 2020 Jared Kaplan and colleagues at OpenAI published a systematic study of how language-model loss depends on parameters, data and compute. Their fitted allocation put most of an extra compute budget into model size, with comparatively little into tokens. Their training runs did not all reach the same point in their learning-rate schedule, and that choice shaped the answer they got.

In 2022 a team at DeepMind led by Jordan Hoffmann re-ran the comparison with more careful controls. They trained many models over a range of sizes and token counts, fitted the loss surface, and found that the best split grows parameters and tokens at roughly the same rate. To test the conclusion they trained Chinchilla, a 70-billion-parameter model on about 1.4 trillion tokens, with about the same compute as Gopher, a model of 280 billion parameters trained on about 300 billion tokens. Chinchilla beat the larger model on a broad set of benchmarks, which made the point in a concrete way.

The result changed how many teams plan training runs. Later open models were trained on far more tokens than earlier models of similar size, and the question shifted from how large a model to build toward how much data to gather for a given model size. The rule is also now debated, because a model's serving cost can justify training past the compute-optimal point.

Check yourself

QuestionWhy does a fixed compute budget force a choice between parameters and tokens?Show answer

Training compute is roughly C≈6NDC \approx 6 N D, the product of parameter count and token count. With CC fixed, increasing NN forces DD to fall, and the reverse holds too. The loss depends on both, so neither term can be pushed to zero by growing one resource alone. The optimal split is the one that balances the two terms.

QuestionA budget is C=1.2×1023C = 1.2 \times 10^{23} operations and the rule is D=20ND = 20 N. Find NN and DD.Show answer

Substitute into C=6NDC = 6 N D: C=6N(20N)=120N2C = 6 N (20 N) = 120 N^2, so N2=1.2×1023/120=1.0×1021N^2 = 1.2 \times 10^{23} / 120 = 1.0 \times 10^{21}. Then N=1010.5≈3.2×1010N = 10^{10.5} \approx 3.2 \times 10^{10}, about 32 billion parameters. The tokens are D=20N≈6.3×1011D = 20 N \approx 6.3 \times 10^{11}, about 630 billion. Check: 6×3.2×1010×6.3×1011≈1.2×10236 \times 3.2 \times 10^{10} \times 6.3 \times 10^{11} \approx 1.2 \times 10^{23}.

QuestionIf α=β\alpha = \beta in the loss model, how do the optimal parameters and tokens change when the budget grows 100 times?Show answer

With α=β\alpha = \beta both NoptN_{\text{opt}} and DoptD_{\text{opt}} scale as C1/2C^{1/2}. A 100-fold budget increase multiplies each by 100=10\sqrt{100} = 10. The ratio of tokens to parameters stays the same, so the model and the data both grow tenfold. Adding only parameters, or only tokens, would leave the other term as the bottleneck.

QuestionA team serves a model to millions of users and must choose between the compute-optimal 70-billion-parameter model and a 7-billion-parameter model trained on more tokens with the same training budget. Which would you pick, and why?Show answer

For training cost alone the compute-optimal model has the lower loss. But serving cost is set by parameter count, so the 7-billion model is about ten times cheaper per query. With millions of queries, inference can dominate total cost, which favours the smaller model trained longer. The answer depends on the expected number of queries and on how much loss matters for the product, so the honest choice compares total cost over the model's lifetime, not training cost alone.

Sources