Key takeaways
- A big training run is too expensive to retry. Scaling laws let us train a batch of small models, find the pattern, and extrapolate it to the big one.
- The pattern is a power law, L=βC−α. On log-log axes it's a straight line with slope −α, and the loss also needs a floor that never goes away, L∞.
- Compute is C≈6ND. With a fixed budget, the best parameter count and the best amount of data both grow roughly with C: about 20 tokens per parameter (Chinchilla).
- μP adjusts initialization and learning rate layer by layer, so hyperparameters tuned on a narrow model carry straight over to a wider one.
- We fit these curves with least squares. A straight line (after taking logs) has a closed-form solution; once the floor L∞ is in the formula, we switch to nonlinear least squares and iterate.
The training run you only get to try once
Imagine you've been handed a budget to train a brand-new large model: hundreds, maybe thousands of GPUs, running nonstop for months. Before you start, you have to settle a few things:
- How big should the model be?
- How much data do you feed it?
- What learning rate do you use?
- How good will it end up?
The catch is that you only get to do this run once. Find out halfway through that the learning rate was wrong, and months of time and a huge pile of money go down the drain. On a small model you can experiment freely: change a setting, and a few hours later you have your answer. On a big model, that kind of trial and error is simply unaffordable.
Engineers who build skyscrapers face the same problem. Nobody just starts pouring concrete for a 100-story tower. They build a few scale models first, run wind-tunnel tests, find the patterns ("every time the tower doubles in height, the foundation needs to be this much thicker"), and use those patterns to work out how to build the real thing. Training big models works the same way: train a batch of small models, find out how performance changes with scale, then extrapolate that pattern up to the big model.
Intuition: The core belief behind scaling laws is that performance doesn't change with scale in a messy, unpredictable way. It follows a smooth power-law curve, and on the right kind of axes that curve is almost a straight line. Measure a few points at small scale, draw the line, extend it, and you know whether the big run is worth it before you spend the money.
This episode works through three questions:
- Can small models tell us, in advance, how well a big model will do?
- With a fixed compute budget, how big should the model be, and how much data should it see?
- If we tune hyperparameters like the learning rate on a small model, will they still work on the big one? For that, we need a method called μP.
Power laws: a toy example
Suppose we train the same kind of model with different amounts of compute and write down the loss at the end of each run:
| Compute C |
Loss L |
| 1 |
4 |
| 10 |
2 |
| 100 |
1 |
| 1000 |
0.5 |
See the pattern? Every time the compute goes up ten times, the loss is cut in half. Whenever multiplying one quantity by a fixed factor also multiplies another by a fixed factor, we call that relationship a power law. As a formula:
L=βC−α
- β is the loss when the compute equals 1. Here, that's 4.
- α sets how fast the loss falls. Multiply the compute by 10 and the loss gets multiplied by 10−α, which has to equal one half:
10−α=21⇒α≈0.3
Let's check: at a compute of 100, 4×100−0.3≈1. That matches the table.
Log axes: straightening out a power law
Ordinary axes hide the pattern
Put these four points on an ordinary graph, with compute from 0 to 1000 along the bottom and loss up the side. Right away there's a problem: the points at 1, 10 and 100 are all crammed against the left edge. The curve plunges, then hugs the axis, and you can't see any pattern at all. The fix is a different kind of scale: a log scale.
Meet the logarithm
The log base 10 of a number asks: how many 10s do you multiply together to get it?
| Log |
Why |
| log10=1 |
just one 10 |
| log100=2 |
10×10 |
| log1000=3 |
10×10×10 |
| log1=0 |
no 10s at all |
| log0.1=−1 |
0.1=101 |
| log2≈0.3 |
100.3≈2 |
Numbers that aren't whole powers of 10 have logs too, like log2≈0.3. Remember α from a moment ago? It's exactly log2.
Log-log axes
A log scale places each tick according to its log. 1, 10, 100 and 1000 have logs of 0, 1, 2 and 3, so they end up perfectly evenly spaced: every step to the right means times 10. Switch the vertical axis to a log scale too, and 0.5, 1, 2, 4 are evenly spaced as well: every step up means times 2.
Now the four points sit on a straight line, and the curve has been pulled straight. What's more, every time the log on the horizontal axis goes up by 1, the log on the vertical axis drops by 0.3. So the slope is −0.3, which is exactly −α. That's the magic of log-log axes.
Why a power law must be a straight line
All we need are two rules of logarithms:
- Multiplication turns into addition: log(ab)=loga+logb. For example, log(100×1000)=log100000=5=2+3, because multiplying numbers just adds up their 10s.
- Powers turn into multiplication: log(xk)=klogx. For example, log(1003)=log1000000=6=3×2.
Take the log of both sides of the power law. Rule one splits the product into a sum; rule two moves the exponent −α out front:
logL=log(βC−α)=logβ+logC−α=logβ−αlogC
Treat logC as the horizontal coordinate and logL as the vertical one, and this is a straight line with slope −α and intercept logβ.
Intuition: It works the other way too: a straight line on log-log axes means there's a power law behind it. Straight lines are the easiest thing to extrapolate (just extend them with a ruler), which is why researchers love power laws and why scaling-law plots are almost always drawn on log-log axes.
Loss, parameters, data and compute
Three quantities, and C≈6ND
Do real language models follow the same kind of rule? In 2020, Kaplan and colleagues at OpenAI trained a whole range of models of different sizes to find out. First, meet three quantities:
- N: the number of parameters in the model;
- D: the number of tokens it reads during training;
- C: the compute spent on training, counted in floating-point operations, or FLOPs.
We worked this out in episode 10. For each token, the forward pass takes about 2N operations, and the backward pass about twice that (about 4N). So the total compute is roughly
C≈6ND
Three power laws
They found that as long as the other two aren't holding it back, the loss follows a power law in each of these three quantities. On log-log axes, that's three straight lines spanning several orders of magnitude.
All three slopes are small, somewhere between about 0.05 and 0.1, and the exponent for compute is about 0.05. What does that mean?
10−0.05≈0.89
Multiply the compute by 10, and the loss only drops to about 89% of what it was. To keep improving steadily, you have to add compute one order of magnitude at a time.
Irreducible loss: the floor under the curve
But the line can't go on forever. If the loss were always βC−α, then as C→∞ the loss would head to zero, and that can't happen.
Why not? Because language itself is uncertain. Take "My favorite color is ___". Red, blue and green are all perfectly reasonable next words, and even a perfect model can't guess right every time. The part of the loss that never goes away is called the irreducible loss, written L∞. At heart, it's the entropy of the data itself, which we covered in episode 5. So a better formula adds this term:
L(C)=L∞+βC−α
On log-log axes, the curve slowly bends and flattens out, hugging that floor.
Watch out: It's easy to forget the L∞ term. Without it, the fitted curve predicts that a big enough compute budget drives the loss to zero, which is absurd. L∞ is a floor no model, however strong, can get below.
A fixed budget: what size model is the best deal?
Model size and data trade off
Now the second question. Since C≈6ND, a fixed budget means N and D trade off against each other: make the model bigger and it reads fewer tokens; make it smaller and it can read more.
Say the budget is C=6×1020 FLOPs. Here are three ways to spend it (illustrative numbers):
| Params N |
Tokens D |
Final loss |
| 100M (108) |
1T (1012) |
2.55 |
| 1B (109) |
100B (1011) |
2.25 |
| 10B (1010) |
10B (1010) |
2.30 |
All three cost exactly the same compute, but they end with different losses. The middle one wins.
Why both extremes lose
The Chinchilla paper describes the loss with a formula like this:
L(N,D)=E+NαA+DβB
Here A,B,α,β are all constants fitted from data (a different α and β from the toy example).
- E is the irreducible loss from before.
- The second term shrinks as the parameter count grows: a model that's too small can't hold enough knowledge.
- The third term shrinks as the data grows: a model that hasn't read enough hasn't learned enough.
With the budget fixed, a bigger model shrinks the second term, but then D shrinks too, so the third term grows. The two forces pull against each other, and somewhere in between there's a sweet spot.
Iso-FLOP curves and the Chinchilla rule
Plot every possible model size for this budget and you get a U-shaped curve, called an iso-FLOP curve (equal compute). The bottom of the U is the best-value model size for that budget.
Repeat for a few different budgets, training a batch of small models for each, and you get a family of U-shaped curves: the bigger the budget, the lower the curve and the further right its bottom sits. Take each of those minimums and plot it on a new log-log graph, compute across and optimal parameter count up. Once again they fall on a straight line: another power law! The Chinchilla paper found a slope of about 0.5:
Nopt∝C0.5,Dopt∝C0.5
So every time the compute goes up ten times, the model and the data should each grow by about 3.2 times (10). As a rule of thumb, that's about 20 tokens for every parameter.
This overturned an earlier view. The 2020 study suggested spending most of any extra compute on making the model bigger; by Chinchilla's findings, many large models of that time had been trained on too little data. Chinchilla itself is the proof:
| Model |
Params |
Tokens |
| Gopher |
280B |
300B |
| Chinchilla |
70B |
1.4T |
Both used about the same compute (around 5×1023 FLOPs), and the smaller, better-read Chinchilla was clearly stronger.
Watch out: "Compute-optimal" only counts the cost of training. Once a model is deployed, every answer costs compute too, and smaller models are cheaper to run. So in practice people often train small models far past 20 tokens per parameter. Llama 3's 8-billion-parameter version, for example, read more than 15 trillion tokens.
Why the learning rate won't transfer
The third question is about hyperparameters, and the most important one is the learning rate: pick it well or badly and the final loss can change a lot.
The usual approach is a sweep: train the same model several times, each with a different learning rate, and see which gives the lowest loss. Plotted, it makes a U-shaped curve. Too small, and the model learns slowly; too large, and training diverges.
On a small model a sweep is cheap. For a model of width 256, say, you quickly find the best learning rate. By width we mean the size of the hidden vector in each layer; making a model wider is one of the main ways to make it bigger.
Now run the same sweep on wider and wider models: 512, 1024, all the way up to 8192. Here's the problem: the wider the model, the further left the bottom of the U moves. Wider models need smaller learning rates. Take the learning rate you tuned on the small model and use it as is, and the wider the model, the further you are from the best; the widest one diverges outright.
Re-run the sweep on the big model? Every point is an expensive training run, which is exactly what we wanted to avoid. So why does the learning rate drift?
Random sums vs aligned sums
Zoom in on one neuron in a hidden layer. Its output y is a sum of n products, where n is the width:
y=w1x1+w2x2+⋯+wnxn
At initialization: random directions cancel out
The weights start out random, some positive and some negative. Draw each term as a little arrow and place them tip to tail: arrows pointing in random directions wander back and forth and largely cancel. The total ends up only about n long (16 arrows give a length of about 4).
That's why standard initialization scales the weights by 1/n: no matter how wide the layer is, the output y stays around 1. Everyone already does this part.
During training: updates line up
Now look at one training update. With an optimizer like Adam, each weight moves by a step roughly the size of the learning rate η: ∣Δwi∣≈η. The change in the output is
Δy=Δw1x1+Δw2x2+⋯+Δwnxn
Here's the key: these updates don't point in random directions. The gradient for wi is proportional to xi, so every term Δwixi has the same sign. Arrows that all point the same way line up into one straight line, with total length
Δy≈nη
So the wider the layer, the harder a single update hits the output. Some numbers (say each xi is about 1):
| Width n |
LR η |
Impact ≈nη |
| 64 |
0.01 |
0.64 |
| 1024 |
0.01 |
10.24 |
| 1024 |
0.01 ÷ 16 |
0.64 |
Same learning rate, width 64 → 1024, and the impact is 16 times bigger. Training can easily blow up. To keep the impact the same, the hidden-layer learning rate has to shrink in proportion to the width, η∝1/n. That's exactly why the bottom of the U moved left.
Not every layer behaves this way
Worse still, the embedding layer at the input just looks up one row per token. There's no sum over n terms, so its impact stays put as the width changes. With one learning rate shared across the whole model, you can't win: turn it down and the hidden layers settle, but the embedding layer barely learns.
Intuition: Under the standard parameterization (SP), different layers get updates of inconsistent size as the width changes: some layers update far too hard, others barely move. The learning rate that was just right on the small model either blows up the big one or makes it crawl.
μP: tune each layer, and hyperparameters transfer
The idea
Maximal Update Parametrization, or μP, was designed to solve exactly this. Instead of one set of settings for the whole model, it adjusts the initialization and the learning rate separately for each layer, so that every layer's update, relative to the size of its own weights, stays the same at any width. However wide the model, each weight moves by about the same fraction of itself per step.
Intuition: Picture a rowing crew. If you just make the boat longer and add rowers without telling anyone how hard to pull, some thrash and some barely touch the water, and the boat spins. μP makes sure that however big the boat gets, every rower pulls with the same effort relative to their own build.
The main rules
Take a Transformer trained with Adam, and say it is m times as wide as a small base model:
| Layer |
Standard |
μP |
| Hidden |
LR η |
LR η/m |
| Output |
Wh |
m1Wh |
| Embedding |
LR η |
unchanged |
| Attention scores |
÷d |
÷d |
- Hidden layers: divide the learning rate by m. That exactly cancels the n aligned terms we just added up. Initialization stays as usual, scaled by 1/width.
- Output layer: it also adds up lots of numbers into a single score, and after training those terms line up too. So multiply its output by m1, so it doesn't grow as the model gets wider.
- Embedding layer: no such sum, so it stays as it is.
- Attention scores: divide by d instead of by d.
Now, however wide the model gets, every layer's update has the same impact, and the same impact it had in the small model. The "maximal update" in the name means every layer learns as much as it can without blowing up, and that amount doesn't change with width.
The payoff: μTransfer
Switch to μP and the learning-rate U-curves for every width bottom out at the same learning rate, with wider models giving lower curves. So the tuning workflow becomes:
- Build a very narrow model as a stand-in (width 256, say).
- Sweep the learning rate and other hyperparameters on it as much as you like.
- Widen it by a factor of m using the μP rules.
- Reuse those hyperparameters on the big model as they are.
This is called μTransfer. In the paper that introduced μP, the authors tuned a 40-million-parameter model and transferred the settings straight to a 6.7-billion-parameter GPT-3. It beat the published GPT-3 of the same size, and the tuning cost only about 7% of the pretraining.
Watch out: μP mainly deals with width. It isn't a cure-all: scaling in other directions, like depth or training length, needs separate treatment or has to be checked by experiment.
Fitting the learning rate: least squares
The learning rate is a power law in compute too
μP handles transfer across width. But as total compute grows, the number of training steps, the batch size and the amount of data all change too, so the best learning rate still drifts slowly. The recipe in the notes is to treat the best learning rate as a power law in compute as well. Take logs and it's a straight line again:
LR(C)=βC−α⟹logLR(C)=logβ−αlogC
In practice: at a few small budgets (say 1017 to 1020 FLOPs), run a learning-rate sweep at each one and find the bottom of each U. Plot those four best learning rates on log-log axes. They roughly form a straight line, but measurements are always a bit noisy, so the points don't sit exactly on one line. Which straight line counts as the best one?
Residuals and the sum of squares
For each point, measure its vertical distance from the line: that's the residual. Square each residual and draw it as an actual square. Add up the areas of all the squares and you get the sum of squared errors, S. Least squares means finding the line that makes this total area as small as possible.
The closed-form solution
For a straight line, we can calculate the best fit directly, with no trial and error. Write the problem in matrix form:
X111117181920θ(interceptslope)≈y
Each row of X stands for one point: a 1, followed by that point's log compute. θ holds the two unknowns, the intercept and the slope, and y holds each point's log best learning rate. Xθ is the line's prediction at every point, and the sum of squared errors is the squared length of the vector y−Xθ:
S(θ)=∥y−Xθ∥2
S is a bowl-shaped function of θ, and at the bottom of the bowl the derivative is zero. Set the derivative to zero, rearrange, and multiply both sides by (X⊤X)−1:
∂θ∂S=2X⊤(Xθ−y)X⊤Xθθ=0=X⊤y=(X⊤X)−1X⊤y
X⊤ ("X transposed") just swaps the rows and columns of X, and the inverse plays the role of division for matrices. This is linear least squares, also called ordinary least squares (OLS), solved in a single step.
Watch out: The notes write this closed form as β=(X⊤X)−1X⊤y (for y=Xβ). Here the unknowns are called θ so they don't get mixed up with the power law's β. It's the same formula.
Work it out and the slope comes to about −0.16 and the intercept to about 0.3, so α≈0.16 and β≈2. Extend the line to the big budget you actually want to train at, say 1023 FLOPs, and read off the learning rate the big model should use: about 3.3×10−4.
Fitting the loss: a curve with a floor
A straight line extrapolates wrong
Can we extrapolate the loss the same way? Train at five small budgets and you get five points (illustrative data). Force a straight line through them and it looks pretty good. But extend it out to 1025 and it predicts a loss of only about 1.15; keep going and sooner or later it hits zero.
Look closely, though, and the points are slowly flattening out: each tenfold jump in compute buys a smaller drop in loss. That's the irreducible loss L∞ at work. So what we need to fit is the formula with a floor:
L=L∞+βC−α⟹log(L−L∞)=logβ−αlogC
If we knew L∞, we could subtract it first: what's left (the reducible part) is a power law again, and taking logs gives a straight line. Try making the vertical axis "loss minus some guess". With a guess of zero, the points curve; the closer the guess gets to the real floor (about 1.75 here), the straighter they line up.
Nonlinear least squares
The catch is that we don't know L∞ in advance. It's one of the parameters we have to fit, and with it in the formula, taking logs can no longer turn the whole problem into a straight line. So we use nonlinear least squares. The goal is still to minimize the sum of squared errors:
S=i∑(yi−f(xi))2,f(C)=L∞+βC−α
But there's no closed-form solution this time, so we use iterative refinement: start with a rough guess for L∞, α and β and measure the error, then nudge them a little in whichever direction shrinks the error, and repeat. It's the same idea as gradient descent from episode 4.
Once it converges, the fitted floor is about 1.75. Extend the curve to 1025 and the predicted loss is about 1.84, sitting safely above the floor.
Intuition: Taking logs to turn a power law into a straight line is exactly what lets us use linear least squares, with its one-step closed-form answer. Add a term like L∞ that logs can't straighten out, and we fall back to nonlinear least squares, inching toward the answer.
This isn't just theory. In the GPT-4 technical report, OpenAI used exactly this kind of formula, with an irreducible loss term, to predict GPT-4's final loss ahead of time, starting from models trained with at most one ten-thousandth of GPT-4's compute. The prediction turned out to be accurate.
Recap
The whole recipe: measure (compute, loss) or (compute, best learning rate) at a few small scales → assume a power law (with L∞ for the loss) → fit α and β by least squares → extrapolate to predict the big model. A power law is a straight line of slope −α on log-log axes. Compute is C≈6ND, and on a fixed budget both N and D grow roughly like C, about 20 tokens per parameter. μP adjusts initialization and learning rate layer by layer so hyperparameters transfer from a narrow model to a wide one. Once a big run is underway, how many bits you use to store each number decides your memory use and speed. That's the topic of the next episode, precision and quantization.