Lecture guides›
✎

Lecture guide: Scaling laws II#

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

In one sentence: Tatsu Hashimoto reads scaling laws as they are practised in recent open-model reports, then covers the three things that must be carried across scale, learning rates, batch sizes and optimizers, through two opposed strategies: fit how the optimum moves, or reparametrize so that it does not.

Before you watch#

The lecture continues the first one on scaling laws: the critical batch size, the Chinchilla methods and the muP idea are assumed. It has three parts: selected papers from teams that train large open models, which mostly means the Chinese open-source community; learning rates, batch sizes and optimizers; and the reasoning behind muP. The video has no chapter marks. The chapter Scaling Laws keeps the recipes of this lecture in its sections on hyperparameters and on the learning-rate schedule.

The lecture, part by part#

0:00–4:00 A grab bag: scaling at the open frontier#

The lecture covers advanced details of scaling up a language model in practice. Does the scaling-law material work at the scale of real open models? Which learning-rate tricks should an informed builder know? And since optimizer behaviour is scale-sensitive, how should initializations, learning rates and batch sizes be set as a function of scale? So far the course covered the classical canon, Kaplan, Hestness and Chinchilla, which brings it to about 2022. Scaling papers since then are fewer and come mostly from the open-source community in China, and a curated selection shows what scaling at the open frontier looks like, a speedrun from Chinchilla to Kimi K2, the most recent release with scaling details. Two papers get the most time, MiniCPM from 2024 and the DeepSeek LLM paper, because both are serious scaling investigations and they take opposite approaches to the key questions. The classics, how to set learning rates and how to do Chinchilla, are now taken for granted and no longer written up, which is a reason to read the older papers. In this book: Scaling Laws › What the practitioners say.

4:00–10:00 MiniCPM: muP and the optimal batch size#

MiniCPM, an industry and academic partnership, was state of the art in the one-to-two-billion bracket when it appeared and is still competitive for 2024. Its first tool is muP, a class of initializations that makes some hyperparameters less scale-dependent, here used so that the optimal learning rate stays the same at every size. The paper's list: scale the embedding output, scale the residual connections with a factor of the square root of the layer count, scale the initialization of every matrix-shaped tensor by the ratio of fan-out to fan-in, scale learning rates per tensor, exotic to anyone unused to per-parameter learning rates, and scale the output head. The point is to avoid brute-forcing a 1.5-billion model: train a ladder of much smaller models, whose largest is about five times smaller than the release, and pin down the sensitive parameters, the optimal batch size, the learning rate and the token-to-size ratio. It works: across all model sizes the lowest loss sits at a learning rate near 10^-2, with only the smallest model slightly off. The optimal batch size still moves, with both data and model size. The authors fit quadratics along equal-loss contours of runs at fixed batch sizes and find the optimal batch size as a function of the tokens processed; it also follows a power law in the target loss, the Kaplan-style critical batch size, which sets the batch size precisely for any loss target. In this book: Scaling Laws › 4. Carry the hyperparameters across scale.

10:00–14:00 WSD: a schedule that lets runs be reused#

A Chinchilla analysis needs many models, and isoFLOP means training on more sequences at a fixed budget. Each length has its own cosine schedule, which must know the total budget in advance, so an eight-million-sequence run cannot continue a four-million-sequence one: everything restarts, at a cost that is in effect quadratic. MiniCPM's answer is now common: warm-up, stable, decay, a trapezoid. The warm-up lasts a constant number of steps, whatever the horizon. The learning rate then holds constant for most of the run and decays quickly at the end, over 10% to 20% of the run, to around 10% of its peak. The gain is reuse: to train longer, roll back to the last stable checkpoint, continue and decay again. Re-decaying costs about a tenth of a run instead of the whole run. Against a well-tuned cosine schedule, WSD curves look worse until the decay, then match or sometimes exceed it; he attributes the comparison to an extensive study by a group at ETH Zurich, one of many papers with similar plots. Anecdotally cosine is slightly better in many cases and WSD about as good in many others, and WSD does not force a rerun to continue a run. The plots also show how much the final decay matters. In this book: Scaling Laws › 5. Use a schedule that lets you reuse runs.

14:00–16:00 MiniCPM's Chinchilla replication#

