Large-Scale GPU All-to-All Communication for MoE: Practices and Design Insights

    This article explains why Mixture-of-Experts (MoE) workloads require dedicated communication libraries, covering the dispatch and combine primitives, the trade-off between high-throughput and low-latency modes, compute-communication overlap pitfalls, network-level optimizations for IB and RoCE, and practical deployment recommendations for large-scale expert-parallel systems.

    1. Why MoE Workloads Need a Dedicated Communication Library

    Mixture-of-Experts models use a routing mechanism to dynamically assign each token to a small set of expert networks, scaling model parameters without proportionally increasing compute. This design creates a unique systems challenge: when experts are sharded across different GPUs for expert parallelism, every token must be sent to the remote device hosting its assigned expert, and the results must be aggregated back to the originating device after computation.

    This communication pattern is fundamentally different from gradient synchronization in traditional data parallelism. Gradient synchronization is a regular collective operation with predictable traffic, whereas MoE communication exhibits the following characteristics:

    • Dynamic and imbalanced traffic: token-to-expert assignments vary with the input, and some experts may suddenly receive a surge of requests, creating hotspots;
    • Two all-to-all transfers per layer: the forward pass requires a dispatch operation and a combine operation, both of which must be serialized with expert computation;
    • Latency sensitivity: in inference—especially during the decoding phase—the communication latency of each MoE layer adds directly to end-to-end latency and is hard to hide with batching.

    General-purpose collective communication libraries provide all-to-all primitives but are not deeply optimized for these characteristics. As a result, the industry has converged on a class of communication libraries designed specifically for MoE and expert parallelism, with a dual goal: maximum throughput for large-batch scenarios such as prefill, and minimal latency for small-batch inference.

    2. Core Primitives: Dispatch and Combine

    A typical MoE communication layer exposes two key primitives. Understanding them is the foundation for understanding the entire system.

    2.1 Dispatch

    Dispatch sends tokens from the local GPU to the GPUs hosting their target experts. The internal workflow typically includes:

    1. Computing the token count for each destination device based on the routing table;
    2. Reordering and packing tokens so the send buffer is organized by destination device;
    3. Writing data into the remote device’s receive buffer over RDMA or NVLink;
    4. Reconstructing the input layout required by the local experts on the receiving side.

    In practice, dispatch usually supports transmitting activations in half precision or even lower precision (such as FP8). Since quantized activations typically preserve model accuracy, low-precision transmission can cut communication volume in half or more—a significant win for bandwidth-constrained cross-node communication.

    2.2 Combine

    Combine performs the reverse: outputs produced by expert computation must return to the device where the token originally resided. Because combine transmits expert outputs rather than inputs, its precision handling can be more aggressive—some implementations allow higher-compression quantization of outputs, since the outputs are subsequently fused with gating weights, which dilutes small information losses.

    A schematic call flow looks like this:

    1. # Pseudocode: communication steps in one MoE forward pass
    2. tokens_and_indices = gate(x) # routing decision
    3. recv_x, recv_counts = dispatch(x, tokens_and_indices) # dispatch to expert GPUs
    4. expert_out = local_experts(recv_x) # local expert computation
    5. combined = combine(expert_out) # aggregate results back

    3. Trade-offs Between Throughput Mode and Low-Latency Mode

    MoE communication libraries must serve two very different workloads, so a dual-mode design is common.

    3.1 High-Throughput Mode

    Aimed at training and prefill scenarios, where single transfers are large and some latency is tolerable. This mode typically:

    • Runs sizeable dedicated kernels on SMs to compress data and saturate link bandwidth;
    • Uses NVLink for intra-node transfers and RDMA for cross-node transfers, coordinating both paths;
    • Prioritizes throughput without worrying about GPU compute resource consumption.

    3.2 Low-Latency Mode

    Aimed at small-batch inference, especially the decoding phase, where each all-to-all may move only a tiny amount of data and kernel launch/wait overhead dominates. Key techniques include:

    • Pure RDMA transfer path: bypassing intermediate proxies and extra memory copies to move data across nodes directly;
    • Low-precision transmission: using even narrower bit widths for activations during inference to further reduce latency;
    • Wait-queue-based asynchronous execution: communication kernels stay resident on the GPU, continuously polling for wake signals to avoid repeated kernel launches and synchronization, pushing end-to-end latency into the microsecond range.

    3.3 Unified Interfaces and Resource Optimization

    An important architectural trend is unifying the high-throughput and low-latency APIs behind a single interface, with the runtime automatically selecting the backend and execution path. Meanwhile, runtime just-in-time (JIT) compilation lets kernels be compiled and loaded on demand, eliminating offline pre-building and simplifying deployment. Such refactoring can also significantly reduce the SM footprint of communication kernels, leaving precious compute units for the model itself—under large-scale expert parallelism, this effectively lowers overall hardware cost.

    Another scalability consideration is supporting larger expert-parallel domains. Sharding experts across a thousand or more GPUs greatly raises the capacity ceiling per expert and reduces per-GPU weight memory pressure, but it requires systematic design in routing table management, topology awareness, and fault-domain control.

    4. Compute-Communication Overlap: An Underestimated Optimization

    Whether communication overhead can be effectively hidden directly determines the real-world efficiency of an MoE system. A recurring problem in practice: KV cache transfers across devices and dispatch communication should overlap, yet implementation details prevent effective parallelism, inflating overall overhead by more than 30%.

    The root cause of such issues is often very low-level. A common case: the intra-node data movement path fails to release the Python Global Interpreter Lock (GIL) in a critical section, forcing two transfer stages that should run in parallel—within an otherwise asynchronous pipeline—to execute serially. Diagnosing these problems requires tracing both the Python call chain and the C++ execution path to confirm lock-holding scopes and async task scheduling timing.

    The lessons are broadly applicable:

    • Overlap does not happen automatically: even if every component is asynchronous on its own, lock contention and implicit synchronization points can degrade the pipeline to serial execution;
    • Measure overhead end to end: looking only at individual stage latencies misses the amplification effect of failed overlap;
    • The payoff can be orders of magnitude: fixing the issue above reduced the extra overhead from over 30% to under 1%, with significant cost implications for large-scale inference services.

    5. Network Environment Differences and Link-Layer Optimization

    The same communication code can perform very differently on InfiniBand versus RoCE networks. Practical experience shows common bottlenecks including:

    1. Underutilized dual-port NIC bandwidth: one port saturates while the other sits idle; multiple queues and traffic partitioning are needed to aggregate bandwidth;
    2. CPU control-plane overhead: control information bouncing between GPU and CPU lengthens the path and slows the data plane; control logic should be pushed down and cross-device synchronization minimized;
    3. Insufficient topology awareness: failing to select shortest paths and optimal groupings based on actual network topology leads to localized link congestion.

    Deep optimization against these bottlenecks has repeatedly delivered large performance gains across different network environments—evidence that a communication library’s performance ceiling depends heavily on how finely it adapts to the underlying network.

    6. Deployment Considerations and Practical Recommendations

    Based on the design principles above, teams deploying large-scale MoE systems can start from the following:

    • Choose the mode by workload: prefer throughput mode for training and long-context prefill; always enable the low-latency path for online inference decoding;
    • Enable low-precision communication and validate accuracy: start with half precision, gradually try narrower bit widths, and confirm no accuracy regression on evaluation sets;
    • Proactively check for failed overlap: use distributed tracing tools to verify that KV transfers, dispatch, and expert computation truly overlap on the timeline;
    • Control communication kernel resource usage: monitor how many SMs communication kernels occupy to avoid contention with compute kernels;
    • Match network hardware capabilities: on RoCE, focus on dual-port aggregation and congestion control configuration; for cross-node scenarios, ensure RDMA is available.

    Conclusion

    MoE architectures decouple parameter scale from compute, but at the cost of shifting complexity into the communication layer. A communication layer built for expert parallelism must coordinate across scheduling semantics, low-precision transmission, dual-mode execution, compute-communication overlap, and network adaptation. Understanding these design points not only helps teams make the most of existing open-source solutions, but also provides a clear architectural reference for building large-scale distributed training and inference systems in-house.