Skip to content
ImagineWorld

Multi-GPU and Multi-Node MoE Deployment

node_idnode-book_mixture-of-experts-architecture-engineering_chapter-08-multi-gpu-and-multi-node-moe-deployment
node_typechapter-node
schema_profileworld.chapter_node.v1
statusactive
entropyhigh
manifoldworld
domainimagineworld.net
authorityinforms
layercorpus
chapter_num8
chapter_titleMulti-GPU and Multi-Node MoE Deployment
governed_byCORPUS
constitutional_citationCONSTITUTION
local graph

Chapter 8 — Multi-GPU and Multi-Node MoE Deployment

Section titled “Chapter 8 — Multi-GPU and Multi-Node MoE Deployment”

Efficiently training and serving large MoE models requires combining multiple parallelism strategies, each targeting a different dimension of the model’s computational structure. Tensor parallelism (TP) splits individual weight matrices across multiple GPUs, allowing very large matrices to be computed in parallel across devices within a single node. Pipeline parallelism (PP) assigns different layers of the model to different GPUs, processing multiple micro-batches in flight simultaneously to maintain high GPU utilization despite the sequential dependency between layers. Expert parallelism (EP), specific to MoE architectures, assigns different experts to different GPUs, processing expert computations in parallel across the expert dimension. Sequence parallelism (SP) distributes the sequence dimension of attention computations across multiple GPUs.

Expert parallelism is the most MoE-specific parallelism strategy and deserves detailed treatment. In expert parallelism with degree EP, the E experts in each MoE layer are divided into EP groups, each group residing on a different GPU. When a token in layer i is routed to expert j, it must be dispatched to the GPU hosting expert j, processed by that expert, and the result gathered back to the originating GPU. This dispatch-and-gather operation is implemented as two all-to-all collective operations - one for dispatch, one for gather - and is the primary communication bottleneck in expert parallelism. The communication volume per all-to-all scales as O(B * d_model * EP) where B is the batch size and d_model is the hidden dimension.

The optimal combination of parallelism strategies depends critically on the hardware topology of the training or serving cluster. Within a single NVLink-connected node, tensor parallelism can exploit the high NVLink bandwidth (up to 600 GB/s bidirectional on NVLink 4.0) with relatively low latency, making TP degrees of 4 or 8 efficient for large weight matrices. Across nodes connected by InfiniBand, the available bandwidth is typically 400-800 GB/s per node (with HDR or NDR InfiniBand) but is shared by all GPUs on the node, making inter-node all-to-all communication significantly more expensive per byte than intra-node NVLink. Optimal parallelism configurations therefore typically prefer to maximize TP within nodes and minimize EP across nodes, keeping the expensive all-to-all communication within the high-bandwidth NVLink fabric where possible.

Hierarchical expert parallelism, introduced in several large-scale MoE training systems, exploits the two-level hierarchy of intra-node and inter-node connectivity. In hierarchical EP, experts are first distributed within a node using fast NVLink all-to-all, then the results are aggregated across nodes using slower InfiniBand all-reduce. This approach can reduce the inter-node communication volume by a factor proportional to the intra-node EP degree, significantly improving communication efficiency at the cost of more complex dispatch logic. Google’s GLaM training and DeepSpeed’s MoE implementation both use hierarchical communication strategies for large-scale MoE training.

Gradient communication in MoE training is complicated by the fact that different experts are updated by different token subsets, creating a non-uniform gradient computation graph. In data parallel training, gradients must be all-reduced across all data-parallel replicas after each forward-backward pass. For expert parameters, this all-reduce can be deferred until after the expert computation on all replicas is complete, which may happen at different times for experts with different utilization rates. Efficient gradient communication for MoE therefore requires asynchronous gradient all-reduce that does not stall the training pipeline waiting for all expert gradients to be available simultaneously, which is not required in dense model training.

