Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

st-moe-pytorch

> DevOps
Open source

Implementation of ST-Moe, the latest incarnation of MoE after years of research at Brain, in Pytorch

387 stars0 likes1 views
WebsiteGitHub

About

Implementation of ST-Moe, the latest incarnation of MoE after years of research at Brain, in Pytorch

ST-MoE - Pytorch

Implementation of ST-MoE, the latest incarnation of mixture of experts after years of research at Brain, in Pytorch. Will be largely a transcription of the official Mesh Tensorflow implementation. If you have any papers you think should be added, while I have my attention on mixture of experts, please open an issue.

This should be SOTA for mixture-of-experts for autoregressive transformers. It is rumored that GPT4 is using 16 experts with top2 gating.

For non-autoregressive, would recommend going with the simpler and better Soft MoE.

Install

bash
$ pip install st-moe-pytorch

Appreciation

  • StabilityAI for the generous sponsorship, as well as my other sponsors, for affording me the independence to open source artificial intelligence.

  • Aran Komatsuzaki for consultation on mixture-of-experts, for removal of 2-level MoE and simplifications to code

Usage

…

Todo

  • add the router z-loss proposed in paper

  • add the geglu expert with multiplicative gating

  • add an entire sparse moe block, complete with rmsnorm + residual as well as the ability to specify a feedforward before or after for stability

  • double check equation for router z-loss for experts inner in hierarchical moe

  • redo all the transcribed code from google with einops, as it is not very clear

  • consult some MoE experts in the open source community; question why hierarchical MoE is needed, in light of results from soft-MoE

  • offer top-n gating generalization, as it seems top3 (with smaller threshold) can work even better

  • figure out if there was an error in a previous transcription - no there was not an error

  • allow for different thresholds for second vs third routed expert

  • add coordinate descent based routing

  • make first naive non-optimized attempt at distributed code for mixture of experts

  • distributed

    • handle any world size less than number of experts
    • handle any world size greater than number of experts - for now, just have remainder machines do nothing
    • support variable batch sizes
    • support variable seq lengths
    • figure out how to move assert.py to pytests
    • simplify the variable sequence length test code from another folder and move in so other researchers gain confidence
    • optimize
    • figure out what is faster, all gather, or broadcast with async followed by barrier
    • make all distributed code pluggable, for different strategies
    • figure out why there is tiny error in gradients
  • improvise a Top2GatingWithCoordinateDescent for MoE without importance

Citations

bibtex
@inproceedings{Zoph2022STMoEDS,
    title   = {ST-MoE: Designing Stable and Transferable Sparse Expert Models},
    author  = {Barret Zoph and Irwan Bello and Sameer Kumar and Nan Du and Yanping Huang and Jeff Dean and Noam M. Shazeer and William Fedus},
    year    = {2022}
}

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Pythonartificial-intelligenceconditional-computationdeep-learningmixture-of-experts

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理