Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Predicting how good a bigger model will be
If you train a series of small language models, their errors fall along a smooth curve as you add size, data or computing power. That curve can be extended to predict how good a model ten thousand times bigger will be before spending millions on it. Scaling laws also answer a practical question: with a fixed budget, should you build a bigger model or train a smaller one on more text? The answer changed in 2022: use much more data than people thought. The demo finds the best split for a budget.
Compute budgets for foundation models, including domain models for aerospace, are planned with scaling laws: they decide model size, data needs and training time before any large run starts.
- 1. Language-model loss falls with size and data as…
- 2. Chinchilla found models should be trained on…
- 3. Training compute is roughly…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Compute: C ≈ 6ND FLOPs (2ND forward, 4ND backward). Chinchilla: 70B × 1.4T tokens = 5.9 × 10²³ FLOPs.
- Kaplan et al. (2020): L(N) ∝ N^(−0.076), L(D) ∝ D^(−0.095), and compute-optimal N ∝ C^0.73. Their runs used a fixed learning-rate schedule length, which biased the fits towards large models.
- Chinchilla (Hoffmann et al., 2022): L(N, D) = E + A/N^a + B/D^b with E = 1.69, A = 406.4, a = 0.34, B = 410.7, b = 0.28. Minimising under C = 6ND gives N ∝ C^(b/(a+b)) ≈ C^0.45 and D ∝ C^0.55. Their other two methods (training curves and isoFLOP profiles) gave about 20 tokens per parameter.
- Three estimation methods:
- minimum loss over training curves;
- isoFLOP profiles: fit a parabola of loss against log N at each fixed budget;
- a parametric fit of L(N, D).
- Beyond compute-optimal: inference-heavy models are trained far past 20 tokens per parameter (LLaMA-3 8B saw 15T tokens), trading training compute for a smaller, cheaper model at inference.
- 1. FLOPs for a 7B model on 2T tokens:
- 2. Chinchilla's rule of thumb:
- 3. Kaplan's compute-optimal N grows as…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Scaling laws in code
Exercise 1.
- Compute training FLOPs with 6ND.
- Apply the 20-tokens-per-parameter rule.
- Fit a power law in log–log space.
Practice.
- Run a ladder of small models (for example 10M–1B parameters) with tuned, budget-matched learning-rate schedules, and record final losses.
- Fit isoFLOP parabolas and a parametric law; check that predictions agree and hold on a held-out larger run before committing compute.
- Account for real throughput: GPU-days = FLOPs / (peak × utilisation), with model FLOPs utilisation often 30–50%.
- Downstream task metrics can change abruptly even when loss is smooth; validate on the capabilities you need.
import numpy as np
# isoFLOP analysis at one budget: losses of several model sizes trained with C = 6ND
N = np.array([2e8, 4e8, 8e8, 1.6e9, 3.2e9]); loss = np.array([3.10, 2.98, 2.94, 2.96, 3.05])
c2, c1, c0 = np.polyfit(np.log(N), loss, 2)
print("optimal N ≈", np.exp(-c1 / (2 * c2)))- 1. Learning-rate schedules in a scaling study should be…
- 2. Real throughput uses model FLOPs utilisation of about…
- 3. Before a big run, check that the law…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Where the optimal split comes from. Minimising E + A/N^a + B/D^b subject to 6ND = C (Lagrange multipliers) gives aA/N^a = bB/D^b at the optimum, hence N_opt = G (C/6)^(b/(a+b)) with G = (aA/(bB))^(1/(a+b)). When a ≈ b, parameters and tokens should grow equally.
Why Kaplan’s allocation was off. Kaplan’s smaller models were trained with a cosine schedule set for a much longer run, so their intermediate losses overstated the cost of using more data. Correcting the schedule shifts the optimum towards more tokens.
The loss is flat near the optimum. Around N_opt, loss changes slowly with N, so moderate errors in the fitted exponents barely matter. Large misallocations (10×) cost a lot. Scaling laws also break down: irreducible loss E, data exhaustion (repeating data, F5-2), and emergent capabilities that loss does not show.
- 1. At the compute optimum, the marginal gains satisfy…
- 2. Kaplan's bias came from…
- 3. Near the optimum, loss as a function of N is…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Can a scaling law fitted on small runs choose the right model size for a run 10,000 times bigger?
History.
- J. Kaplan et al., “Scaling laws for neural language models” (2020).
- J. Hoffmann et al., “Training compute-optimal large language models” (NeurIPS 2022), Chinchilla.
- T. Besiroglu et al., “Chinchilla scaling: a replication attempt” (2024), which found the published parametric fit inconsistent with the paper’s other methods.
Exercise 2 (simulated runs).
- Runs: “training runs” at budgets 10¹⁸, 3 × 10¹⁸, 10¹⁹, 3 × 10¹⁹ and 10²⁰ FLOPs, 9 model sizes each. Losses come from Chinchilla’s published parametric law with 1% noise, a stand-in for real runs that cost GPU-months.
- Procedure:
- fit E, A, a, B and b by least squares in log space;
- find the optimal N at 10²⁰ by an isoFLOP parabola;
- extrapolate the optimal N to 10²⁴ FLOPs, and compare with a Kaplan-style rule (N ∝ C^0.73) from the same starting point.
| quantity | value |
|---|---|
| fitted exponents a, b (truth 0.34, 0.28) | 0.302, 0.246 |
| isoFLOP optimal N at 10²⁰ (truth 0.645B) | 0.561B |
| true optimal N at 10²⁴ | 41.3B (98 tokens per parameter under this fit) |
| predicted optimal N at 10²⁴ | 38.2B |
| loss at the true optimum / predicted optimum | 1.9112 / 1.9113 |
| Kaplan-style N at 10²⁴ | 536.4B |
| loss with Kaplan-style allocation | 1.9805 |
- The extrapolation works: fitted exponents are biased low (noise and a narrow range), but the biases offset each other, and the predicted size is within 8% of the truth.
- Small errors do not matter: the loss is essentially identical, because it is flat near the optimum.
- Large misallocation does: a Kaplan-style 536B model, under-trained on too few tokens, loses 0.07 nats at the same compute.
- Under the parametric fit the optimum is 98 tokens per parameter at 10²⁴ FLOPs, far above the famous 20, which came from Chinchilla’s other two methods. This is the inconsistency Besiroglu and colleagues pointed out.
- Seeds: seeds 1 and 2 predicted 41.3B and 41.9B, with identical losses.
- What I tried first: a real measurement (least-squares models of N Fourier modes on D samples). The Chinchilla form fitted it poorly, because least-squares estimation error grows as N/D rather than separately in N and D. The irreducible loss could not be identified from cheap runs, and both fitted forms extrapolated wrongly. I switched to simulated runs so the procedure itself could be tested. A real study must first check that the chosen functional form fits.
Scaling laws in AI, robotics and aerospace
- Planning domain models: sizing a model and its data budget before committing GPU time.
- Edge models: deliberately “over-training” small models for cheap onboard inference.
- Design lesson: extrapolate only after validating the functional form on your own runs, and remember that loss is not the same as capability.
References
- J. Kaplan et al. (2020). “Scaling laws for neural language models.” arXiv:2001.08361.
- J. Hoffmann et al. (2022). “Training compute-optimal large language models.” NeurIPS.
- T. Besiroglu, E. Erdil, M. Barnett and J. You (2024). “Chinchilla scaling: a replication attempt.” arXiv:2404.10102.
- N. Sardana and J. Frankle (2023). “Beyond Chinchilla-optimal: accounting for inference in language model scaling laws.” arXiv:2401.00448.