With WSD a Chinchilla analysis is easy: one long run, its checkpoints rewound and decayed again and again, gives the sweep over data, and a sweep over model sizes completes it. MiniCPM chose to replicate methods one and three, the least reliable of the three in his view, and obtained clean lower envelopes and smooth curves for compute against non-embedding parameters. Their joint fit, however, has exponents quite different from Chinchilla's, and the paper concludes that models need far more tokens than Chinchilla says; he cannot tell whether that is true or whether their fits are odd. Two things to remember from the paper: muP to stabilize the learning rate, and WSD. In this book: Scaling Laws › 2. Pick a method for the trade-off · Scaling Laws › 5. Use a schedule that lets you reuse runs.

16:00–20:00 DeepSeek LLM: fit how the optimum moves#

The first DeepSeek paper, from before its mixtures of experts, remains one of the better executed scaling analyses in the open world. It takes the other road: no muP and no scaling adjustments, but a direct scaling-law fit for the best batch size and the best learning rate. If the way they move with scale is predictable, nothing else is needed. The method: extensive grid searches over learning rate and batch size at several scales, each at a fixed number of tokens, with the lowest loss marked at every scale. Plotted against non-embedding training FLOPs, the optimal batch sizes fall on a line. The learning-rate fit is, in his words, not the best linear fit he has seen in his life; the models train all the same. That is the method's weakness: a grid that is not in the right place quantizes the answer, and the fit becomes an arbitrary line. The stars on the plots are the full runs, with larger batches and lower learning rates at higher FLOPs. To a question: the spread at equal FLOPs comes from different model sizes. In this book: Scaling Laws › 4. Carry the hyperparameters across scale.

20:00–26:45 DeepSeek's Chinchilla replication, and what newer reports say#

In 2024 every open builder replicated the whole stack. DeepSeek complemented its learning-rate analysis with a Chinchilla replication on a WSD schedule, with an odd second decay phase that never caught on. Its isoFLOP sweeps give cleaner curves than MiniCPM's, and a similar law for data against model size: the Chinchilla laws hold at large compute. The punchline of such work is a plot he misses from current papers: many small runs, a power law drawn through them, and predictions close to the two models actually trained. Later reports give this little space. Qwen 2.5 ran scaling experiments to predict the optimal hyperparameters, for mixtures of experts too, and Qwen 3 repeated the recipe. Kimi K2, the newest paper discussed, is about scaling mixtures of experts: losses against FLOPs at several sparsity levels, sparser being better per FLOP, and a sparsity of 48 chosen where the returns diminish. Hunyuan did the same and settled on 96 tokens per active parameter with the sparsity fixed. LLaMA 3's isoFLOP ratios are similar to others, and its more interesting plot maps log loss to downstream accuracy with a sigmoid, which has systematic deviations but shows how tightly the two couple. In this book: Scaling Laws › What the practitioners say · Scaling Laws › 2. Pick a method for the trade-off.

26:45–30:00 MiniMax-01, and a question about post-training#

MiniMax-01 used scaling for architecture choice: lightning attention, a linear variant, full softmax attention and a hybrid of the two, compared in Kaplan-style plots. They scale much alike and want similar model sizes, which justified the hybrid in the deployed system. The trends across reports: DeepSeek fits scaling laws, MiniCPM reparametrizes, Kimi, Qwen and Hunyuan scale their mixtures of experts, MiniMax compares architectures, several replicate isoFLOP, and all of it in less detail, in his guess, because the machinery is understood by everyone. Asked what changes once post-training is standardized, he says it is an open question: post-training can change what pretraining should be, and work on coverage or diversity in pretraining as a predictor of post-training is nascent. In this book: Scaling Laws › What the practitioners say.

30:00–34:00 The StepFun study: gridding learning rate and batch size#

The middle part follows the DeepSeek road: scaling laws for learning rates, batch sizes and optimizers, drawn from a recent preprint by StepFun. No truly robust study of hyperparameters exists; this comes close, at the price of much compute spent on grids. Its table of proposed laws shows the disagreement in the field: OpenAI's batch-size law is a function of the terminal loss, StepFun's a function of the data, DeepSeek's of compute for both quantities; the laws do not even share inputs. None should be taken as gospel, since such formulas are brittle, but the experiments teach a lot. The design repeats DeepSeek's: a grid over learning rate and batch size across model sizes and data sizes. The contour plot of loss, for a slice at one billion parameters and 100 billion tokens, is smooth and convex along every slice, so the minimum can be searched with confidence. Had it been jagged, gridding would be doubtful. In this book: Scaling Laws › 4. Carry the hyperparameters across scale · Scaling Laws › What the practitioners say.

34:00–40:00 What the optima depend on#

