Lecture guides›
✎

Lecture guide: Scaling laws I#

Lecturer: course staff · Course: Stanford CS336 Language Modeling from Scratch, Spring 2026, lecture 9 · Length: 1:18:00 Video: watch on YouTube Chapters that cite this lecture: 07. Scaling Laws

In one sentence: Tatsu Hashimoto treats scaling laws as an engineering practice: fit simple regularities on small runs, whether in data, architecture, batch size or the balance of model size against data, and extrapolate them to decide a large run before spending on it.

Before you watch#

The lecture leaves systems for a while and needs only the resource accounting of lecture 2, that FLOPs grow with data times parameters, and the critical batch size from the parallelism lectures. It is the first of two: the basics and the classical papers here, the modern technical reports, parameterizations and optimizers in a later lecture, with inference in between. The chapter Scaling Laws turns the lecture into a procedure.

The lecture, part by part#

0:00–4:02 The scenario: 10,000 B200s for a month#

Two lectures cover scaling laws and neighbouring phenomena: the basics today, the advanced version later, with technical reports of modern open models, parameterizations such as muP and, new this year, optimizers; inference comes in between. The scenario: a wealthy friend lends 10,000 B200s for a month and wants a very good open-source model. The infrastructure team is assignment 2 and the pretraining data set assignment 4, both taken as given. What remains is a long list of choices, architecture and hyperparameters, on a run that may cost millions. Some choices can be copied from the literature, as the architecture lecture surveyed. To beat the state of the art they must be optimized instead, and that means taking scaling seriously. In the large labs, Hashimoto says, scaling laws are a paradigm and almost a belief: simple predictive rules that carry small-scale behaviour up to large scale. The naive approach tunes hyperparameters on big runs, which is wasteful. The scaling approach does all the optimization at small scale and relies on robust regularities to extrapolate. In this book: Scaling Laws › The core idea · Scaling Laws › 6. Predict, then run.

4:02–11:22 Scaling laws before scaling laws#

Scaling laws are both the newest paradigm and a classical idea. To a machine-learning theorist they look like empirical sample complexities: a generalization bound says how much worse than the training error a model's error can be, and it often depends on the sample size, which makes it a bound on loss as data grows. The first scaling-law paper goes back to Bell Labs in 1993: training classifiers on a large data set is expensive, so fit them on smaller samples, fit a curve to the decay of their error, and read off the large-sample performance. Banko and Brill made the same NLP argument, that more data beats algorithm development. Kolachina and colleagues in 2012 fitted functional forms to machine translation scores against training data and found the same family of power laws that today's fits give. His favourite, and undercited, is Hestness and colleagues in 2017: data scaling laws for speech recognition, translation and language models, all polynomial, and already the points that define the present, such as emergence, since accuracy is more discontinuous than loss, and scaling by compute, which turns speed into accuracy. Much of the current regime could have been known in 2017. To a question: the forms come from curve fitting, but theory, which studies error rates, and physics, which studies limits, supply candidates. In this book: Scaling Laws › The core idea.

11:22–16:00 Data scaling laws, and a line on a log-log plot#

Power-law relationships hold for a great variety of factors. The usual pretraining plots put compute, data set size or parameters on the x-axis and the test loss, on a log scale, on the y-axis, and all are linear on log axes. More exotic ones exist: downstream benchmarks against compute follow a sigmoid, and forecasting plots with dates on the x-axis often have an upper envelope that is linear. Data scaling laws come first because they are the simplest. The training procedure is fixed, the model outsizes the data set, and the data set grows. The expected shape is monotone-ish with well-tuned hyperparameters, from random guessing down to an entropy-like noise floor. The empirical observation, which assignment 3 reproduces: a very big model on growing data gives a clear straight line on log-log axes. A line on a log-log plot is a power-law relationship: the error decays polynomially, and the system is usually far from its asymptote, since near the asymptote the curve bends. In this book: Scaling Laws › The core idea · Scaling Laws › 3. Fit, then extrapolate.

16:00–20:27 Why a power law? A statistics detour#

