All courses

Scaling laws: loss vs parameters, data, compute

State that loss falls as a power law in N, D and C toward an irreducible floor. Use a fitted law to predict a larger model's loss from small runs.

Builds on: Reading pretraining loss curves, FLOPs per token: 2N forward, 6N training

▶ Watch this lesson Start the whole course

What the animation says

Predict before you pay

Training a frontier model costs millions of dollars in compute. The compute is roughly six times the parameters times the training tokens, in floating point operations. Before you pay, you want to know what loss the model will reach. And whether ten times more parameters, data or compute is worth buying. Good news: loss is predictable. Fit a simple curve on cheap small runs, then extend it to the big one.

Floor plus a shrinking gap

Loss has two parts. First, a floor: the entropy of text itself. Even a perfect model can't know which word a writer picks next. Above the floor sits the reducible loss. It is the only part that scale can shrink. Every ten times more parameters multiplies that gap by about the same factor, say zero point six, at every scale. Data and compute work the same way, each with its own factor. So if you keep scaling forever, where does the loss go?

A straight line in log-log

It creeps toward the floor and never touches it. As a formula: loss is about the floor, E, plus a constant A divided by N to the power alpha. Alpha is small. Real fits give roughly zero point zero five to zero point three five. Subtract the floor and take logs of both axes. The gap becomes a straight line that slopes down by alpha. Data and compute follow the same shape, as long as the other factors aren't the bottleneck.

Two small runs, one big guess

Let's predict a ten-billion-parameter model from two small runs. The fitted floor is one point seven. Ten million parameters reaches loss three point seven. A hundred million reaches two point seven. Subtract the floor, and the gaps are two, then one. So each ten times in parameters halves the gap. That means alpha is about zero point three. Ten billion is a hundred times bigger than a hundred million. What loss do you predict?

Keep the floor

A hundred times is two decades, so the gap halves twice: one, then a half, then a quarter. Add the floor back: one point seven plus a quarter is about one point nine five. Now the trap: drop the floor and fit the raw loss instead. Then each decade multiplies the whole loss by about zero point seven three. Two decades from two point seven gives about one point four four. That is below the floor, which is impossible. So always subtract the floor before you multiply.

Fitting the floor

In real fits, the floor isn't given. You estimate it too. This script tries many candidate floors. For each one, this line subtracts the floor and takes logs, and this line fits a straight line. The floor that makes the points straightest wins: here one point seven, with alpha zero point three. Then extrapolate a few orders of magnitude, and watch for the factor you didn't scale becoming the bottleneck. Your turn: drag the floor until the points line up.

Can small runs predict a big model's loss?

A large training run costs $C \approx 6ND$ FLOPs, and at frontier scale that is millions of dollars of hardware time. Before spending it, you want to know what loss the model will reach, and whether 10× more parameters, data or compute is worth paying for. Loss turns out to be predictable. Across many orders of magnitude it follows a simple curve. You can fit that curve on cheap small runs and extend it to the big one.

Each 10× buys a fixed fraction

Loss has two parts. Cross-entropy equals the entropy of text plus the KL divergence from the true distribution to the model. The entropy part is **irreducible**: even a perfect model cannot know which word a writer picks next. Scale only shrinks the rest, the **reducible loss**. In practice, every 10× in parameters multiplies the reducible loss by roughly the same factor, say 0.6, at every scale. The same holds for data and for compute, each with its own factor. The gains are steady fractions, and loss approaches the floor without ever reaching it.

The power-law form

$$\mathcal L(N) \approx E + \frac{A}{N^{\alpha}}$$ - $E$: the irreducible floor, in nats per token. - $A$: a fitted constant (here not the attention pattern). - $\alpha$: a small exponent; fits give roughly 0.05–0.35. The same form holds for $D$ (with $N$ large) and for $C$ (the best loss reachable at that compute). Taking logs gives $\log(\mathcal L-E)=\log A-\alpha\log N$, a straight line of slope $-\alpha$ on log-log axes. Each law holds only while the other factors are not the bottleneck. Combined: $\mathcal L(N,D)\approx E+A/N^{\alpha}+B/D^{\beta}$. Here $B$ is the data term's fitted constant (not the batch size) and $\beta$ is its exponent (not the KL coefficient).

Predicting a 10B model from two small runs

Take a fitted floor $E=1.7$. 1. Runs: $N$=10M gives 3.70; $N$=100M gives 2.70. 2. Reducible parts: 2.00, then 1.00. So 10× in $N$ halves it: $10^{-\alpha}=0.5$, giving $\alpha\approx0.30$. 3. 10B is 100× larger than 100M, which is two more decades: $1.00\times0.5\times0.5=0.25$. 4. Prediction: $\mathcal L\approx1.95$. If you drop the floor and fit $\mathcal L$ alone, each decade multiplies by 0.73, giving $2.70\times0.73^2\approx1.44$. That is below the floor, which is impossible.

Fitting the floor and exponent

Real fits estimate $E$ too. Try many candidate floors and keep the one that makes $\log(\mathcal L-E)$ against $\log N$ straightest. Then extrapolate. The losses here are synthetic. The script prints E=1.70, alpha=0.300 and a predicted loss of about 1.952 at 10B.
import numpy as np
N = np.array([1e7, 3e7, 1e8, 3e8, 1e9])
loss = 1.7 + 2.0 * (N / 1e7) ** -0.3  # synthetic "measured" losses
def fit(E):  # straight line in log-log after removing floor E
    y = np.log(loss - E)
    s, c = np.polyfit(np.log(N), y, 1)
    err = np.sum((s * np.log(N) + c - y) ** 2)
    return err, s, c, E
err, s, c, E = min(fit(E) for E in np.linspace(0, 1.9, 191))
print(f"E={E:.2f} alpha={-s:.3f} pred@1e10={E + np.exp(c) * 1e10**s:.3f}")

Remember

Loss = an irreducible floor $E$ + a reducible part that falls as a power law ($A/N^{\alpha}$, and likewise in $D$ and $C$). After you subtract $E$, that part is a straight line on log-log axes. Fit it on small runs and extrapolate a few orders of magnitude. Keep the floor, and watch for the factor you did not scale becoming the bottleneck.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.