The paper's key takeaway: the optimal batch size depends only on the total amount of data. Model sizes of every colour follow one trend line against the tokens trained on, a power law on log-log axes. The learning rate behaves differently: bigger models want a smaller one, and more data wants a larger one, which is counterintuitive and may be fragile, since other papers argue for the reverse dependence on data. Learning rates are also robust: practitioners know that a range around 10^-3 to 10^-4 is a good start, and the paper's laws transfer to mixtures of experts to a degree, the predictions landing near the optima measured on them, once active parameters are controlled. What does shift the optima is the training data, so the specific numbers are contingent on it. In sum: batch size near a constant times the square root of the data, learning rate up with data and down with model size; under Chinchilla-like scaling the two partly cancel, and the learning rate falls with compute while the batch size rises, as in DeepSeek's law with other exponents. Asked whether to apply published laws or run a grid of one's own: it depends on the budget; near StepFun's regime their law is a better default than anything from a hat, but a large run has its own differences, such as a large weight decay, which is why teams redo the analyses. Much of scaling-law work is still, by his word, vibes. In this book: Scaling Laws › 4. Carry the hyperparameters across scale.

40:00–46:00 Muon at small scale, and how to compare optimizers#

Optimizers are scale-dependent and have moved fast in the last year or two. The motivation is the nanoGPT speedrun, which inspired assignment 1: reach the target loss as fast as possible on a tiny model. The Muon optimizer, in the purple curve, gains a great deal over AdamW, in blue, at no extra cost. Is it good at scale? He offers a story rather than a prescription, built on a large systematic comparison by four researchers, Liang among them. The first lessons are ordinary empirical machine learning: each optimizer has its own hyperparameters; tuned badly, an optimizer looks far worse than it is, and a small change of learning rate erases the apparent gains; a weight decay tuned for one method hurts another. The scale lessons come on two axes. One is compute, with the model-to-data ratio fixed: Muon's speed-up over AdamW is large at small scale and shrinks as compute grows, not the picture one hopes for. The other is the Chinchilla ratio, data per parameter: an algorithm may shine when the model is over-parameterized, perhaps by implicit regularization, and another when data is plentiful, because it packs knowledge more efficiently. It is a large confounder, neglected even by papers with good hygiene on the model-size axis. Here the gains were consistent across ratios, but both axes deserve vigilance. In this book: nothing beyond this guide; nearest: Scaling Laws › What the practitioners say.

Establishing scaling for a new algorithm, or even a new setting, is far from easy. His example is a set of hyperparameters being proven out by a researcher working with Marin, Liang's open-source training project: Cautious AdamC, an Adam variant, square-root batch-size scaling and other ordinary choices. Their Chinchilla analysis is beautiful up to about 10^20 FLOPs; then a little worse, a lot worse, and the largest run has blown up. Because this was a series of experiments rather than a paper, the failed runs were published too. The fix was more careful muP-style parameterization and a different optimizer, after which the scaling held over more orders of magnitude. A fair share of attempts look like this. In this book: Scaling Laws › Pitfalls.

50:00–56:00 What Muon does, and its story at scale#

Muon now appears in large training runs, which is his criterion for including a topic. A momentum optimizer adds the gradient to a momentum buffer and steps along it. Muon's observation is that gradients treat all parameters alike, though a model has vector parameters, the gains of RMS norm, and matrix parameters, the projections of attention and MLPs, and matrices have spectra. So Muon takes the momentum update of a matrix parameter and orthogonalizes it, with a Newton-Schulz iteration: write the update as U S Vᵀ, set every singular value to one, and use UVᵀ. AdaGrad and Adam equalize the size of each coordinate; Muon equalizes each direction in spectral norm. It is defined only for matrices, so the vector parameters may keep AdamW. Newton-Schulz approximates the orthogonalization with matrix products only, which is why it is fast on GPUs, where a full decomposition is not. The story: found on the speedrun, questioned by scaling studies arguing that its gains shrink with scale, and then Kimi K2 was trained entirely with Muon, with safeguards against instabilities, and is an outstanding model. So Muon works at scale; whether it beats AdamW there is unknown, since no ablation exists at that size. In questions: the hyperparameters differ between parameter types; and one of Muon's authors argues that every layer deserves its own optimizer, the limit being one per parameter. In this book: nothing beyond this guide; nearest: Scaling Laws › What the practitioners say.

56:00–60:00 muP: the game and the evidence#