Estimate the mean of a Gaussian from n samples: the error is the variance over n, which is a scaling law, a term in 1/n plus a constant. Classical parametric estimation, a mean or a regression, gives rates near 1/n, so a slope near minus one. The fitted neural exponents, from Hestness and from Kaplan, are about −0.1, −0.3 and −0.1: polynomial, but far slower. Such a rate appears for non-parametric problems. To estimate an arbitrary smooth function in the unit square, cut it into boxes of side n to the power −1/4: about the square root of n boxes with as many samples each, and an error near 1 over the square root of n. In d dimensions the error is about n to the power −1/d. So one mental model is that these networks learn like non-parametric regressors in ten dimensions. Bahri and others argue that the exponents literally show networks behaving like non-parametric smoothers; he is not sure how much to buy, since the evidence leans on estimators of intrinsic dimension. To a question: "larger than the data set" means staying in the power-law regime, often around ten times the data; a model small relative to the data reaches its irreducible error, unless the asymptote is fitted explicitly. In this book: Scaling Laws › The core idea.

20:27–26:00 Data mixtures and repetition#

Data scaling laws alone say only how fast a model learns, which serves forecasting and little else. Engineering asks about the data mixture and about repetition. In classical models the composition of the data moves the offset of the law while the slope is set by the model class, and a toy regression on two kinds of data needs a mixture of both. So data scaling laws can be fitted on mixtures: with news and Wikipedia, train small models on small data, fit how performance depends on the mixing weight, scale up and extrapolate the optimum. Practitioners find reality noisier than this picture, and the DataDecide study found that the best mix at small scale works without any scaling law, consistent with slopes that do not change. On repetition, since compute grows and data does not: the study on scaling data-constrained language models found about four epochs with standard recipes do no harm, and past that the realized law is much worse than the dashed projection with fresh data; a modified functional form predicts it. In this book: Training Data › 5. Mix · Scaling Laws › What the practitioners say.

26:00–30:16 Infinite compute, and filtering that loosens with scale#

With Liang and a co-advised student he pushed repetition to the limit: infinite compute, as many epochs as desired. More passes and larger models have diminishing returns, so one ends up regularizing and ensembling. Every intervention improved the loss while the slopes stayed much the same, a lesson he repeats: slopes rarely change, interventions move the intercept. Much about data is also scale-dependent. With little compute, filter aggressively and keep only the best text; with much compute the filters loosen, since repeating high-quality data is worse than adding lower-quality text. The optimal filter is not fixed as a function of scale. To a question about a plot's axes: they were badly labelled, and in a small slice of a range linear and logarithmic look alike. The same caution applies to functional forms: over a narrow range of compute it is hard to tell a power law from an exponential, since everything looks linear when zoomed in. In this book: Scaling Laws › What the practitioners say · Training Data › 3. Filter.

30:16–36:00 Model engineering: architecture and optimizer#

Scaling laws give quantitative answers to questions the architecture lecture answered by surveying others. Are transformers better than LSTMs? The brute-force answer trains a big LSTM; the scaling-law answer trains many small transformers and LSTMs across compute ranges. The LSTM has a different intercept and perhaps a different slope, which settles the matter without a large model. Architecture papers, Mamba's and Gated DeltaNet's among them, always carry such a plot, and a worse slope is disqualifying. In the labs this becomes a rule: what does not show up in the scaling law is not a good intervention. He likes a Google study of many architectures on T5-style models: Performer, an efficient attention, scales badly and is not used; gated linear units are better at every scale; the Switch Transformer has good trends; and a mixture of softmaxes, though abandoned, probably worked. Optimizers too: with data and model fixed, Hestness's comparison of SGD and Adam shows different intercepts and almost the same slopes, which still surprises him. In this book: Scaling Laws › What the practitioners say · Transformer Architectures and Hyperparameters › What the practitioners say.

36:00–40:55 Depth, aspect ratio, and what counts as a parameter#

Depth: a one-layer model goes nowhere, two or more are competitive, and at every compute level more layers did better. Kaplan's finer study looks at scale-invariant quantities: the number of layers is not one, since bigger models want more, but the aspect ratio may be, and its minimum stays near a hundred units of width per layer at every model size, shifting slightly toward smaller ratios for deeper models. A strategy that fixes the aspect ratio and scales up can be checked this way. Then a can of worms: not all parameters are equal, and a scaling law looks good or bad depending on what is counted. Kaplan's depth laws looked odd with embedding parameters included, so they counted non-embedding parameters only, with consequences that return later. Scaling laws are engineered, Liang's point: the right x-axes and the right hyperparameters make scaling predictable. For mixtures of experts, where total and active parameters come apart, an analysis by researchers at Apple and MIT shows that bigger models favour sparser ones, and that inactive parameters still lower the loss. In this book: Scaling Laws › What the practitioners say · Attention Alternatives and Mixture of Experts › 6. Mixture of experts.

40:55–46:00 The critical batch size#

