A plug-and-play inference-time dispatching framework that eliminates synchronization bottlenecks in distributed sparse MoE serving through deterministic capacity bounds and local candidate expansion.
Adjust the MoE architecture, token batch size, and capacity factor $\gamma$ in real time. Compare how Vanilla Top-$k$ routing creates severe synchronization stragglers, while Token Drop and Expanded Drop balance multi-GPU workloads.
8 total experts distributed across 4 GPU ranks.
Learned gating functions route tokens unevenly based on natural linguistic affinities. Under multi-GPU expert parallelism, the whole cluster slows down to match the single most overloaded worker.
Figure 1: Token queue skew creates GPU idle cycles at the synchronization barrier.
In production MoE models (Mixtral, DeepSeek, OLMoE), 10–20% of the experts receive over 60% of all tokens, while the rest remain substantially underutilized.
Under Expert Parallelism (EP), all devices must exchange activations via all-to-all communications before proceeding to the next layer, serializing execution on the slowest GPU.
The straggler effect persists across language and multimodal MoEs alike, and exacerbates with larger batch sizes and higher expert counts ($E=64, 128$).
Select a model architecture to inspect its layer-wise token assignment distribution and straggler hotspots.
Figure: Layer-wise token routing frequency across all available expert slots.
In intermediate and deep layers, router logits heavily polarize. Up to 78% of tokens route to only 15% of active experts.
Under Expert Parallelism (EP), All-to-All communication blocks on the most saturated worker, stalling healthy GPUs.
Enforcing $\gamma \in [1.0, 1.2]$ caps the long tail and reallocates excess tokens with negligible perturbation to downstream accuracy.
We regulate expert workload using a capacity factor $\gamma$, bounding the maximum computation time per expert without retraining the underlying weights.
Calculates capacity threshold $C$ per expert. Tokens routed to an expert are ranked by router probability score; overflow tokens beyond $C$ are cleanly dropped, ensuring no GPU exceeds runtime budget $C$.
Instead of discarding overflow tokens, the router dynamically reallocates them to alternative candidate experts situated on the same local GPU rank that have available capacity, maximizing parameter utilization.
Extensive multi-GPU benchmarks demonstrating superior throughput, compressed P99 tail latency, and lossless accuracy across major LLM benchmarks.
| Model Architecture | Experts ($E$) | Top-$k$ | Strategy | Capacity ($\gamma$) | Avg Benchmark Acc | Layer Speedup | End-to-End Speedup |
|---|---|---|---|---|---|---|---|
| Mixtral-8x7B-Instruct | 8 | 2 | Baseline | ∞ | 71.4% | 1.00× | 1.00× |
| Mixtral-8x7B-Instruct | 8 | 2 | Expanded Drop | 1.0 | 71.6% (+0.2%) | 1.92× | 1.85× |
| OLMoE-1B-7B-Instruct | 64 | 8 | Baseline | ∞ | 63.8% | 1.00× | 1.00× |
| OLMoE-1B-7B-Instruct | 64 | 8 | Expanded Drop | 0.8 | 63.5% (-0.3%) | 1.32× | 1.28× |
| DeepSeek-V2-Lite-Chat | 64 | 6 | Baseline | ∞ | 68.2% | 1.00× | 1.00× |
| DeepSeek-V2-Lite-Chat | 64 | 6 | Expanded Drop | 1.0 | 68.1% (-0.1%) | 1.45× | 1.39× |
Patch any Hugging Face, vLLM, or DeepSpeed MoE checkpoint in 3 lines of Python without re-training or modifying model weights.
# 1. Import transformers and our lightweight patch engine
import torch
from types import SimpleNamespace
from transformers import AutoModelForCausalLM, AutoTokenizer
from capacity_aware import apply_capacity_aware_moe_patch
# 2. Load standard MoE checkpoint (e.g. Mixtral, DeepSeek, OLMoE)
model_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="auto")
# 3. Configure Capacity-Aware parameters
config = SimpleNamespace(
expert_capacity=1.0, # Capacity factor gamma (C = gamma * N_avg)
strategy="score", # Drop heuristic: "score", "first", "last"
rounds=1, # Expansion rounds for candidate reallocation
capacity_scope="expert", # "expert" or "device"
)
# 4. Patch the model in-place (Zero Retraining!)
num_patched = apply_capacity_aware_moe_patch(model, config)
print(f"Patched {num_patched} MoE layers with Capacity-Aware routing.")
# 5. Run accelerated inference!
inputs = tokenizer("Capacity-Aware inference solves MoE stragglers by", return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=64)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
# Launch standardized evaluation on Mixtral-8x7B
cd lm-evaluation-harness
CUDA_VISIBLE_DEVICES=0,1,2,3 PRETRAINED="mistralai/Mixtral-8x7B-Instruct-v0.1" TASKS="mmlu,gsm8k,arc_challenge,hellaswag" EXPERT_CAPACITY=1.0 STRATEGY=score ROUNDS=1 BATCH_SIZE=8 bash runs_prune/eval_capacity.sh
# Launch multimodal evaluation on MMBench
cd VLMEvalKit
python run.py --data MMBench_DEV_EN --model DeepSeek-VL-7B --mode all
If you find Capacity-Aware Inference helpful in your research, please cite our ICLR 2026 paper:
@inproceedings{he2026capacityaware,
title={Capacity-Aware Inference: Mitigating the Straggler Effect in Mixture of Experts},
author={He, Shwai and Cai, Weilin and Huang, Jiayi and Li, Ang},
booktitle={International Conference on Learning Representations (ICLR)},
year={2026},
url={https://arxiv.org/abs/2503.05066}
}