Neural Scaling Laws and Compute-Optimal Training
Loss falls as a power of parameters, data, and compute: in two solvable models the exponents are theorems — Zipf's tail for data, a spectrum's tail for size — and a Lagrange multiplier turns the fitted law into the compute-optimal split, whose exponent depends on what you count as a parameter
Overview & Motivation
Train a small transformer on the shared filings with a fixed budget of compute, and choose how to spend it: a narrow model trained on many tokens, or a wide one trained on few. At each budget the losses form a valley. At FLOPs the valley’s floor sits near weights. At times that budget it sits near , and at times near . On log–log axes the floors rise with the budget, at a slope of and then , so three noisy points only suggest a line. Kaplan and colleagues (2020) found loss falling as a power law, with some trends spanning more than seven orders of magnitude. Hoffmann and colleagues (2022) measured the valleys on far larger models, and both papers turned the result into rules for sizing real models.
Lines on log–log axes are power laws. The usual form is , a line only while the loss stays well above its floor , and this topic asks two questions about it. Where do the exponents come from? And how should a budget be split? We develop the answer in order:
- Data scaling is Zipf’s tail. A memorizer must err when the next word is one it has not seen. Under the Pitman–Yor generator behind our corpus, that probability is an exact ratio of Gamma functions, which falls as a power of the data.
- Model-size scaling is a spectrum’s tail. A linear model whose spectrum and target decay as powers of the coordinate index leaves a tail it cannot represent, a power of its size.
- Training time has its own exponent. Gradient flow learns the large-eigenvalue directions first, and what remains decays as a power of time. For Gaussian data we compute SGD’s expected loss exactly.
- Compute is per token, plus attention. We count it by instrumenting the arrays of a real training step.
- The optimal split has a closed form. A Lagrange multiplier on the budget gives the compute-optimal size, and the solvable model predicts its exponent, which the fitting procedures recover.
- Kaplan and Chinchilla measured one law in two units. Counting only non-embedding parameters at small scale can turn an exponent near Chinchilla’s into one near Kaplan’s .
Then the finance case. A firm that trains on its own filings has a fixed amount of text. A few repeated epochs cost almost nothing, and the cap moves the optimum only when the corpus is far smaller than the law asks for.
Data scaling from Zipf: the missing mass
The simplest learner is a lookup table. It predicts a token’s type only if that type has occurred before, and it is wrong whenever the next type is new. That error has a name.
Definition 1 (Memorizer and missing mass).
After tokens , the missing mass is the probability that token has a type not among . A memorizer is any predictor that can be right only on types it has seen, so its error rate is at least the missing mass.
The shared corpus draws its content words from Pitman–Yor restaurants (the Zipf–Heaps topic, its Definition 4) with discount and strength . Customer opens a new table, which is a new word type, with probability , where is the number of tables after customers.
Theorem 1 (The missing mass under Pitman–Yor).
For a sequence with and ,
Proof.
Conditioned on the first draws, the probability is , which is linear in ; taking expectations gives the first equality. For the second, , so satisfies with . The product telescopes to , which is the Zipf–Heaps topic’s Theorem 3. Then , and dividing by gives the Gamma form. The asymptote is as . At the same argument gives .
∎Over simulated restaurants the share of sequences whose draw is new is , against the exact , and the agreement holds within three standard errors at every checkpoint from to . The corpus’s text mixes seven restaurants with template words that stop growing early. Past ten thousand tokens its rate of new types falls with log–log slope , against the theorem’s .
The exponent is Zipf’s. A Pitman–Yor measure’s ranked frequencies decay as , so its Zipf exponent is . Hutter (2021, §3) shows that a lookup learner on data with Zipf exponent errs at a rate proportional to , which is here. At , the one-parameter Chinese restaurant of a Dirichlet process, the rate is and the exponent is . Hutter’s §6 remarks that the two-parameter process also leads only to exponent , in his continuous-feature extension. For the missing mass itself, Theorem 1 gives . The n-gram topic estimates the same quantity without a model, by Good and Turing’s (its Theorem 2), and Theorem 1 is its Bayesian counterpart under the generator.
So the heavier the tail of the type distribution, the slower a memorizer learns. The power is the limit of an exact Gamma ratio: at the exact value is below the asymptote, and at it is under below. With , a tenfold increase in data cuts the missing mass by about ( from to ), not .
Model-size scaling: the tail of a spectrum
A memorizer has no size: it remembers everything it sees. For a model of size we need a learner that can only represent part of the target. The cleanest one is linear.
Definition 2 (The solvable model).
Features are in with and . The target is with , for exponents and . A model of size fits , and its population loss is
We take , , and .
Coordinate is a direction of the input with variance , and the target puts of its variance there. The first coordinates are both the loudest and the most important. Language need not be so tidy: a word like the is as loud as any and predicts little. The second sum is what a size- model cannot touch however long it trains.
Theorem 2 (The approximation tail).
For ,
so as the tail lies between and .
Proof.
is decreasing, so for every . Summing the right inequality over gives the lower bound, and summing the left one over gives the upper.
∎This is formalCalculus’ integral test (its Theorem 8) with the remainder kept. The harness checks the bracket on random , and the tail of our model falls with exponent . A size exponent is therefore the exponent of a spectrum’s tail.
Data scaling in the same model: gradient flow and exact SGD
Now train the model from . Gradient flow on half the population loss, , moves each coordinate on its own: . We take the half because it is the scale the SGD step below descends; flow on itself would run twice as fast. Coordinate is learned on the time scale , so at time the directions with are done and the rest have barely moved. A frontier sweeps through the spectrum, and what is left behind it is a tail again.
Theorem 3 (The gradient-flow residual).
With every coordinate kept () and ,
Proof.
Let . Substituting gives
rises and then falls, with maximum at . By the Zipf–Heaps topic’s lemma on sums of unimodal functions (its Lemma 1), the sum over is within twice that maximum of the integral over . The maximum is , which is because .
∎At the ratio of the sum to the asymptote is already , and in our model the asymptote is . One-pass SGD takes one fresh sample per step with step size . Its expected step is , a gradient step on , so it follows this flow at time after samples, plus noise. So the data exponent is , and in our model it is . For Gaussian features the noise can be computed exactly.
Proposition 1 (One-pass SGD in closed form).
Let and , and let . One SGD step on a fresh sample gives
and the expected loss after the step is .
Proof.
The residual is , where is independent of with mean and variance . Expanding and taking expectations, the cross terms in vanish, and Isserlis’ theorem for Gaussian gives for symmetric . With , the diagonal of the result depends on only through its diagonal and through , which is the stated recursion.
∎The off-diagonal entries of are not zero, but the loss never needs them. The recursion costs per step, so the expected loss of every size at every step is cheap to compute, with no sampling. Against Monte Carlo runs it agrees within three standard errors. With , a step costs multiply-adds, so here compute is . That step is not small: , so . The recursion’s fixed point shows what the noise does. There , with the loss, so , where . The recursion settles there while and diverges past that, which for the full model means , not . At our step the floor is times the tail at and times at . So the noise rescales the size term and barely moves its exponent. Paquette and colleagues (2024) and Bordelon, Atanasov, and Pehlevan (2024) map the phases where it does more. We cite that analysis rather than prove it, and the harness’s recovered exponents are the evidence that we are in the simple phase.
Counting compute
The budget of a real model is counted in floating-point operations. A product of an and a matrix costs FLOPs, one multiply and one add per term. Per token, a weight matrix is used once in the forward pass and twice in the backward pass: once to send the gradient back to its input, and once to form its own gradient.
Proposition 2 (The FLOPs of a training step).
Take the toy decoder of this topic: pre-LN blocks of width (the transformer-block topic, its Definition 1) with causal attention over a context of tokens, and a tied embedding that is also the unembedding. Let count the weights that enter matrix products. One training step on windows costs exactly
matrix-multiply FLOPs.
Proof.
Each block’s weights are : the query, key, value, and output maps () and the MLP’s and maps (). The tied unembedding adds one product per token. Each weight costs FLOPs per token forward and backward, which is . The scores and the weighted sum cost each per token per layer forward, and the backward pass takes four products of the same size: per layer. The embedding lookup and its gradient are a gather and a scatter, not products.
∎We check this by counting, not by reading the code. The harness wraps every parameter in an array type that adds FLOPs for each output entry of each matrix product it takes part in, then runs one real forward and backward pass. At all seven widths the count equals to the integer. leaves out the biases and the position table, which take part in no matrix product: at it is of parameters. The attention term is not small at toy scale. Its ratio to is exactly , here , so it falls as the model widens: at and at . Of all the compute, those are and .
Kaplan and colleagues’ Table 1 and Eq. 2.2 write the forward cost as . That is one context-sized term per layer, where the scores and the weighted sum cost that much each, and is the non-embedding count, which leaves out the unembedding’s . At small widths the unembedding is most of the compute. Porian and colleagues (2024) list this last-layer cost as the first of three corrections that move Kaplan’s exponent toward Chinchilla’s.
Compute-optimal allocation
Fix a budget and a loss law . A model too small for the budget saturates at its own tail, and a model too large sees too few tokens to learn anything. Between them is a valley, and its floor is the compute-optimal size.
Theorem 4 (The compute-optimal split).
Let with . On the budget the unique minimizer is
the frontier is for a constant , and the budget’s Lagrange multiplier is .
Proof.
Put and . Then is a sum of a constant and two strictly convex exponentials, so it has at most one critical point. reads . At the optimum, the two reducible terms stand in the ratio . Substituting and solving gives and . Then and are both constant multiples of , which gives the frontier, and differentiating it gives . By the envelope theorem is the multiplier of the constraint.
∎The exponent splits each extra order of magnitude of compute between size and data. With they grow together, and the number of tokens per parameter is constant. Read through formalML’s Lagrangian-duality topic, is the sensitivity theorem’s shadow price (its Theorem 7): the loss one more FLOP buys at the optimum. The harness checks the closed form against a numeric minimum and against a numeric derivative on random laws.
For the solvable model, Theorems 2 and 3 suggest and , and Theorem 4 then predicts
whatever is. This is a prediction, not a corollary, because the model’s loss is not exactly additive. With it says : the spectrum’s decay alone decides how compute should be split. (Here , since a step costs , and the constant factor does not change the exponent.)
Hoffmann and colleagues estimated three ways. Approach 1 takes, at each budget, the size whose training curve is lowest. Approach 2 fits a parabola in to each budget’s valley and takes its vertex. Approach 3 fits the five parameters of the law to every run at once, minimizing a Huber loss of the log-residuals with by L-BFGS from a grid of starting points. That is a robust M-estimator, the subject of formalStatistics’ method-of-moments topic (its Theorem 11). On the solvable model’s exact loss over sizes and data sizes, the three approaches give , , and , against . Approach 3’s exponents are and , against and .
Other spectra test the prediction. Approach 1 gives at and at , against ; at , against ; at , against ; and at , against , once the data grid runs to . On our usual grid that last spectrum gives , because its optima run off the end. All of them land within .
The law recovers the exponents, but it is not the model’s loss surface. Its root-mean-square log error over the grid is , and its worst point, at and , is off by a factor of . The fit overstates the loss there, against , for two reasons. About of the gap is the data term: a size- model’s data term sums only the coordinates it keeps, so a small model finishes learning sooner than the additive form allows. The rest is the fitted size term, against a true tail of . It sits on SGD’s floor at this size, , which the run has not reached at . A law that recovers its exponents can still misdescribe the region it was not built for.
The published fits. Hoffmann and colleagues print , , , , and (their Eq. 10), so . Besiroglu and colleagues (2024) recovered the unrounded values from the paper’s source, with and , giving . At Gopher’s budget of FLOPs, the printed values give B parameters. The unrounded ones give B, which rounds to the paper’s B for Approach 3. Besiroglu and colleagues then refit the law to data reconstructed from the paper’s figures and found . That puts at B and about tokens per parameter, beside Approaches 1 and 2 (67B and 63B) and Chinchilla’s own ratio of .
Toy transformers on the filings
The theorems above live in models we chose. To ask whether text behaves the same way, we train transformers. The decoders have two pre-LN blocks of width , a learned position table, and a tied embedding over the commonest types of the training text plus [UNK]. They read windows of tokens from synthetic filings, about thousand tokens, of which the last are held out. Adam’s peak rate is , a one-over-width rule fixed on a small sweep, with warmup and a linear decay that ends at each run’s own horizon. Hoffmann and colleagues stress that the schedule must match the horizon, and Kaplan and colleagues’ did not. Each of three budgets, , trains five widths between and .
Every budget’s losses form a valley with its minimum inside the grid. The parabola vertices sit at , , and weights, so Approach 2 gives . Approach 3 on all fifteen runs gives , with , , and an irreducible nats.
One seed says little. We reran all fifteen with four more seeds. Each valley stays interior, but a point’s standard deviation runs from to nats, with median . That is small against the valleys’ depths but not against the differences between neighboring widths near a floor. (Retraining the middle run at with two seeds gives only , which understates it.) The published Approach 3 exponent is the highest of the five, which run from to , and runs from to . Approach 2 is steadier, from to , and on the five-seed mean losses it gives , with slopes of and between budgets.
Three budgets spanning a factor of cannot pin down an exponent. In total parameters ours is about , against Chinchilla’s . In non-embedding parameters, Kaplan’s count, it is about , against Kaplan’s . The honest reading is that the grid cannot separate the two.
Against D, each size’s curve falls with slope near −1 until it reaches the tail its N coordinates cannot touch, then flattens; bigger models flatten later and lower. The fitted law tracks the large models closely and overstates the small ones: a size-N model’s data term sums only its N kept coordinates.
Left of the floor the model is too small and sits on its tail; right of it the model is too big for its data. Every factor of 16 in compute moves the floor right by about 16^0.4 ≈ 3.
Four epochs cost 0.019 nats, and sixty-four cost half a nat. The top row draws random windows from the whole stream, 0.65 passes of it. At 16 and 64 epochs the repeated run beats a run that reads D′ tokens of the whole stream, so here a repeated token is worth more than D′ says, though that run also takes fewer steps.
Above the unconstrained D* the cap does not bind. Just below it, a few repeated epochs are nearly free. Far below it, more passes stop paying, and the compute goes into a bigger model.
Kaplan against Chinchilla
Kaplan and colleagues found (their Eq. 6.1), and Hoffmann and colleagues found . The two papers differ in schedules, data, and scale, but one difference is a matter of definition. Kaplan counted only non-embedding parameters , and compute as .
Proposition 3 (The same optimum in Kaplan's units).
Suppose in total parameters along a family of models, and let along the family. Then the non-embedding optimum, measured against , has local exponent
If the embedding grows as , then rises from toward as the embedding’s share grows, and the exponent rises toward .
Proof.
Along the optimum, and , since . So , and . Divide. For and , , which increases from at to as , and the exponent is increasing in .
∎A model family of fixed shape has , so its embedding, , grows as . Take GPT-2’s vocabulary of and context of , Kaplan’s setting, with , and size the models by Besiroglu and colleagues’ fit (). Below FLOPs, where the embedding is between and of the model, the non-embedding exponent is . By FLOPs the embedding share has fallen below , and the exponent is back to . The local exponent agrees with Proposition 3 to at every budget, and the limit is . This is a calculation about units, not a measurement. It extrapolates Besiroglu and colleagues’ fit far below its range, since Hoffmann and colleagues’ IsoFLOP runs start at FLOPs, and its smallest rows are not real models: at FLOPs the family has of a layer. Still, this is Pearce and Song’s (2024) reconciliation, with the closed form behind it: most of Kaplan’s experiments ran where embeddings dominated, so Kaplan’s and Chinchilla’s can be the same law. Proposition 3 says nothing about which count is the right one. On our toy grid the same reading moves Approach 2’s exponent from to on the five-seed mean losses, and from to on the published seed.
Where this goes next
The losses on this page are cross-entropies, so everything in the perplexity topic about what a nat buys applies to the frontier: a loss gain of nats cuts perplexity by a factor of , about , whatever the scale. The decoding topics take a trained model as given and ask how to generate from it. The fine-tuning topic asks how few new parameters adapt a pretrained one, which is a scaling question in a regime this page does not touch.
Three things are outside our scope. Emergent abilities on downstream tasks are not losses and need not follow a power law. Compute spent at inference, by sampling longer or more, has its own trade-offs. And the variance-limited regimes of Bahri and colleagues (2024), where a model is large enough to interpolate, belong with formalML’s double-descent topic, whose risk curves have the peak that our monotone laws leave out.
Honest caveats
Implementation
The companion notebook (notebookPath) imports scaling_laws.py, which owns every number on this page. That module imports the transformer-block topic’s module for the pre-LN block, attention, LayerNorm, and their backward passes. Through it, it also gets the neural-language-models topic’s Adam constants and the shared finance corpus. It imports the contextual-embeddings topic’s module for the faster MLP backward pass, and the perplexity topic’s module, which brings the Zipf–Heaps topic’s Pitman–Yor sampler and closed form. It computes the solvable model’s SGD losses exactly, trains decoders from scratch in NumPy with hand-written gradients, and runs a harness of assertion-based tests in about two and a half minutes on a laptop CPU. The tests cover:
- Theorem 1 against simulated restaurants, its Dirichlet case, its asymptote at three , and the corpus’s own learning curve.
- Theorem 2’s bracket on random instances, and Theorem 3’s bracket against the exact incomplete-gamma integral on .
- Theorem 3’s clock against small-step SGD, and Proposition 1 against Monte Carlo SGD runs.
- Proposition 1’s fixed point and its divergence past .
- Theorem 4 against a numeric minimum on random laws, with its multiplier against a numeric derivative.
- The three approaches’ recovery of the predicted exponent, Approach 1 on five more spectra, and the law’s misfit split into its two causes.
- Proposition 2 by instrumented counting at seven widths, and the decoder’s gradient against central differences.
- The published fits’ exponents and optima, Proposition 3 against finite differences, the toy grid’s valleys at all five seeds, the seed spread, the repetition runs with their no-fit control, and the capped optimum.
The laboratory reads its data from a JSON file that one of those tests requires to equal the module’s viz_payload() exactly, so the figure cannot drift from the code.
References & Further Reading
- paper Scaling Laws for Neural Language Models — Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B. Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, and Dario Amodei (2020) N* ∝ C^0.73 (Eq. 6.1) and the FLOP accounting of Table 1 and Eq. 2.2, beside Proposition 2
- paper Training Compute-Optimal Large Language Models — Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch, Elena Buchatskaya, Trevor Cai, Eliza Rutherford, Diego de Las Casas, et al. (2022) NeurIPS 35: 30016–30030, printed as “An Empirical Analysis of Compute-Optimal Large Language Model Training”; arXiv 2203.15556. Chinchilla's three approaches, Eq. 2, and Theorem 4's closed form (their Eq. 4)
- paper Deep Learning Scaling Is Predictable, Empirically — Joel Hestness, Sharan Narang, Newsha Ardalani, Gregory Diamos, Heewoo Jun, Hassan Kianinejad, Md. Mostofa Ali Patwary, Yang Yang, and Yanqi Zhou (2017) Power-law learning curves across domains
- paper Learning Curve Theory — Marcus Hutter (2021) A lookup learner on Zipf data and its exponent 1 − 1/s, beside Theorem 1
- paper Explaining Neural Scaling Laws — Yasaman Bahri, Ethan Dyer, Jared Kaplan, Jaehoon Lee, and Utkarsh Sharma (2024) Proceedings of the National Academy of Sciences 121 (27). Resolution- and variance-limited regimes
- paper A Solvable Model of Neural Scaling Laws — Alexander Maloney, Daniel A. Roberts, and James Sully (2022) Power-law spectra as the source of the exponents, beside Theorems 2 and 3
- paper 4+3 Phases of Compute-Optimal Neural Scaling Laws — Elliot Paquette, Courtney Paquette, Lechao Xiao, and Jeffrey Pennington (2024) NeurIPS 37. One-pass SGD on power-law random features and the phases of its compute-optimal exponent
- paper A Dynamical Model of Neural Scaling Laws — Blake Bordelon, Alexander Atanasov, and Cengiz Pehlevan (2024) ICML 2024, PMLR 235. Training dynamics behind the data and time exponents
- paper Chinchilla Scaling: A Replication Attempt — Tamay Besiroglu, Ege Erdil, Matthew Barnett, and Josh You (2024) The unrounded Chinchilla parameters (Eq. 4) and the refit of Eq. 3, Table 1
- paper Reconciling Kaplan and Chinchilla Scaling Laws — Tim Pearce and Jinyeop Song (2024) Transactions on Machine Learning Research. Non-embedding parameters at small scale, beside Proposition 3
- paper Resolving Discrepancies in Compute-Optimal Scaling of Language Models — Tomer Porian, Mitchell Wortsman, Jenia Jitsev, Ludwig Schmidt, and Yair Carmon (2024) NeurIPS 37. Last-layer FLOPs, warmup, and optimizer tuning
- paper Scaling Data-Constrained Language Models — Niklas Muennighoff, Alexander M. Rush, Boaz Barak, Teven Le Scao, Nouamane Tazi, Aleksandra Piktus, Sampo Pyysalo, Thomas Wolf, and Colin Raffel (2023) NeurIPS 36. The effective data of repeated epochs (Eq. 5, R* = 15.4)
- paper BloombergGPT: A Large Language Model for Finance — Shijie Wu, Ozan İrsoy, Steven Lu, Vadim Dabravolski, Mark Dredze, Sebastian Gehrmann, Prabhanjan Kambadur, David Rosenberg, and Gideon Mann (2023) A finance model sized by Chinchilla's laws under a data limit (§3.2); the token counts of the case study
- paper The Two-Parameter Poisson–Dirichlet Distribution Derived from a Stable Subordinator — Jim Pitman and Marc Yor (1997) Annals of Probability 25 (2). The Pitman–Yor process
- book Combinatorial Stochastic Processes — Jim Pitman (2006) Lecture Notes in Mathematics 1875. The seating rule (§3.2, Eq. 3.9) and the growth of E K_n (§3.3), Theorem 1
- paper The Population Frequencies of Species and the Estimation of Population Parameters — I. J. Good (1953) Biometrika 40. The frequentist estimator of the missing mass
- paper Robust Estimation of a Location Parameter — Peter J. Huber (1964) Annals of Mathematical Statistics 35 (1). The loss of Approach 3