← Contents Volume IX · Lecture 19

Volume IX · Teaching at Scale

19

The Optimizer That Didn't Explode

A pretraining run reports its loss every few seconds, and for weeks the number falls. Then one reading is higher than the one before. Sometimes the curve forgives it within a few hundred steps. Sometimes it never comes back, and everyone who paid for the cluster-days since the last checkpoint learns what a restart costs.

The mental model

A loss spike is a step that outran what the network could absorb. Stability at scale is not luck with the data; it is a property of the update rule, and an update rule can be designed to bound the step it takes.

A curve that turns around

A loss spike is a sudden rise in training loss, out of line with the downward trend, that appears within a handful of steps. There are two grades of it. In the mild grade the loss jumps, then settles back onto the old curve. In the severe grade it does not settle, and the run diverges. At small scale you rerun with a lower learning rate and lose an afternoon. At the scale this volume is about, you have a very large number of accelerators waiting while a person decides what to do.

The two most detailed public accounts of living with this are both from 2022. The PaLM paper reports that the 540-billion-parameter model suffered roughly twenty loss spikes during training, despite gradient clipping. The team's remedy was operational: rewind to a checkpoint about a hundred steps before the spike began, then skip a few hundred batches of data and carry on. They also report that the spikes were not simply bad data — the same batches did not cause a spike when fed from a different checkpoint — which points at a specific batch meeting a specific state of the parameters. The OPT-175B paper and logbook tell a similar story from a different team: repeated divergences, learning-rate reductions made by hand, and restarts from earlier checkpoints, interleaved with hardware failures.

TRAINING LOSS STEPS → SPIKE settles back diverges the run you wanted
Figure 19a A schematic, not data. The mild spike costs the steps it wastes. The divergence costs everything since the last good checkpoint — which is why the PaLM and OPT teams kept checkpoints close enough together to make rewinding affordable.

Four suspects

There is no single cause. The literature points at at least four, and they interact. The first is the one PaLM reports: a particular batch meets a particular parameter state that is sharp enough to be thrown off by it. That cannot be fixed by cleaning the data alone, because the same data was harmless a few checkpoints earlier.

The second lives in the optimiser. Adam and AdamW scale every step by a running estimate of the squared gradient. That estimate is an average with a long memory, so when gradients suddenly grow, the denominator lags behind the numerator and the step comes out too large. Molybog and colleagues analyse this as a source of instability in large-scale training. The common practical response is to give the estimate a shorter memory, which is why large-model recipes typically set the second-moment decay β2 well below Adam's textbook default of 0.999; DeepSeek-V3's AdamW configuration, for example, uses 0.95.

The third is that the model's own softmaxes saturate. Wortsman and colleagues reproduced large-model instabilities at small scale and traced two of them to logits growing without bound: the attention logits, q·k before the softmax, and the output logits feeding the final softmax. Once an attention softmax is saturated, its output is nearly one-hot and its gradient is nearly zero in some places and enormous in others. The fixes they study are normalising the queries and keys (QK-norm), which the ViT-22B team had independently adopted to stop divergence at that scale, and an auxiliary z-loss that keeps the final softmax's normaliser near one, which PaLM used.

The fourth is arithmetic. Narrow number formats overflow, round away small gradients and magnify the other three; Volume VIII is the long form of that argument.

The suspects, and the standard remedy for each
SuspectMechanismStandard remedyReported in
Batch meets sharp stateA specific batch destabilises specific parametersRewind about 100 steps; skip a few hundred batchesPaLM
Stale second momentAdam's squared-gradient average lags a sudden gradient increase; the step is oversizedShorter memory (lower β2)Molybog et al.
Attention-logit growthq·k grows until the softmax saturatesQK-norm; later, QK-clip (§ 19.5)Wortsman et al.; ViT-22B; Kimi K2
Output-logit driftThe final softmax's normaliser wandersAuxiliary z-lossPaLM; Wortsman et al.
Embedding gradient shockLarge early gradients land on the embedding layerScale down the embedding's gradientGLM-130B
Numerical overflowLow-precision formats cannot hold the dynamic rangeFormat choice and scalingVolume VIII

What AdamW does to a matrix

Every remedy in that table treats a symptom of an update rule that does not know what it is updating. AdamW, the decoupled-weight-decay form of Adam, updates each weight from its own gradient history, divided by its own running scale. Nothing in that formula knows that a weight belongs to a matrix, and that a matrix is a linear map that stretches some input directions more than others.

Keller Jordan, who developed the optimiser this lecture is named for, makes an observation about what that produces. The momentum matrices that SGD and Adam build for a transformer's weight matrices tend to be dominated by a small number of directions: a few large singular values, and a long tail of tiny ones. In effect a handful of directions receive nearly all of every update, while the directions that carry rarer features are barely moved. Jordan presents this as a motivating observation, not a theorem, and the evidence for it is that the optimiser built on it trains faster in his benchmarks.

