Maps to: UC Berkeley EE 290/194 Scalable AI, Spring 2026 Lecture 9, Optimizer Fundamentals (slides
lecture9.pdf, slides from Gireeja Ranade): SGD, momentum, sign descent, Adam and AdamW, steepest descent under norms, induced norms, Shampoo and Muon in outline, and µP learning-rate scaling. Also drawn on: Fall 2026 Lecture 8 §2, The training step (schedules, optimizer set-up, batch size). Muon, Shampoo and their systems side are the subject of Lecture 13. Recommended reading: Kingma and Ba, Adam (arXiv:1412.6980); Loshchilov and Hutter, Decoupled Weight Decay Regularization (AdamW, arXiv:1711.05101); Bernstein and Newhouse, Old Optimizer, New Norm (arXiv:2409.20325); McCandlish et al., An Empirical Model of Large-Batch Training (arXiv:1812.06162); Yang et al., Tensor Programs V (µP, arXiv:2203.03466); Chen et al., Symbolic Discovery of Optimization Algorithms (Lion, arXiv:2302.06675). Code:code/lecture12/containsoptim_lab.py(optimizers from scratch, checked againsttorch.optim; clipping, steepest-descent directions, quadratics, the gradient noise scale) and seven demos on Lecture 9’s Atlas World models. Reading time: ~2.5 hours for the prose; ~7 minutes to run all demos.
0. How to read this lecture
0.1 Learning goals
After this lecture you should be able to:
-
Write the optimizers down. SGD, momentum, sign descent, Adam (with bias correction), Adam + L2 vs AdamW, Lion. Say what each stores and costs in memory.
-
Explain them geometrically. A step is the steepest descent direction inside a norm ball:
- gives the normalized gradient;
- gives sign descent, whose smoothed version is Adam;
- the spectral norm gives (Muon).
You should also be able to explain why plain GD is capped by the sharpest direction, and why Adam’s per-coordinate scaling helps when curvature lines up with the coordinates.
-
Set the schedule. Warm-up, cosine vs WSD, and what WSD’s branching cooldowns buy.
-
Get the numerics right. When ε matters; why BF16 optimizer states depend on β₂; stochastic rounding for BF16 weights.
-
Choose a batch size. The gradient noise scale and the critical batch size; why bigger batches stop paying.
-
Use weight decay correctly. Decoupled vs coupled; equilibrium weight sizes; the timescale and WSD.
-
Derive µP’s learning-rate rule. Do it from the RMS-to-RMS norm, and say why the rule depends on the optimizer.
0.2 Prerequisites and scope
- Prerequisites: Lecture 9 (AdamW settings, schedules, µP measured, numerics of mixed precision); calculus and linear algebra (gradients, eigenvalues, the SVD).
- Scope: first-order optimizers and their geometry; schedules and warm-up; clipping; optimizer numerics; batch size; weight decay; µP’s derivation.
- Not in scope today: Muon, Newton–Schulz, Shampoo, SOAP and Kron in depth, and optimizers at scale (sharded states, matrix owners): Lecture 13.
0.3 Section → code map
| Section | Idea | Code in code/lecture12/ |
|---|---|---|
| §1 | SGD, momentum, sign descent, Adam, AdamW, Lion; checked; compared; memory | optim_lab.py, 01_optimizers_from_scratch.py |
| §2 | steepest descent under norms; conditioning; why Adam helps | 02_geometry_of_steps.py |
| §3 | warm-up, cosine, WSD, branching cooldowns, clipping | 03_schedules_and_warmup.py |
| §4 | ε, BF16 moments, stochastic rounding | 04_numerics.py |
| §5 | gradient noise scale, critical batch size | 05_batch_size.py |
| §6 | decoupled weight decay, equilibrium, | 06_weight_decay.py |
| §7 | the µP derivation | 07_mup_derivation.py |
0.4 Notation
- or = parameters; ; = learning rate.
- = Adam’s averaging factors; = Adam’s epsilon; = weight decay.
- = batch size.
- for a matrix = its largest singular value (spectral norm).
- = condition number (largest / smallest curvature).
1. The optimizers, written out
1.1 SGD and its two problems
SGD can be thought of as gradient descent with noise, and it shares GD’s pros and cons. The slide names one of each:
- Pro: implicit regularization. Combined with early stopping, there is less movement along directions with small singular values.
- Con: one learning rate for everything. It is bottlenecked by the largest singular value (to avoid instability), so directions with “medium” singular values make slow progress.
Section 2 makes the second point exact.
1.2 Momentum
, (the slide’s EMA form). PyTorch’s form, , differs only by a factor absorbed into .
Averaging smooths the trajectory: components that flip sign from step to step cancel, and consistent ones accumulate. That permits larger learning rates and faster convergence on ill-conditioned problems (§2.3).
1.3 The spirit of sign descent
The dream is a different learning rate for each singular direction, so everything converges at once with no bottleneck. What is achievable cheaply is coordinate-wise normalization:
with every operation elementwise: equal-sized steps per coordinate. The caveat is that near an optimum the signs flip and the iterate bounces. Learning-rate decay solves this, one reason schedules end with a decay (§3).
1.4 Adam: momentum plus sign descent
Two exponential moving averages:
- the first moment (the gradient) , with less averaging, ;
- the second moment (the squared gradient) , with more averaging, –.
Bias correction. and start at zero, so early estimates are biased toward zero. Without correction, the first update is times the intended one (demo 01 Part D):
- 3.16× too large for ;
- 0.45× too small for .
The error fades only as fills, over about steps; with the uncorrected step is still 6.1× the corrected one at step 6. Warm-up (§3) hides much of this.
Memory. SGD stores the weights (1×); momentum adds a buffer (2×); Adam adds two (3×). Under mixed precision (BF16 weights and gradients, FP32 master weights), demo 01 Part C counts:
| optimizer | optimizer state | bytes / parameter | for 405B parameters |
|---|---|---|---|
| SGD | — | 8 | 3.24 TB |
| momentum, signum, Lion | one FP32 buffer | 12 | 4.86 TB |
| Adam / AdamW | and in FP32 | 16 | 6.48 TB |
Lion keeps the sign-descent idea plus momentum. It avoids storing the squared gradient by “dithering” between momentum and the current gradient: . The slide’s warning: with Lion you must change the weight decay (and the learning rate, about 3× lower in demo 01).
1.5 AdamW: decoupled weight decay
If is added to the gradient (L2 regularization), it passes through Adam’s normalization by . That couples the learning rate and the regularization strength in an undesirable way. AdamW decouples them:
The difference is not subtle. In demo 01, at the same , Adam + L2 ends at 2.195 bits/byte and AdamW at 0.818 (§6 explains why). The slide adds that should be moved together with in WSD schedules (§6.3).
1.6 Checked and compared
optim_lab.py writes each optimizer out in a few lines.
- Exactness. The self-test matches
torch.optim.SGD,AdamWandAdamto over 50 steps in float64. - On a real run. In float32 on a 300-step LM run (demo 01 Part A), AdamW’s weights differ by at most from rounding order, and the validation loss is identical (0.8182). SGD at a high learning rate amplifies the same rounding to , with identical final quality.
Demo 01 Part B gives each optimizer its best of four learning rates on the same model and data (validation bits/byte; floor 0.718):
| optimizer | best lr | val bits/byte |
|---|---|---|
| SGD | 1.0 | 1.009 |
| SGD + momentum 0.9 | 0.3 | 0.889 |
| signum (sign of momentum) | 3e-3 | 0.820 |
| Lion (wd 0.1) | 3e-3 | 0.807 |
| AdamW (wd 0.1) | 1e-2 | 0.804 |
| Adam (no decay) | 1e-2 | 0.801 |
Plain SGD is far behind; per-coordinate normalization (sign descent, Lion, Adam) closes most of the gap. The next section explains why.
2. A shift in perspective: the geometry of a step
2.1 Steepest descent in a norm ball
Take the linear (first-order Taylor) model of the loss, . Choosing a step balances two competing goals:
- safety: steps small enough that the linear approximation holds;
- progress: steps large enough to converge quickly.
As an optimization problem (Bernstein and Newhouse):
The answer depends on which norm defines “small”:
| norm | the ball | best step | value |
|---|---|---|---|
| a sphere | (normalized GD) | ||
| a box: no parameter changes by more than | (sign descent) | ||
| spectral, for a matrix | (orthogonalized update) | (nuclear norm) |
- . Cauchy–Schwarz gives the closed form. With a penalty instead of a constraint, you get back classic GD.
- . A box pushes every coordinate to its limit, which is why sign descent is a natural steepest-descent rule.
- Spectral. The slide’s proof: write ; if then every . The bound is achieved by : keep the directions, drop the magnitudes. This is the matrix analogue of sign descent.
Demo 02 Part A checks all three on a random 6 × 4 gradient. Each closed-form step achieves exactly minus the dual norm (−5.09, −21.90, −9.04), and none of 20,000 random unit steps does better.
Why parameter-space norms might not be enough. A step that is small in parameter space need not be small in function space: small does not imply small for typical . What we care about is stable activations across layers, bounded changes of outputs for typical inputs, and invariance to width. That leads to induced norms, , and to the RMS-to-RMS norm of §7. Muon and µP come out of this view.
Shampoo’s identity. . Matrix roots can be computed iteratively with GEMMs, which is fast on GPUs, and the factors can be cached and updated as EMAs across steps; that is Shampoo. Muon computes of the momentum with Newton–Schulz iterations. Both are Lecture 13.
2.2 Gradient descent is capped by the sharpest direction
On a quadratic with eigenvalues , GD multiplies the error along eigenvector by each step. It diverges if ; the slowest direction then converges like , so GD needs on the order of steps.
Demo 02 Part B uses 40 dimensions, and 500 steps:
| step size | ||||
|---|---|---|---|---|
| final / initial loss | 1.2e-3 | 3.7e-4 | 8.4e-5 | 2.5e+20 (diverged) |
At , the flattest direction () has covered only 61% of the way, exactly as predicts, while the sharp directions converged to machine precision long ago.
2.3 Momentum and per-coordinate scaling
Each method gets its best learning rate, 500 steps (demo 02 Part C):
| method | axis-aligned curvature | rotated curvature |
|---|---|---|
| GD | 1.0e-4 | 7.3e-5 |
| heavy-ball momentum | 1.4e-20 | 7.8e-21 |
| sign descent (signum) | 8.8e-14 | 2.1e-08 |
| Adam | 4.9e-26 | 9.2e-09 |
- Momentum needs on the order of steps, and like GD it is rotation-invariant. (The small differences between columns come from where the start point lies relative to the eigenvectors.)
- Sign descent and Adam scale every coordinate separately, a diagonal preconditioner (对角预条件). When the curvature is axis-aligned, that matches it exactly and Adam reaches 4.9e-26. After a random rotation, the same Adam reaches only 9.2e-9: still better than GD thanks to momentum and a decaying rate, but a 10¹⁷-fold advantage is gone.
So why does Adam work for neural networks? Their Hessians are roughly block-structured: by layer, by neuron, by embedding row. Per-coordinate scaling captures much of the curvature, but not the correlations inside a weight matrix. That is what matrix-aware optimizers (Shampoo, Muon) add.
3. Schedules, warm-up and clipping
3.1 Why warm-up and why decay
- Warm-up. Early in training the weights are poorly calibrated and Adam’s moment estimates are empty or noisy (§1.4), so large updates can destabilize activations and gradients. Warm-up raises the rate gradually; Llama 3 405B used 8,000 steps. The Spring slides call warm-up “not optional at scale”.
- Decay. Sign-like steps bounce near an optimum (§1.3), and the noise in SGD-type updates has a floor set by the learning rate. Decaying at the end lowers both.
- Two shapes of decay. Cosine decays over a fixed horizon. WSD (warm-up, stable, decay) holds the peak, then decays at the end (the “cooldown”).
Debugging tip (Spring slides): when a run diverges, check the actual learning rate vs the intended one, the scheduler state after a resume, and whether the effective batch size changed.
3.2 Measured (demo 03)
Five schedules, 600 steps, same model and data:
| schedule | final val bits/byte | train loss, steps 461–480 | train loss, last 20 steps |
|---|---|---|---|
| constant after warm-up | 0.7934 | 1.821 | 1.845 |
| cosine to 10% | 0.7701 | 1.766 | 1.788 |
| WSD, last 10% decays | 0.7792 | 1.821 | 1.811 |
| WSD, last 20% decays | 0.7755 | 1.821 | 1.799 |
| WSD, last 40% decays | 0.7718 | 1.793 | 1.791 |
The decay is where the gain appears. Before its decay starts, the WSD-20% run is identical to the constant run (1.821). Over the last 120 steps its loss falls to 1.799, while the constant run’s drifts to 1.845. In this short run cosine is best, and longer WSD decays close most of the gap.
WSD’s real advantage is that you choose when to stop. Demo 03 Part B runs one stable run and branches a 20% cooldown off it at three horizons:
| horizon | WSD branch | dedicated cosine run |
|---|---|---|
| 300 steps | 0.7958 | 0.7969 |
| 600 steps | 0.7755 | 0.7701 |
| 900 steps | 0.7646 | 0.7610 |
That is a finished model at every horizon for 1,080 training steps instead of 1,800, within a few thousandths of the dedicated runs. This is why Marin and Nemotron 3 Ultra use WSD, and why Nemotron could start its decay early after a divergence (Lecture 9 §5.4).
3.3 Warm-up and clipping at a high learning rate
At 10× the tuned rate (demo 03 Part C):
| run | loss ~step 10 | ~step 100 | final val bits/byte |
|---|---|---|---|
| warm-up 60, clip 1.0 | 5.11 | 3.14 | 0.924 |
| no warm-up, clip 1.0 | 4.93 | 3.75 | 1.149 |
| warm-up 60, no clipping | 5.12 | 3.30 | 0.942 |
| no warm-up, no clipping | 5.07 | 3.89 | 1.189 |
Skipping warm-up does not show up at first: the no-warm-up run even has the lower loss at step 10, and a similar peak gradient norm. But it ends far worse. Full-size steps taken while weights and moment estimates are poorly scaled put the model somewhere it does not recover from at this learning rate. Clipping does not substitute for warm-up. It bounds single bad steps (Lecture 9’s data spike), not a systematically too-large rate.
Clipping, precisely. Global-norm clipping rescales all gradients together so that (typically ), preserving the gradient’s direction. Log the norm before clipping. optim_lab.clip_global_norm matches torch.nn.utils.clip_grad_norm_.
4. Numerics of the optimizer step
ε. Adam’s steady-state step for a constant gradient is :
| 1e-2 | 1.000 | 0.999 | 0.909 |
| 1e-4 | 1.000 | 0.909 | 0.091 |
| 1e-5 | 0.999 | 0.500 | 0.010 |
| 1e-6 | 0.990 | 0.091 | 0.001 |
only matters when gradients are comparable to it, but then it turns Adam into slow SGD for exactly the parameters with the smallest gradients. Demo 04 measures against a noise floor: three seeds of the same run span 0.0029 bits/byte. In this tiny model 26.7% of gradient entries are below , yet changes the result by −0.0021, within the noise; only hurts (+0.0171). Large models have far smaller per-parameter gradients, which is why OLMo 2’s move from to mattered at 7B (Lecture 9 §5.4).
BF16 optimizer states. Storing and in BF16 saves half their memory. But ‘s update moves it by of the gap per step. For that is 0.1%, below BF16’s 0.4% resolution, so stops tracking the gradient: one BF16 update of toward 1.2 gives 1.0000 instead of 1.0002. For the 5% step survives. In demo 04’s 300-step runs the effect stays within the noise floor (+0.0012 for ). The mechanism is real; whether it bites depends on the run. Low-precision states need the averaging horizon to fit the format.
BF16 weights and stochastic rounding. Lecture 9 showed that round-to-nearest BF16 weights lose small updates. Demo 04 Part C confirms it at Lecture 9’s learning rate (3e-3):
- 72.9% of entries are unchanged by a late update, costing +0.0205 bits/byte (beyond the 0.0039 noise floor).
- Stochastic rounding rounds up with probability proportional to the distance, so an update below half a BF16 step still moves the weight on average. It recovers the loss (+0.0005, within noise).
- Stochastic rounding is a way to drop the FP32 master copy (4 bytes per parameter) at the cost of noise.
At 3× the learning rate the updates are larger and round-to-nearest loses less.
5. Batch size and the critical batch size
Why there is a critical batch size. A minibatch gradient is the true gradient plus noise with covariance . Two regimes follow:
- Noise dominates (small ): doubling halves the noise and nearly halves the steps needed.
- The true gradient dominates (large ): more examples per step barely change the step, so tokens are wasted.
McCandlish et al. model this as
where is steps and is examples to reach a target loss. The critical batch size (临界批大小) is where both costs are twice their minimum. A cheap estimate is the simple noise scale
measured from the spread of several small-batch gradients (optim_lab.noise_scale).
Demo 05 Part A measures it during a run:
| step | 0 | 50 | 100 | 200 | 600 | 1,200 |
|---|---|---|---|---|---|---|
| loss | 6.24 | 3.22 | 2.18 | 1.91 | 1.83 | 1.80 |
| (sequences of 64 tokens) | 11.1 | 22.0 | 47.4 | 45.2 | 91.0 | 94.4 |
The noise scale grows as the loss falls. Early on, every example’s gradient points roughly the same way. Later, the true gradient shrinks relative to per-example noise. So runs start with small batches and ramp up (Llama 3 405B: 4M → 8M → 16M tokens), and the critical batch grows with compute.
Demo 05 Part B measures steps to a fixed loss with learning rate :
| batch (sequences) | 4 | 8 | 16 | 32 | 64 | 128 | 256 |
|---|---|---|---|---|---|---|---|
| steps to target | 287 | 184 | 126 | 101 | 87 | 78 | 73 |
| tokens / | 1.33× | 1.70× | 2.33× | 3.73× | 6.43× | 11.5× | 21.6× |
The fit gives steps and sequences (766 tokens), and it matches every point to within 4 steps. Past , doubling the batch saves a few steps and doubles the tokens. At 256 sequences the run spends 21.6× the minimum tokens.
The noise scale near the target loss (47 sequences) is within a factor of 4 of the fitted . treats all directions alike; the exact noise scale weights them by curvature (), and the two track each other up to a roughly constant factor.
Systems consequences:
- Data parallelism adds tokens per step, so past each extra GPU buys little progress.
- Batch size and learning rate interact. Square-root scaling is a common heuristic for Adam; retune when you change .
- A larger critical batch lets a run use more parallelism productively. That is one of Muon’s claimed advantages (Lecture 13), and the slide’s reason why “it is worth amortizing [Muon’s cost] over a larger batch size”.
6. Weight decay
6.1 Coupled vs decoupled
With L2 inside Adam, the decay term is divided by . For parameters with small gradients, is small and the decay becomes a full-size step toward zero. Demo 06 Part A:
| optimizer | val bits/byte | RMS of attention/MLP weights | RMS of embeddings | |
|---|---|---|---|---|
| no decay | 0 | 0.7978 | 0.0871 | 0.0932 |
| Adam + L2 | 0.01 | 1.0833 | 0.0081 | 0.0153 |
| AdamW | 0.01 | 0.7968 | 0.0864 | 0.0921 |
| Adam + L2 | 0.1 | 1.7328 | 0.0007 | 0.0055 |
| AdamW | 0.1 | 0.7969 | 0.0813 | 0.0838 |
AdamW shrinks every weight by the same factor per step, independent of its gradient history. That is the fix in Loshchilov and Hutter’s paper, and why every modern recipe uses AdamW. Lecture 9’s set-up also exempts embeddings and norms from decay (OLMo 2).
6.2 Equilibrium weight size
With decay, the weights are pulled toward a balance of updates and shrinkage. A random-walk model predicts an RMS of : each Adam update adds about per entry in a random direction, and decay removes of .
Demo 06 Part B finds the measured RMS within a factor of about 2.6 of that prediction (ratios 0.54–2.56), and not even monotone in . Two reasons:
- Adam’s updates are correlated with where the loss wants the weights, not random.
- With near the run length, some runs have not settled.
For weights followed by a normalization layer, which are scale-invariant, the equilibrium becomes exact in shape. That is the “rotational equilibrium” behind treating weight decay as an angular step size (Lecture 13). Strong decay also costs quality: ends at 2.55 bits/byte.
6.3 The timescale and WSD
AdamW’s weights behave like an exponential moving average of past updates with horizon steps (Wang and Aitchison). If decays 10× during a WSD cooldown with fixed, grows 10× (from 33K to 333K steps in demo 06’s example), and decay effectively switches off. Moving with keeps the horizon fixed. That is the Spring slide’s instruction to “move it together with the learning rate when doing WSD”.
7. µP: deriving the learning-rate rule
Lecture 9 showed µP working: under SP the best rate drifted from to as width grew 8×, and under µP it stayed at . The Spring slides derive why, from the induced-norm view of §2.1.
7.1 The RMS-to-RMS norm
controls the average per-coordinate scale, the quantity activations, Xavier/He initialization and normalization layers are stated in. The induced norm is
Demo 07 Part A confirms it by power iteration for three shapes. Layer geometry () thus enters what counts as a “small” update.
7.2 Adam (sign descent) needs
- Idealize Adam as sign descent. The update is . We want for each layer.
- One input gives a rank-1 gradient. For a linear layer and batch size 1, is rank 1. Its sign, , is also rank 1. So (demo 07 Part B: exactly 64, 256 and 1,024 for ).
- The bound. Then
- Checked. Demo 07 Part C matches to every digit. With the change is the same at widths 64 to 4,096.
Takeaway (µP scaling): use for weight matrices when using Adam or sign descent. Widening the model while keeping activation RMS comparable keeps each layer’s update size comparable. That makes zero- or few-shot learning-rate transfer possible: sweep on small models, then only refine on big ones.
7.3 On a real batch
A real batch’s gradient is not exactly rank 1. In demo 07 Part D (Lecture 9’s model, 64 × 64 tokens) its stable rank is about 3, so one AdamW step changes the layer by less than , but the scaling survives:
| width | 32 | 64 | 128 | 256 |
|---|---|---|---|---|
| SP: | 0.204 | 0.357 | 0.701 | 1.309 |
| µP | 0.204 | 0.179 | 0.175 | 0.164 |
Under SP the change grows 6.4× from width 32 to 256; under µP it stays roughly flat. This is the mechanism behind Lecture 9’s sweep.
7.4 Careful: the math changes with the optimizer
The slide’s warning: without the underlying reasoning, one can mistake the scaling for a fixed formula.
For SGD, the batch-1 gradient has (assuming later layers keep activations controlled), so . A “maximal” update wants , giving
which depends on shape, not scale, unlike Adam’s .
Initialization from the same viewpoint. Xavier/He variance keeps the expected RMS constant with depth. A safer target bounds the worst-case amplification, . With i.i.d. entries of variance , the Frobenius energy spread over singular values gives
Demo 07 Part E checks this. Xavier overshoots the target most when the output is narrow (2.99× for a 256 × 1024 matrix). The “safe” variance halves that (1.50×) and keeps every shape within a factor of about 2. That remaining factor comes from the random-matrix edge, .
Muon uses the same constraint, but computes the semi-orthogonal direction directly instead of relying on sign descent’s rank-1 approximation. Lecture 13 continues from here.
8. Summary
- The optimizers are short. SGD, momentum (smooth, accelerate), sign descent (per-coordinate normalization), Adam = momentum + sign-like normalization + bias correction, AdamW = decoupled decay, Lion = signed momentum with one state. Adam costs 16 bytes per parameter under mixed precision. From-scratch versions match
torch.optimto . - Geometry. Steepest descent under , and the spectral norm gives normalized GD, sign descent and . GD is capped at and needs about steps; momentum needs about . Adam’s diagonal preconditioning is huge when curvature is axis-aligned and modest when it is not.
- Schedules. The gain comes in the decay. WSD gives a finished model at any horizon by branching cooldowns off one stable run (1,080 vs 1,800 steps for three horizons). Warm-up protects the start, and clipping does not replace it.
- Numerics. ε matters only for gradients comparable to it. BF16 moments fail when is below BF16’s resolution. Round-to-nearest BF16 weights lose small updates (+0.02 bits/byte beyond noise), and stochastic rounding recovers them. Always compare against a noise floor.
- Batch size. The noise scale grows as the loss falls (11 → 94 sequences). Past the critical batch (12 sequences here), bigger batches waste tokens (21.6× the minimum at 256).
- Weight decay. Use decoupled decay: Adam + L2 at ruined the model (1.733 vs 0.797). Weights equilibrate on a scale set by , and the memory horizon says to move with .
- µP. In RMS-to-RMS norm, a sign step changes a layer by , so Adam needs , while SGD needs . The rule is derived from the optimizer, not memorized.
9. Common pitfalls
- Adam + L2 instead of AdamW (or “weight_decay” in
torch.optim.Adam, which is L2). - Comparing optimizers at one learning rate each, or at grid edges. Sweep, and bracket the optimum.
- Skipping warm-up because the first steps look fine. The damage shows later.
- Expecting clipping to fix a learning rate that is too high.
- ε = 1e-5 or larger in a large model.
- BF16 optimizer states with β₂ = 0.999 without checking.
- Scaling the batch past the critical batch and calling the throughput gain progress.
- Keeping λ fixed while the learning rate decays 10× in a WSD cooldown, without meaning to.
- Applying µP’s Adam rule to SGD, or a µP formula without knowing what it keeps constant.
10. Exercises
- Bias correction. With , , what is the ratio of uncorrected to corrected Adam step at ? At , for a constant gradient?
Answer
At : , , so the uncorrected step is times , and the corrected step is also : ratio 1. At : , , so the uncorrected step is . Corrected: 1. With these betas the error is zero at step 1 but grows before fading over about 100 steps.
- Steepest descent. For , give the steepest-descent step of size under and under , and the first-order decrease of each.
Answer
: ; decrease . : ; decrease . The ball contains the ball of the same radius, so it allows a larger first-order decrease; whether that step is safe depends on the curvature.
- Conditioning. A quadratic has eigenvalues from 0.01 to 10. What is GD’s largest stable learning rate, and roughly how many steps does it need to shrink the error along the flattest direction by ? With heavy-ball momentum?
Answer
. At (= ), the flattest direction shrinks by per step, so about 10,000 steps (κ = 1,000; at about 5,000). With momentum the rate is about , so about 160 steps.
- Critical batch. A run’s measured noise scale is 2M tokens. You have 4,096 GPUs, each processing 4K tokens per step. What is your batch, how does it compare with , and roughly how many more tokens than necessary will you spend to reach the same loss?
Answer
M tokens, . Tokens: , so about 9.4× the minimum. Steps: , only 12% more than the minimum possible. You are trading tokens (compute) for wall-clock. Options: fewer GPUs per run (or several runs at once), ramping the batch up as the noise scale grows, or an optimizer with a larger critical batch.
- Coupled decay. A parameter has a tiny gradient (), value , Adam with L2 , , . Approximately how far does it move per step toward zero? Under AdamW?
Answer
Adam + L2: the decay term is , which dominates the tiny gradient. Normalized: ; once tracks the ratio is about 1, so the step is about per step toward zero. It reaches 0 in about 50 steps. AdamW: per step, 200× smaller, with a horizon of steps.
- µP for a new optimizer. An optimizer’s update for a weight matrix is (normalized gradient). At batch size 1, how must scale with width () to keep constant?
Answer
At batch 1, is rank 1, so and . The RMS-to-RMS norm is for square matrices. So should be constant in width (and scale as for non-square). Each optimizer’s normalization changes the rule, which is the slide’s point.
- BF16 v. For which β₂ does a BF16 second moment stop updating when the gradient is steady? (BF16 has 8 significant bits; a relative change below about rounds away.)
Answer
The update changes by times the relative gap. With a steady gradient the gap shrinks to the noise level, but even a 20% gap gives a relative change of . That rounds away when , i.e. . So β₂ = 0.95 is safe, and 0.999 stalls for all but large gaps. FP32 states (or stochastic rounding, or Kahan-style compensation) avoid it.
11. The related assignment (concepts only)
The optimizer choices of Assignment 2 (pre-training from scratch on one node) follow directly:
- AdamW with decoupled decay, not applied to embeddings and norms;
- and ;
- warm-up, then cosine or WSD (WSD lets you decide when to stop and branch cooldowns for ablations);
- a batch near, not far above, the critical batch for your loss range;
- learning rates swept on small proxies with µP so they transfer.
Spring 2026’s student blog post “Optimizer Mismatch & Catastrophic Forgetting” (course site) studied how optimizer choice drives forgetting during fine-tuning, a reminder that optimizers matter beyond pre-training. No assignment solutions are given here.
12. Research directions
- Geometry-aware optimizers. Which norm should each parameter type use: embeddings, attention, MLP, norms? Modular norms and “old optimizer, new norm” give a framework; measuring it at scale is open.
- Critical batch size as a design target. Optimizers, schedules and architectures that raise let runs use more data parallelism productively.
- Low-precision optimizer states. FP8 or 4-bit moments with error compensation or stochastic rounding, and when the averaging horizon breaks them.
- Schedules without a horizon. WSD and schedule-free methods remove the need to know the run length. What is lost, and can cooldowns be made cheaper still?
- µP beyond width. Depth, batch size, training length and MoE sparsity each need transfer rules; unified “maximal update” reasoning across all of them.
13. Further reading
- Kingma and Ba, Adam (arXiv:1412.6980); Loshchilov and Hutter, Decoupled Weight Decay Regularization (arXiv:1711.05101).
- Bernstein and Newhouse, Old Optimizer, New Norm: An Anthology (arXiv:2409.20325); Bernstein et al., signSGD (arXiv:1802.04434).
- Chen et al., Symbolic Discovery of Optimization Algorithms (Lion, arXiv:2302.06675).
- McCandlish et al., An Empirical Model of Large-Batch Training (arXiv:1812.06162).
- Hägele et al., Scaling Laws and Compute-Optimal Training Beyond Fixed Training Durations (WSD and cooldowns, arXiv:2405.18392).
- Wang and Aitchison, How to set AdamW’s weight decay as you scale model and dataset size (arXiv:2405.13698).
- Yang et al., Tensor Programs V (arXiv:2203.03466); Yang, Simon and Bernstein, A Spectral Condition for Feature Learning (arXiv:2310.17813).
- Gupta, Koren and Singer, Shampoo (arXiv:1802.09568); Jordan et al., Muon (2024).
14. Next lecture
Lecture 13 · Modern Optimizers and Architectures. This lecture ended where the spectral norm gives . Lecture 13 builds the optimizers that use it:
- Muon’s Newton–Schulz iterations and their coefficients (Polar Express); Shampoo, SOAP and Kron;
- the systems problem of orthogonalizing matrices that are sharded across GPUs (gathers, matrix owners, Dion);
- stability (QK-clip, gated attention) and weight decay as an angular step size, with fixed-norm variants;
- how to evaluate an optimizer claim fairly;
- memory-traffic-aware architecture (n-gram tables in host memory, hyper-connections).
术语表 (Glossary, English → 中文)
| English | 中文 |
|---|---|
| stochastic gradient descent (SGD) | 随机梯度下降 |
| momentum / heavy-ball momentum | 动量 / 重球动量 |
| exponential moving average (EMA) | 指数滑动平均 |
| sign descent / signum | 符号下降 / 带动量的符号下降 |
| Adam / bias correction | Adam / 偏差修正 |
| first / second moment | 一阶矩 / 二阶矩 |
| L2 regularization (coupled) / decoupled weight decay (AdamW) | L2 正则(耦合) / 解耦权重衰减 |
| Lion | Lion 优化器 |
| optimizer state | 优化器状态 |
| steepest descent / norm ball / dual norm | 最速下降 / 范数球 / 对偶范数 |
| spectral norm / nuclear norm / orthogonalization | 谱范数 / 核范数 / 正交化 |
| induced (operator) norm / RMS-to-RMS norm | 诱导(算子)范数 / RMS 到 RMS 范数 |
| condition number / curvature / Hessian | 条件数 / 曲率 / 海森矩阵 |
| diagonal preconditioner / rotation invariance | 对角预条件 / 旋转不变性 |
| warm-up / cosine decay / WSD / cooldown | 预热 / 余弦衰减 / 预热-稳定-衰减 / 冷却期 |
| gradient clipping (global norm) | 梯度裁剪(全局范数) |
| epsilon (numerical stability term) | ε(数值稳定项) |
| stochastic rounding / round to nearest | 随机舍入 / 就近舍入 |
| gradient noise scale / critical batch size | 梯度噪声尺度 / 临界批大小 |
| equilibrium norm / timescale | 平衡范数 / 时间尺度 |
| rank-one / stable rank | 秩一 / 稳定秩 |
| µP / hyperparameter transfer / width multiplier | 最大更新参数化 / 超参数迁移 / 宽度倍数 |
| Xavier/He initialization | Xavier/He 初始化 |