NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Exploiting Inter-Layer Expert Affinity for Accelerating Mixture-of-Experts Model Inference

Jinghan Yao, Quentin Anthony, Aamir Shafi, Hari Subramoni, Dhabaleswar K. PandaIPDPS 2024

Abstract

In large language models like the Generative Pre-trained Transformer, the Mixture of Experts (MoE) paradigm has emerged as a powerful technique for enhancing model expressiveness and accuracy. However, deploying GPT MoE models for parallel inference on distributed systems presents significant challenges, primarily due to the extensive Alltoall communication required for expert routing and aggregation. This communication bottleneck exacerbates the already complex computational landscape, hindering the efficient utilization of high-performance computing resources. In this paper, we propose a lightweight optimization technique called ExFlow, to largely accelerate the inference of these MoE models. We take a new perspective on alleviating the communication overhead by exploiting the inter-layer expert affinity. Unlike previous methods, our solution can be directly applied to pre-trained MoE models without any fine-tuning or accuracy degradation. By proposing a context-coherent expert parallelism on distributed systems, our design only uses one Alltoall communication to deliver the same functionality while previous methods all require two Alltoalls. By carefully examining the conditional probability in tokens' routing across multiple layers, we proved that pre-trained GPT MoE models implicitly exhibit a strong inter-layer expert affinity. We then design an efficient integer programming model to capture such features and show that by properly placing the experts on corresponding GPUs, we can reduce up to 67% cross-GPU routing latency. Our solution beats the cutting-edge MoE implementations with experts from 8 to 64, with up to 2.2x improvement in inference throughput.

The Communication Bottleneck in MoE Inference

Large Language Models (LLMs) often utilize a Mixture-of-Experts (MoE) architecture to scale parameters efficiently. In an MoE model, only a sparse subset of the model—the "experts"—is active for any given input token. While this saves on computation, it introduces a massive communication overhead in distributed environments.

Because experts are distributed across multiple GPUs, tokens must be routed to the specific GPU holding the required expert. Standard MoE implementations require two Alltoall communication operations per layer: one to send tokens to experts and another to return them to their "home" GPU for subsequent attention calculations. In latency-sensitive inference, this communication often becomes the primary bottleneck, sometimes accounting for up to 76% of total inference time.

ExFlow: Optimizing Through Affinity and Coherence

Researchers from The Ohio State University have introduced ExFlow, a system designed to attack this bottleneck from two angles without requiring model retraining or fine-tuning.

1. Context-Coherent Expert Parallelism

ExFlow introduces a "context-coherent" approach where every GPU maintains access to the contexts of all tokens being processed. By ensuring context coherence, ExFlow can perform attention calculations in-place on whichever GPU the token was routed to for its expert computation. This effectively cuts the number of required Alltoall operations from two down to one per layer.

2. Exploiting Inter-Layer Expert Affinity

The core discovery of ExFlow is that token routing is not random. Tokens exhibit a high statistical probability of moving from a specific expert in one layer to a specific expert in the next. The researchers call this "Expert Affinity."

Comparison of vanilla expert placement versus ExFlow's affinity-aware placement strategy.

By modeling this affinity using Integer Linear Programming (ILP), ExFlow determines an optimal placement for experts across a cluster. Highly affiliated experts are placed on the same GPU or within the same physical node (connected by high-speed NVLink) to minimize slow inter-node traffic.

Key Insights: The Nature of Affinity

One of the most significant findings is that expert affinity is an intrinsic, stable property of pre-trained MoE models. Profiling on datasets like The Pile, C4, and Yelp Reviews revealed that these routing patterns are remarkably consistent across different types of text.

Heatmaps showing expert affinity across different layer pairs in a pre-trained MoE model, illustrating predictable token paths.

As shown in the heatmaps above, the routing preferences (indicated by red intensity) are not uniform; certain experts have strong "affinities" for others in subsequent layers. This affinity develops very early in the training process and remains stable thereafter, allowing for a static, "plug-and-play" optimization that works on existing models.

Performance Results

ExFlow demonstrates substantial improvements over state-of-the-art implementations like DeepSpeed-MoE:

  • Throughput: Achieved up to a 2.2x improvement in inference throughput.
  • Latency: Reduced cross-GPU routing latency by up to 67%.
  • Efficiency: In a 64-expert model, ExFlow successfully kept approximately 40% of tokens on the same GPU across layers, whereas baseline methods saw nearly all tokens jumping between GPUs at every step.
  • Accuracy: Since ExFlow only optimizes the location of computation and not the mathematical operations themselves, it results in zero accuracy loss.

Conclusion

ExFlow represents a significant step forward in making large-scale MoE models more practical for real-world deployment. By identifying and exploiting the hidden "affinity" between experts, it shifts the balance of distributed inference back toward productive computation and away from expensive network communication.

Summary updated

BibTeX
@inproceedings{yao2024exploiting,
  author = {Jinghan Yao and Quentin Anthony and Aamir Shafi and Hari Subramoni and Dhabaleswar K. Panda},
  title = {{Exploiting Inter-Layer Expert Affinity for Accelerating Mixture-of-Experts Model Inference}},
  booktitle = {IPDPS},
  year = {2024},
}
Figure