NVLaink Interconects
NODE 0 ┌──────────────────────┐ NODE 3
┌───────────────┐ │ ┌───────────────┐
│ GPU ⇄ GPU │ │ │ GPU ⇄ GPU │
│ ⇅ ╳ ⇅ │ │ │ ⇅ ╳ ⇅ │
│ GPU ⇄ GPU │ │ │ GPU ⇄ GPU │
└───────────────┘ │ └───────────────┘
IInfiniBamections ────┼──── NVLink Interncnects (lines from every GPU meet at the centre)
┌───────────────┐ │ ┌───────────────┐
│ GPU ⇄ GPU │ │ │ GPU ⇄ GPU │
│ ⇅ ╳ ⇅ │ │ │ ⇅ ╳ ⇅ │
│ GPU ⇄ GPU │ │ │ GPU ⇄ GPU │
└───────────────┘ │ └───────────────┘
NODE 1 └──────────────────────┘ NODE 3
InfiniBand Connections

Expert-to-GPU Assignment

Expert IDAssined GUS
Expert 0NODE 0: GPU 0,1
Expert 1NODE 0: GPU 2,3
Expert 2NODE 1: GPU 4,5
Expert 4NODE 5: GPU 6,5
Expert 8NODE 2: GPU 6,7
Expert 10NODE 2: GPU 0,7
10: bo 11NODE 2: GPU 6,7
Expert 14NODE 3: GPU 6,7
Expert 15NODE 3: GPU 6,7

[!visual-conversion] Four nodes of four fully connected GPUs, joined by NVLink and InfiniBand, plus the assignment table. All labels are transcribed as printed, including the figure’s own errors (“NVLaink Interconects”, “IInfiniBamections”, two nodes labelled NODE 3, a “NODE 5”, “Assined GUS”, “10: bo 11”). Lost: the exact fan of lines through the centre.

The all-to-all collective operation is the dominant communication cost in expert-parallel MoE training and serving, and its optimization has been a major focus of MoE systems research. In the standard all-to-all, each participating GPU sends a unique message to every other participating GPU and receives a unique message from every other GPU simultaneously. The communication volume is O(N^2) where N is the number of participating GPUs, and the latency is determined by either the bandwidth or the message latency depending on message size. For typical MoE batch sizes and hidden dimensions, the all-to-all bandwidth is the bottleneck, making the optimization of bandwidth utilization the primary systems goal.

DeepSpeed’s MoE implementation introduced hierarchical all-to-all that first performs all-to-all within each node using fast NVLink, then between nodes using InfiniBand, reducing the amount of data that must cross the slower inter-node links. The hierarchical approach works correctly when experts are arranged such that the intra-node all-to-all covers most of the routing locality - a condition that holds naturally if experts are assigned to GPUs on the same node that processes the same types of tokens. Measuring and exploiting this locality requires profiling the routing patterns of the target workload to inform the expert assignment strategy.

Overlap of communication and computation is the primary technique for hiding all-to-all latency behind useful computation. In standard sequential MoE execution, the expert dispatch all-to-all must complete before expert computation can begin, and the expert gather all-to-all must complete before the output can be combined. By restructuring the computation to overlap these operations - beginning the dispatch communication for the next micro-batch while processing the current micro-batch, and beginning the expert computation for dispatched tokens as they arrive rather than waiting for all tokens to arrive - the effective all-to-all latency can be significantly reduced. Achieving this overlap requires sophisticated scheduling of micro-batch operations and careful memory management to avoid conflicts between overlapping communication and computation.

Expert capacity imbalance has direct implications for all-to-all communication efficiency. When some experts receive many more tokens than others, the all-to-all messages are variable-size, and the communication is bottlenecked by the largest message. Padding all messages to the size of the largest (capacity) message wastes bandwidth proportional to the degree of imbalance. Variable-size all-to-all implementations that avoid padding can improve bandwidth efficiency but require more complex communication scheduling. The relationship between load balancing quality (achieved through auxiliary loss and routing design) and communication efficiency is therefore direct: better load balancing produces more uniform message sizes and better all-to-all efficiency.

