Muon's core operation is , and its current standard implementation is Newton-Schulz iteration. It must be said that this is indeed an extremely efficient and GPU-friendly algorithm; Muon's popularity is due in no small part—at least more than half—to this algorithm. However, this algorithm also gives off a sense of being "the one and only, with no alternatives," because it seems strictly limited to computing ; once we want to modify Muon (for example, replacing with the linked article's ), the corresponding computation becomes quite troublesome.
This article proposes a new implementation idea: approximating SVD via Streaming Power Iteration. This is not an entirely new idea, as it has already appeared in some previous optimizer works, but here we extract it separately and use it as an independent algorithm.
In "Lipschitz Constraints in Deep Learning: Generalization and Generative Models", "Reflections from Spectral Norm Gradients to Novel Weight Decay" and other articles, we have already had some initial exposure to power iteration, which we used to compute the dominant eigenvector of , or equivalently the dominant right singular vector of , with the iteration format as follows:
Assuming that we have already obtained the dominant eigenvector , we can add orthogonalization to power iteration to find the subdominant eigenvector:
Because orthogonality to is guaranteed, this will converge to the subdominant eigenvector . Similarly, assuming that are known, we can combine this with Gram-Schmidt orthogonalization to find the -th eigenvector:
In fact, we do not need to wait until have all been computed before computing ; all of can be iterated in parallel. Specifically, starting from the existing approximation , we compute in batches , and then re-orthogonalize by column vectors (which can be done via QR decomposition) to obtain a better approximation, which we denote as ; iterating repeatedly, this will ultimately converge to our target :
Here, denotes the orthogonal matrix from QR decomposition. Having obtained , we clearly have , where means performing L2 normalization along each column (axis=0), and , so we obtain an approximate scheme for computing the SVD based on power iteration and QR decomposition. Of course, when , it yields only an incomplete decomposition, where and , but this is already sufficient.
However, using power iteration to compute the SVD is extremely inefficient in practice, far inferior to directly calling the framework's built-in SVD function, so this is not practical. But considering that training itself is an iterative process over a long horizon, we can assume that at each step, the change in is not large. Thus, we can store from the previous step as the initialization for the current step, and perform only a single power iteration per step, namely:
where . Empirical tests show that Muon implemented via this streaming power iteration indeed achieves convergence curves on the LM loss that almost coincide with the Newton-Schulz version, demonstrating that it is indeed a viable scheme. This is largely due to the momentum mechanism and small learning rates, which make the assumption that "at each step, the change in is not large" approximately hold, thereby allowing the cost of power iteration to be "amortized" across each step.
Thanks to directly approximating the SVD, we can also perform operations on the singular values and incorporate them into the optimizer, such as
This way, implementing or Muon variants based on a general Schatten norm becomes much easier. In short, with explicit results for (even if only approximate), we can easily try out small modifications, markedly enhancing extensibility and playability.
Now the pressure shifts to the QR decomposition. In Eq. , the most time-consuming step is the QR decomposition. The standard implementation is Householder QR; although it is already considerably faster than SVD, it is still slower than computed via Newton-Schulz iteration (polynomial iterations that allow BF16 multiplication are practically cheating). Therefore, to enhance the competitiveness of this new scheme, we also need to speed up the QR decomposition.
For a given matrix (), QR decomposition seeks an orthogonal matrix and an upper triangular matrix , such that (here the orthogonal matrix only needs to satisfy , more accurately called a Stiefel matrix). Notice that , which means we only need to factorize into the product of a lower triangular matrix and its transpose to obtain , and this is precisely what the Cholesky decomposition is designed to do!
The Cholesky decomposition is extremely efficient, so in the first step we can use it to obtain , and then solve the equation to obtain , which can also be written as , which can be solved using solve_triangular , which is also highly efficient. Combining these two steps gives the QR decomposition algorithm known as "Cholesky QR". Disregarding numerical stability, it is probably the fastest QR decomposition method.
Unfortunately, compared to standard QR decomposition, Cholesky QR is very unstable, being extremely sensitive to 's condition number. To address this, 《Shifted CholeskyQR for computing the QR factorization of ill-conditioned matrices》 (abbreviated as "SCQR") proposed adding to a regularization term () to alleviate this issue. But this is also a double-edged sword: the larger is, the more stable SCQR becomes, but the resulting will be less orthogonal, leading to worse final performance.
Furthermore, even with , there is no guarantee that SCQR will always succeed, so we still need an extra check to fall back to standard QR upon failure.
A simple Jax-based reference implementation is as follows:
import jax.numpy as jnp
from jax.scipy.linalg import solve_triangular
from jax import lax
def shift(A, eps=1e-9):
return A + eps * jnp.linalg.matrix_norm(A, keepdims=True) * jnp.eye(A.shape[-1])
def scqr(A, eps=1e-9):
"""Compute using Shifted Cholesky QR first; fall back to default QR upon failure."""
R = jnp.linalg.cholesky(shift(A.mT @ A, eps), upper=True)
Q = solve_triangular(R.mT, A.mT, lower=True).mT
return lax.cond(jnp.isfinite(Q).all(), lambda: Q, lambda: jnp.linalg.qr(A)[0])
Simple tests show that if it executes smoothly, the efficiency of SCQR is comparable to the Newton-Schulz version of . However, to guarantee the degree of approximation, cannot be set too small; otherwise, performance drops noticeably. In practice, it usually needs to reach for performance to be relatively well guaranteed. At this point, SCQR still has a fairly high probability of falling back to standard QR, so the final speed still lags somewhat behind Newton-Schulz iteration.
In addition to directly improving the QR decomposition algorithm, there are other acceleration techniques. For instance, if we only keep the top eigenvectors, then only needs to be initialized to a size of rather than , which can also reduce some computation. Further acceleration of the QR decomposition is left for everyone to explore; I will not expand on it further here.
In addition, there are several details that require special attention, as they are closely related to both training stability and the final performance.
First, according to the convention of , we need to ensure that ; otherwise, it needs to be transposed. If , then the matrix is bound to be rank-deficient. Performing QR decomposition on a rank-deficient matrix is ill-posed; in particular, SCQR is more prone to various ill-conditioned phenomena, ultimately degrading performance. Therefore, ensuring that not only guarantees numerical stability and improves performance, but also speeds things up—killing multiple birds with one stone.
Second, empirical tests show that for the step, adding an extra is also very helpful for boosting performance:
This is merely equivalent to taking Eq. and changing to , which does not alter the convergence of the power iteration itself. However, experiments show that having this extra step noticeably helps training performance, being even more prominent under SCQR and significantly narrowing its performance gap with standard QR.
It can be shown that this operation theoretically does not alter the power iteration, and only affects the numerical computation of QR. According to experimental observations, it actually makes SCQR fall back to standard QR with a higher probability (though not by much, so it does not noticeably slow down), and it also slightly helps standard QR. Thus, it seems to improve the conditioning of the matrix to be QR-decomposed, yielding better QR quality.
In fact, taking an algorithm that requires multiple iterations to converge and, leveraging the fact that model training inherently requires long-term updates, turning it into a streaming version that iterates only once per training step to amortize the cost is not an overly difficult idea to conceive. Previously, in Steepest Descent on Manifolds, Part 5: Dual Gradient Descent, we had already tried this. So having so many related works already is not surprising at all.
The main reference for this post is last month's 《ARO: A New Lens On Matrix Optimization For Large Models》, which actually already covers most of the content of this post and further generalizes it. The line of thought behind this generalization is also well worth pondering. Notice that the update in Muon can now be written as
where can be viewed as a base optimizer that merely performs simple column normalization on the momentum, which is not very competitive. Therefore, we find a new orthogonal basis , apply the base optimizer under this new basis, and then transform back. Now we know that this is in fact Muon, and compared to directly using it is indeed noticeably stronger. Then, the next thought is naturally: can be replaced with other base optimizers? To this end, ARO proposed a general optimizer framework (Rotational Steepest Descent)
where represents any matrix function, and the original notation is replaced by (Rotation). As for more details on Rotational Steepest Descent, we will discuss them later when the opportunity arises.
This article mainly introduced the idea of computing the SVD via streaming power iteration to implement Muon. It requires only a single QR decomposition per step, offering more flexible extensibility compared to the standard Newton-Schulz iteration implementation.