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 (mt,ij,vt,ij)(m_{t,ij}, v_{t,ij}) independently for each entry WijW_{ij} of a weight matrix W\mathbf{W}: if the entries of W\mathbf{W} were arbitrarily permuted, AdamW would take the exact same steps.

Yet more than 80%80\% of the parameters in a Transformer reside in two-dimensional hidden projection matrices W∈Rm×n\mathbf{W} \in \mathbb{R}^{m \times n} that act as linear operators mapping layer activations x∈Rn\mathbf{x} \in \mathbb{R}^n to y=Wx∈Rm\mathbf{y} = \mathbf{W}\mathbf{x} \in \mathbb{R}^m. 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 (ℓ2\ell_2) norm yields the raw gradient direction of SGD; measuring it in the coordinate-wise ℓ∞\ell_\infty box norm yields sign descent, the memoryless limit of Adam. If instead we bound the maximum change that an update ΔW\Delta\mathbf{W} can induce in the layer output ∥ΔWx∥2/∥x∥2\|\Delta\mathbf{W}\mathbf{x}\|_2 / \|\mathbf{x}\|_2, namely the spectral norm ∥ΔW∥2\|\Delta\mathbf{W}\|_2, the direction of steepest descent replaces every nonzero singular value of the gradient matrix with 11, yielding the orthogonalized gradient UV⊤\mathbf{U}\mathbf{V}^\top.

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 UV⊤\mathbf{U}\mathbf{V}^\top 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, ℓ∞\ell_\infty, 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 random

9.6.1 Norms and Steepest Descent#

9.6.1.1 Steepest Descent in a Norm Ball#

Given the first-order Taylor expansion f(x+d)≈f(x)+⟨g,d⟩f(\mathbf{x} + \mathbf{d}) \approx f(\mathbf{x}) + \langle \mathbf{g}, \mathbf{d} \rangle with gradient g=∇f(x)\mathbf{g} = \nabla f(\mathbf{x}), the steepest descent step of radius η>0\eta > 0 under a norm ∥⋅∥\|\cdot\| solves

d⋆=argmin⁡∥d∥≤η  ⟨g,d⟩.(9.6.1)\mathbf{d}^\star = \operatorname*{argmin}_{\|\mathbf{d}\| \leq \eta} \; \langle \mathbf{g}, \mathbf{d} \rangle. \tag{9.6.1}

Different norm geometries yield fundamentally different update directions (Bernstein and Newhouse, 2024) (Figure 9.6.1 and Table 9.6.1):

  1. Euclidean ball (∥d∥2≤η\|\mathbf{d}\|_2 \le \eta): By Cauchy–Schwarz, the minimizer aligns with the negative gradient, d⋆=−η g/∥g∥2\mathbf{d}^\star = -\eta\,\mathbf{g}/\|\mathbf{g}\|_2, decreasing the linearized objective by η∥g∥2\eta\|\mathbf{g}\|_2 (the direction of SGD).
  2. Coordinate box (∥d∥∞=max⁡i∣di∣≤η\|\mathbf{d}\|_\infty = \max_i |d_i| \le \eta): Minimizing ∑igidi\sum_i g_i d_i subject to ∣di∣≤η|d_i| \le \eta pushes every coordinate to its boundary, d⋆=−η sign⁡(g)\mathbf{d}^\star = -\eta\,\operatorname{sign}(\mathbf{g}), decreasing the linearized objective by the dual ℓ1\ell_1 norm η∥g∥1\eta\|\mathbf{g}\|_1. This is sign descent, the zero-memory (β1=β2=0\beta_1 = \beta_2 = 0) limit of Adam (Section 9.5).

9.6.1.2 Matrices and the Spectral Norm#

For a hidden weight matrix W∈Rm×n\mathbf{W} \in \mathbb{R}^{m \times n} mapping x↦Wx\mathbf{x} \mapsto \mathbf{W}\mathbf{x}, a perturbation ΔW\Delta\mathbf{W} shifts the output by ∥ΔWx∥2≤∥ΔW∥2∥x∥2\|\Delta\mathbf{W}\mathbf{x}\|_2 \le \|\Delta\mathbf{W}\|_2 \|\mathbf{x}\|_2, where ∥ΔW∥2=σ1(ΔW)\|\Delta\mathbf{W}\|_2 = \sigma_1(\Delta\mathbf{W}) is the spectral norm (operator norm, Section 1.3.5). Let the gradient matrix G∈Rm×n\mathbf{G} \in \mathbb{R}^{m \times n} have reduced Singular Value Decomposition (Section 21.5)

