5 Pre-training 3 / 5
  1. In this chapter
  2. The LLM Training Pipeline
  3. Pretraining Data Engineering
  4. Scaling Laws
  5. The Compute and Memory Ledger of Training
  6. Distributed Training
All chapters →

Chapter 5 · Pre-training 5.3

Scaling Laws: How to Split Compute Between Parameters and Data

From Kaplan to Chinchilla: why loss falls as a power law in parameters, data and compute, how to split a compute budget between parameters and tokens, and why today's models are trained on far more data than the compute-optimal amount.

Intermediate 20 min read Updated Companion code ↓

After this page you will be able to

  • Say why loss falls as a power law in parameters, data and compute.
  • Estimate training compute with C ≈ 6ND, and compare what Kaplan and Chinchilla conclude about splitting parameters and data.
  • Given a compute budget, work out the optimal parameter count and number of tokens, and play with the interactive calculator.
  • Explain why today's models are trained on far more data than the Chinchilla optimum, and know where scaling laws stop applying.
On this page
  1. The problem: with limited compute, how big a model should you train?
  2. The empirical fact: loss falls as a power law with scale
  3. Estimating training compute: C ≈ 6ND
  4. From Kaplan to Chinchilla: how to split parameters and data
  5. A parametric loss formula
  6. Given a compute budget, what is the optimal split?
  7. Beyond the Chinchilla optimum: why today’s models are trained so “excessively”
  8. Using scaling laws in practice
  9. The limits of scaling laws
  10. Test extrapolation with a small budget
  11. Summary and exercises
  12. Quick self-check
  13. Further reading
  14. FAQ

The problem: with limited compute, how big a model should you train?

Training a large model easily consumes hundreds of thousands to millions of GPU hours, and there is almost no chance for a redo. Before you start you need to answer a few questions:

  • With a fixed compute budget, how large should the model be and how many tokens should it see?
  • Before a training run finishes, can its final loss be predicted?
  • To lower the loss a little more, should you grow the model, add data, or add compute?

Scaling laws are the method of using regularities from small-scale experiments to predict the results of large-scale training. They are not strict theorems but empirical regularities confirmed again and again across many experiments.

The empirical fact: loss falls as a power law with scale

OpenAI’s 2020 study (Kaplan et al.; see the paper breakdown) found that, as long as nothing else is the bottleneck, the test cross-entropy loss LL follows an approximate power law in the number of parameters NN, the amount of data DD and the training compute CC:

L(N)=(NcN)αN,L(D)=(DcD)αD,L(C)=(CcC)αCL(N) = \left(\frac{N_c}{N}\right)^{\alpha_N},\qquad L(D) = \left(\frac{D_c}{D}\right)^{\alpha_D},\qquad L(C) = \left(\frac{C_c}{C}\right)^{\alpha_C}

Here Nc,Dc,CcN_c, D_c, C_c are fitted constants, and the exponents are about αN≈0.076\alpha_N \approx 0.076, αD≈0.095\alpha_D \approx 0.095 and αC≈0.050\alpha_C \approx 0.050. These trends held across more than seven orders of magnitude of compute in their experiments.

A power law is a straight line on a log-log plot: every time the scale grows by a fixed factor, the loss is multiplied by a fixed factor. If the parameter count grows 10×, for example, the loss becomes about 10−0.076≈0.8410^{-0.076} \approx 0.84 of what it was. This means two things: returns are diminishing (cutting the loss by the same fraction costs more and more resources), but they are also stable and predictable.

Estimating training compute: C ≈ 6ND

For a dense Transformer, every parameter takes part in one multiply-add per token in the forward pass (about 2N2N FLOPs), and the backward pass costs about twice the forward pass (about 4N4N), for a total of about 6N6N FLOPs per token. The total compute for training on DD tokens is

C≈6 N DC \approx 6\,N\,D

This ignores the attention overhead that depends on sequence length, which matters little unless the sequences are very long. Let’s check the estimate against Llama 2 7B:

N, D = 6.74e9, 2.0e12     # Llama 2 7B: parameters and training tokens
C = 6 * N * D             # training compute ≈ 8.1e22 FLOPs
gpu_hours = 184_320       # A100-80GB GPU hours reported in the Llama 2 paper
peak = 312e12             # A100 BF16 dense peak (FLOPs/s)
mfu = C / (gpu_hours * 3600 * peak)
print(f"C = {C:.2e} FLOPs, MFU ≈ {mfu:.0%}")
# C = 8.09e+22 FLOPs, MFU ≈ 39%

The implied MFU (Model FLOPs Utilization, the fraction of hardware peak that goes into useful work) is about 39%, inside the 30%–50% range typical of large-scale training, which shows that 6ND6ND is a quite reliable estimate. Which parameters count toward NN, the attention term, how recomputation changes the FLOPs and the exact definition of MFU are covered in The Compute and Memory Ledger of Training.

From Kaplan to Chinchilla: how to split parameters and data

Given that loss falls with NN and DD, the next question is: at a fixed compute CC, should the budget go more to parameters or to data? The early conclusion and the later correction did not agree:

Kaplan et al. (2020)Hoffmann et al. (2022, Chinchilla)
Core conclusionAs compute grows, make the model bigger firstParameters and data should grow in equal proportion
Optimal parametersN∝C0.73N \propto C^{0.73}N∝C0.5N \propto C^{0.5}
Optimal dataD∝C0.27D \propto C^{0.27}D∝C0.5D \propto C^{0.5}
Representative modelGPT-3: 175B parameters, 300B tokens (about 1.7 tokens/parameter)Chinchilla: 70B parameters, 1.4T tokens (20 tokens/parameter)

DeepMind’s Chinchilla study trained more than 400 models (from 70 million to over 16 billion parameters, on 5 billion to 500 billion tokens) to refit this law, and verified it experimentally: Chinchilla, with 70B parameters and 1.4T tokens, used about the same compute as Gopher (280B parameters, 300B tokens) yet was clearly stronger on most evaluations. The conclusion was that earlier large models were generally “undertrained”: many parameters, but not enough data. Later analysis (Porian et al., 2024) attributes the disagreement between the two studies mainly to how parameters and compute were counted (whether the embedding and last-layer costs are included), the length of the learning-rate warmup, and whether the optimizer hyperparameters were tuned separately for each scale.

A parametric loss formula

Chinchilla writes the loss as a function of parameters and data:

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

Each of the three terms has an intuitive meaning: EE is the irreducible loss (the randomness of natural language itself, which no model size or amount of data can remove); A/NαA/N^{\alpha} is the loss caused by limited model capacity; B/DβB/D^{\beta} is the loss caused by limited data. The larger the model, the smaller the second term; the more data, the smaller the third.

About the fitted coefficients

The Chinchilla paper estimates the optimal ratio with three methods, and all conclude that “parameters and data should grow in roughly equal proportion”. The coefficients that the paper gave for the third method (the parametric formula above) were later found by a replication study (Besiroglu et al., 2024) to be inconsistent with the first two. This page uses the coefficients corrected by the replication study, E=1.8172E=1.8172, A=482.01A=482.01, B=2085.43B=2085.43, α=0.3478\alpha=0.3478, β=0.3658\beta=0.3658, which agree with the “about 20 tokens per parameter” conclusion. These coefficients only illustrate the trend; do not treat them as an exact prediction for your own data and architecture.

Given a compute budget, what is the optimal split?

Minimize L(N,D)L(N, D) under the constraint 6ND=C6ND = C. Substituting D=C/(6N)D = C/(6N), differentiating with respect to NN and setting the derivative to zero gives a closed-form solution:

Nopt=(αAβB)1α+β(C6)βα+β,Dopt=C6 NoptN_{\text{opt}} = \left(\frac{\alpha A}{\beta B}\right)^{\frac{1}{\alpha+\beta}} \left(\frac{C}{6}\right)^{\frac{\beta}{\alpha+\beta}}, \qquad D_{\text{opt}} = \frac{C}{6\,N_{\text{opt}}}