Muon: keep the direction, flatten the spectrum

Muon — MomentUm Orthogonalized by Newton–Schulz — takes the momentum matrix for a weight matrix and replaces it with the nearest matrix whose singular values are all one. Write the momentum as M = UΣVT. Muon's update direction is UVT: the same pair of singular-vector bases, with the spectrum flattened. The directions that were already large stop dominating, and the ones that were tiny receive a full-sized push.

MOMENTUM · SINGULAR VALUES AFTER ORTHOGONALISING 1 Newton–Schulz 5 steps, no SVD σ₁ … σ₈, largest to smallest σ₁ … σ₈, pushed toward 1 a few directions dominate every direction gets a say
Figure 19b Schematic, drawn to show the idea rather than any measured matrix. The orthogonalised bars wobble around one instead of landing on it exactly; § 19.4 explains why that approximation is deliberate.

Computing UVT with a singular value decomposition at every step, for every matrix, would be far too slow. Muon avoids the decomposition with a Newton–Schulz iteration: a short sequence of matrix multiplications that drives all singular values toward one while leaving the singular vectors alone. Matrix multiplications are exactly what accelerators are built for, and Jordan runs the iteration in bfloat16.

The Muon update for one hidden weight matrix W Bt = μ · Bt−1 + Gt   (momentum of the gradient G)
X0 = Bt / ‖Bt‖F
Xk+1 = a·Xk + b·(XkXkT)Xk + c·(XkXkT)²Xk   (a, b, c) = (3.4445, −4.7750, 2.0315), five steps
W ← W − η · X5

Why a polynomial in the matrix acts on its singular values

If X = UΣVT, then XXTX = UΣ³VT. Any odd polynomial in X therefore applies the same scalar polynomial to each singular value and leaves U and V untouched. The classical cubic, σ ← 1.5σ − 0.5σ3, has a fixed point at one and converges for any starting value in (0, √3), which is why the first step divides by the Frobenius norm: it guarantees the largest singular value is at most one.

Jordan's quintic uses the coefficients above instead, chosen so the curve is steep near zero: a singular value starting near zero is multiplied by about 3.44 at the first step, so tiny directions are lifted quickly within the five-step budget. The price is that the outputs do not converge to exactly one. Jordan reports that they land in a band around it, and that this looser approximation does not hurt the trained model.

Three practical details matter for what comes next. First, Muon is for the two-dimensional hidden weight matrices only. Embeddings, the output head, biases and gain vectors stay on AdamW. Second, the iteration needs each matrix whole, which makes sharded training harder than it is for an elementwise optimiser, so Muon at scale needs a purpose-built distributed implementation. Third, the framing: Bernstein and Newhouse frame this update as steepest descent under the spectral norm, so each step has a bounded, predictable effect on what the layer does to its input, whatever the skew of the gradient. That is the principled case for Muon's stability. It is a case, not a measurement, and the rest of the lecture is about what happened when it met a real trillion-parameter run.

One more piece makes Muon usable as a drop-in for AdamW. A raw Muon step is not on the same scale as the AdamW step a team has already tuned. An orthogonal A×B matrix has Frobenius norm √min(A,B), so its per-entry root-mean-square is 1/√max(A,B): large matrices get small entries and differently shaped matrices get differently sized steps. Moonshot AI's Muon is Scalable for LLM Training paper, which trained the Moonlight models, fixes this with two changes. It adds decoupled weight decay, which plain Muon lacked, and it rescales each update by 0.2·√max(A,B) so that its per-entry magnitude matches the roughly 0.2–0.4 that AdamW produces in practice. With that match the AdamW learning rate and decay can be reused unchanged. Moonshot reports roughly twice the compute efficiency of AdamW under its setup; treat that as a lab-reported result under that lab's conditions.

Matching AdamW's step size (Moonshot's rescaling) W ← (1 − η·λ)·W − η · 0.2·√max(A, B) · X5

The new way to blow up

Kimi K2's technical report describes what happened when this optimiser was scaled up. In a mid-sized mixture-of-experts run with plain Muon, Moonshot reports that the maximum attention logit grew rapidly, to magnitudes on the order of a thousand, and that the run became unstable. This is a suspect from § 19.2 appearing in a new place. The reason it matters here is geometric: a pre-softmax logit is q·k = (Wqx)·(Wky), a product of two weight matrices, so it grows with both. Moonshot reports that Muon is more exposed to this than AdamW. One plausible reading, which is this lecture's gloss rather than a result from the report, is that Muon gives every singular direction of each matrix a full-sized step, so a product of two such matrices has more ways to grow than under an update dominated by a few directions. Treat the mechanism as a hypothesis; the logit growth itself is what the lab observed.