Most choices are copied; two have to be reinvented for every large model, batch size and learning rate, and they interact. Batch size wants to be large, since data parallelism needs it; the systems question is how large it can get before suffering, and how that changes with model size. The critical batch size is the crossover. Up to it, returns to batch size are perfect: in the noise-limited regime each extra example reduces the noise of the gradient step, which pays fully. Past it the run is bias-limited: gradient descent follows the local shape of the objective, its direction always disagrees a little with the direction of the optimum, and more examples buy little. The estimation is mechanical. Pick a target loss, sweep batch sizes, and record for each the steps and the examples needed to reach it. The OpenAI authors of the large-batch paper argue that steps and examples trade off against each other, normalized by a minimum number of steps and a minimum number of examples: fewer steps cost more examples and fewer examples cost more steps. Balance the two terms and the critical batch size is the minimum examples divided by the minimum steps, both obtained by fitting. It costs slightly more steps and slightly more examples than the optimum of either. A second estimate compares the gradient covariance with the squared norm of the gradient. In this book: Scaling Laws › 4. Carry the hyperparameters across scale.

46:00–50:00 Batch size as a scaling law, and the learning rate#

The critical batch size belongs in this lecture because it is a reasonable batch size, and it scales with the target loss, which stands for compute: as the loss to reach falls, the critical batch size grows as a power law. A long run can therefore use large batches, which makes sense, since near the minimum the variance matters more as the differences optimized become tiny. The learning rate is the other half, with more in the advanced lecture. In the standard picture, with width scaling only, a bigger model needs a smaller learning rate, since more parameters change at once; a rule of thumb scales it as one over the width. Another school reparametrizes the network instead, changing initializations and the optimizer's step sizes per part so that the best learning rate is the same at every scale: muP and its relatives. Reports of success differ. So there are two philosophies for a large run, predict where the minimum moves, which is fairly predictable, or hold it fixed and reuse the best value; both have worked at scale, and anecdotally more teams favour the scaling-law approach. In this book: Scaling Laws › 4. Carry the hyperparameters across scale.

50:00–53:44 Upstream against downstream, and the procedure#

In the Google architecture study, perplexity improves with parameters in a very clean linear trend. The model to ship, the best by perplexity, turned out not to be the best: another one, much worse upstream, was better downstream. Upstream and downstream performance correlate, and this is among the worst correlations he has seen, but the transfer is far less certain than it seems, so scaling laws belong on the perplexity side. His former students in post-training teams complain that pretraining hands over a model with a good perplexity and calls the rest someone else's problem, when the trouble started earlier. The procedure, then: before the large run, know roughly what to expect, even the numerical gain of one optimizer over another. Train several smaller models, fit the lines on log-log plots, and if the fit is good, trust that the gap persists at scale. In this book: Scaling Laws › 3. Fit, then extrapolate · Scaling Laws › Pitfalls.

53:44–56:00 Questions: variance, downstream metrics, train or validation loss#

Are the points single runs? Almost always, because perplexities are clean: reruns differ in about the second decimal, with homogeneous training data and large evaluation sets. Learning-rate and critical-batch-size scaling laws look horrendous by comparison, and variance reduction is rarer than it should be. Scaling laws fitted directly on downstream metrics inherit the transfer problem, so the philosophy is to establish regularity on a low-variance measurement first, then rely on transfer, or establish it separately. Train or validation loss? Good practice fits test loss, as Kaplan did, but nearly all these models make a single pass over the data, so the gap is tiny and the two are interchangeable; some pretraining code bases do not compute a validation loss at all. In this book: Scaling Laws › What the practitioners say.

56:00–62:00 Joint scaling: more data or bigger models?#

The best-known use of a scaling law answers whether a fixed amount of FLOPs should go into more data or into a bigger model. FLOPs are roughly data times parameters. A tiny model fed enormous data is flat for most of its training, a waste next to a larger model on the same tokens. Joint scaling laws describe how model size and data together set the error; Kaplan and Rosenfeld proposed roughly equivalent forms almost at the same time, Rosenfeld's as plain as a sum of two inverse terms. Take the limits: infinite data leaves a pure model-size law, an infinite model a pure data law. Fitted on small runs, low compute and little data, they extrapolate to the large regime. With FLOPs fixed, minimizing the fitted law is a small nonlinear optimization. Kaplan's answer had parameters growing as compute to the 0.73 and data as compute to the 0.27, so tokens per parameter fall as compute grows: train ever larger models. In the years after GPT-3 that in part produced dense models of hundreds of billions of parameters. In 2022 Hoffmann and colleagues at DeepMind argued that those predictions were far off, that the large models were far too large, and that much smaller models on much more data do better: Chinchilla, with 20 tokens per parameter. In this book: Scaling Laws › 2. Pick a method for the trade-off.

