24 / 28 · Scaling and LLM Pretraining
Scaling laws and compute-optimal training
Allocate a fixed training budget between parameters and tokens using an explicit loss model, and see how deployment cost changes the optimum.
On this page 9
Baseline: increasing model size while holding data fixed#
After separating information paths from training objectives in model families, we can choose an autoregressive model. Another decision remains: how much computation goes into parameters, and how much into showing those parameters more training tokens?
A larger network can lower the loss when it has enough training. Under a fixed budget, however, increasing its size leaves fewer updates or tokens available. Comparing a large and a small model trained for the same number of tokens therefore answers a different question from comparing them at equal training cost.
We use a deliberately invented loss function to make that allocation visible. Its coefficients, candidate models and resulting numbers are an original calculation, not measurements of a trained language model.
What is counted: parameters, tokens and compute#
Let denote model parameters under a stated counting convention, the number of training tokens processed, and training floating-point operations. Processing the same token twice contributes twice to ; it does not create a second independent piece of information.
For a dense Transformer, a useful first approximation is
In the convention of Kaplan et al., excludes embeddings. The factor six approximates matrix-multiplication work in forward and backward passes. Attention’s context-dependent work, output-vocabulary costs and other operations need separate treatment when they matter. Hardware utilization determines elapsed time as well: a FLOP estimate is not a runtime measurement. The source’s precise conventions are in §1.3 and §2.1.
For planning, record the tokenizer, context length, processed versus unique tokens, parameter convention and validation distribution. Changing any of them can break a comparison. A loss per subword token cannot simply be compared with a loss per character.
Loss falls as a power law#
Empirical scaling laws fit validation loss over a range of training experiments. Kaplan et al. found power-law trends under their experimental conditions; their coefficients describe that setup. Hoffmann et al. subsequently studied allocation using learning-curve envelopes, fixed-compute comparisons and a joint parametric fit. For , one useful form from their §3.3 is
Here is a fitted floor; the other two terms represent model-size and finite-training contributions within the approximation. They are not separately observed errors for each individual token. A good fit in one region does not establish behavior at arbitrary model sizes or after changing the data mixture.
For our calculation, choose , , and :
and now mean dimensionless planning units. The values were selected for transparent arithmetic; they are not a recommended token-to-parameter ratio. At , the two reducible terms both equal two and the total is five. Doubling only reduces the first term by , while leaving the other contribution unchanged.
Where a language model becomes a large one#
The equations contain no parameter-count boundary at which a model acquires the category “large.” A task also needs an evaluation rule. In our example, a rule “success if ” turns losses of , and into failure, failure and success. The underlying function remains continuous. These are constructed losses, not evidence of a new language capability.
Schaeffer, Miranda and Koyejo (§2) analyze how nonlinear or discontinuous metrics can create apparent jumps. That is a reason to inspect the metric and sampling uncertainty, not a proof that every observed capability change is an artifact. Report task performance separately from aggregate next-token loss.
Compute-optimal training#
Write for the available product budget. Under , training tokens become . The loss is then a function of just one choice:
Differentiating with respect to and multiplying the zero-derivative equation by gives
The two sides are marginal improvements on a logarithmic size scale. The optimum is
Both terms are positive, and this stationary point is the unique minimum for positive : as one allocation tends to zero, its loss term diverges. This statement belongs to the assumed function; a fitted curve still needs validation against actual runs.
For our , the solution is and . Five allocations of exactly the same budget make the tradeoff visible:
| Model units | Training units | Constructed loss |
|---|---|---|
| 4 | 324 | 6.000000 |
| 9 | 144 | 5.166667 |
| 16 | 81 | 5.000000 |
| 36 | 36 | 5.333333 |
| 81 | 16 | 6.388889 |
The largest candidate is the worst of these five. It uses too much of this budget on parameters. With a fourfold budget, the equal exponents in our example give and : both double. With unequal exponents, their growth rates differ.
Gopher and Chinchilla on the same budget#
Hoffmann et al. used Gopher’s training budget to test a smaller model trained on more tokens: Chinchilla had 70 billion parameters and processed 1.4 trillion tokens, versus Gopher’s 280 billion parameters and roughly 300 billion tokens. Their §4 describes the comparison. No training or evaluation of either model is performed here.
This was not an experiment changing only model size and token count. The paper also lists optimizer, tokenizer and training-setup differences. It supports reconsidering budget allocation; it does not assign every measured improvement to a single cause. The near-equal scaling reported by the authors also depends on their fitted regime, rather than establishing a universal ratio for future models.
Compute-optimal does not mean inference-optimal#
Training happens once; serving may continue for many requests. Sardana et al. (§2) include both costs, using a proxy , and optimize total computation for a target loss and expected demand. This adds assumptions about future usage. A model that is economical to train can be expensive over its lifetime.
To see the direction without fitting real deployment costs, choose and change our original budget to
is an invented serving allowance in training-equivalent units. It is not sixteen actual generation tokens and is not a latency model. The feasible training allocation is . Searching integer from one through 49 with the same loss function gives the best candidate at . The adjacent candidates and have losses about and . This is an optimum over that integer grid, not the continuous solution.
Compared with the training-only allocation, the chosen network is smaller and sees more training units. Its loss is nevertheless higher, because some of the same total budget is now reserved for serving. Real planning also needs memory, prompt lengths, batching, output lengths and measured hardware throughput.
What scaling contributes to general-purpose models#
More favorable next-token predictions can support many tasks expressed as text. The GPT note explains how a prompt supplies task context without changing weights. Scaling allocation addresses the cost of learning that distribution; it does not specify instruction following, factual verification or acceptable behavior.
A planning experiment should therefore pair a language-model loss with task evaluations and a deployment budget. Keeping those measurements separate makes it possible to notice a model whose average loss improves while the particular application does not.
What changed#
Model size alone has become an allocation decision involving training tokens and intended usage. The original example makes two dependencies explicit: the best size changes when the budget changes, and it changes again when serving is charged to that budget. Every optimum needs its objective and constraints attached.
Limitations#
This note fits no empirical law and trains no model. Repeated or lower-quality data need not behave like fresh tokens in the assumed curve. Sparse activation, long contexts, different tokenizers and optimization schedules require appropriate accounting. Uncertainty in small-scale fits can grow substantially when extrapolated.
The formula also says nothing about permission to use training material. The next note follows the data pipeline and its separate source decisions.
What you should remember#
Compare budgets using explicit counting conventions. Under a fixed product budget, adding parameters removes available training tokens. Scaling fits estimate a region of experiments; they do not define universal model-size thresholds or certify downstream ability. Including serving cost changes the optimization problem.
Code#
This Python standard-library calculation reproduces the training allocation table and the integer serving search. It downloads nothing.
from math import sqrt
def loss(n, d):
return 1 + 8 / sqrt(n) + 18 / sqrt(d)
for n in [4, 9, 16, 36, 81]:
d = 1296 / n
print(n, f"{d:.0f}", f"{loss(n, d):.6f}")
candidates = [(loss(n, 1296 / n - 16), n) for n in range(1, 50)]
value, n = min(candidates)
print("serving", n, f"{1296 / n - 16:.0f}", f"{value:.6f}")
4 324 6.000000
9 144 5.166667
16 81 5.000000
36 36 5.333333
81 16 6.388889
serving 12 92 5.186031
Next#
Continue to pretraining data: processed token counts are useful only after deciding which documents enter the mixture, how duplicates are handled and what evaluation material stays outside it.
References#
- Kaplan et al. (2020), Scaling Laws for Neural Language Models, §1.2–§2.1. Counting conventions and empirical scaling framework.
- Hoffmann et al. (2022), Training Compute-Optimal Large Language Models, Table 1, §3–§4.1. Joint loss model and training-budget comparison.
- Sardana et al. (2024), Beyond Chinchilla-Optimal: Accounting for Inference in Language Model Scaling Laws, §2. Combined training and inference objective.
- Schaeffer, Miranda and Koyejo (2023), Are Emergent Abilities of Large Language Models a Mirage?, §2. Metric-dependent appearance of capability changes.
These papers are conceptual references. No paper figure, benchmark dataset, model checkpoint or implementation is redistributed. The planning function, table and executable example were composed for these notes.