Why Mixture-of-Experts Models Are Slow at Inference
This article explains why Mixture-of-Experts (MoE) models often fail to scale throughput alongside parameter count. It breaks down three main bottlenecks—routing imbalance, memory bandwidth and weight swapping, and parallelism-related communication overhead—and outlines optimization paths covering load balancing, weight compression, scheduling, and elastic resources.
1. The Problem: More Parameters, Not More Throughput
Mixture of Experts (MoE) decouples total parameter count from the compute used per token through sparse activation. In theory, this lets a model carry far more knowledge capacity at the same inference compute budget. In practice, engineers often see a counterintuitive result: total parameters grow several times over, but single-GPU throughput does not scale proportionally. At low concurrency, latency can even get worse.
To understand this, you have to treat “parameter count” and “compute per token” as two independent metrics.
2. Bottleneck One: Routing Dynamics and Load Imbalance
The core of MoE is a gating network that selects the top-K experts for each token. This introduces two kinds of overhead:
- The routing computation itself, plus data-dependent branching that cannot be resolved statically at compile time.
- Naturally skewed expert load, where a few popular experts are hit repeatedly while cold experts sit nearly idle.
The direct consequence of load imbalance is synchronization waiting: under tensor or expert parallelism, the slowest device determines the latency of the entire batch. The logic can be sketched as follows:
# Pseudocode: the capacity factor sets buffer size; overflow tokens are dropped or bypassedcapacity = int(tokens_per_batch * top_k / num_experts * capacity_factor)for expert in experts:x_e = tokens[assignments == expert][:capacity] # overflow means information lossy_e = expert(x_e)
Set the capacity factor too low and tokens get dropped, hurting quality. Set it too high and a large share of compute is spent on padding positions that are discarded. This is the first source of slowness.
3. Bottleneck Two: Memory Bandwidth and Weight Swapping
A dense model uses all of its weights for every token. MoE touches only a small subset of experts per token, which looks compute-efficient. But inference is memory-bound: every generated token requires moving the selected expert weights from GPU memory to the compute units. When there are many experts, each expert is small, and the total weights exceed memory capacity, weight swapping kicks in and latency is gated by bandwidth rather than compute.
The diagnostic is straightforward: if throughput grows roughly linearly as concurrency increases, you are limited by memory access or scheduling. If concurrency rises but throughput stays flat, the bottleneck is more likely compute.
4. Bottleneck Three: Parallelism and Communication Amplification
Expert parallelism places different experts on different devices, and All-to-All communication volume scales with top_k and sequence length. Tensor parallelism requires a reduction at every layer. Combined, communication dominates at small batch sizes, leaving GPUs waiting on the network most of the time.
On top of that, the autoregressive decoding phase runs with small batches and low arithmetic intensity, so MoE’s sparsity advantage is hard to realize. This is the root cause of “token-by-token generation is much slower than prefill.”
5. Optimization Paths
- Load balancing: an auxiliary balancing loss, capacity factor tuning, and prefix caching to reuse routing results.
- Weight compression: low-bit quantization, expert pruning and merging to reduce memory access pressure.
- Scheduling and batching: continuous batching, speculative decoding, and redundant placement of expert replicas to eliminate hotspots.
- Elastic resources: use container platforms with monitoring and alerting for elastic scaling and bottleneck identification, and log services to capture routing distribution metrics.
6. Conclusion
MoE slowness is not an implementation defect. The sparse architecture shifts cost from compute to memory access, communication, and scheduling. A practical tuning order is: first check whether routing distribution is balanced, then confirm whether memory bandwidth is the constraint, and finally adjust parallelism and batching strategy. For these inference scenarios, Baidu AI Cloud typically recommends running elastic scaling on a general-purpose container platform and using monitoring and alerting to locate bottlenecks, rather than stacking hardware all at once.
