Mixture of Experts and the Muon Optimizer: A Practical Guide
This article explores why Mixture of Experts (MoE) architectures demand a fresh look at optimizers, how matrix-orthogonalization methods such as Muon work, and what it takes to scale them to production. It covers the core Newton-Schulz approximation, two key modifications for large-scale training (weight decay and update-magnitude calibration), a three-layer framework for measuring compute efficiency, stability engineering practices for trillion-parameter runs, and common pitfalls to avoid. Readers will gain a clear picture of how optimizer choice and stability tooling together determine whether MoE's efficiency advantage actually materializes.
1. Why Mixture of Experts Forces a Rethink of the Optimizer
The Mixture of Experts (MoE) architecture replaces the single feed-forward network of a dense model with multiple parallel expert subnetworks, and a routing mechanism selects a small subset of experts for each token. One immediate consequence is that total parameter count is decoupled from the number of parameters activated per token. A common industry configuration, for example, might have 16 billion total parameters while activating only about 3 billion per token. Parameter scale goes up, but per-step compute does not grow proportionally.
This decoupling places new demands on the training stack. There are many parameter matrices, individual matrices tend to be either “wide and flat” or “tall and thin,” gradients are highly unevenly distributed across the parameter space, and load and update frequency differ noticeably from expert to expert. Conventional adaptive optimizers maintain first- and second-order moments for every parameter, so memory overhead scales linearly with parameter count and becomes severe as the number of experts grows. At the same time, element-wise scaling introduces systematic bias in update magnitude across different matrices and experts, and loss spikes tend to appear late in training, forcing checkpoint rollbacks.
So a natural question arises: can we find an optimizer that, without significantly increasing state overhead, makes updates more uniform across the parameter space and more consistent across matrices, with benefits that hold steadily as scale increases? Matrix-orthogonalization optimizers are one answer to this question.
2. Core Principles of Matrix-Orthogonalization Optimizers
The update logic of mainstream adaptive optimizers is element-wise: a first- and second-moment estimate is computed for each scalar parameter, then used to scale the update via division. This completely ignores the structure of the parameter matrix itself.
Matrix-orthogonalization optimizers take a different approach: treat the gradient (or momentum) as a matrix, orthogonalize it, and use the orthogonalized matrix to update the parameters. Intuitively, orthogonalization removes scale differences across the singular directions of the original matrix, spreading update energy more evenly across directions. It is effectively a “condition-number normalization” of the update.
In practice, Newton-Schulz iteration is typically used to approximate the orthogonalization. It does not require a true SVD; a few rounds of matrix-multiplication iterations converge to an approximately orthogonal matrix, which makes it accelerator-friendly. A schematic implementation follows (illustrating the computation flow only, not a specific product interface):
def zeropower_via_newtonschulz(G, steps=5):# G: gradient/momentum matrixX = G / (G.norm() + 1e-7) # normalize to keep the iteration stablea, b, c = 3.4445, -4.7750, 2.0315for _ in range(steps):A = X @ X.TB = b * A + c * (A @ A)X = a * X + B @ Xreturn X
Three engineering details deserve attention: the iteration coefficients need to be chosen from tuned variants according to matrix size; “tall and thin” matrices and their transposes must be handled separately to avoid shape mismatches; and orthogonalization applies only to two-dimensional parameter matrices, while one-dimensional parameters (such as normalization-layer weights and biases) still follow the regular update path.
3. Two Key Modifications: From “Works on Small Models” to “Scales to Large Models”
Matrix-orthogonalization methods were initially validated only on small and medium-scale models. Scaling them directly to billion-parameter, trillion-token training runs surfaces two new problems that must be addressed specifically.
The first is weight decay. Large models combined with very long token budgets cause parameter norms to grow continuously, which pushes up activation magnitudes and compresses the effective update space. The fix is to add the decay term explicitly into the update rule, keeping weight norms under control over long horizons rather than relying on the data distribution to constrain them naturally. This change has the greatest impact on late-training stability.
The second is update-magnitude calibration. Parameter matrices vary widely in dimensionality, so a uniform scaling coefficient makes the effective step size differ by several times between wide and narrow matrices. The calibration rule scales each parameter’s update magnitude by the square root of the largest dimension of its weight matrix, aligning the effective update magnitude across all matrices:
scale = 0.2 * max(A.shape) ** 0.5 # update-magnitude calibrationparam -= lr * scale * orthogonalized_update
Together, these two modifications allow the compute-efficiency advantage to actually materialize at scale: under the same compute budget, this class of optimizer is roughly twice as compute-efficient as element-wise adaptive optimizers, and the Pareto frontier shifts outward as a whole, meaning fewer floating-point operations are needed for the same loss, or lower loss is achieved with the same compute.
4. Empirical Evaluation: How to Measure “Compute Efficiency” Correctly
Evaluating an optimizer means looking beyond final loss. A three-layer set of metrics is recommended:
- Compute dimension: record the cumulative floating-point operations required to reach a target loss, not the number of training steps. Equal step counts do not mean equal compute.
- Stability dimension: track the number of loss spikes, gradient-norm percentiles, expert load imbalance, and checkpoint rollback count.
- Overhead dimension: optimizer-state memory footprint, and the share of per-step time spent on orthogonalization iterations.
A reference experiment design is to fix the model architecture and data mixture, swap only the optimizer, sweep three or four scale tiers, and plot loss–FLOPs curves. Only if an optimizer shows a slight advantage at the smallest tier and a steadily widening advantage at larger tiers can its scalability be considered established. Conclusions without a scale sweep are insufficient to support production decisions.
5. From a Validation Model to Trillion Parameters: The Evolution of Stability Engineering
Getting the pipeline working end-to-end on a validation model with 3 billion activated parameters, 16 billion total parameters, and a 5.7-trillion-token training budget is a reasonable intermediate step: the scale is large enough to expose problems while keeping cost manageable. Scaling from there toward the trillion-parameter level causes stability issues to surface in concentrated form. Common industry responses include:
- Update clipping: apply global or per-tensor norm clipping to the orthogonalized update to prevent gradient spikes from individual experts.
- Numerical precision strategy: use lower precision for matrix multiplications and iterations, while keeping the master copy of parameters and scaling factors at higher precision to avoid overflow during normalization.
- Routing and load balancing: jointly tune the auxiliary loss and capacity factor to reduce expert collapse and long-tail latency.
- Observability: wire gradient norms, update-to-weight ratios, and expert activation distributions into logging services and monitoring alerts, with automatic rollback thresholds.
Long-tail latency also needs engineering attention: expert parallelism in MoE introduces load skew, and training throughput is often held back by the slowest device. Capacity constraints, dynamic dropping, and communication overlap can significantly compress the long tail.
6. Running It on the Cloud: Resource and Engineering Setup
To reproduce a similar training run on Baidu AI Cloud, you can assemble general-purpose capabilities: use a container platform to host distributed training jobs with elastic scaling, object storage for checkpoints and datasets, a message queue to decouple data preprocessing from the main training loop, and logging and monitoring services to track loss, throughput, and hardware metrics. For parallelism, expert parallelism, tensor parallelism, data parallelism, and pipeline parallelism need to be searched jointly; communication topology and network bandwidth often become the bottleneck before compute does.
7. Common Pitfalls and Practical Recommendations
- Pitfall 1: Orthogonalization is always faster. It adds per-step matrix-multiplication overhead and only pays off when the compute-efficiency gain covers that overhead and the training budget is long enough.
- Pitfall 2: Applying default hyperparameters directly. Learning rate, decay coefficient, and iteration count must be re-searched as scale changes; optimal values from small models do not extrapolate.
- Pitfall 3: Looking only at the loss curve. Without expert load and gradient statistics, spike problems often surface only late in training.
Recommended path: first validate the update rule and numerical stability at small scale, then run a two-to-three-tier scale sweep to confirm scalability, and finally scale up the budget only after the full observability stack is in place. Whether the value of Mixture of Experts is realized depends largely on whether the optimizer and stability engineering are in place together.
