Designing Effective Sparse Expert Models

Barret Zoph, Irwan Bello, Sameer Kumar, Nan Du, Yanping Huang, Jeff Dean, Noam Shazeer, William FedusarXiv 2022

Introduction

Mixture-of-Experts (MoE) models represent a paradigm shift in scaling natural language processing. By using a "router" to activate only a subset of parameters (experts) for each token, these sparse models achieve the capacity of hundreds of billions of parameters while maintaining the computational footprint of much smaller dense models. However, MoE models have historically been plagued by two issues: training instability and poor performance on downstream tasks (transferability).

The Precision Trap

The primary cause of training instability in large-scale MoE models is numerical precision. Most modern training uses the bfloat16 format to save memory and speed up computation. However, MoE routers rely on exponential functions (softmax) that are highly sensitive to large input values (logits).

Comparison of Float32 and BFloat16 precision formats and their respective roundoff errors.

As shown in the data above, bfloat16 has significantly higher roundoff errors than float32 as the magnitude of numbers increases. When logits grow large, tiny roundoff errors can lead to massive, incorrect shifts in routing decisions, causing the sudden, irrecoverable loss spikes typical of MoE training.

Stabilizing with Router Z-Loss

To combat this, the authors introduced the router z-loss. This auxiliary loss function penalizes large logits entering the routing network. By encouraging the model to keep these values small, it ensures the computation remains within the stable range of the bfloat16 format.

Training loss curves showing the contrast between unstable training (left) and the stability achieved with router z-loss (right).

This simple intervention improved training success rates from 66% to 100% in experimental trials without degrading model quality. Unlike other methods like gradient clipping, the z-loss actually provides a slight boost to model quality.

Unlocking Transferability

Even stable MoE models often underperform during fine-tuning. The authors discovered that sparse models are exceptionally prone to overfitting and require different hyperparameters than their dense counterparts. Specifically, "noisier" training conditions—smaller batch sizes and higher learning rates—are necessary to help these massive models generalize to downstream tasks.

Interestingly, the study found that dropping up to 15% of tokens (when experts are overloaded) during fine-tuning has negligible impact on accuracy, suggesting that MoE models are robust to partial information loss.

Results and Specialization

The resulting ST-MoE-32B model (269B total parameters) achieved state-of-the-art results across a wide range of benchmarks, including a score of 91.2 on SuperGLUE and 86.5 on ARC Challenge.

Analysis of the model's internal behavior revealed that encoder experts specialize by linguistic concept (e.g., syntax or semantics) rather than by language. In contrast, decoder experts showed significantly less specialization, suggesting potential for future architectural simplifications in the decoder to speed up generation.

Conclusion

ST-MoE provides a blueprint for building massive, stable, and high-performing sparse models. By addressing the fundamental numerical issues of routing and tailoring fine-tuning protocols, sparse models can finally fulfill their promise of efficient, large-scale intelligence.

Summary updated

BibTeX
@misc{zoph2022designing,
  author = {Barret Zoph and Irwan Bello and Sameer Kumar and Nan Du and Yanping Huang and Jeff Dean and Noam Shazeer and William Fedus},
  title = {{Designing Effective Sparse Expert Models}},
  year = {2022},
  eprint = {2202.08906},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2202.08906},
}
Figure