TL;DR
Mixture-of-Experts (MoE) models offer a path to larger, more capable models with manageable computational costs. However, distributed MoE training and inference are bottlenecked by all-to-all communication. This paper introduces Lina, a system that optimizes this communication by prioritizing all-to-all during training and dynamically scheduling resources during inference, leading to significant speedups.
What Problem Does This Paper Address?
Deep learning models have seen remarkable improvements with increased parameter counts, but this comes at a steep computational cost for training and inference. Mixture-of-Experts (MoE) architectures offer a solution by activating only a subset of model parameters (experts) for each input, leading to sub-linear scaling of computation with model size. However, when these MoE models are distributed across multiple devices, the all-to-all communication required to route data to and from experts becomes a major performance bottleneck. This bottleneck is particularly problematic during training, where all-to-all communication can contend for network bandwidth with other operations, and during inference, where skewed expert popularity can lead to imbalanced workloads and straggler devices.
Methods
Lina tackles the all-to-all bottleneck with two main strategies:
- Prioritizing All-to-All in Training: Lina introduces tensor partitioning to break down communication operations into smaller micro-ops. This allows for a more granular scheduling approach where all-to-all micro-ops are prioritized over allreduce operations (used for non-expert gradients). By doing so, Lina ensures that all-to-all gets dedicated network bandwidth, reducing its blocking period. Pipelining is also employed to overlap expert computation with communication.
- Dynamic Resource Scheduling in Inference: To address the skewed expert popularity during inference, Lina uses a two-phase scheduling approach.
- Estimation Phase: Lina exploits a learned pattern in token-to-expert selection across layers to estimate expert popularity before the gating network makes its final decision. This allows for proactive resource allocation.
- Fine-tuning Phase: After the gating network selects experts, Lina checks if the actual selection deviates significantly from the estimation. If so, it performs a fine-tuning step to adjust resource allocation, ensuring better load balancing.
Datasets
The paper does not introduce new datasets. It uses standard datasets for evaluation:
- Training: Transformer-XL, BERT2GPT2, and GPT-2 models are used for training.
- Inference: Transformer-XL on Enwik8 and BERT-Large on WMT En-De are used for inference tasks.
Key Insights and Ideas
- All-to-all is the primary bottleneck: The paper provides empirical evidence that all-to-all communication is a significant performance limiter in distributed MoE, consuming a substantial portion of step time.
- Different causes for the bottleneck: The root causes of the all-to-all bottleneck differ between training (bandwidth contention with allreduce) and inference (skewed expert popularity and straggler devices).
- Prioritization is key for training: Simply allowing all-to-all and allreduce to compete for bandwidth is inefficient. Lina's approach of prioritizing all-to-all through micro-ops significantly improves training speed.
- Expert popularity is predictable: The paper demonstrates that token-to-expert selection exhibits a predictable pattern across layers, which can be leveraged for proactive resource scheduling in inference.
- Two-phase scheduling for inference: A two-phase approach (estimation followed by optional fine-tuning) effectively balances the workload and minimizes inference latency, even with real-world, non-uniform request patterns.
Key Results
- Training Speedup: Lina reduces training step time by an average of 1.37x to 1.73x compared to DeepSpeed.
- MoE Layer Speedup: MoE layer forward and backward pass times are accelerated by up to 1.89x and 2.41x, respectively.
- All-to-all Time Reduction: Lina achieves an average speedup of 2.21x, 2.39x, and 2.31x in all-to-all time for 4-, 8-, and 16-expert configurations.
- Inference Speedup: Lina reduces median inference time by 1.36x to 1.54x and 95%ile inference time by 1.68x to 1.82x compared to the baseline.
- GPU Utilization: Lina improves average GPU utilization by 17.6%.
- Estimation Accuracy: Lina's popularity estimation achieves an accuracy of 58.41% and 54.16% for Transformer-XL and BERT-Large, respectively.
Limitations and Future Work
- Estimation Accuracy: While Lina's estimation is effective, it's not perfect. The paper acknowledges that inaccurate estimations can lead to suboptimal resource allocation and that a fine-tuning phase is necessary to correct for these deviations.
- Overhead: Lina introduces some overhead for tensor partitioning, concatenation, and the estimation/fine-tuning phases in inference. However, the paper argues that these overheads are significantly outweighed by the gains from improved load balancing and communication efficiency.
- Future Work: The authors suggest exploring more sophisticated machine learning models to predict expert selection more accurately, potentially reducing the need for fine-tuning and further improving inference efficiency. They also note that Lina's techniques can be integrated with other communication acceleration methods.
Summary updated