NoptN_{\text{opt}} and DoptD_{\text{opt}} are proportional to Cβ/(α+β)C^{\beta/(\alpha+\beta)} and Cα/(α+β)C^{\alpha/(\alpha+\beta)} respectively. When α≈β\alpha \approx \beta both exponents are close to 0.5, which is where “parameters and data grow in equal proportion” comes from. Let’s just compute it:

E, A, B, alpha, beta = 1.8172, 482.01, 2085.43, 0.3478, 0.3658


def loss(N, D):
    return E + A / N**alpha + B / D**beta


def compute_optimal(C):
    """Given compute C, return the (parameters N, tokens D) that minimize the loss."""
    N = (alpha * A / (beta * B)) ** (1 / (alpha + beta)) * (C / 6) ** (beta / (alpha + beta))
    return N, C / (6 * N)


for C in [1e21, 1e22, 1e23, 5.76e23, 1e25]:
    N, D = compute_optimal(C)
    print(f"C={C:.2e}  N={N/1e9:7.1f}B  D={D/1e12:6.3f}T  D/N={D/N:5.1f}  loss={loss(N, D):.3f}")

Output:

Training compute CC (FLOPs)Optimal parameters NNOptimal tokens DDD/ND/NPredicted loss
102110^{21}2.8B0.06T21.62.306
102210^{22}9.0B0.18T20.42.141
102310^{23}29.4B0.57T19.22.032
5.76×10235.76\times10^{23} (Gopher scale)72.2B1.33T18.41.974
102510^{25}312.1B5.34T17.11.912

At Gopher-scale compute the optimum is about 72B parameters and 1.3T tokens, which is almost Chinchilla itself, and across the whole range D/ND/N stays around 20. This gives an easy rule of thumb: about 20 training tokens per parameter. Combined with C≈6NDC \approx 6ND, that is C≈120N2C \approx 120N^2, so the optimal parameter count is about C/120\sqrt{C/120}.

Plotting the loss against the parameter count at fixed compute gives the “IsoFLOP curves” from the Chinchilla paper:

IsoFLOP curves: loss versus parameter count at several compute budgets The horizontal axis is the parameter count (log scale) and the vertical axis is validation loss. At four compute budgets, 10^21, 10^22, 10^23 and 10^24 FLOPs, every curve is U-shaped: a model that is too small is limited by capacity, and a model that is too large gets too little training data. The lowest point of each curve is the optimal parameter count for that budget, and the dashed line through these points shows the optimal model growing with compute. Same compute, different model sizes: every curve has a best point 1.9 2.0 2.1 2.2 2.3 2.4 2.5 1B 10B 100B 1T Parameters N (log scale) Validation loss N≈2.8B N≈9.0B N≈29B N≈96B 10²¹ FLOPs 10²² FLOPs 10²³ FLOPs 10²⁴ FLOPs Optimum per budget ← model too small: capacity-limited model too large: undertrained →
IsoFLOP curves: fix the training compute C ≈ 6ND, vary the parameter count N (the number of training tokens D = C / 6N changes with it) and record the final loss. The curves are drawn from the Chinchilla parametric loss formula (with the coefficients from the replication study) and only illustrate the trend.

Every curve is U-shaped: on the left the model is too small and capacity-limited; on the right the model is too large, and the same compute can feed it only a little data, so it is undertrained. The lowest point is the optimal parameter count for that budget, and the bigger the budget, the further right the optimum lies.

Beyond the Chinchilla optimum: why today’s models are trained so “excessively”

The Chinchilla optimum answers: what is the least training compute needed to reach a given loss? But after release a model will be called billions of times, and the inference cost per token is about 2N2N FLOPs, proportional to the parameter count. So the real total cost is

total cost≈6 N D⏟training+2 N Tserve⏟inference\text{total cost} \approx \underbrace{6\,N\,D}_{\text{training}} + \underbrace{2\,N\,T_{\text{serve}}}_{\text{inference}}

where TserveT_{\text{serve}} is the total number of tokens the model will generate or process during its lifetime. If the final loss is required to hit a fixed target (we take 2.0, purely for demonstration), what does the cheapest model look like for different amounts of traffic?