G=UΣV⊤=∑i=1rσi uivi⊤,\mathbf{G} = \mathbf{U} \boldsymbol{\Sigma} \mathbf{V}^\top = \sum_{i=1}^r \sigma_i\, \mathbf{u}_i \mathbf{v}_i^\top,

where U∈Rm×r\mathbf{U} \in \mathbb{R}^{m \times r} and V∈Rn×r\mathbf{V} \in \mathbb{R}^{n \times r} have orthonormal columns and σ1≥⋯≥σr>0\sigma_1 \ge \cdots \ge \sigma_r > 0. Notice that the Frobenius norm ∥G∥F=∑iσi2\|\mathbf{G}\|_F = \sqrt{\sum_i \sigma_i^2} (the Euclidean norm of the flattened matrix) can exceed the spectral norm σ1\sigma_1 by up to min⁡(m,n)\sqrt{\min(m, n)} when singular values are comparable.

Solving (9.6.1) under the spectral norm constraint ∥ΔW∥2≤η\|\Delta\mathbf{W}\|_2 \le \eta yields the orthogonalized gradient:

ΔW⋆=argmin⁡∥ΔW∥2≤η  ⟨G,ΔW⟩=−η UV⊤,(9.6.2)\Delta \mathbf{W}^\star = \operatorname*{argmin}_{\|\Delta \mathbf{W}\|_2 \leq \eta} \; \langle \mathbf{G}, \Delta \mathbf{W} \rangle = -\eta\, \mathbf{U} \mathbf{V}^\top, \tag{9.6.2}

which sets every nonzero singular value of G\mathbf{G} to 11. The proof is immediate: for any A\mathbf{A} with ∥A∥2≤1\|\mathbf{A}\|_2 \le 1, cyclic trace invariance gives

⟨G,A⟩=tr⁡(G⊤A)=tr⁡(Σ U⊤AV)=∑i=1rσi (U⊤AV)ii≤∑i=1rσi,\langle \mathbf{G}, \mathbf{A} \rangle = \operatorname{tr}(\mathbf{G}^\top \mathbf{A}) = \operatorname{tr}(\boldsymbol{\Sigma}\, \mathbf{U}^\top \mathbf{A} \mathbf{V}) = \sum_{i=1}^r \sigma_i\, (\mathbf{U}^\top \mathbf{A} \mathbf{V})_{ii} \leq \sum_{i=1}^r \sigma_i,

since ∥(U⊤AV)∥2≤∥A∥2≤1\|(\mathbf{U}^\top \mathbf{A} \mathbf{V})\|_2 \le \|\mathbf{A}\|_2 \le 1 implies ∣(U⊤AV)ii∣≤1|(\mathbf{U}^\top \mathbf{A} \mathbf{V})_{ii}| \le 1 (Exercise 1). Setting A=−UV⊤\mathbf{A} = -\mathbf{U}\mathbf{V}^\top makes U⊤AV=−Ir\mathbf{U}^\top\mathbf{A}\mathbf{V} = -\mathbf{I}_r, achieving the minimum −η∑iσi=−η∥G∥∗-\eta\sum_i \sigma_i = -\eta\|\mathbf{G}\|_* (the dual nuclear norm).

Figure 9.6.1:

Steepest descent directions under three norm balls: Euclidean ℓ2\ell_2 (gradient direction), coordinate ℓ∞\ell_\infty box (sign descent), and spectral norm ∥⋅∥2\|\cdot\|_2 (orthogonalized gradient UV⊤\mathbf{U}\mathbf{V}^{\top}, where every active singular value equals 11).

Whereas Adam equalizes update magnitudes across individual matrix entries (which can still collapse onto a rank-11 direction, as sign⁡ ⁣[3111]=[1111]\operatorname{sign}\!\begin{bmatrix}3 & 1\\ 1 & 1\end{bmatrix} = \begin{bmatrix}1 & 1\\ 1 & 1\end{bmatrix} has singular values 22 and 00), spectral steepest descent −ηUV⊤-\eta\mathbf{U}\mathbf{V}^\top moves with equal step size η\eta along every active singular direction (ui,vi)(\mathbf{u}_i, \mathbf{v}_i) 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.

Figure 9.6.2:

Singular values of a gradient matrix G=UΣV⊤\mathbf{G} = \mathbf{U}\boldsymbol{\Sigma}\mathbf{V}^\top relative to the largest, σi/σ1\sigma_i/\sigma_1 (left), and of its orthogonalization UV⊤\mathbf{U}\mathbf{V}^\top (right). Orthogonalization keeps the singular vectors and sets every nonzero singular value to 11, so the update moves by η\eta along each of them.

