← All posts

Model development

Post 7 of 26

Scaling laws: spending a compute budget on parameters and tokens

Posts in this series · 26

The previous post trained a model with about a million parameters in minutes. A frontier run costs months and millions of dollars, and it happens once. Before it starts, someone has to decide two numbers: how many parameters the model should have, and how many tokens it should be trained on. Get the split wrong and the same compute buys a worse model.

Scaling laws are the tool for that decision: empirical formulas, fitted to many small training runs, that predict how loss changes with model size, data and compute. This post explains the compute arithmetic, what the best-known experiments found, how serving changes the answer, and what small experiments can and cannot tell you.

Counting training compute

A forward pass through a model with NN parameters costs about 2N2N floating-point operations per token: one multiply and one add for each weight. The backward pass costs about twice that, because it computes gradients with respect to both activations and weights. So training on DD tokens costs about

C≈6ND FLOPs.C \approx 6 N D \ \text{FLOPs}.

A 1-billion-parameter model trained on 20 billion tokens needs 6×109×2×1010=1.2×10206 \times 10^9 \times 2 \times 10^{10} = 1.2 \times 10^{20} FLOPs, the figure in Chinchilla’s Table 3. At an assumed sustained 400 trillion FLOPs per second per GPU, that is about 83 GPU-hours. The same formula says what a budget buys: every factor of ten in compute can go to parameters, tokens or both.

How to split a budget

Chinchilla asked the question directly. Its authors trained over 400 models, from 70 million to over 16 billion parameters, on 5 to 500 billion tokens, and estimated the best model size for each compute budget in three ways (abstract, §3):

  1. Minimum over training curves: for each budget, take the lowest loss reached by any model.
  2. IsoFLOP profiles: at each of several fixed budgets, train models of different sizes and find the size at the bottom of the loss curve.
  3. A parametric fit: fit a formula for loss as a function of NN and DD and minimize it.

The first two agree: the optimal parameter count and token count should grow at about the same rate with compute, Nopt∝C0.50N_{\text{opt}} \propto C^{0.50} and Dopt∝C0.50D_{\text{opt}} \propto C^{0.50} (Table 2). Their projections put the optimum near 20 tokens per parameter: 20.2 billion tokens for a 1-billion-parameter model, 205 billion for a 10-billion one (Table 3). Earlier work had recommended putting most extra compute into parameters, and many large models of the time were, by this analysis, too big for their data. The test was Chinchilla itself: 70 billion parameters trained on four times more data than the 280-billion-parameter Gopher with the same compute, and it outperformed Gopher across a large range of evaluations (abstract).

With D=20ND = 20N, the budget formula becomes C=6N×20N=120N2C = 6N \times 20N = 120N^2, so N=C/120N = \sqrt{C/120}. A budget of 1.2×10211.2 \times 10^{21} FLOPs gives about 3.2 billion parameters and 63 billion tokens.

The third approach disagrees. Chinchilla’s fitted formula is

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

with published values E=1.69E = 1.69, A=406.4A = 406.4, B=410.7B = 410.7, α=0.34\alpha = 0.34 and β=0.28\beta = 0.28 (§3.3, App. D.2). Minimizing that formula at our budget gives about 2.0 billion parameters and 51 tokens per parameter, not 20. A later replication traced the mismatch to the fit itself: the optimizer stopped before converging and the published coefficients were rounded in a way that biases predictions; refitting gave results consistent with the first two approaches (Besiroglu et al., 2024, abstract). The Chinchilla review looks at this in detail. For planning, the lesson is to trust the robust conclusion, that parameters and tokens should scale together, more than any one fitted constant.

Try it: compare three plans. With C=1.2×1021C = 1.2 \times 10^{21} FLOPs you could train (a) 10 billion parameters on 20 billion tokens, (b) 3.2 billion on 63 billion, or (c) 1 billion on 200 billion. All cost the same. Using the published formula only to see the shape, the predicted losses are (a) 2.39, (b) 2.32, (c) 2.33. Which would you train?

Answer. On loss alone, (b), the compute-optimal plan, with (c) close behind and (a), the oversized model, clearly worst. The bottom of the curve is flat: being off by a factor of three in model size costs little, being off by ten costs more. Llama 3’s report observed the same flatness at large budgets and used it to choose a convenient size near the predicted optimum (Llama 3, §3.2.1). But loss is not the only cost. Read on.

When the model has to be served

Compute-optimal means optimal for training compute. A deployed model then generates tokens, at about 2N2N FLOPs each. Suppose the model will serve 101310^{13} tokens over its life:

PlanTrainingServing 101310^{13} tokensTotal
(a) 10B on 20B1.2×10211.2 \times 10^{21}2.0×10232.0 \times 10^{23}2.0×10232.0 \times 10^{23}
(b) 3.2B on 63B1.2×10211.2 \times 10^{21}6.3×10226.3 \times 10^{22}6.4×10226.4 \times 10^{22}
(c) 1B on 200B1.2×10211.2 \times 10^{21}2.0×10222.0 \times 10^{22}2.1×10222.1 \times 10^{22}

Serving dominates, and the smaller model trained longer is three times cheaper overall for almost the same predicted loss. This is why widely deployed models are trained far beyond 20 tokens per parameter: Llama 3’s 405-billion-parameter model saw 15.6 trillion tokens, about 39 per parameter, and smaller models are usually trained much further. Sardana et al. (2024) worked this out formally: with large expected inference demand, models should be smaller and trained longer than Chinchilla-optimal, and in their experiments quality kept improving up to extreme ratios of 10,000 tokens per parameter (abstract). The limit then becomes data: training longer needs more unique tokens, which brings back the repetition question from the mixtures post.

What small experiments can predict

Scaling laws are only as good as the experiments behind them, and the decision they inform is made once, at a scale nobody has measured. Three cautions:

Everyday picture: a scaling law is a tide table. Fitted to past tides at one harbour, it predicts the next high water remarkably well. It is a poor guide to a different harbour, and it says nothing about whether a particular boat will float.

What to remember

Try it yourself

Sources

Further reading