import numpy as np


def tokens_needed(N, target):
    """Training tokens a model with N parameters needs to reach the target loss."""
    gap = target - E - A / N**alpha
    return (B / gap) ** (1 / beta) if gap > 0 else np.inf


def best_model(target, served_tokens):
    best = None
    for N in np.logspace(9, 12.5, 4000):
        D = tokens_needed(N, target)
        if np.isfinite(D):
            cost = 6 * N * D + 2 * N * served_tokens   # training + inference FLOPs
            if best is None or cost < best[0]:
                best = (cost, N, D)
    return best


for served in [0, 1e12, 1e13, 1e14, 1e15]:
    cost, N, D = best_model(target=2.0, served_tokens=served)
    print(f"served {served:.0e} tokens: N={N/1e9:5.1f}B  D={D/1e12:5.2f}T  D/N={D/N:5.0f}")

The output, tidied up:

Expected total tokens servedCheapest parameter countTraining tokensTokens / parameter
0 (train only, no serving)46.9B0.88T19
101210^{12}34.3B1.25T36
101310^{13}20.0B3.01T150
101410^{14}12.7B11.12T876
101510^{15}9.6B50.60T5264

With zero traffic we recover the Chinchilla optimum (about 19 tokens per parameter); the more traffic, the more the best choice becomes a smaller model trained on far more data than the “optimum”. This calculation counts only FLOPs, whereas real inference is also affected by memory bandwidth, the KV cache (see KV Cache and Inference Performance) and batching efficiency, and the fitted formula is extrapolated at extreme token-to-parameter ratios, so treat it as a trend rather than exact numbers. But the direction matches industry practice exactly:

ModelParametersTraining tokensTokens / parameter
GPT-3 (2020)175B300Babout 1.7
Chinchilla (2022)70B1.4T20
LLaMA 7B (2023)7B1Tabout 143
Llama 2 7B (2023)7B2Tabout 286
Llama 3 8B (2024)8B15Tabout 1,875

The LLaMA paper states its goal explicitly as “the best performance at a given inference budget”, and so deliberately trains smaller models for longer (see the LLaMA explainer). Later open models pushed the ratio even higher, and observed that the loss keeps falling even at data sizes far beyond the Chinchilla optimum.

Using scaling laws in practice

A typical workflow is:

  1. Run a set of small experiments. Pick a few small compute budgets and, for each budget, train models of several sizes (IsoFLOP experiments). Tune the learning rate and batch size separately for every size, or the curve will reflect hyperparameters instead of scale.
  2. Fit the curves. Find the size with the lowest loss at each budget, or fit L(N,D)L(N, D) directly.
  3. Extrapolate. Use the fit to predict the optimal scale and final loss at the target compute.
  4. Compare during training. During the real run, keep comparing the actual loss with the prediction; a deviation often points to a problem with data, learning rate or implementation. The GPT-4 technical report, for example, says the final loss could be predicted from models using no more than 1/1000 of GPT-4’s compute.

Be restrained about extrapolation distance: a common rule of thumb is that extrapolating two or three orders of magnitude beyond the fitted range calls for special care.

The limits of scaling laws

  1. Loss is not capability. Loss falls smoothly, but downstream accuracy can seem to jump “suddenly” at some scale. Schaeffer et al. (2023) point out that many so-called “emergent” phenomena come from the choice of evaluation metric: with a continuous metric the curve is often smooth.
  2. Data is finite. The total amount of high-quality text is limited, and the returns from repeating data diminish: Muennighoff et al. (2023) found that repeating data for up to about 4 epochs performs close to fresh data, after which the benefit decays quickly (the effective-data formula and a table computed from it are in Pretraining Data Engineering).
  3. Data quality can shift the whole curve. With the same number of tokens, better filtering, deduplication and mixing lower the whole loss curve.
  4. MoE uses active parameters for compute. The training compute of a sparse mixture-of-experts model should be estimated from the active parameters, C≈6 Nactive DC \approx 6\,N_{\text{active}}\,D; memory and communication are determined by the total parameter count. See Modern LLM Architecture.
  5. A new scaling dimension has appeared: inference-time compute. Models such as o1 and DeepSeek-R1 spend compute on “thinking”, and accuracy rises markedly after they generate a long chain of reasoning. Snell et al. (2024) found that on easier problems, spending extra compute at inference time can even beat a model 14 times larger. See Reinforcement Learning for Reasoning: RLVR and GRPO.