To a question on interactions: the space of hyperparameters grows exponentially, so teams grid the most sensitive one, the learning rate, and sweep weight decay on its own afterwards. muP remains a little mysterious: papers and implementations disagree on the underlying mathematics, yet a core of shared ideas is generally effective. The game: as width grows, the optimal learning rate normally shifts; the aim is to keep it fixed; the permitted knobs are per-layer initializations, per-parameter learning rates and the scaling of residual connections. The evidence includes CerebrasGPT, models from 0.1 to 13 billion trained by a chip company whose language-model arm is run by the author of the Hestness scaling paper: with muP the scaling fits were more stable and the projected losses landed almost exactly on the real models, where the others fluctuated. MiniCPM and others validate it at scale. In this book: Scaling Laws › 4. Carry the hyperparameters across scale.

60:00–66:00 The reasoning behind muP, part 1: two invariants#

For the mathematics he recommends an accessible review that puts muP into another framework, since the Tensor Programs papers that started the program are, for him, inscrutable. The reasoning is a physicist's. Widen the network and assert two invariants in the limit. First, activations at initialization stay of order one in size, whatever the width; if they explode or vanish, the parametrization is wrong. Second, after one gradient step the change of an activation is of order one: feature learning. In the neural tangent kernel regime that change vanishes with width, which is not wanted. If each activation is of order one, the norm of a layer's activation vector grows as the square root of its width. For the first invariant take a deep linear network with weights drawn as scaled Gaussians: matrix concentration gives the operator norm, the output of a layer is roughly its input times that norm, and the induction on layers holds if the initialization scale makes the operator norm the square root of fan-out over fan-in. The equalities are approximate, the assumptions mostly legitimate. In this book: Scaling Laws › 4. Carry the hyperparameters across scale.

66:00–70:00 The reasoning behind muP, part 2: the update#

The second invariant is hairier. Take SGD on a single example in a deep linear network. The update of a layer's weights is a rank-one outer product of the loss gradient and the activations. The change of the layer's activation expands into three terms, one from the change of the previous activation and two from the change of the weights, and each should be of order the square root of the layer's width, assuming no cancellation. He insists this is not rigorous mathematics but bookkeeping of orders of magnitude. The first term is right by the induction hypothesis. The other two fix the operator norm that the weight update must have, the square root of fan-out over the square root of fan-in, so the question becomes which learning rate produces such an update. One more assumption, the least palatable: the loss changes by order one at each step. With a Taylor expansion, the change in the loss is the gradient times the change in the weights, a rank-one object, and solving for the learning rate gives the ratio of fan-out to fan-in. With Adam, he adds, the learning rate scales as one over the fan-in instead. In this book: Scaling Laws › 4. Carry the hyperparameters across scale.

70:00–74:00 What muP prescribes#

The outcome is a small change of practice. Initialization is one over the square root of the previous width times the square root of fan-out over fan-in, which equals the standard initialization when the ratio is one. The learning rate, normally a constant, is set to the ratio of fan-out to fan-in. For Adam the rule is one over the fan-in, so layers with large fan-ins get smaller learning rates: layer-adaptive learning rates. The high-level point is the kind of mathematics: take a scaling limit, assert invariants, add assumptions, and derive constraints on the hyperparameters. It is a general way to invent algorithms and scalings, unlike the usual practice in machine learning. In this book: Scaling Laws › 4. Carry the hyperparameters across scale.

74:00–1:18:00 Stress-testing muP, and the closing word#

An independent researcher stress-tested muP. In a controlled setting it transfers the optimal learning rate and its variance across scales, as MiniCPM found, and each part of a transformer, embeddings, attention, MLP inputs and outputs, the output layer, has its own scaling. Much of a real model lies outside the theory: SwiGLU, variations of initialization, RMS norm, exotic optimizers. Most of it works with muP anyway. What breaks it: learning the gain of RMS norm, which can often be removed; optimizers such as Lion, built on the sign of the gradient and akin in spirit to Muon; and, most concerning, large decoupled weight decay. Is muP useful? To stabilize learning rates, yes: without it the optimum shifts greatly, though predictably, with width. It is one tool among several for controlling hyperparameter drift, an open area of research, as promising as fitting scaling laws directly. His closing word: scaling in the wild is presented as a science, but it is messier and more unknown. People do use scaling laws to pick architectures, optimizers and hyperparameters, and no one knows whether a law will extrapolate forever. Reasonable practices raise the odds; there is no silver bullet yet. In this book: Scaling Laws › Pitfalls · Scaling Laws › Key takeaways.

What to take away#

Sources#