MPipeMoE: Memory Efficient MoE for Pre-trained Models with Adaptive Pipeline Parallelism

Zheng Zhang, Donglin Yang, Yaqi Xia, Liang Ding, Dacheng Tao, Xiaobo Zhou, Dazhao Cheng · DOI

Abstract

Recently, Mixture-of-Experts (MoE) has become one of the most popular techniques to scale pre-trained models to extraordinarily large sizes. Dynamic activation of experts allows for conditional computation, increasing the number of parameters of neural networks, which is critical for absorbing the vast amounts of knowledge available in many deep learning areas. However, despite the existing system and algorithm optimizations, there are significant challenges to be tackled when it comes to the inefficiencies of communication and memory consumption. In this paper, we present the design and implementation of MPipeMoE, a high-performance library that accelerates MoE training with adaptive and memory-efficient pipeline parallelism. We analyze the memory footprint breakdown of MoE training and identify that activations and temporary buffers are the primary contributors to the overall memory footprint. Toward memory efficiency, we propose memory reusing strategies to reduce memory requirements by eliminating memory redundancies. We implement MPipeMoE upon PyTorch and evaluate it with common MoE models. Compared with the state-of-art approach, MPipeMoE achieves up to 2.8x speedup and reduces memory footprint by up to 47% in training large models.

The Challenges of Scaling MoE

Scaling neural networks to trillions of parameters often relies on Mixture-of-Experts (MoE) architectures, which use "conditional computation" to activate only a fraction of the model for any given input. While MoE is computationally efficient, it introduces two massive hurdles:

  1. Communication Overhead: Training requires "All-to-All" operations to dispatch tokens to specific experts across different GPUs. This often becomes the primary performance bottleneck.
  2. Memory Exhaustion: As models grow, the memory required for activations and temporary buffers (needed for the backward pass) quickly exceeds the capacity of GPU DRAM, especially with large batch sizes.
Memory footprint breakdown across different MoE models, highlighting the dominance of activations and temporary buffers as model size and utilization scale.

Methods: Adaptive Pipelining and Memory Reuse

The authors introduce three core components in MPipeMoE to address these inefficiencies:

Adaptive Pipeline Parallelism

The system divides a mini-batch of tokens into multiple micro-batches. This allows the system to overlap the "All-to-All" communication of one micro-batch with the computation of another. Crucially, MPipeMoE uses an online search algorithm to find the optimal number of partitions ($n$) at runtime. Unlike previous methods that split data along the device dimension, MPipeMoE splits along the batch dimension (B-dimension), allowing the continued use of highly optimized NCCL primitives for All-to-All operations.

Comparison of standard pipeline parallelism (GPipe) and the overlapping of communication (S/R) with computation (C) enabled by micro-batching.

Memory Reusing Strategies

In standard pipeline parallelism, memory sits idle ("bubbles") while waiting for different partitions to activate. MPipeMoE "compresses" these bubbles by sharing the same physical memory buffer across different micro-batch partitions.

Adaptive Selection Component

Since reusing memory overwrites data needed for the backward pass, the system must "restore" it. The authors developed a performance model to choose between four strategies (S1–S4) involving different combinations of CPU offloading, re-computation, and re-communication. The model selects the strategy that minimizes total execution time based on current hardware bandwidth and computation speeds. A key insight is that re-computing a tensor can sometimes be faster than fetching it from CPU memory if the GPU's computation units are idle while the PCIe bus is saturated.

Key Results

Evaluations were performed on a physical cluster of 8 NVIDIA DGX A100 servers using MoE-configured GPT-3 and BERT architectures.

  • Throughput: MPipeMoE achieved up to 2.8x speedup over FasterMoE and significantly outperformed the baseline FastMoE.
  • Memory Efficiency: The system reduced the peak memory footprint by up to 47%. This allows researchers to train much larger models or use significantly larger batch sizes on the same hardware. The actual memory savings achieved were within 95% of the theoretical bound derived by the authors.
  • Granularity: The adaptive algorithm successfully identified that as batch sizes increase, finer-grained pipelining (more micro-batches) is required to maintain high GPU utilization.

Conclusion

MPipeMoE demonstrates that the communication and memory bottlenecks of MoE training can be significantly mitigated through intelligent, adaptive system design. By overlapping communication with computation and aggressively reusing memory buffers, MPipeMoE enables more efficient scaling of the next generation of massive pre-trained models.

Summary updated

BibTeX
@inproceedings{zhang2023mpipemoe,
  author = {Zheng Zhang and Donglin Yang and Yaqi Xia and Liang Ding and Dacheng Tao and Xiaobo Zhou and Dazhao Cheng},
  title = {{MPipeMoE: Memory Efficient MoE for Pre-trained Models with Adaptive Pipeline Parallelism}},
  booktitle = {IPDPS},
  year = {2023},
  doi = {10.1109/ipdps54959.2023.00026},
}
Figure