Back to posts

Dounan Du /

Understanding the Muon Optimizer

How the geometry of a weight update leads from gradient descent to Muon.

I've been curious about the Muon optimizer for a while, and today I finally made time to read about it. This blog post documents what I learned.

Revisiting the intuition of gradient descent (with geometry in mind!)

Before diving into Muon, I found it helpful to revisit the intuition of gradient descent. Imagine you find yourself in a landscape with hills and valleys, and you want to reach a low point in a valley. How should you choose a path to get there (there is more than one!)? Gradient descent tells you to step in the direction of the fastest local drop in altitude per unit of step length. There is an interesting detail hidden in that sentence: the direction of the fastest drop with respect to step length actually depends on the geometry you use to measure your step length! The most straightforward choice is the Euclidean metric, using the L2L_2 norm for vectors or the Frobenius norm for matrices. This gives the familiar negative-gradient direction.

Mathematically, the steepest descent direction under the Frobenius norm can be obtained by minimizing this linear approximation within a fixed step budget:

minΔWWL,ΔWsubject toΔWFη(1)\min_{\Delta W} \langle \nabla_W \mathcal{L}, \Delta W \rangle \quad \text{subject to} \quad \|\Delta W\|_F \leq \eta \tag{1}

Here, η\eta is the step budget, ΔW\Delta W is the change in a weight matrix of the neural net, and A,B=tr(ATB)\langle A,B\rangle=\operatorname{tr}(A^T B) is the Frobenius inner product. For a nonzero gradient, the solution is ΔW=ηWL/WLF\Delta W=-\eta\nabla_W\mathcal{L}/\|\nabla_W\mathcal{L}\|_F. This is a normalized gradient step: it has the same direction as ordinary gradient descent, but its length is fixed at η\eta.

For a given gradient, the steepest descent direction depends on how you measure the size (norm) of the step. We can also choose other norms, giving different constraints:

minΔWWL,ΔWsubject toΔWsome normη(2)\min_{\Delta W} \langle \nabla_W \mathcal{L}, \Delta W \rangle \quad \text{subject to} \quad \|\Delta W\|_{\text{some norm}} \leq \eta \tag{2}
A hiker considers two paths into a valley, with different step shapes illustrating how the choice of norm changes the descent direction.

The core rationale behind Muon

With this in mind, we can dive into the Muon optimizer. Here, we focus on a weight matrix WW in a hidden linear layer of the neural network. With the input xx held fixed, a weight update ΔW\Delta W changes the output activation y=Wxy=Wx by Δy=ΔWx\Delta y=\Delta W x.

Notice that (2) constrains the norm of the weight update. Now comes the core rationale behind this derivation of Muon: we want to choose a norm for the step that also lets us bound the resulting change in the output activation Δy\Delta y [1]. My intuition is that a large activation change can propagate through later layers, making the first-order approximation below less reliable:

L(θ+Δθ)L(θ)+lWlL,ΔWl.(3)\mathcal{L}(\theta+\Delta\theta) \approx \mathcal{L}(\theta)+\sum_l\langle \nabla_{W_l}\mathcal{L}, \Delta W_l\rangle. \tag{3}

Here, the sum runs over the weight matrices being updated. The bound we derive below controls each layer's direct response to its own weight update at a fixed input; it does not, by itself, guarantee that the approximation is accurate for the whole network.

RMS-to-RMS operator norm

For a vector vRdv\in\mathbb{R}^d, its root-mean-square (RMS) norm is

vRMS:=1di=1dvi2=v2d.\|v\|_{\mathrm{RMS}} := \sqrt{\frac{1}{d}\sum_{i=1}^{d}v_i^2}=\frac{\|v\|_2}{\sqrt{d}}.

The RMS-to-RMS operator norm measures the largest ratio between the output and input RMS norms when a matrix WW acts on a nonzero vector:

