Large-Scale MoE Model Inference Deployment and Parallelism Strategies
This article explains why deploying large-scale Mixture of Experts (MoE) models for inference is harder than training them, focusing on two asymmetries: total parameters versus activated parameters, and the compute-bound prefill stage versus the memory-bandwidth-bound decode stage. It covers the three hardware constraints that shape deployment, three key techniques (expert parallelism, prefill/decode disaggregation, and multi-level caching with attention compression), how parallelism domains differ across model sizes, and the evaluation metrics needed for fair comparison. A practical implementation checklist is included to help teams plan observable and scalable inference resources.
1. Why Inference Deployment Is Harder Than Training
Many teams hit a counterintuitive result when moving a Mixture of Experts (MoE) model from an experimental environment to production: the parameter count grows several times over, compute demand does not scale at the same rate, yet memory and bandwidth run out first. Understanding this requires looking at two asymmetries in the inference cost structure.
The first asymmetry is between total parameters and activated parameters. Take a publicly known class of ultra-large-scale MoE models: total parameters can reach the hundreds of billions, but the experts that actually participate in computation for each token are usually only a small fraction of the whole. This means compute cost (FLOPs) is calculated mainly from the activated parameters, while memory must hold all expert weights. So the minimum deployment bar is not compute, but “can all the expert weights fit into memory.”
The second asymmetry is the load imbalance between the two stages:
- Prefill stage: processes all input tokens at once, with large matrix sizes and high parallelism. It is compute-intensive and directly determines time to first token (TTFT).
- Decode stage: generates tokens autoregressively one at a time, reading the entire KV cache at every step. It is memory-bandwidth-intensive and determines time per output token (TPOT).
The two workloads have almost opposite hardware demands. Running them on the same set of GPUs causes mutual drag, where compute idles waiting for bandwidth or bandwidth idles waiting for compute. This is the starting point for modern inference system design.
2. Three Constraints on Deployment Form
The deployment form of an inference system is not a free choice; it is constrained by three hardware conditions:
- Per-GPU compute: determines the throughput ceiling of prefill;
- Capacity and bandwidth of high-bandwidth memory (HBM): capacity determines how many weights and how much KV cache a single replica can hold, and bandwidth determines decode TPOT;
- Intra-node and inter-node interconnect capability: determines how wide the parallelism strategy can be spread; when interconnect is insufficient, parallel gains are eaten by communication.
A practical order of judgment is: first use the weight size and KV cache budget to calculate the “minimum memory requirement per replica,” then determine the minimum parallelism domain width accordingly, and only then discuss throughput optimization. Skipping the first step and tuning concurrency directly usually makes things worse the more you tune.
3. Three Key Techniques and Their Design Logic
3.1 Expert Parallelism (EP)
EP serves two core purposes: it distributes expert weights scattered across devices over multiple GPUs to reduce per-GPU memory pressure; and it aggregates tokens sent to the same expert into larger batches, improving the arithmetic intensity of matrix multiplications. Note that the benefit of EP depends heavily on routing balance—once hot experts concentrate, load skew locks overall throughput to the slowest GPU. In engineering, this is usually tuned together with a capacity factor, token dropping strategy, and a routing-balance auxiliary loss.
The routing and dispatch logic can be abstracted schematically as:
# Pseudocode: dispatch and aggregation for expert parallelismlogits = router(hidden_states) # [tokens, num_experts]topk_idx, topk_w = topk_softmax(logits, k) # sparse activationtokens_per_expert = scatter_count(topk_idx) # load statistics for skew monitoring# all-to-all dispatch to the devices holding the expertsrecv = all_to_all(permute(hidden_states, topk_idx))out = expert_forward(recv, tokens_per_expert)# all-to-all return and weighted mergehidden = unpermute(all_to_all(out), topk_w)
3.2 Prefill and Decode Disaggregation
After splitting the two stages into different resource pools, each can independently set its concurrency, batch size limit, and parallelism strategy: the prefill pool pursues large batches and compute utilization, while the decode pool pursues sufficient memory bandwidth and stable KV cache reads. The two are connected via KV cache transfer, so interconnect bandwidth and transfer scheduling become the new critical path. The benefit of disaggregation is more controllable tail latency; the cost is more complex resource planning and scaling logic.
3.3 Multi-Level Caching and Attention Compression
There are two main ways to reduce repeated prefill: one is prefix cache reuse, which reuses KV hits for common prefixes such as system prompts, long documents, and multi-turn history; the other is compression of the attention structure itself, for example low-rank latent attention that reduces the per-token KV footprint from tens of KB to hundreds of bytes up to around 1 KB. The direct effect of a higher compression rate is that the same memory can hold longer context and higher concurrency.
It is worth emphasizing that context length, cache hit rate, and speculative decoding configuration together change the relationship between throughput and latency. Therefore a single metric (such as tokens/s alone) cannot evaluate whether a deployment is good or bad; the input length distribution and hit rate assumptions must be stated.
4. How Parallelism Domain Planning Differs by Model Size
Weight size directly raises the per-replica memory requirement, which limits the minimum parallelism domain. The general rule is:
- Ultra-large flagship models: a single replica is hard to fit within one machine; a typical approach combines data-parallel replicas within a machine with expert parallelism (for example, 8-way data parallelism plus expert parallelism);
- Lightweight models: with smaller weights, the per-replica memory requirement drops and the minimum parallelism domain can narrow (for example, 4-way data parallelism plus expert parallelism), obtaining usable throughput on fewer devices.
During planning, the following inequality can be used for a quick check:
weight memory + KV_cache(context length × concurrency × bytes per token) + activation and temporary buffers ≤ available memory per replicaparallelism domain width ≥ ceil(per-replica memory requirement / available memory per GPU)
If the check fails, the preferred measures in order are: increase the attention compression rate, reduce per-replica concurrency, enable prefix caching, and only then consider expanding the parallelism domain (because expanding the domain introduces more communication overhead).
5. The Problem of Evaluation and Comparison Criteria
Cross-system and cross-generation comparisons easily reach contradictory conclusions mainly because of differences in criteria: different input/output length distributions, different cache hit rates, whether speculative decoding is enabled, different batch size limits, and differences in portability across heterogeneous hardware. In addition, deterministic inference (whether the same input stably reproduces the same output) and cache economics (whether the memory occupied by the cache pays off in hit benefits) are often overlooked.
The recommended minimum evaluation set includes: P50/P99 of TTFT, P50/P99 of TPOT, throughput curves under different input lengths, cache hit rate sensitivity analysis, and per-token memory and compute cost. Only by stating the assumptions clearly do the numbers become comparable.
6. An Actionable Implementation Checklist
- Quantify first: measure the input length distribution and common-prefix ratio of real workloads;
- Then shape: use the memory inequality to determine the per-replica configuration and minimum parallelism domain;
- Then disaggregate: plan the concurrency and batch size limits of the two resource pools separately according to the SLAs for TTFT and TPOT;
- Watch balance: bring expert load skew and communication wait time into daily monitoring and alerting;
- Use caching: prioritize prefix caching for common-prefix and long-document scenarios, and evaluate the context benefit of compressed attention;
- Re-evaluate regularly: rerun the evaluation set when hardware, model structure, or traffic characteristics change.
Overall, efficiency gains in ultra-large-scale MoE inference come from the coordination of model structure and system implementation: attention compression reduces KV cost, expert parallelism spreads out weights and amplifies batches, stage disaggregation isolates the two workloads, and multi-level caching cuts repeated computation. None of the four can be missing, and the quality of a deployment plan must ultimately be tested against the specific hardware foundation and real traffic characteristics. With the combination of general container platform, object storage, log service, and monitoring and alerting capabilities on platforms such as Baidu AI Cloud, the planning methods above can be directly mapped into an observable and scalable inference resource solution.