Table 9.6.1. Steepest descent under three norm geometries.
Norm ball on updateSteepest directionLinearized decrease (dual norm)Suited parameter group
Euclidean (∥d∥2≤η\|\mathbf{d}\|_2 \leq \eta)−η g/∥g∥2-\eta\, \mathbf{g} / \|\mathbf{g}\|_2η ∥g∥2\eta\, \|\mathbf{g}\|_2Unstructured vector (SGD)
Coordinate box (∥d∥∞≤η\|\mathbf{d}\|_\infty \leq \eta)−η sign(g)-\eta\, \mathrm{sign}(\mathbf{g})η ∥g∥1\eta\, \|\mathbf{g}\|_1Heterogeneous coordinates / embeddings (AdamW)
Spectral (∥ΔW∥2≤η\|\Delta \mathbf{W}\|_2 \leq \eta)−η UV⊤-\eta\, \mathbf{U}\mathbf{V}^\topη∥G∥∗=η∑iσi\eta \|\mathbf{G}\|_* = \eta \sum_i \sigma_iDense 2D hidden weight matrices (Muon)

9.6.1.3 Connection to Matrix Preconditioners (Shampoo) and Parameter Partitioning#

The orthogonalized gradient UV⊤\mathbf{U}\mathbf{V}^\top also arises as the zero-memory limit of Kronecker-factored matrix preconditioning. Shampoo (Gupta et al., 2018) accumulates left and right Gram matrices Lt=∑s≤tGsGs⊤\mathbf{L}_t = \sum_{s \le t} \mathbf{G}_s \mathbf{G}_s^\top and Rt=∑s≤tGs⊤Gs\mathbf{R}_t = \sum_{s \le t} \mathbf{G}_s^\top \mathbf{G}_s and preconditions the gradient via Lt−1/4GtRt−1/4\mathbf{L}_t^{-1/4}\mathbf{G}_t\mathbf{R}_t^{-1/4}. Evaluated on a single gradient G=UΣV⊤\mathbf{G} = \mathbf{U}\boldsymbol{\Sigma}\mathbf{V}^\top without historical accumulation, the singular values cancel identically:

(GG⊤)−1/4 G (G⊤G)−1/4=UΣ−1/2U⊤⋅UΣV⊤⋅VΣ−1/2V⊤=UV⊤.(9.6.3)(\mathbf{G}\mathbf{G}^\top)^{-1/4}\, \mathbf{G}\, (\mathbf{G}^\top\mathbf{G})^{-1/4} = \mathbf{U}\boldsymbol{\Sigma}^{-1/2}\mathbf{U}^\top \cdot \mathbf{U}\boldsymbol{\Sigma}\mathbf{V}^\top \cdot \mathbf{V}\boldsymbol{\Sigma}^{-1/2}\mathbf{V}^\top = \mathbf{U}\mathbf{V}^\top. \tag{9.6.3}

By applying orthogonalization to a standard first-moment momentum buffer rather than storing and inverting Lt\mathbf{L}_t and Rt\mathbf{R}_t, 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 UV⊤\mathbf{U}\mathbf{V}^\top via an explicit SVD is prohibitively slow during training. Instead, observe that any odd matrix polynomial acts independently on the singular values of X=UΣV⊤\mathbf{X} = \mathbf{U}\boldsymbol{\Sigma}\mathbf{V}^\top while preserving its singular vectors:

p(X)=aX+b (XX⊤)X+c (XX⊤)2X=U p(Σ) V⊤,(9.6.4)p(\mathbf{X}) = a\mathbf{X} + b\,(\mathbf{X}\mathbf{X}^\top)\mathbf{X} + c\,(\mathbf{X}\mathbf{X}^\top)^2\mathbf{X} = \mathbf{U}\, p(\boldsymbol{\Sigma})\, \mathbf{V}^\top, \tag{9.6.4}

since XX⊤=UΣ2U⊤\mathbf{X}\mathbf{X}^\top = \mathbf{U}\boldsymbol{\Sigma}^2\mathbf{U}^\top. Normalizing X←X/∥X∥F\mathbf{X} \leftarrow \mathbf{X} / \|\mathbf{X}\|_F first ensures that all singular values lie in [0,1][0, 1]. Iterating an odd scalar polynomial p(x)p(x) that maps (0,1](0, 1] toward 11 (Newton–Schulz iteration, Section 21.5.4.2) therefore orthogonalizes X\mathbf{X} using only fast matrix multiplications.

