MoonshotAI/MoonEP
MoonEP: A Perfectly Balanced Expert Parallelism Library via Dynamic Redundant Experts
What it solves
MoonEP addresses the load imbalance problem in Mixture-of-Experts (MoE) models during Expert Parallelism (EP). In traditional MoE, some experts receive significantly more tokens than others, leading to "hot ranks" that slow down the entire training or inference process and can cause GPU memory fragmentation or Out-of-Memory (OOM) errors.
How it works
MoonEP ensures every GPU rank receives an identical number of tokens regardless of the routing distribution. It achieves this through:
- Dynamic Redundant Experts: It plans a small number of redundant experts online and prefetches them to ranks that need them, ensuring the workload is perfectly balanced across all ranks.
- Online Planning: A high-performance GPU kernel handles the planning of these redundant experts with minimal overhead.
- Zero-Copy Communication: It uses fused permute/unpermute operations to send tokens directly to their final positions on remote ranks, providing views of the communication buffer directly to the computation, which eliminates expensive data copies.
- Static Memory Shapes: By maintaining a fixed buffer size for tokens, it prevents memory fragmentation and ensures predictable memory usage.
Who it’s for
Developers and researchers building large-scale MoE models who need to optimize communication overhead and maintain stable training performance across multiple GPUs using NVLink.
Highlights
- Immune to Imbalance: Iteration time remains flat even as routing imbalance increases.
- Zero-Copy Efficiency: Faster raw communication by eliminating the copy between communication and user buffers.
- Static Memory: Prevents GPU memory fragmentation and OOMs at high imbalance levels.
- Integrated Weight Prefetching: Includes specialized kernels for prefetching and reducing gradients for redundant experts.
Related
- Project
- Dispatch
- Dispatch
- Project
- Dispatch