Scaling Beyond the GPU Memory Limit for Large Mixture-of-Experts Model Training

Yechan Kim, Hwijoon Lim, Dongsu Han

Introduction

ES-MoE is a novel training framework designed to break the "GPU memory wall" for Mixture-of-Experts (MoE) models by offloading expert parameters to CPU memory and SSDs. By combining pipelined data transfers with a dynamic expert placement strategy that eliminates wasted computation, ES-MoE achieves up to 67× better scalability and 17.5× higher throughput than existing offloading frameworks.

The Challenge of Scaling MoE

Mixture-of-Experts (MoE) models are highly effective for large-scale AI because they decouple a model's total parameter count from its computational cost. In an MoE layer, only a small subset of "experts" (sub-networks) is activated for any given input token. This allows for massive models that remain relatively fast to execute.

However, scaling these models presents two major hurdles:

  1. The Memory Wall: Even if computation is restricted to a few experts, the system must still store all of them. Standard "expert parallelism" requires adding more GPUs just to hold the parameters, making it nearly impossible for researchers with limited hardware to train state-of-the-art MoE models.
  2. Load Imbalance: Input tokens are rarely distributed evenly across experts. Some experts are overloaded with tokens while others sit idle. Existing systems handle this by "zero-padding" batches to a uniform size, which wastes significant GPU cycles and memory on useless computations.

The ES-MoE Framework

The authors introduce ES-MoE, which treats GPU memory as a cache rather than a permanent home for experts. Its core components include:

  • Expert-wise Offloading & Pipelining: Instead of loading an entire layer of experts at once, ES-MoE loads them sequentially. It utilizes a sophisticated pipeline to overlap the time spent moving expert weights from the CPU to the GPU with the time the GPU spends computing the previous expert's tokens.
Pipelined expert optimization overlapping GPU computation and CPU communication
  • Dynamic Expert Placement: Unlike traditional systems where an expert is statically assigned to a specific GPU, ES-MoE decides where to place an expert on-the-fly based on the actual token load from the gating network. It uses a greedy scheduling algorithm (a 4/3-approximation of the minimum makespan problem) to balance the workload across all available GPUs.
Comparison of traditional static expert placement with zero-padding versus ES-MoE's dynamic expert placement
  • Expert-wise CPU Optimization: To handle the massive memory footprint of optimizer states (which can be up to 6× larger than the model itself), ES-MoE offloads them to the CPU. It initiates CPU-side weight updates as soon as an individual expert finishes its backward pass, rather than waiting for the entire layer to finish.
  • Adaptive Offloading & Pinning: If a model fits entirely in GPU memory, ES-MoE keeps it there. As the model grows, it begins offloading. It also "pins" the most frequently used experts (the top 25%) to the GPU to minimize data transfer overhead.

Key Insights and Results

The researchers evaluated ES-MoE using GPT-derived MoE models (ranging from MoE-S to MoE-XL) on WikiText-103 for pre-training, and GLUE Benchmarks (SST-2, MNLI) & BoolQ for fine-tuning. They demonstrated that ES-MoE can fine-tune a 15B parameter model to high accuracy in just 6.5 hours using only 4 GPUs.

  • Eliminating Zero-Padding: By dynamically placing experts based on token load, ES-MoE completely removes the need for zero-padding. In baselines with 32 experts, up to 39% of computations are wasted on padding; ES-MoE reclaims this efficiency.
  • Sequential vs. Batched Execution: Most frameworks use Batched Matrix Multiplication (BMM) for experts, requiring all experts to be in memory simultaneously. ES-MoE's sequential approach saves enormous amounts of memory, allowing for much larger microbatches.
  • Scalability: ES-MoE successfully trained a 29B parameter model on just 4 GPUs. For context, existing frameworks like FairSeq or Tutel would run out of memory (OOM) at this scale.
  • Throughput and Efficiency: Compared to generic offloading (like ZeRO-Offload), ES-MoE provides up to 11.6× to 17.5× better throughput. It also achieves a 2.13× speedup over Tutel by eliminating the overhead of load imbalance and zero-padding, all while maintaining mathematical equivalence to standard training.

Limitations and Future Work

While highly effective, the framework has constraints. The CPU-side Adam optimizer is significantly slower than a GPU-side one, meaning CPU bottlenecks can occur on very small models (mitigated by adaptive offloading). Additionally, the system relies heavily on PCIe bandwidth for moving experts; performance may degrade on older hardware with slower interconnects. Finally, while SSD offloading is supported for models exceeding ~100 experts, the performance impact of deep SSD prefetching at extreme scales remains an area for further exploration.

Summary updated

BibTeX
@inproceedings{kim2024scaling,
  author = {Yechan Kim and Hwijoon Lim and Dongsu Han},
  title = {{Scaling Beyond the GPU Memory Limit for Large Mixture-of-Experts Model Training}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=uLpyWQPyF9},
}
Figure