The standard remedies do not all fit. QK-norm needs the full query and key vectors at the moment of attention. The report states that this is unavailable under multi-head latent attention (Lecture 4), because the keys are never fully materialised at inference. So Moonshot reached for something that works on the weights, not the forward pass.

QK-clip, per head h, applied after each optimiser step Smaxh = largest pre-softmax attention logit in head h over the batch
γh = min(1, τ / Smaxh)
Wqh ← √γh · Wqh,   Wkh ← √γh · Wkh
logit ∝ Wq·Wk — the rescaled head's largest logit is γ·Smax = τ
LARGEST ATTENTION LOGIT IN A HEAD STEPS → τ unclipped: keeps growing QK-clip: held at τ SCHEMATIC · NOT KIMI DATA
Figure 19c The clip is a cap on the quantity that blew up, not a change to what attention computes. Below τ it does nothing at all.

Three properties make this cheap. It is per head: only a head whose largest logit exceeds τ is rescaled, so heads behaving normally are untouched. It is conditional: when γ is one, the step costs a comparison. And it acts on the weights after the update, so the forward and backward passes are unchanged. The report gives τ = 100 for K2 and describes, for latent attention, rescaling only the head-specific query and key components while leaving the shared rotary key alone. It also reports that the clip fired early in training and then stopped firing on its own as the logits fell back below the threshold. If that holds, QK-clip behaved less like a permanent constraint and more like a scaffold that was needed only at the start.

Muon with weight decay, Moonshot's update-scale matching, and QK-clip together are what the report names MuonClip.

ONE MUONCLIP STEP forward + backward Muon update momentum → NS read S_max max logit per head QK-clip if S_max > τ next step, with the clipped weights the next step starts from weights that are already capped
Figure 19d The clip is the last stage of the step, after the optimiser has already done its work. Everything upstream of it is Muon as in § 19.4.

Fifteen and a half trillion tokens

Kimi K2 is a mixture-of-experts model with one trillion total parameters and 32 billion active per token (Volume VII), pretrained on 15.5 trillion tokens with MuonClip. The report states that this ran without a single loss spike, and shows a smooth training-loss curve in support self-reported. This is the claim the contents page refers to, and it belongs to Moonshot AI. This course has no independent re-run to cite against it.

How much it proves is worth stating carefully, because the headline invites a stronger reading than the evidence supports.

It is a single run. The report supports the contribution of QK-clip with smaller-scale experiments, where logit growth and instability were observed without it. At full scale the report shows one trajectory with the clip on and, as far as it shows, no matching trajectory with it off; running that counterfactual would mean paying for a second trillion-parameter run.

"No spike" also depends on a definition and a plot. A spike on a smoothed, downsampled loss curve is not the same event as one in a raw per-step log, and a published figure is not a raw log.

Nor is Muon necessary for a quiet run. DeepSeek-V3's report states that its 14.8-trillion-token pretraining, under plain AdamW, had no irrecoverable loss spikes and needed no rollbacks. That is a different claim from "no spike at all", and it shows that a stable run at this scale is reachable with the older optimiser. What Muon is claimed to change is the efficiency of the run that stays stable, not the possibility of one.

What to carry away

Muon changes what the optimiser does to a matrix: it flattens the update's spectrum so no direction is starved and none dominates. QK-clip is a second, separate device that caps one specific quantity — the attention logit — when the first change makes that quantity grow. Together they let one lab report an unbroken 15.5-trillion-token run. Read it as a well-documented claim from the lab that did it, and hold the causal story to the standard the underlying experiments can bear.

Other laboratories have also reported moving to Muon-family optimisers, GLM-4.5's report among them verify in report. If the field is converging on this, the 2026 flagship in Lecture 24 will have an optimiser sentence in its recipe that Volume IX's readers can now parse.

Three optimisers, one weight matrix
AdamWMuonMuonClip
Sees a matrix asIndependent scalars, each rescaled by its own historyOne linear map; update has all singular values near 1As Muon
State per parameterTwo running averagesOne momentum bufferOne momentum buffer, plus a per-head max-logit reading
Applies toEvery parameter2-D hidden matrices; embeddings, head, gains stay on AdamWAs Muon, with the clip on query and key projections
Extra work per stepNoneFive Newton–Schulz iterations per matrixThose, plus a max-logit reduction and a conditional rescale
Failure it is exposed toStale second momentAttention-logit growth, per Kimi's reportThe clip caps that growth per head
EvidenceDecades of practiceJordan's benchmarks; Moonshot's reported ~2× efficiencyKimi K2's 15.5T-token run (self-reported)

A stable optimiser makes a run survivable. The next lecture is about what to ask of the model while it trains, and about how that same extra ask, kept at inference, turns into speed.

Read the primary source

❦