62:00–66:00 Chinchilla's three methods#

The Kaplan-Chinchilla disagreement is worth going through, because it shows that scaling laws are sensitive and not a crank to turn. Chinchilla fitted its law three ways, which guards against modelling assumptions, since each estimates the balance of parameters against tokens by a different route. Methods one and two agree that the exponents of data and of model size are about equal, near one half; method three gives 0.46 and 0.54. Method one takes the lower envelope of training curves: for each FLOP count, the best loss any run achieved, and then the model sizes of those envelope points against FLOPs, a linear trend, which for their budget recommends a 67-billion-parameter model. It is simple and tricky in the definition of the envelope. Method two, isoFLOP, is his favourite, easy and robust: fix a FLOP budget, sweep the parameter-to-data trade-off at that budget, take the minimum of the final losses, or of a fitted quadratic, and plot the minima against FLOPs: 63 billion. Method three fits the hypothesized joint form to all runs by curve fitting, the most brute force, where how the fit is done matters. In this book: Scaling Laws › 2. Pick a method for the trade-off.

66:00–72:00 Why Kaplan and Chinchilla disagree#

Neither paper did anything unreasonable, yet their predictions differ, and hindsight favours Chinchilla; a Chinchilla-style analysis of one's own lands close to it. The laws move with the details of implementation, hyperparameters and x-axes. A paper on resolving the discrepancies, whose last author was a student here, replicates Kaplan with Kaplan's settings, then counts parameters differently, then changes the learning-rate warm-up, then tunes the optimizer, and arrives at Chinchilla. The details: Kaplan excluded the output layer along with the embeddings, since the two matrices have the same shape, and whether that layer is counted changes the law materially; many of Kaplan's models were so small that warm-up ended before they had converged, so their learning rates were poorly set; and one large batch size was fixed throughout, too large for the small models. A scaling law is in this sense a lower bound: continue this recipe at scale and this is what you get, so the recipe had better be one worth scaling. A second paper trains nothing: from Chinchilla's implied training curves it derives what Kaplan's counting would show, and concludes that Kaplan's smaller compute scale plus the slight nonlinearity of non-embedding parameters is enough to explain the gap. In this book: Scaling Laws › 2. Pick a method for the trade-off · Scaling Laws › Pitfalls.

72:00–76:00 The mystery of method three, and why not to train Chinchilla-optimal models#

One mystery remained in the paper that took Kaplan down: method three never agreed with methods one and two, and the authors were unperturbed. The implications are not small. Equal exponents mean parameters and tokens grow together at a fixed ratio, the source of the factor of 20; unequal exponents mean that with more compute tokens eventually far outnumber parameters. Researchers at Epoch AI, unable to obtain the raw data or code, extracted the points from the paper's plots and refitted the surface: the original fit was too loose, and the refitted model gives almost exactly 20 tokens per parameter. The authors had been righter than they realized. Even so, a production model probably should not be Chinchilla-optimal. Surveys of how labs spend compute show most of it in research and development and in serving, not in training, and serving wants small capable models. GPT-3 saw, by his account, 3 tokens per parameter, Chinchilla 20, and since serving became real, models are overtrained, by his definition trained the right amount, and mixtures of experts trade further for cheaper inference. Chinchilla matters for how to fit scaling laws, not as a golden ratio. In this book: Scaling Laws › What the practitioners say · Scaling Laws › Key takeaways.

76:00–1:18:00 IsoFLOP endures; a summary#

IsoFLOP is the tool that has endured: fix a FLOP budget and sweep the other degrees of freedom to see the surface. One of his students used it for diffusion models, the mixture-of-experts study was designed that way, and it is a good default whenever trade-offs must be decided. The summary: a log-linear regularity between resources and performance holds for parameters, compute and the sparsity of a mixture of experts, and it turns arbitrary choices into evidence-driven ones. Data scaling is natural except for its strange exponent; model scaling enables engineering decisions; and scaling is a robust predictor for engineering at large scale without large training runs. Next: Liang on inference, then the advanced scaling topics. In this book: Scaling Laws › 2. Pick a method for the trade-off · Scaling Laws › Key takeaways.

What to take away#

Sources#