skip to content
← Scientific Spaces English

Implementing Muon with Streaming Power Iteration, Part 5: Extensions

The theme of this series is "streaming power iteration." As the name implies, it consists of two parts: "streaming" and "power iteration." Here, "power iteration" is a classic multi-step iterative scheme for computing matrix SVD, while "streaming" refers to amortizing an algorithm that originally required multi-step iterations across every training step, bringing the computational cost down to an acceptable level. Its core idea is: rather than completing a complex computation all at once, it is better to continuously approach the target throughout the training process.

As an extension of this series, this article will introduce some other applications of the "streaming" idea, further demonstrating how relatively expensive operations can be cleverly integrated into the training process via streaming conversion.

Orthogonal Projection #

In some scenarios, we want to constrain the orthogonality of certain parameter matrices. Orthogonal matrices possess good numerical stability, which can prevent some numerical explosion or vanishing issues, while also providing better theoretical guarantees in certain designs. Of course, as to where it is appropriate to constrain parameters to be orthogonal matrices, we need to analyze specific scenarios individually, and we will not expand on that here.

In the articles Steepest Descent on Manifolds, Part 2: Muon + Orthogonality and Steepest Descent on Manifolds, Part 3: Muon + Stiefel, we did some exploration of the orthogonal (Stiefel) manifold, but back then the idea was to combine it with steepest descent to derive new update rules, which was overall quite complicated. Here, we only consider a simpler approach: re-projecting (retracting) the parameters back onto the orthogonal manifold after each update step.

Without loss of generality, let the parameter be , where , then the operation we want to perform can be written as

Here, is defined as

that is, finding the orthogonal matrix closest to . This operation already appeared in our first blog post introducing Muon, "An Appreciation of the Muon Optimizer: An Essential Leap from Vectors to Matrices"; it is actually just Muon's , so the operation we want to implement can also be written as

Streaming Iteration #

That is to say, after completing each update step, we need to execute once more to project the parameters back onto the orthogonal manifold. However, is an operation that, while not terribly expensive, is not cheap either. We know that the core operation of Muon is , but Muon's runs under BF16, whereas the parameters are stored in FP32, and the parameters' needs to run under FP32, which comes with a fairly substantial cost.

can be efficiently computed based on the Newton-Schulz iteration, which we have already discussed in detail in "Newton-Schulz Iteration for the msign Operator (Part 1)" and "Newton-Schulz Iteration for the msign Operator (Part 2)". Different Newton-Schulz iterations have different polynomial degrees and coefficients, corresponding to different convergence rates. A classic 3rd-order scheme is

It can be proven that . Although this iteration is classic, its convergence is slow; in Muon, we usually use a 5th-order iteration with faster convergence. But regardless of which one is used, the cost of executing the full iteration is fairly substantial.

However, on the parameter side, is it really necessary for us to execute the full iteration at every step? Suppose is already orthogonal or nearly orthogonal. Since the learning rate is very small, will not deviate significantly from orthogonality either. This is precisely where the streaming idea comes into play—perhaps iterating just once per training step is enough. For example, consider

From an asymptotic perspective, this also achieves the effect of , and each step only requires computing one extra term, , at a cost significantly lower than the full Newton-Schulz iteration.

Spectral Constraints #

In general, orthogonality constraints can only be imposed on certain special matrices because they are overly restrictive, halving the degrees of freedom of the matrix—or in other words, halving the parameter count. Often, we may prefer looser spectral constraints, such as the singular value clipping mentioned in "Higher-Order MuP: Simpler yet Smarter Spectral Condition Scaling".

If turns all singular values of a matrix into 1, then singular value clipping turns only singular values greater than 1 into 1 while keeping the remaining singular values unchanged, in "Computing Singular Value Clipping mclip via msign (Part 1)" and "Computing Singular Value Clipping mclip via msign (Part 2)", we called this operation . Suppose what we want to do is clip the singular values to within 1 after each parameter update step; then this can be written as

However, is considerably more troublesome to compute than . Previously, we explored schemes based on to implement , such as the identity

It requires two evaluations of to compute , which is quite costly. Of course, we could also perform streaming power iteration separately on and then compute via SVD, but this would require adding another buffer variable, which also seems like quite a hassle.

Clipping One by One #

From another perspective, let us understand : turns all singular values greater than 1 into 1, so an essential operation is to turn the leading singular value into 1 (if it is greater than 1). Once we clip the leading singular value, if there are still singular values greater than 1, the largest among them will become the new leading singular value. This means that we only need to repeatedly 'clip the leading singular value to 1' to achieve .

The advantage of this 'clipping one by one' strategy is that computing only the leading singular value and leading singular vectors (which we might call ) is far cheaper than performing a full SVD. It only requires vector-based power iteration

to converge to 's right leading singular vector , followed by and ; in practice, we can simply fix the number of iteration steps to obtain an approximation. Next, we still carry through the 'streaming' idea, performing only a single leading singular value clipping at each update step, namely

Over long-term training, this can keep the singular values of around 1 (in practice, slightly larger than 1 due to the approximation of power iteration and the streaming nature). This 'streaming singular value clipping' can be regarded as a variant of the 'spectral weight decay' introduced in "Reflections from Spectral Norm Gradients to Novel Weight Decay"; in the paper 《Training Transformers with Enforced Lipschitz Constants》, it is called the 'Spectral Hammer'.

Other Examples #

When is the streaming idea applicable? A typical scenario is: when we can anticipate that over long-term training, a certain variable changes slowly, we can try performing only a few iterations at each training step, expecting that this will suffice to correct for the changes brought by parameter updates. In addition to the two new examples above, we have also used the 'streaming' idea in some previous articles; let us briefly review them here.

In Steepest Descent on Manifolds, Part 3: Muon + Stiefel and Steepest Descent on Manifolds, Part 4: Muon + Spectral Sphere, when solving for steepest descent on the corresponding manifolds, we needed to solve a nonlinear equation. At that time, we proposed a fixed-point iteration method to solve it, and later in Steepest Descent on Manifolds, Part 5: Dual Gradient Descent, we discussed the dual gradient descent solution and proposed using the streaming idea to amortize the solving process across each training step.

Coincidentally, in MoE Journey, Part 6: Optimal Allocation Promotes Balance, we viewed the load balancing problem in MoE from the perspective of optimal allocation. When solving the dual problem of optimal allocation, we originally needed to alternately optimize and at each step until convergence. However, considering that the change in at each step should not be large, then still based on the streaming idea, we only execute a single step of and updates at each training step, which already achieves good load balancing.

In summary, when we realize that a variable changes slowly, we can consider executing only a small number of iteration steps at each step to amortize the computational cost. To achieve this, we sometimes need to add extra cache variables (such as in streaming power iteration), but sometimes we do not. How to better design streaming iterations may require some ingenuity, which is well worth delving into and savoring.

Summary #

This article mainly introduced two other examples of applying the "streaming" idea: projecting parameters onto the orthogonal (Stiefel) manifold, or clipping parameter spectral norms to not exceed 1, both at minimal extra cost. These examples once again demonstrate the beauty of the streaming idea: many complex calculations that seemingly must be completed in one shot can be broken down into gradual, fine-tuning operations and integrated into every step of training.