WRMSRMS:=maxx0WxRMSxRMS(4)\|W\|_{\mathrm{RMS}\rightarrow\mathrm{RMS}} := \max_{x\neq0}\frac{\|Wx\|_{\mathrm{RMS}}}{\|x\|_{\mathrm{RMS}}} \tag{4}

This gives a bound on the change in the output activation:

ΔyRMS=ΔWxRMSΔWRMSRMSxRMS.(5)\|\Delta y\|_{\mathrm{RMS}}=\|\Delta W x\|_{\mathrm{RMS}}\leq\|\Delta W\|_{\mathrm{RMS}\rightarrow\mathrm{RMS}}\|x\|_{\mathrm{RMS}}. \tag{5}

The motivation for using RMS norms here is that the layer's inputs and outputs are expected to be dense activations with RMS norms around one [1]. To make the next bound exact, let us assume xRMS1\|x\|_{\mathrm{RMS}}\leq1. Then

ΔyRMSΔWRMSRMS.(6)\|\Delta y\|_{\mathrm{RMS}}\leq\|\Delta W\|_{\mathrm{RMS}\rightarrow\mathrm{RMS}}. \tag{6}

We can use this bound to choose a constraint in (2). Keeping η\eta as our step budget, we obtain

minΔWWL,ΔWsubject toΔWRMSRMSη.(7)\min_{\Delta W}\langle\nabla_W\mathcal{L},\Delta W\rangle\quad\text{subject to}\quad\|\Delta W\|_{\mathrm{RMS}\rightarrow\mathrm{RMS}}\leq\eta. \tag{7}

This update minimizes the linearized loss while keeping ΔyRMSη\|\Delta y\|_{\mathrm{RMS}}\leq\eta for any fixed input with RMS norm at most one!

Connection to the spectral norm

The RMS-to-RMS operator norm is closely related to the spectral norm Wop\|W\|_{\mathrm{op}}, which is the largest singular value of WW. Here is a brief explanation.

Let WW have shape fan-out×fan-in\text{fan-out}\times\text{fan-in}. Consider its full singular value decomposition (SVD), W=UΣVTW=U\Sigma V^T, where UU and VV are square orthogonal matrices and Σ\Sigma has the same shape as WW. Substituting into (4),

WRMSRMS=maxx0UΣVTxRMSxRMS.(8)\|W\|_{\mathrm{RMS}\rightarrow\mathrm{RMS}}=\max_{x\neq0}\frac{\|U\Sigma V^T x\|_{\mathrm{RMS}}}{\|x\|_{\mathrm{RMS}}}. \tag{8}

Because UU preserves Euclidean length and the output dimension stays the same, it also preserves the RMS norm:

WRMSRMS=maxx0ΣVTxRMSxRMS.(9)\|W\|_{\mathrm{RMS}\rightarrow\mathrm{RMS}}=\max_{x\neq0}\frac{\|\Sigma V^T x\|_{\mathrm{RMS}}}{\|x\|_{\mathrm{RMS}}}. \tag{9}

Now define a new vector z=VTxz=V^T x. Since VV is also orthogonal,

zRMS=VTxRMS=xRMS.\|z\|_{\mathrm{RMS}}=\|V^T x\|_{\mathrm{RMS}}=\|x\|_{\mathrm{RMS}}.

Substituting into (9), and noting that zz ranges over all nonzero input vectors,

WRMSRMS=maxz0ΣzRMSzRMS.(10)\|W\|_{\mathrm{RMS}\rightarrow\mathrm{RMS}}=\max_{z\neq0}\frac{\|\Sigma z\|_{\mathrm{RMS}}}{\|z\|_{\mathrm{RMS}}}. \tag{10}

Let k=min(fan-in,fan-out)k=\min(\text{fan-in},\text{fan-out}). Since

ΣzRMS2=1fan-outi=1kσi2zi2σmax2fan-outi=1fan-inzi2,\|\Sigma z\|_{\mathrm{RMS}}^2=\frac{1}{\text{fan-out}}\sum_{i=1}^{k}\sigma_i^2z_i^2\leq\frac{\sigma_{\max}^2}{\text{fan-out}}\sum_{i=1}^{\text{fan-in}}z_i^2,