Flash communication, analogous to FlashAttention, is an emerging approach to all-to-all optimization that fuses the dispatch, expert computation, and gather operations into a single CUDA kernel with optimal memory access patterns. Standard implementations of these operations involve multiple separate kernel launches with intermediate results written to and read from HBM memory. Fused implementations that keep intermediate results in shared memory (SRAM) can dramatically reduce the number of HBM accesses, improving throughput in the same way that FlashAttention reduces attention computation memory traffic. Early implementations of fused MoE dispatch-compute-gather kernels show 30-50 percent throughput improvements over unfused baselines on representative workloads.

moea-fig-8-all-to-all-performance.png

All-to-All Communication Performance in MoE Training: all-to-all throughput (fraction of peak bandwidth) against the number of GPUs in the expert-parallel group, for Standard, Hierarchical and Overlapped All-to-All. All-to-All Communication Performance in MoE Training Standard All-to-All Hierarchical All-to-All Overlapped All-to-All

Fault Tolerance and Checkpointing for Large MoE Runs

Section titled “Fault Tolerance and Checkpointing for Large MoE Runs”

Training very large MoE models over extended periods - weeks or months on thousands of GPUs - requires robust fault tolerance mechanisms to minimize the compute wasted when hardware failures occur. GPU failures, network link failures, and storage system failures are all common at scale, and a training run that restarts from scratch after each failure is economically untenable. Checkpoint-and-restart is the standard fault tolerance strategy: the model state is periodically written to persistent storage, and the training run resumes from the most recent checkpoint when a failure occurs. The checkpoint frequency is a trade-off between the I/O overhead of frequent checkpointing and the compute wasted by restarting from a stale checkpoint after a failure.

Asynchronous checkpointing is essential for minimizing the performance impact of the checkpoint operation in large-scale MoE training. In synchronous checkpointing, all training processes stop simultaneously, serialize the model state, and write it to storage before resuming training. This can cause training pauses of tens of minutes for very large models, wasting GPU time and disrupting the training throughput. In asynchronous checkpointing, a background process copies the model state to CPU memory while training continues on the GPU, then writes the CPU copy to storage in parallel with ongoing training. The memory overhead of keeping both the current model state and the checkpoint copy in CPU memory must be considered in cluster memory planning.

Expert-specific checkpointing strategies for MoE models must handle the fact that expert weights are distributed across multiple GPUs in expert-parallel training. A complete checkpoint requires collecting the expert weights from all expert-parallel GPUs onto storage nodes, which involves significant data movement. Distributed checkpointing, where each GPU writes its own shard of the checkpoint independently to distributed storage, avoids this data movement bottleneck but requires the checkpoint infrastructure to support sharded reading and writing with appropriate consistency guarantees. Modern distributed storage systems like Lustre, GPFS, and AWS S3 support high-bandwidth parallel I/O that can sustain checkpoint write rates of hundreds of GB/s for large cluster configurations.

Checkpoint size management is an ongoing challenge for MoE training runs that may produce checkpoint files measured in terabytes. A 236 billion parameter MoE model in bfloat16 requires approximately 472 GB per checkpoint, and full optimizer state (including Adam moments in fp32) brings the total to approximately 1.9 TB per checkpoint. Checkpointing every 1,000 steps and retaining the last 10 checkpoints requires approximately 19 TB of checkpoint storage for a single training run, which may be the binding constraint on checkpoint frequency for storage-constrained deployments. Differential checkpointing - storing only the parameters that changed since the last checkpoint - can reduce checkpoint size for training runs where most parameters change by small amounts between checkpoints.

Fault Tolerance for Large-Scale MoE Training
Asynchronous Checkpoint Operations │ GPU Failure Event ⤴ Restart from Most Recent Checkpoint
─────────────────────────────────────┼▒▒▒▒▒──────────────────────────────▶ Training Steps
Asynchronous Checkpoint Operations └ Compute Waste Calculation: Lost Progress Asynchronous Checkpoint Operations
Storage Hierachy
Training GPUs ─────────▶ [ Flash Storage (Hot) ] ──▶ Recent Checkpoints
│
▼
Training Cluster GPUS ─▶ [ Object Storage Cold ] ──▶ Full History/Backup

[!visual-conversion] Both parts are transcribed with their labels as printed (“Hierachy”, “Storage Cold”). Lost: the dashed checkpoint ticks on the timeline and the small storage icons.