Skip to main content

PyTorch GitHub

SparseMixer

Sparse Backpropagation for Mixture-of-Expert Training

Mixture-of-Expert • SparseMixer • How to Use? • Examples • Citation • License

sparsemixer, a scalable gradient estimator, bridges the gap between backpropagation and sparse expert routing.

What is Mixture-of-Expert

The significant success of large-scale pre-training across various applications has underscored the imperative need for scalable models that are economically feasible. Recent advances in sparsely activated networks, prominently known as Mixture-of-Experts (MoE), have attracted widespread interest. Unlike traditional networks that densely activate all modules for all input, MoE selectively activates parts of modules to specific inputs through a process called {expert routing}, leading to notable efficiency enhancements.

Numerous methods have emerged to bridge discrete and back-propagation, and most of them are based on Straight-Through (ST). Unfortunately, all existing ST estimators are incompatible with MoE, since they require activating all experts for gradient computing, thereby eliminating all the efficiency improvements of MoE. Consequently, typical MoE training strategically neglects the gradient computation for routing, trading certain training signals for sparse computation. Despite the scalability brought by sparse computation, this trade-off may result in slow convergence and improperly trained models.

Backpropagation Made Sparse

We propose sparsemixer, a scalable gradient estimator, bridges the gap between backpropagation and sparse expert routing. Grounded in a numerical ODE framework, SparseMixer harnesses the mid-point method, a second-order ODE solver, to deliver precise gradient approximations with negligible computational overhead. Applying SparseMixer to Switch Transformer on both pre-training and machine translation tasks, SparseMixer showcases considerable performance gain, accelerating training convergence up to 2 times

How to use?

sparsemixer can be installed via pip

pip install sparsemixer

Examples

Please check the example folder for a working example.

Citation

Please cite the following papers if you found our model useful. Thanks!

Liyuan Liu, Jianfeng Gao, and Weizhu Chen (2023). Sparse Backpropagation for MoE Training. ArXiv, abs/2304.08612.

@inproceedings{liu2023bridging,
  title={Sparse Backpropagation for MoE Training},
  author = {Liu, Liyuan and Gao, Jianfeng and Chen, Weizhu},
  booktitle = {arXiv:2304.08612 [cs]},
  year={2023}
}

Liyuan Liu, Chengyu Dong, Xiaodong Liu, Bin Yu, and Jianfeng Gao (2023). Bridging Discrete and Backpropagation: Straight-Through and Beyond. ArXiv, abs/2304.08612.

@inproceedings{liu2023bridging,
  title={Bridging Discrete and Backpropagation: Straight-Through and Beyond},
  author = {Liu, Liyuan and Dong, Chengyu and Liu, Xiaodong and Yu, Bin and Gao, Jianfeng},
  booktitle = {arXiv:2304.08612 [cs]},
  year={2023}
}

Metadata

Release files for sparsemixer 0.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sparsemixer 0.0.0
File Size Uploaded Provenance
sparsemixer-0.0.0.tar.gz 4.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sparsemixer 0.0.0
File Interpreter ABI Platform
sparsemixer-0.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 9.1 kB

Release files / sparsemixer-0.0.0.tar.gz

Download URL sparsemixer-0.0.0.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f2dd1948ee1a6fb489b3a3d7c94c2dfffe87bf28a21a25e92aaba8cc7343dcdd
BLAKE2b-256 checksum
How to use checksums
01ec3abe7d838d6aef2495d137666dae2a1ceec3b71f7a708e912073d2930bc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Release files / sparsemixer-0.0.0-py2.py3-none-any.whl

Download URL sparsemixer-0.0.0-py2.py3-none-any.whl
Size 4.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
56b60c288528cdc5d8a251a55333ea96733acf3835441656cb985998d6aa3ff4
BLAKE2b-256 checksum
How to use checksums
dc1f8596bcf5a70d772c3e71fee83f0968b378012ec047fa6fa95a9a859d0766
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.12

Security for sparsemixer 0.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page