we have

maxz0ΣzRMSzRMSfan-infan-outσmax.(11)\max_{z\neq0}\frac{\|\Sigma z\|_{\mathrm{RMS}}}{\|z\|_{\mathrm{RMS}}}\leq\sqrt{\frac{\text{fan-in}}{\text{fan-out}}}\sigma_{\max}. \tag{11}

The upper bound is attained by choosing zz along a coordinate corresponding to the largest singular value. Therefore,

WRMSRMS=fan-infan-outWop.(12)\|W\|_{\mathrm{RMS}\rightarrow\mathrm{RMS}}=\sqrt{\frac{\text{fan-in}}{\text{fan-out}}}\|W\|_{\mathrm{op}}. \tag{12}

The optimization problem in (7) can now be expressed as

minΔWWL,ΔWsubject tofan-infan-outΔWopη.(13)\min_{\Delta W}\langle\nabla_W\mathcal{L},\Delta W\rangle\quad\text{subject to}\quad\sqrt{\frac{\text{fan-in}}{\text{fan-out}}}\|\Delta W\|_{\mathrm{op}}\leq\eta. \tag{13}

Solving the constrained minimization

The gradient matrix in (13) can also be decomposed using SVD. From now on, UU and VV refer to the singular vectors of the gradient, rather than those of WW. We use the compact SVD, retaining only the rr positive singular values:

G:=WL=UΣVT=i=1rσiuiviT.(14)G:=\nabla_W\mathcal{L}=U\Sigma V^T=\sum_{i=1}^{r}\sigma_i u_i v_i^T. \tag{14}

The matrices uiviTu_i v_i^T form an orthonormal basis for a subspace containing the gradient, with σi\sigma_i as its coordinates. Intuition for minimizing G,ΔW\langle G,\Delta W\rangle is:

  1. ΔW\Delta W needs to be in the same subspace spanned by uiviTu_i v_i^T and every component should point to the opposite direction of WL\nabla_W \mathcal{L}.
  2. Under the spectral norm constraint, the magnitude along each direction can be at most R=ηfan-out/fan-inR=\eta\sqrt{\text{fan-out}/\text{fan-in}}. Since this norm only limits the largest singular value, all of these components can reach magnitude RR at the same time. To minimize the linearized loss, choose the coefficient R-R for each one.

This gives an optimal solution to (13):

ΔW=ηfan-outfan-inUVT.(15)\Delta W=-\eta\sqrt{\frac{\text{fan-out}}{\text{fan-in}}}UV^T. \tag{15}

If the gradient is zero, we can simply choose a zero update.

Newton–Schulz iteration

With (15), we have solved the optimization problem, at least theoretically. However, computing an SVD is expensive. Muon uses a Newton–Schulz iteration to approximately perform the transformation to UVTUV^T using matrix multiplications. A good explanation of the iteration can be found in Jeremy Bernstein's post [1].

One detail separates this derivation from the practical optimizer: Muon applies the iteration to a momentum update, rather than directly to the gradient. The dimensional scaling can also differ from the factor in (15). Keller Jordan's post [2] covers the implementation; the derivation here focuses on the geometry behind the update.

One consequence of this geometry is that small singular directions no longer receive small updates simply because their gradients are small. Suppose the gradient has two singular values, 100 and 1. Under the Frobenius constraint in (1), the optimal update allocates its magnitude between those directions in a 100:1 ratio. Under the spectral constraint in (13), both can receive magnitude RR: using the second direction does not increase the largest singular value of the update. This is what makes the UVTUV^T update click for me. Equalizing the singular values follows directly from how we define the step budget.

References

  1. [1]Jeremy Bernstein. (2025). Deriving Muon.
  2. [2]Keller Jordan. (2024). Muon: An optimizer for hidden layers in neural networks.