C-LIGHT telephone TEL:+86 132 6656 7067    
Language
C-LIGHT search
Industry News

All-to-All Communication Patterns in Distributed AI Inference

By C-LIGHT Marketing 丨 Mar 26, 2025
Table of Contents

    All-to-All-Communication-Patterns-in-Distributed-AI-Inference.jpg

    Distributed AI inference increasingly relies on Mixture of Experts (MoE) models, where different expert networks are distributed across multiple GPUs. When a router assigns tokens to experts hosted on different devices, the inference system must transfer token data to the appropriate GPUs and return the computed results. This creates an All-to-All communication pattern that can significantly influence inference latency, throughput and cluster scalability. Its performance depends not only on network bandwidth, but also on token distribution, expert placement, message size, communication scheduling and the efficiency of dispatch and combine operations.

    1. Why All-to-All Communication Matters in Distributed AI Inference

    Large AI inference systems often distribute model computation across multiple GPUs to accommodate model size, increase serving capacity and process concurrent requests. Dense models generally follow relatively predictable tensor-parallel or pipeline-parallel communication patterns. MoE models introduce an additional requirement: tokens must be routed dynamically to selected expert networks.

    When experts are distributed across GPUs, a token generated on one GPU may need to be processed by an expert on another GPU. The system must exchange token activations, execute the expert computation and return the results to the original sequence or request context.

    This process creates two major communication phases:

    • Dispatch: Sends tokens and associated routing information to the GPUs hosting their selected experts.

    • Combine: Returns expert outputs to the appropriate source ranks and reconstructs the required token order and weighted results.

    These operations form the core All-to-All communication path in many expert-parallel inference deployments. As the number of GPUs and concurrent requests increases, communication efficiency becomes an important factor in overall serving performance.

    2. How MoE Routing Creates All-to-All Traffic

    A Mixture of Experts layer contains multiple expert networks and a router. Instead of sending every token through every expert, the router selects a subset of experts for each token, commonly determined by a Top-K routing configuration.

    For example, a Top-2 configuration selects two experts for each token. If those experts are located on different GPUs, the token's activation data must be transferred to the corresponding devices.

    Consider a simplified deployment with four GPU ranks:

    • GPU 0 hosts Experts 0 and 1.

    • GPU 1 hosts Experts 2 and 3.

    • GPU 2 hosts Experts 4 and 5.

    • GPU 3 hosts Experts 6 and 7.

    If a token is assigned to Expert 1 and Expert 6, its activation data must reach GPU 0 and GPU 3. Other tokens in the same batch may be assigned to entirely different combinations of experts.

    As a result, each GPU may send data to several other GPUs and receive data from multiple sources. This many-to-many exchange is the defining characteristic of All-to-All communication.

    3. The Dispatch and Combine Process

    The All-to-All process is generally organized around the execution of an MoE layer.

    StageOperationData involvedPurpose
    1. RouterExpert selectionToken representations, expert indices and routing weightsDetermines which experts process each token
    2. DispatchAll-to-All exchangeToken activations and routing metadataTransfers tokens to the ranks hosting selected experts
    3. Expert computationLocal grouped computationReceived token batchesRuns the assigned expert networks
    4. CombineReturn exchangeExpert outputs and routing informationReturns results to the originating ranks
    5. AggregationWeighted combinationReturned expert outputs and router weightsReconstructs the final MoE layer output

    Dispatch and combine are closely related but are not identical operations. Dispatch distributes tokens according to expert ownership. Combine performs the reverse mapping, returning expert results and applying the required aggregation.

    Efficient implementations can integrate data movement, token permutation and buffer placement into optimized communication kernels. This reduces intermediate processing and unnecessary memory traffic.

    4. All-to-All vs AllGather and ReduceScatter

    All-to-All is not the only way to distribute data across expert-parallel ranks. Some implementations use AllGather followed by ReduceScatter to achieve related communication behavior.

    With AllGather, each rank receives data from all participating ranks. This can distribute more token data than necessary when each token is routed to only a small subset of experts. ReduceScatter then combines partial results and distributes output segments among ranks.

    Direct All-to-All dispatch can avoid sending a token to ranks that do not host any of its selected experts.

    Communication patternData movementPotential advantageConsideration
    AllGather + ReduceScatterBroad data exchange across participating ranksCan be useful for particular parallel layouts and implementationsMay transfer data to ranks that do not own selected experts
    All-to-All dispatch and combineRoutes tokens to ranks hosting selected expertsCan avoid unnecessary distribution when Top-K is much smaller than EP sizeRequires efficient routing, packing and receive-buffer management
    Fused or specialized exchangeCombines communication with selected data-processing operationsCan reduce intermediate buffers and kernel overheadDepends on hardware, software backend and workload support

    The appropriate approach depends on expert placement, parallelism configuration, message size and the communication backend. All-to-All is not automatically faster in every deployment.

    5. Communication Volume and Top-K Routing

    The amount of data exchanged by an MoE layer depends on the number of tokens, hidden-state dimensions, activation precision and routing configuration.

    For a simplified dispatch model, the approximate activation payload sent to selected experts can be expressed as:

    Dispatch payload:

    \(V_{\text{dispatch}}\approx T\times K\times H\times S\)

    Where T is the number of local tokens, K is the number of selected experts per token, H is the hidden-state dimension and S is the number of bytes per activation element.

    This expression assumes that each token-to-expert assignment is counted as a separate payload. Actual network traffic may differ because of local expert assignments, packing, quantization, metadata, padding, protocol overhead and implementation-specific buffer layouts.

    For example, a Top-2 routing configuration can generate up to two expert assignments per token. When the expert-parallel group contains many more ranks than the Top-K value, direct routing may avoid distributing every token to every rank.

    However, Top-K alone does not determine communication cost. The number of tokens assigned to each destination rank and the proportion of local versus remote expert assignments are also important.

    6. Expert Parallelism and GPU Placement

    Expert Parallelism (EP) distributes different expert networks across multiple GPU ranks. Each rank stores and executes a subset of the experts, while the router determines where each token should be processed.

    When EP spans multiple GPUs within a server, communication may use high-bandwidth GPU interconnects such as NVLink, depending on the platform. When experts are distributed across servers, token exchange may traverse the network fabric through RDMA-capable adapters and high-speed switching infrastructure.

    The physical placement of experts therefore affects the communication path:

    • Same GPU: The selected expert can process the token locally without inter-GPU network transfer.

    • Same server: Data may move through a high-bandwidth intra-node GPU interconnect.

    • Different servers: Data generally traverses NICs and the data center switching fabric.

    Good placement can increase locality and reduce expensive cross-node transfers. Poor placement may concentrate traffic on a small number of network links or create uneven communication demand between servers.

    7. Intra-Node and Inter-Node All-to-All

    Distributed inference systems often use a combination of intra-node and inter-node communication. These two domains have different bandwidth, latency and resource characteristics.

    CharacteristicIntra-node exchangeInter-node exchange
    Physical pathGPU-to-GPU links within a serverGPU, NIC, switch and remote NIC path
    Common interconnectNVLink or other supported accelerator interconnectsInfiniBand or Ethernet-based RDMA networking
    Communication overheadDepends on GPU topology, link utilization and memory movementAlso includes NIC, transport and network-fabric overhead
    Scaling concernGPU interconnect bandwidth and topologyNetwork bandwidth, routing, congestion and endpoint placement
    Optimization focusLocality and efficient GPU data movementMessage aggregation, path utilization and communication scheduling

    A hybrid design can keep frequently communicating experts within a server or high-bandwidth domain while using the data center network for remote expert traffic. This approach requires balancing model placement, GPU utilization and the capacity of the available interconnects.

    8. All-to-All Communication During Prefill and Decode

    Inference workloads commonly contain two phases: prefill and decode. Their token counts and communication characteristics can differ significantly.

    Prefill phase

    During prefill, the model processes the input prompt. A request may contain many input tokens, creating a relatively large batch of tokens for MoE routing. Dispatch and combine can therefore involve substantial data movement.

    When multiple prompts are processed together, the number of tokens routed through the expert-parallel group may increase further. This can make aggregate communication bandwidth an important performance factor.

    Decode phase

    During decode, the model generates output tokens iteratively. Each sequence typically contributes a smaller number of newly generated tokens per step than during prefill, although continuous batching can combine tokens from many active sequences.

    Smaller communication messages can make latency, kernel launch overhead and synchronization more visible. A communication backend optimized for large data transfers may not be the best choice for small decode batches.

    The system should therefore evaluate prefill and decode separately rather than assuming that one All-to-All configuration is optimal for both phases.

    9. Token Distribution and Expert Load Imbalance

    All-to-All traffic is influenced by how the router distributes tokens across experts. Even when each token selects the same number of experts, different experts may receive very different numbers of tokens.

    If one GPU hosts several heavily selected experts, it may receive substantially more data than other ranks. This creates an imbalance in both communication volume and expert computation.

    Potential consequences include:

    • Uneven receive-buffer sizes across ranks.

    • Longer processing time on overloaded expert GPUs.

    • Idle periods on ranks that finish their expert computation earlier.

    • Uneven utilization of NICs and network links.

    • Higher tail latency for requests affected by overloaded destinations.

    Expert load balancing can address some of these problems through improved expert placement, redundant expert copies or runtime reassignment mechanisms where supported. These techniques must be evaluated alongside model accuracy, memory consumption and communication overhead.

    10. Communication Latency and Message Size

    All-to-All performance depends on both the amount of data transferred and the time required to coordinate the exchange.

    For a simplified communication model, the time required to transfer a message can be approximated as:

    \(T_{\text{comm}}\approx \alpha+\frac{V}{B_{\text{eff}}}\)

    Where \(\alpha\) represents fixed communication overhead, V is the transferred data volume and \(B_{\text{eff}}\) is the effective bandwidth.

    This is a simplified model. Real All-to-All operations involve multiple destinations, synchronization, routing, message scheduling, memory operations and possible contention. Their performance cannot always be represented by a single message-size equation.

    For small token batches, fixed overhead may dominate. For larger batches, effective bandwidth and congestion become more important.

    Inference systems must therefore optimize both latency and throughput, rather than focusing exclusively on peak network bandwidth.

    11. Network Topology and All-to-All Traffic Distribution

    All-to-All communication can place traffic across many pairs of GPU ranks. The network topology determines the physical paths used to carry this traffic.

    A leaf-spine Clos fabric provides multiple paths between different leaf groups and can scale to large endpoint populations. However, the actual performance depends on uplink capacity, routing behavior and the distribution of destination traffic.

    Important topology considerations include:

    • Leaf uplink capacity: Determines how much traffic can leave each server-facing switch.

    • Spine capacity: Determines aggregate bandwidth between leaf groups.

    • Path diversity: Provides multiple routes for distributed traffic.

    • Oversubscription: Can limit simultaneous inter-server communication.

    • Network locality: Determines whether frequently communicating ranks are connected through shorter or higher-bandwidth paths.

    A balanced fabric helps reduce capacity bottlenecks, but it does not eliminate localized congestion when many token transfers target the same expert rank or network output.

    12. InfiniBand and RoCE for Distributed Inference

    High-performance All-to-All communication often relies on efficient data movement between GPUs across server boundaries. RDMA-capable networking can reduce CPU involvement and provide low-overhead data transfer when supported by the hardware and software stack.

    Design areaInfiniBandRoCE over Ethernet
    Network infrastructureInfiniBand switches and compatible adaptersEthernet switches and RDMA-capable NICs
    Data movementInfiniBand transport and RDMA capabilitiesRDMA over Converged Ethernet
    Congestion managementInfiniBand-specific fabric and congestion mechanismsOften uses ECN-based congestion signaling and transport response; PFC may be used where required
    Scaling considerationsFabric routing, adapter configuration and network capacityQoS, ECN, queue management, routing and end-to-end consistency
    Deployment focusDedicated high-performance interconnect infrastructureHigh-performance Ethernet integrated with data center networking

    Both approaches can support distributed AI inference. The appropriate choice depends on existing infrastructure, endpoint support, operational requirements and workload characteristics.

    For RoCE deployments, congestion management should be designed across the complete network path. PFC should not be treated as a substitute for adequate capacity planning or effective congestion control.

    13. All-to-All Communication Backends and Optimized Kernels

    Modern inference frameworks provide different communication backends to implement expert-parallel token exchange. These implementations can differ in their data movement model, synchronization behavior, memory layout and optimization target.

    Backend or approachGeneral characteristicsTypical consideration
    NCCL-based All-to-AllUses collective communication primitives for distributed token exchangePerformance depends on topology, message size and collective configuration
    DeepEPProvides specialized expert-parallel communication kernels for dispatch and combineSupports different throughput and latency-oriented communication paths
    One-sided All-to-AllUses direct remote memory operations where supportedCan reduce handshake and intermediate data-movement overhead
    Two-sided exchangeCoordinates sending and receiving operations between ranksRequires suitable synchronization and buffer management
    Fused communication and computationCombines selected data movement with expert processingCan reduce intermediate kernel and memory overhead, subject to workload support

    There is no universally optimal backend. The best implementation depends on GPU architecture, interconnect topology, expert-parallel group size, token count, activation precision and inference latency targets.

    Framework support also changes over time. Backend availability and configuration options should be checked against the deployed version of the inference framework rather than assumed to be identical across releases.

    14. Buffer Management and Token Permutation

    Before token activations can be exchanged, they must be organized according to their destination ranks and experts. This commonly involves counting assignments, calculating offsets and placing token data into communication buffers.

    After receiving the data, each rank organizes tokens into groups suitable for its local expert computations. Following expert execution, the outputs must be mapped back to their original source ranks and token positions.

    Buffer management affects both performance and memory usage:

    • Receive capacity: Must accommodate the expected number of tokens arriving at each rank.

    • Token ordering: Must preserve the mapping between tokens, experts and source ranks.

    • Padding: May be required for alignment or efficient grouped computation.

    • Temporary memory: Additional buffers can increase GPU memory consumption.

    • Synchronization: Communication and computation must coordinate access to shared buffers.

    Optimized implementations can combine permutation with communication to reduce extra memory operations. However, buffer sizing must still account for uneven token distribution and workload variability.

    15. Quantization and Its Effect on Communication Volume

    Inference systems frequently use reduced-precision formats to lower memory consumption and improve computation efficiency. The activation format also affects the amount of data exchanged during All-to-All communication.

    For the same number of token elements, a lower-byte representation can reduce the raw activation payload. For example, BF16 and FP16 commonly use two bytes per element, while FP8 uses one byte per element.

    However, actual communication formats may include additional scale information, metadata or packing requirements. Some implementations also convert activations before dispatch or after receiving them.

    FormatTypical storage per elementCommunication consideration
    FP324 bytesHigher payload size
    BF162 bytesCommon reduced-precision activation format
    FP162 bytesCommon reduced-precision activation format
    FP81 byteMay require scale metadata and format-specific handling
    FP4Typically 0.5 byte per value when packedMay require additional scaling information and specialized packing

    Reduced payload size can improve communication efficiency, but quantization must preserve the numerical behavior required by the model. Communication optimization and model precision should be evaluated together.

    16. Prefill and Decode Require Different Communication Strategies

    Prefill and decode have different workload characteristics, so an All-to-All implementation optimized for one phase may not be ideal for the other.

    FactorPrefillDecode
    Token volumeOften larger due to prompt processingUsually fewer new tokens per sequence per iteration
    Communication patternCan generate larger dispatch and combine payloadsCan involve frequent smaller exchanges
    Primary concernAggregate throughput and efficient data movementLatency, synchronization and per-step overhead
    BatchingPrompt batching can create large token groupsContinuous batching combines active sequences
    Optimization focusHigh-throughput communication kernelsLow-latency exchange and reduced coordination overhead

    Disaggregated serving architectures may also separate prefill and decode resources. In those systems, the expert-parallel communication pattern must be considered alongside the data transfer between serving stages.

    17. Common All-to-All Performance Bottlenecks

    Uneven expert assignments

    Some expert ranks receive more tokens than others, increasing their communication and computation time.

    Insufficient inter-node bandwidth

    Cross-server traffic may exceed the available uplink or network-fabric capacity, especially when expert placement creates many remote assignments.

    Small-message overhead

    During decode, smaller token batches can make synchronization and kernel launch overhead more significant than raw bandwidth.

    Excessive data movement

    Unnecessary replication, repeated permutation or inefficient buffer layouts can increase memory traffic and communication volume.

    Network congestion

    Destination hotspots and uneven routing can cause localized queue buildup even when aggregate fabric capacity appears sufficient.

    GPU and NIC imbalance

    Different GPU-to-NIC paths or unequal endpoint capabilities can prevent ranks from achieving consistent communication performance.

    18. Measuring All-to-All Performance in Inference Systems

    Performance evaluation should measure the complete dispatch and combine path rather than relying only on theoretical network bandwidth.

    MetricWhat it measuresWhy it matters
    Dispatch latencyTime required to distribute tokens to expert ranksIdentifies overhead before expert computation
    Combine latencyTime required to return expert outputsMeasures the cost of result aggregation
    Effective bandwidthUseful payload transferred per unit of timeShows actual communication efficiency
    Per-rank token countNumber of tokens received by each expert rankReveals routing imbalance
    GPU utilizationCompute activity during expert executionShows whether communication leaves GPUs waiting
    Network utilizationTraffic on NICs and switch portsIdentifies constrained links and uneven path usage
    Queue and congestion metricsNetwork queue occupancy and congestion signalsHelps distinguish capacity problems from endpoint limitations
    End-to-end inference latencyRequest processing timeConnects communication performance to user-visible serving behavior

    Measurements should cover different batch sizes, sequence lengths, Top-K values and expert-parallel group sizes. Prefill and decode should be evaluated separately, and tail latency should be considered alongside average latency.

    19. Practical Optimization Approaches

    Improving All-to-All communication requires coordination across model placement, GPU topology, network architecture and inference software.

    1. Optimize expert placement: Place frequently communicating experts within suitable high-bandwidth domains where possible.

    2. Balance expert load: Monitor token counts per expert and avoid persistent concentration on a small number of ranks.

    3. Choose suitable parallelism: Evaluate EP size and its interaction with tensor and data parallelism.

    4. Select the appropriate backend: Benchmark available communication implementations for the actual GPU and network configuration.

    5. Reduce unnecessary data movement: Use direct routing and efficient token packing where supported.

    6. Improve buffer management: Minimize redundant copies and use appropriate receive-buffer sizing.

    7. Match communication to workload phase: Evaluate throughput-oriented and latency-oriented paths separately.

    8. Validate the network fabric: Check uplink capacity, path utilization, congestion and physical link health.

    9. Measure end-to-end behavior: Confirm that improvements in dispatch and combine reduce actual inference latency or increase serving throughput.

    Optimization should be based on measured workload behavior. Reducing communication volume may not improve performance if expert computation or synchronization is already the dominant bottleneck.

    20. Conclusion

    All-to-All communication is a central component of distributed MoE inference. It connects token routing with expert execution by moving activations to the GPUs that host selected experts and returning the computed results to their original ranks.

    Its performance depends on token distribution, Top-K routing, expert placement, GPU interconnects, network-fabric capacity, buffer management and communication backend efficiency. Prefill and decode also introduce different communication requirements, making workload-aware optimization important for production inference systems.

    As MoE models and distributed inference clusters continue to scale, efficient dispatch and combine operations will remain essential to controlling communication overhead. A balanced GPU fabric, appropriate expert placement and optimized All-to-All kernels can help maintain predictable performance across increasingly large AI serving deployments.

    Planning high-speed optical connectivity for distributed AI infrastructure?

    Evaluate optical transceiver and interconnect options for GPU clusters, high-bandwidth switching fabrics and scalable data center networks.

    Contact C-LIGHT

    For any questions, please contact us by email or WhatsApp.

    Email: sales@c-light.com

    WhatsApp: +86 132 6656 7067

    Related Articles

    Call
    Top