Rather than the classical cubic p(x)=32x−12x3p(x) = \frac{3}{2}x - \frac{1}{2}x^3 (whose small slope p′(0)=1.5p'(0) = 1.5 lifts small singular values too slowly over 55 steps), Jordan et al. (2024) use a tuned quintic polynomial with a steep initial slope p′(0)=3.4445p'(0) = 3.4445:

p(x)=3.4445 x−4.7750 x3+2.0315 x5.(9.6.5)p(x) = 3.4445\,x - 4.7750\,x^3 + 2.0315\,x^5. \tag{9.6.5}

As shown in Figure 9.6.3, five compositions of (9.6.5) lift every singular value in [0.01,1][0.01, 1] into the narrow band [0.68,1.13][0.68, 1.13] (and every singular value above 0.00150.0015 to at least 0.680.68), trading exact asymptotic convergence to 11 for rapid 55-step inflation of small singular directions.

Figure 9.6.3:

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 [10−3,1][10^{-3}, 1] (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 X

For an m×nm \times n matrix (m≤nm \le n) and token batch size BB, five Newton–Schulz iterations cost 5(4m2n+2m3)5(4m^2n + 2m^3) FLOPs compared to 6mnB6mnB FLOPs for the forward and backward passes—an overhead of ∼5m/B\sim 5m/B (<1%\lt 1\% at production batch sizes B∼5×105B \sim 5 \times 10^5, and ∼12%\sim 12\% on TinyLM at B=4,096B = 4{,}096). Applying newton_schulz to a 96×6496 \times 64 Gaussian matrix illustrates how the iterations collapse the singular value spectrum: into [0.68,1.20][0.68, 1.20] after k=3k = 3 and [0.68,1.13][0.68, 1.13] after k=5k = 5:

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 Gt+βMt\mathbf{G}_t + \beta\mathbf{M}_t (averaged over ∼1/(1−β)=20\sim 1/(1-\beta) = 20 steps at β=0.95\beta = 0.95) rather than a noisy single-batch gradient; second, any singular value below 0.15%0.15\% of the Frobenius norm (where 3.44455≈4853.4445^5 \approx 485 is insufficient to reach 0.680.68) is amplified linearly rather than pushed all the way to 11, 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 m×nm \times n hidden weight matrix W\mathbf{W} with gradient Gt\mathbf{G}_t, Muon updates the momentum buffer Mt\mathbf{M}_t (β=0.95\beta = 0.95) and applies five Newton–Schulz iterations NS5\mathrm{NS}_5 to the Nesterov look-ahead gradient Gt+βMt\mathbf{G}_t + \beta\mathbf{M}_t, combined with decoupled weight decay (Liu et al., 2025):

Mt=β Mt−1+Gt,Wt+1=(1−ηλ) Wt−η⋅0.2max⁡(m,n)  NS5(Gt+β Mt).(9.6.6)\begin{aligned} \mathbf{M}_t &= \beta\, \mathbf{M}_{t-1} + \mathbf{G}_t, \\ \mathbf{W}_{t+1} &= (1 - \eta\lambda)\, \mathbf{W}_t - \eta \cdot 0.2 \sqrt{\max(m, n)}\; \mathrm{NS}_5(\mathbf{G}_t + \beta\, \mathbf{M}_t). \end{aligned} \tag{9.6.6}

Why multiply by 0.2max⁡(m,n)0.2\sqrt{\max(m, n)}? An orthogonal m×nm \times n matrix UV⊤\mathbf{U}\mathbf{V}^\top has min⁡(m,n)\min(m, n) unit singular values, Frobenius norm min⁡(m,n)\sqrt{\min(m, n)}, and entrywise RMS min⁡(m,n)/(mn)=1/max⁡(m,n)\sqrt{\min(m, n)/(mn)} = 1/\sqrt{\max(m, n)}. Multiplying by 0.2max⁡(m,n)0.2\sqrt{\max(m, n)} gives the update an entrywise RMS of 0.2 η0.2\,\eta regardless of matrix dimensions—matching the empirical ∼0.2 η\sim 0.2\,\eta entrywise RMS step of AdamW measured in Section 9.5 so that both optimizers can share the same learning rate η\eta and weight decay λ\lambda (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 0.2max⁡(m,n)0.2\sqrt{\max(m, n)} of (9.6.6)? To find out, we take a single step from zero weights on a 96×6496 \times 64 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 0.18 η0.18\,\eta. This is a little below the nominal 0.2 η0.2\,\eta because five Newton–Schulz iterations leave the singular values spread between 0.680.68 and 1.131.13, not at 11. 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 0.2max⁡(m,n)0.2\sqrt{\max(m, n)}; the default, 'original', multiplies by max⁡(1,m/n)\sqrt{\max(1, m/n)} instead, and the default weight decay is 0.10.1. 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 88 internal block matrices (qkv, proj, mlp1, mlp2 across 22 blocks) to Muon and the remaining 2222 tensors (embeddings, LayerNorm vectors, biases, and output head) to AdamW assigns 393,216393{,}216 of the 470,784470{,}784 parameters (84%84\%) 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 42%42\%.

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 η∈{10−3,3×10−3,10−2,3×10−2,10−1}\eta \in \{10^{-3}, 3 \times 10^{-3}, 10^{-2}, 3 \times 10^{-2}, 10^{-1}\} with λ=0.1\lambda = 0.1 on the hidden matrices for 2,0002{,}000 steps from shared initial weights, evaluating validation loss every 250250 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 1.61.6 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 >0.1>0.1-nat validation lead at step 500500, crosses the 1.61.6-nat threshold at least one checkpoint (250250 steps) earlier than AdamW, and expands the usable learning-rate window up to η=3×10−2\eta = 3 \times 10^{-2} (where AdamW finishes well above 22 nats because rank-11 early gradients under entrywise normalization can have spectral norm min⁡(m,n)\sqrt{\min(m, n)} 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 1.4×1.4\times at 0.1B0.1\text{B} parameters to about 1.1×1.1\times at 1.2B1.2\text{B}. 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 ℓ2\ell_2 ball yields SGD, the coordinate ℓ∞\ell_\infty box yields sign descent (smoothed by Adam), and the spectral norm ball ∥ΔW∥2≤η\|\Delta\mathbf{W}\|_2 \le \eta yields the orthogonalized gradient −ηUV⊤-\eta\mathbf{U}\mathbf{V}^\top, which steps equally along every active singular direction of a matrix operator. Muon approximates UV⊤\mathbf{U}\mathbf{V}^\top 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 0.2max⁡(m,n)0.2\sqrt{\max(m, n)} 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 3×3\times higher learning rates than AdamW, and reduces optimizer-state memory by 42%42\%.

9.6.5 Exercises#

  1. Diagonal-entry bound and uniqueness of the spectral step. Let U∈Rm×r\mathbf{U} \in \mathbb{R}^{m \times r} and V∈Rn×r\mathbf{V} \in \mathbb{R}^{n \times r} have orthonormal columns. Show that ∥U⊤AV∥2≤∥A∥2\|\mathbf{U}^\top\mathbf{A}\mathbf{V}\|_2 \le \|\mathbf{A}\|_2 and ∣(U⊤AV)ii∣≤∥A∥2|(\mathbf{U}^\top\mathbf{A}\mathbf{V})_{ii}| \le \|\mathbf{A}\|_2, and determine when the minimizer ΔW⋆=−ηUV⊤\Delta\mathbf{W}^\star = -\eta\mathbf{U}\mathbf{V}^\top in (9.6.2) is unique.

  2. [code] Empirical update RMS and singular value spectrum. Instrument Muon on TinyLM to track the entrywise RMS of ΔW/η\Delta\mathbf{W} / \eta across 2,0002{,}000 steps and compare the singular value spectrum of a single minibatch gradient Gt\mathbf{G}_t against the momentum buffer Mt\mathbf{M}_t at step 00 and step 500500.

  3. [code] Newton–Schulz iteration count and polynomial degree. Compare num_iters ∈{1,3,5,10}\in \{1, 3, 5, 10\} with the tuned quintic (9.6.5) against 55 iterations of the classical cubic p(x)=1.5x−0.5x3p(x) = 1.5x - 0.5x^3 on TinyLM, reporting validation loss and wall-clock step time.

  4. [code] Why embeddings remain with AdamW.

    1. If an m×nm \times n gradient matrix M\mathbf{M} has only r≤nr \le n nonzero linearly independent rows (corresponding to rr distinct tokens in a minibatch), show that every active row of UV⊤\mathbf{U}\mathbf{V}^\top has unit ℓ2\ell_2 norm regardless of whether its token occurred once or 500500 times.
    2. Move token_emb into the Muon parameter group on TinyLM and verify empirically that validation perplexity degrades compared to keeping token_emb in the AdamW group.

Discussions