Test extrapolation with a small budget

CS336 Assignment 3 gives students a limited pilot budget to predict the configuration and validation loss at a larger budget. For self-study, hold out a larger compute tier and inspect it after fitting and selection.

  1. Find the optimum within each tier. Sweep model size and adjust token count to keep compute comparable. If loss keeps decreasing all the way to a sweep boundary, test farther in that direction before treating the boundary as an optimum.
  2. Fit across tiers. Use the estimated optima to fit model size and token budget. Record the fit range, model family, data, and learning-rate schedule. Refit on different ranges to see how stable the extrapolated optimum is.
  3. Check the predictions. Record the predicted configuration, loss, and error tolerance before inspecting the held-out tier. A fixed-FLOP study should also report wall time or GPU-hours because communication and operator efficiency can change the actual cost.

Summary and exercises

Key points of this page:

  1. Loss falls as a power law in parameters, data and compute: predictable, but with diminishing returns.
  2. Training compute can be estimated as C≈6NDC \approx 6ND, and MFU converts it to GPU hours.
  3. Chinchilla concluded that parameters and data should grow in equal proportion, about 20 tokens per parameter.
  4. Once inference cost is counted, the best choice is a smaller model with far more data than the “optimum”, which explains why today’s open models are trained on far more tokens than the Chinchilla ratio.
  5. Scaling laws are a planning tool; their limits include the ceiling on data, data quality, evaluation metrics and inference-time compute.

Quick self-check

1. With the parameter exponent fitted by Kaplan et al. (about 0.076), by roughly what factor does the test loss change when you make the model 10 times larger?

  • 0.10
  • 0.50
  • 0.84
  • 0.92

In a power law the loss is multiplied by 10 to the power −0.076, about 0.84. That shows the returns are diminishing: each further reduction of the loss by the same ratio costs more and more resources, yet the trend is stable and predictable.

2. What is the main difference between Kaplan et al. (2020) and Chinchilla (2022) on how to split a fixed compute budget between parameters and data?

  • None, they reach the same conclusion at different model sizes
  • Kaplan says to favor making the model larger as compute grows, while Chinchilla says parameters and data should grow in equal proportion
  • Kaplan says to favor more data, Chinchilla says to favor a larger model
  • Chinchilla finds that neither parameters nor data matter, only compute does

Kaplan’s optimal parameter count is roughly proportional to C to the power 0.73 and the data to only the power 0.27; Chinchilla has about 0.5 for both. Later analysis attributes the difference mainly to how parameters and compute are counted, the length of the learning-rate warmup, and whether the optimizer hyperparameters were tuned separately for each scale.

3. With the rules of thumb D≈20N and C≈6ND, about what is the optimal parameter count for a training budget of 1.2×10^21 FLOPs?

  • About 0.3B
  • About 3.2B
  • About 10B
  • About 32B

Combining the two gives C≈120N², so N≈√(1.2×10^21/120)=√(10^19)≈3.2×10^9, with a matching data size of about 20N≈63B tokens.

4. Llama 3 8B was trained on about 15T tokens, far beyond Chinchilla’s 20 tokens per parameter. Why did Meta do it anyway?

  • Because Chinchilla’s conclusion has been refuted
  • Because more data always makes the model larger
  • Because the Chinchilla optimum only minimizes training compute; a released model serves a huge number of requests and inference cost is proportional to the parameter count, so training a smaller model for longer lowers the total cost
  • Because 15T tokens is exactly the minimum data needed to train an 8B model

