9.6 Muon
Every optimizer examined so far (SGD, Momentum, and AdamW) treats the parameters of a neural network as an unstructured flat vector. Even AdamW maintains two scalar averages independently for each entry of a weight matrix : if the entries of were arbitrarily permuted, AdamW would take the exact same steps.
Yet more than of the parameters in a Transformer reside in two-dimensional hidden projection matrices that act as linear operators mapping layer activations to . What is the direction of steepest descent for a weight matrix viewed as a linear operator?
As Bernstein and Newhouse (2024) emphasize, steepest descent is defined relative to the norm chosen to bound the update step. Measuring the step in the Euclidean () norm yields the raw gradient direction of SGD; measuring it in the coordinate-wise box norm yields sign descent, the memoryless limit of Adam. If instead we bound the maximum change that an update can induce in the layer output , namely the spectral norm , the direction of steepest descent replaces every nonzero singular value of the gradient matrix with , yielding the orthogonalized gradient .
Computing an exact Singular Value Decomposition (SVD) at every step is too slow for GPUs, but a five-step odd matrix polynomial Newton–Schulz iteration approximates using only matrix multiplications. Applied to Nesterov momentum buffers on hidden 2D weight matrices (while leaving embeddings, 1D parameters, and the output head to AdamW), this yields Muon (Momentum Orthogonalized by Newton–Schulz, Jordan et al. (2024)). In this section, we derive steepest descent across the Euclidean, , and spectral norm balls, analyze the tuned quintic Newton–Schulz iteration, implement the hybrid Muon+AdamW optimizer from scratch, and benchmark it against AdamW on TinyLM.
import random9.6.1 Norms and Steepest Descent#
9.6.1.1 Steepest Descent in a Norm Ball#
Given the first-order Taylor expansion with gradient , the steepest descent step of radius under a norm solves
Different norm geometries yield fundamentally different update directions (Bernstein and Newhouse, 2024) (Figure 9.6.1 and Table 9.6.1):
- Euclidean ball (): By Cauchy–Schwarz, the minimizer aligns with the negative gradient, , decreasing the linearized objective by (the direction of SGD).
- Coordinate box (): Minimizing subject to pushes every coordinate to its boundary, , decreasing the linearized objective by the dual norm . This is sign descent, the zero-memory () limit of Adam (Section 9.5).
9.6.1.2 Matrices and the Spectral Norm#
For a hidden weight matrix mapping , a perturbation shifts the output by , where is the spectral norm (operator norm, Section 1.3.5). Let the gradient matrix have reduced Singular Value Decomposition (Section 21.5)
where and have orthonormal columns and . Notice that the Frobenius norm (the Euclidean norm of the flattened matrix) can exceed the spectral norm by up to when singular values are comparable.
Solving (9.6.1) under the spectral norm constraint yields the orthogonalized gradient:
which sets every nonzero singular value of to . The proof is immediate: for any with , cyclic trace invariance gives
since implies (Exercise 1). Setting makes , achieving the minimum (the dual nuclear norm).
Steepest descent directions under three norm balls: Euclidean (gradient direction), coordinate box (sign descent), and spectral norm (orthogonalized gradient , where every active singular value equals ).
Whereas Adam equalizes update magnitudes across individual matrix entries (which can still collapse onto a rank- direction, as has singular values and ), spectral steepest descent moves with equal step size along every active singular direction of the gradient. Figure 9.6.2 shows what this does to the spectrum: a gradient dominated by a few directions becomes an update that weights all of them equally.
Singular values of a gradient matrix relative to the largest, (left), and of its orthogonalization (right). Orthogonalization keeps the singular vectors and sets every nonzero singular value to , so the update moves by along each of them.
| Norm ball on update | Steepest direction | Linearized decrease (dual norm) | Suited parameter group |
|---|---|---|---|
| Euclidean () | Unstructured vector (SGD) | ||
| Coordinate box () | Heterogeneous coordinates / embeddings (AdamW) | ||
| Spectral () | Dense 2D hidden weight matrices (Muon) |
9.6.1.3 Connection to Matrix Preconditioners (Shampoo) and Parameter Partitioning#
The orthogonalized gradient also arises as the zero-memory limit of Kronecker-factored matrix preconditioning. Shampoo (Gupta et al., 2018) accumulates left and right Gram matrices and and preconditions the gradient via . Evaluated on a single gradient without historical accumulation, the singular values cancel identically:
By applying orthogonalization to a standard first-moment momentum buffer rather than storing and inverting and , Muon captures full-matrix preconditioning with only a single momentum buffer per matrix (Section 23.5.5).
Because the spectral-norm geometry applies specifically to dense linear maps between activation spaces, Muon is applied only to hidden 2D weight matrices (attention qkv/proj and MLP weights). Embedding tables (which perform one-hot row lookups), 1D biases and LayerNorm scales, and the final vocabulary readout head are optimized with AdamW (Jordan et al., 2024).
9.6.2 Orthogonalization by Newton–Schulz#
Computing via an explicit SVD is prohibitively slow during training. Instead, observe that any odd matrix polynomial acts independently on the singular values of while preserving its singular vectors:
since . Normalizing first ensures that all singular values lie in . Iterating an odd scalar polynomial that maps toward (Newton–Schulz iteration, Section 21.5.4.2) therefore orthogonalizes using only fast matrix multiplications.
Rather than the classical cubic (whose small slope lifts small singular values too slowly over steps), Jordan et al. (2024) use a tuned quintic polynomial with a steep initial slope :
As shown in Figure 9.6.3, five compositions of (9.6.5) lift every singular value in into the narrow band (and every singular value above to at least ), trading exact asymptotic convergence to for rapid -step inflation of small singular directions.
Newton–Schulz polynomials acting on singular values. Left: single application of the classical cubic vs. the tuned quintic (9.6.5). Right: five composed iterations on (alongside the multi-polynomial Polar Express variant (Amsel et al., 2026)).
def newton_schulz(M, num_iters=5, a=3.4445, b=-4.7750, c=2.0315, eps=1e-7):
"""Approximate the orthogonalization U V^T of M by num_iters steps of
the odd polynomial a x + b x^3 + c x^5 (Jordan et al.'s tuned quintic)."""
tall = M.shape[0] > M.shape[1]
X = M.T if tall else M # Keep the Gram factor X @ X.T small
X = X / (X.norm() + eps)
for _ in range(num_iters):
A = X @ X.T
X = a * X + (b * A + c * A @ A) @ X
return X.T if tall else XFor an matrix () and token batch size , five Newton–Schulz iterations cost FLOPs compared to FLOPs for the forward and backward passes—an overhead of ( at production batch sizes , and on TinyLM at ). Applying newton_schulz to a Gaussian matrix illustrates how the iterations collapse the singular value spectrum: into after and after :
G = torch.randn(96, 64)
sigmas = [torch.linalg.svdvals(newton_schulz(G, num_iters=k))
for k in (0, 1, 3, 5)]
d2l.plot(torch.arange(1, 65), sigmas, 'index', 'singular value',
legend=[f'k = {k}' for k in (0, 1, 3, 5)], yscale='log')
for k, sigma in zip((3, 5), sigmas[2:]):
print(f'after {k} iterations: [{sigma.min():.2f}, {sigma.max():.2f}]')after 3 iterations: [0.68, 1.20]
after 5 iterations: [0.68, 1.13]
On real network gradients, two details work in Muon's favor: first, Muon orthogonalizes the Nesterov momentum buffer (averaged over steps at ) rather than a noisy single-batch gradient; second, any singular value below of the Frobenius norm (where is insufficient to reach ) is amplified linearly rather than pushed all the way to , naturally damping pure noise directions in the trailing spectrum.
9.6.3 Muon from Scratch#
9.6.3.1 The Update and RMS Alignment#
For an hidden weight matrix with gradient , Muon updates the momentum buffer () and applies five Newton–Schulz iterations to the Nesterov look-ahead gradient , combined with decoupled weight decay (Liu et al., 2025):
Why multiply by ? An orthogonal matrix has unit singular values, Frobenius norm , and entrywise RMS . Multiplying by gives the update an entrywise RMS of regardless of matrix dimensions—matching the empirical entrywise RMS step of AdamW measured in Section 9.5 so that both optimizers can share the same learning rate and weight decay (Liu et al., 2025).
class Muon(torch.optim.Optimizer):
"""Steepest descent under the spectral norm: orthogonalized momentum."""
def __init__(self, params, lr, momentum=0.95, weight_decay=0.0):
super().__init__(params, dict(lr=lr, momentum=momentum,
weight_decay=weight_decay))
@torch.no_grad()
def step(self):
for group in self.param_groups:
for p in group['params']:
if p.grad is None: # A parameter that received no gradient
continue
state = self.state[p]
if not state: # First step: allocate the momentum buffer
state['buf'] = torch.zeros_like(p)
buf = state['buf'].mul_(group['momentum']).add_(p.grad)
G = p.grad + group['momentum'] * buf # Nesterov momentum
M = G.reshape(len(G), -1) # Flattens conv kernels
O = newton_schulz(M).reshape(p.shape)
rms_scale = 0.2 * math.sqrt(max(M.shape)) # AdamW's RMS
p.mul_(1 - group['lr'] * group['weight_decay']) # Decoupled
p.add_(O, alpha=-group['lr'] * rms_scale)We wrote Muon ourselves to see every step of it, but the framework also ships one. How do its settings relate to the factor of (9.6.6)? To find out, we take a single step from zero weights on a Gaussian gradient, once with our implementation and once with the library's, and compare the two updates:
grad, steps = torch.randn(96, 64), []
for make in (lambda p: Muon([p], lr=0.01),
lambda p: torch.optim.Muon([p], lr=0.01,
adjust_lr_fn='match_rms_adamw')):
p = nn.Parameter(torch.zeros(96, 64))
p.grad = grad.clone()
make(p).step()
steps.append(p.detach()) # The update, since p started at zero
for name, step in zip(('ours', 'torch.optim.Muon'), steps):
rms = step.pow(2).mean().sqrt()
print(f'{name:16s} update RMS / lr = {rms / 0.01:.3f}')
gap = (steps[0] - steps[1]).norm() / steps[0].norm()
print(f'relative difference: {gap:.1e}')ours update RMS / lr = 0.176
torch.optim.Muon update RMS / lr = 0.176
relative difference: 1.3e-02
The two updates agree to within about a percent, and both have an entrywise RMS of about . This is a little below the nominal because five Newton–Schulz iterations leave the singular values spread between and , not at . The experiments below keep our own implementation.
torch.optim.Muon accepts only 2D parameters, so biases, normalization parameters, and embeddings still need a second optimizer. Its setting adjust_lr_fn='match_rms_adamw' is the factor ; the default, 'original', multiplies by instead, and the default weight decay is . The library runs Newton–Schulz in bfloat16, which accounts for the difference of about a percent between the two updates.
9.6.3.2 Parameter Groups and Hybrid Optimizer#
On TinyLM, routing the internal block matrices (qkv, proj, mlp1, mlp2 across blocks) to Muon and the remaining tensors (embeddings, LayerNorm vectors, biases, and output head) to AdamW assigns of the parameters () to Muon. Because Muon stores only one momentum buffer per parameter instead of AdamW's two moments, the hybrid optimizer reduces total optimizer-state memory by .
data = d2l.WikiText103(batch_size=64, num_steps=64)
def split_lm(model):
hidden, rest = [], []
for name, p in model.named_parameters():
is_hidden = p.ndim == 2 and 'emb' not in name and 'head' not in name
(hidden if is_hidden else rest).append(p)
return hidden, rest
hidden, rest = split_lm(d2l.TinyLM(len(data.vocab)))
print(f'Muon: {len(hidden):>2} tensors, '
f'{sum(p.numel() for p in hidden):>7} parameters')
print(f'AdamW: {len(rest):>2} tensors, '
f'{sum(p.numel() for p in rest):>7} parameters')Muon: 8 tensors, 393216 parameters
AdamW: 22 tensors, 77568 parameters
We then combine Muon (with decoupled weight decay on the hidden 2D matrices) and AdamW (without weight decay on the remaining parameters) into a single hybrid optimizer via muon_adamw:
class MultiOptimizer:
"""Apply independent optimizers to disjoint parameter groups."""
def __init__(self, *optimizers):
self.optimizers = optimizers
def step(self):
for opt in self.optimizers:
opt.step()
def zero_grad(self):
for opt in self.optimizers:
opt.zero_grad()
def muon_adamw(hidden, rest, lr, weight_decay):
"""Muon with decoupled weight decay on hidden, AdamW without it on rest."""
return MultiOptimizer(Muon(hidden, lr, weight_decay=weight_decay),
torch.optim.AdamW(rest, lr, weight_decay=0.0))9.6.3.3 Comparison with AdamW#
We benchmark the Muon+AdamW hybrid against standard AdamW across with on the hidden matrices for steps from shared initial weights, evaluating validation loss every steps. First we run the adamw baseline sweep via run_lm:
def val_loss(model):
"""Mean cross-entropy per byte over the validation split."""
return math.log(d2l.lm_perplexity(model, data.val_dataloader()))
def run_lm(make_optimizer, lrs, seed):
"""d2l.lr_sweep of TinyLM, validated every 250 steps."""
return d2l.lr_sweep(lambda: d2l.TinyLM(len(data.vocab)), make_optimizer,
data, lrs, seed, evaluate=val_loss,
metric='validation loss', every=250)
lrs, wd = [1e-3, 3e-3, 1e-2, 3e-2, 1e-1], 0.1
def adamw(model, lr): # Decay on the hidden matrices only, as for Muon
hidden, rest = split_lm(model)
return torch.optim.AdamW([{'params': hidden, 'weight_decay': wd},
{'params': rest, 'weight_decay': 0.0}], lr=lr)
seed = random.getrandbits(32) # One draw, shared by every run below
adamw_lm, adamw_val = run_lm(adamw, lrs, seed)lr 0.001: final loss 1.685, validation loss 1.660
lr 0.003: final loss 1.610, validation loss 1.584
lr 0.01: final loss 1.667, validation loss 1.646
lr 0.03: final loss 2.745, validation loss 2.735
lr 0.1: final loss 2.967, validation loss 2.974
Next we sweep the muon_adamw hybrid across the exact same learning-rate grid lrs and initial seed:
muon_lm, muon_val = run_lm(
lambda model, lr: muon_adamw(*split_lm(model), lr, wd), lrs, seed)lr 0.001: final loss 1.624, validation loss 1.598
lr 0.003: final loss 1.573, validation loss 1.548
lr 0.01: final loss 1.602, validation loss 1.578
lr 0.03: final loss 1.693, validation loss 1.673
lr 0.1: final loss 2.063, validation loss 2.010
Comparing each optimizer at its best validation learning rate (best_adamw and best_muon), we plot the smoothed training and validation curves and tabulate the step at which validation loss drops below nats alongside the usable learning-rate window:
best_adamw = min(adamw_val, key=lambda lr: adamw_val[lr][-1])
best_muon = min(muon_val, key=lambda lr: muon_val[lr][-1])
d2l.plot([list(range(0, 2000, 25))] * 2 + [list(range(250, 2001, 250))] * 2,
[d2l.smooth(adamw_lm[best_adamw]), d2l.smooth(muon_lm[best_muon]),
adamw_val[best_adamw], muon_val[best_muon]], 'step', 'loss',
legend=['AdamW, training', 'Muon + AdamW, training',
'AdamW, validation', 'Muon + AdamW, validation'],
fmts=('C0-', 'C1-', 'C0o--', 'C1o--'), ylim=(1.4, 2.6),
figsize=(5, 3.5))
print('validation loss lr step 500 step 2000 below 1.6 within 0.15')
for name, lr, vals in [('AdamW', best_adamw, adamw_val),
('Muon+AdamW', best_muon, muon_val)]:
below = d2l.steps_to_reach(vals[lr], 1.6, k=1) # Checkpoint 1, 2, ...
near = [r for r in lrs if vals[r][-1] < vals[lr][-1] + 0.15]
print(f'{name:<16} {lr:<6g} {vals[lr][1]:<9.3f} {vals[lr][-1]:<10.3f} '
f'{250 * below if below else "never":<10} '
f'{near[0]:g} to {near[-1]:g}')validation loss lr step 500 step 2000 below 1.6 within 0.15
AdamW 0.003 1.884 1.584 1750 0.001 to 0.01
Muon+AdamW 0.003 1.762 1.548 1500 0.001 to 0.03
On TinyLM, Muon+AdamW establishes a -nat validation lead at step , crosses the -nat threshold at least one checkpoint ( steps) earlier than AdamW, and expands the usable learning-rate window up to (where AdamW finishes well above nats because rank- early gradients under entrywise normalization can have spectral norm times larger than an orthogonalized update).
At larger scale the advantage is smaller and less well documented. With full learning-rate decay, Wen et al. (2025) measure step reductions over heavily tuned AdamW that shrink as the model grows, from about at parameters to about at . Liu et al. (2025) report roughly twice the compute efficiency of AdamW in their own scaling experiments. The trillion-parameter Kimi K2 was trained with Muon and attention-logit clipping (Team, 2025), but no AdamW run exists at that size to compare it with. The saving in optimizer state, nearly half, does not depend on scale.
9.6.4 Summary#
Steepest descent is defined relative to the norm ball bounding the update: the Euclidean ball yields SGD, the coordinate box yields sign descent (smoothed by Adam), and the spectral norm ball yields the orthogonalized gradient , which steps equally along every active singular direction of a matrix operator. Muon approximates on the Nesterov momentum buffer of each hidden 2D weight matrix via five iterations of a tuned quintic Newton–Schulz polynomial (9.6.5), scales the update by to match AdamW's entrywise RMS step size, and applies decoupled weight decay while leaving embeddings, 1D vectors, and the readout head to AdamW. On TinyLM, this Muon+AdamW hybrid accelerates early convergence, remains stable at higher learning rates than AdamW, and reduces optimizer-state memory by .
9.6.5 Exercises#
-
Diagonal-entry bound and uniqueness of the spectral step. Let and have orthonormal columns. Show that and , and determine when the minimizer in (9.6.2) is unique.
-
[code] Empirical update RMS and singular value spectrum. Instrument
MuononTinyLMto track the entrywise RMS of across steps and compare the singular value spectrum of a single minibatch gradient against the momentum buffer at step and step . -
[code] Newton–Schulz iteration count and polynomial degree. Compare
num_iterswith the tuned quintic (9.6.5) against iterations of the classical cubic onTinyLM, reporting validation loss and wall-clock step time. -
[code] Why embeddings remain with AdamW.
- If an gradient matrix has only nonzero linearly independent rows (corresponding to distinct tokens in a minibatch), show that every active row of has unit norm regardless of whether its token occurred once or times.
- Move
token_embinto the Muon parameter group onTinyLMand verify empirically that validation perplexity degrades compared to keepingtoken_embin the AdamW group.