Large-Scale MoE Model Inference Deployment and Parallelism Strategies

    This article explains why deploying large-scale sparse Mixture-of-Experts (MoE) models is harder than it first appears, focusing on two key asymmetries: total versus activated parameters, and the differing demands of the prefill and decode stages. It then walks through three core techniques—expert parallelism (EP), prefill/decode disaggregation, and multi-tier caching—along with the dimensions that distinguish generations of MoE systems, such as attention compression, parallel domain width, and scheduling. Readers will find a practical, capacity-first workflow for deriving deployment configurations, plus guidance on evaluation methodology and common pitfalls to avoid.

    1. Why Deploying Large Sparse Models Is Harder Than Expected

    The inference cost of large sparse Mixture-of-Experts (MoE) architectures is fundamentally shaped by two asymmetries. Understanding both is the prerequisite for a sound deployment plan.

    The first asymmetry is between total parameters and activated parameters. Take a publicly documented model with 671B total parameters that activates roughly 37B per token: compute cost (FLOPs) is calculated only on the activated portion, but GPU memory must hold all expert weights. This means memory capacity and memory bandwidth—not peak compute—are often the primary constraint. If you size resources based only on activated parameters, deployment will almost certainly fail at the loading stage.

    The second asymmetry is the load imbalance between the two inference stages:

    • Prefill: processes all input tokens at once, with large matrix dimensions and high arithmetic intensity. It is compute-bound and directly determines time to first token (TTFT).
    • Decode: generates tokens autoregressively one at a time, reading the full KV cache and required expert weights at every step. It has low arithmetic intensity, is memory-bandwidth-bound, and determines time per output token (TPOT).

    When these two workloads compete for the same hardware, they interfere with each other: a long-prompt prefill can block requests that are decoding, causing jitter in token output; meanwhile, a large volume of concurrent decoding can crowd out the compute budget for prefill, driving up TTFT. This is the root motivation for all the parallelism and scheduling designs discussed below.

    2. Three Core Techniques

    2.1 Expert Parallelism (EP): Distributing Weights and Amplifying Batches

    Expert parallelism places different experts on different devices, so each card holds only a subset of expert weights. This spreads the capacity pressure of “having to hold all weights” horizontally. An additional benefit is that when multiple tokens on the same device route to the same expert, they can be merged into a larger batch, turning scattered memory accesses into more efficient dense computation.

    Two costs must be confronted in practice. First, routing imbalance: the device hosting a hot expert becomes a bottleneck, which must be mitigated with capacity factors, expert reordering, and redundant replicas. Second, cross-device communication: the two All-to-All dispatches and gathers can easily become the bottleneck on low-speed interconnects, so the EP domain should generally be kept within a single high-speed interconnect boundary.

    2.2 Prefill/Decode Disaggregation: Isolating the Two Workloads

    Deploying the two stages onto separate resource pools, each with its own concurrency, batch limits, and parallelism strategy, allows both TTFT and TPOT targets to be met on the same model. After disaggregation, KV cache must be transferred across pools, typically via a high-speed link or a shared cache layer, combined with request-level routing to avoid overloading either side.

    2.3 Multi-Tier Caching: Reducing Repeated Prefill

    Prefix reuse (system prompts, long documents, multi-turn conversation history) is the highest-hit-rate optimization in real workloads. The typical approach is a tiered structure spanning GPU memory, host memory, and remote cache, combined with prefix-hash addressing and eviction policies, turning repeated computation into a single cache read.

    Illustrative pseudocode (expressing scheduling logic only, not any specific API):

    1. def schedule(request):
    2. prefix = hash_prefix(request.tokens)
    3. hit = cache.lookup(prefix) # GPU memory -> host memory -> remote
    4. if hit:
    5. request.kv = hit # skip repeated prefill
    6. return route_to_decode(request)
    7. return route_to_prefill(request) # on miss, run full prefill

    3. Key Differences Across Four Generations

    When comparing across generations, the variables that are truly explanatory concentrate in five areas: attention compression ratio, parallel domain width, whether stages are disaggregated, number of cache tiers, and scheduling mechanism.

    The evolution of attention design is the most visible: KV cache overhead has been progressively compressed from around 70 KB/token with Multi-head Latent Attention (MLA) down to the order of 890 B/token—a reduction of more than two orders of magnitude. A smaller KV cache brings a chain of benefits: more concurrency fits in the same memory, per-step memory access in decode drops, and the cost of moving cache across devices falls. In million-token context scenarios, the new generation’s per-token compute and KV cache footprint can drop to roughly 27% and 10% of the previous generation, respectively (based on public technical materials; exact figures vary by version and configuration).

    Weight scale directly constrains the minimum parallel domain: the larger the memory requirement per replica, the higher the minimum number of devices needed to fit it. Public information indicates that the ultra-large version typically uses a single-node configuration of DP8+EP, while the lightweight version can use DP4+EP. This rule is very practical for procurement decisions—first derive the minimum parallel domain from weights and KV cache, then decide on the machine type and interconnect topology.

    4. Putting a Deployment Plan into Practice: Deriving Configuration from Capacity

    It is recommended to derive the configuration in the following order, avoiding arbitrary card counts:

    1. Calculate memory: total memory ≈ all expert weights + shared weights such as attention + KV cache (context length × concurrency) + framework and communication buffers.
    2. Determine the minimum parallel domain: divide the result from step 1 by the usable memory per card and round up to get the lower bound for EP/DP.
    3. Split pools and set ratios: determine the card ratio between prefill and decode based on business TTFT/TPOT targets; tilt toward prefill for long-document, low-concurrency scenarios, and toward decode for short-prompt, high-concurrency scenarios.
    4. Set batch limits: the decode side is bandwidth-bound, so an overly large batch raises TPOT; the prefill side is compute-bound, so a per-batch token limit is needed to prevent blocking.
    5. Benchmark and calibrate: use a fixed input-length distribution, fixed cache hit rate, and fixed speculative decoding configuration as a baseline, sweep concurrency and batch size item by item, plot the throughput–latency curve, and then pick the operating point.

    5. Evaluation Criteria and Common Pitfalls

    • Do not evaluate with a single metric. Throughput and latency are a trade-off, and results depend heavily on hardware, input-length distribution, cache hit rate, and speculative decoding configuration; a “N× improvement” claimed without these premises is not comparable.
    • Watch for portability across heterogeneous platforms. Different accelerators differ in interconnect bandwidth, communication primitive efficiency, and numerical implementations, so the same parallelism strategy can perform significantly differently after migration.
    • Deterministic inference requirements. Batch merging and the order of parallel reductions affect numerical results; scenarios that require reproducibility need a fixed execution path.
    • Cache economics. Deeper cache tiers yield greater benefits, but storage and network costs rise accordingly; input/output should be assessed against hit rate and TTFT gains.
    • Use a unified evaluation standard. Align context length, concurrency, sampling parameters, and warm-up strategy; otherwise cross-system comparison conclusions are invalid.

    6. Conclusion

    Efficient inference for large sparse models is the result of co-design between model architecture and system implementation: attention compression reduces memory access, expert parallelism spreads capacity, stage disaggregation isolates workloads, and multi-tier caching eliminates repeated computation. When building inference services on top of the general capabilities of platforms such as Baidu AI Cloud—container platforms, object storage, logging services, and monitoring and alerting—it is advisable to make capacity-first derivation, pool splitting and ratio setting, and curve-based benchmarking into a standard process, driving continuous tuning with a reproducible evaluation standard rather than chasing a single-point metric.