The total cost is roughly 6ND for training plus 2N times the total number of served tokens for inference. The more is served, the more the best choice is a smaller model with far more than the optimal amount of data. The fitted formula is extrapolated at extreme token-per-parameter ratios, so read it as a trend.

5. In Chinchilla’s parametric loss L(N, D) = E + A/N^α + B/D^β, what does the constant E stand for?

  • The loss caused by limited model capacity
  • The loss caused by limited data
  • The irreducible loss: the randomness of natural language itself, which no model size or amount of data can remove
  • The upper limit of training compute

The second term A/N^α is the loss caused by limited model capacity and the third term B/D^β the loss caused by limited data. The larger the model and the more the data, the smaller these two terms get, but the loss never goes below E.

6. What does MFU (Model FLOPs Utilization), used when working back from the training efficiency, mean?

  • The share of GPU memory taken by the model parameters
  • The share of the hardware’s peak compute that is actually useful, typically 30% to 50% in large-scale training
  • The share of the dataset that the training tokens cover
  • The utilization of the GPU’s memory bandwidth

The page estimates the training compute of Llama 2 7B as about 8.1×10^22 FLOPs with 6ND and, combined with the reported 184,320 A100 GPU hours, works back to an MFU of about 39%, inside the usual range, which shows that 6ND is a reliable estimate.

Exercises:

  1. You have a budget of 102210^{22} FLOPs. Estimate the optimal NN and DD from D≈20ND \approx 20N and C≈6NDC \approx 6ND.
  2. How many FLOPs does it take to train a 7B model on 3T tokens? How many GPU hours does it take on H100s (BF16 dense peak about 989 TFLOPS) at 40% MFU?
  3. Llama 3 8B was trained on 15T tokens, whereas 20 tokens per parameter would need only about 160B. Why did Meta still choose to train for so long?
Reference answers
  1. From C=120N2C = 120N^2 we get N=1022/120≈9.1×109N = \sqrt{10^{22}/120} \approx 9.1\times10^{9}, i.e. about 9B parameters; D=20N≈1.8×1011D = 20N \approx 1.8\times10^{11}, i.e. about 180B tokens. This agrees with the 102210^{22} row of the table above.
  2. C=6×7×109×3×1012=1.26×1023C = 6 \times 7\times10^{9} \times 3\times10^{12} = 1.26\times10^{23} FLOPs. The effective throughput is 989×1012×0.4≈3.96×1014989\times10^{12}\times0.4 \approx 3.96\times10^{14} FLOPs/s, so the time needed is about 3.2×1083.2\times10^{8} seconds, i.e. about 88,000 GPU hours.
  3. Because after release the model serves a large number of requests and inference cost is proportional to the parameter count. Spending more training compute to train the small model for longer buys lower serving cost, and the loss keeps falling at data sizes far beyond the Chinchilla optimum.

Further reading

FAQ

What is the Chinchilla-optimal ratio of parameters to data?
Empirically about 20 training tokens per parameter (D ≈ 20N), together with the training-compute approximation C ≈ 6ND. In other words, every time compute grows 4×, parameters and data each grow roughly 2×. This ratio minimizes training compute and ignores inference cost.
Why are models like Llama 3 trained on far more tokens than the Chinchilla optimum?
Because after release a model serves a huge number of requests, and inference cost is proportional to the parameter count. Training a smaller model for longer costs more compute during training but makes every inference cheaper; with enough traffic the total cost is lower. Llama 3 8B was trained on about 15T tokens, roughly 1,875 tokens per parameter.
How do I estimate the compute and GPU hours needed to train a model?
The training compute of a dense model is about 6ND FLOPs (N parameters, D training tokens). Divide by the effective throughput of one GPU (peak FLOPs times model FLOPs utilization, MFU, which is typically 30%–50% in large-scale training) to get the GPU seconds required.
Can scaling laws break down?
Within the range covered by many experiments, the power-law trend of loss versus scale has been confirmed again and again, but extrapolating to larger scales is always uncertain, and data quality, the ceiling on total data, the training recipe and new scaling dimensions (such as inference-time compute) all change the curve. Scaling laws should be treated as a planning tool, not as laws of nature.