Deploying Sparse Mixture-of-Experts Models: Parallelism Strategies and System Design

    This article explains how to deploy large-scale sparse mixture-of-experts (MoE) models effectively. It covers the difference between total and activated parameters, prefill and decode workloads, data/tensor/expert parallelism, prefill-decode separation, KV cache compression and tiering, batching and scheduling controls, cluster sizing, benchmarking pitfalls, and a step-by-step implementation path. Readers will learn how to balance memory cost, throughput, time to first token, and generation speed.

    1. Background: Model Size Is Not the Same as Per-Token Compute

    Large sparse mixture-of-experts models use a Mixture-of-Experts (MoE) architecture. The model may contain tens or hundreds of billions of parameters in total, but each input token does not touch the entire network. Instead, a router selects only a few experts from the pool to process each token. Deployment planning must therefore distinguish two concepts:

    • Total parameter count: the sum of all shared, attention, and expert layer parameters;
    • Activated parameter count: the parameters actually involved in computing a single token.

    Activated parameters primarily determine compute load and hardware demand, while total parameters determine how much memory (GPU VRAM or host RAM) the weights occupy. In other words, sparsity reduces the compute cost per token, but it does not eliminate the storage burden of holding all weights.

    Consider a model with many experts: each token activates only a few of them, so a single forward pass may involve only a small fraction of total parameters. Yet during inference, all expert weights still have to reside in device memory, host memory, or a tiered storage system. If those weights cannot be accessed quickly, the theoretical compute savings are offset by data movement and communication overhead.

    Deployment planning therefore needs to answer three questions beyond activated parameter counts:

    1. Can a single accelerator hold the required shared weights and expert weights?
    2. How should expert weights be partitioned across devices?
    3. How can tokens routed to different experts communicate efficiently across devices?

    This is why expert parallelism has become a core deployment technique.

    2. Two Kinds of Workload in Inference

    Online inference for large models is typically split into a prefill phase and a decode phase. Although they belong to the same request, their hardware bottlenecks and scheduling requirements differ.

    Prefill: A Compute-Intensive Phase

    Prefill processes all tokens of a user’s input in one pass and builds the KV cache used for subsequent generation. Longer inputs mean larger matrix multiplications and attention computations, so this phase typically has the following characteristics:

    • High parallelism;
    • High compute-unit utilization;
    • Sensitivity to batch size;
    • Primary impact on time to first token (TTFT).

    When multiple requests enter prefill simultaneously, batching improves matrix computation efficiency. However, overly large batches increase memory usage and queuing time, degrading TTFT for shorter requests. The goal for prefill is therefore to maximize compute throughput while controlling input queuing delay.

    Decode: A Memory-Bandwidth-Intensive Phase

    Decode generates only one or a few tokens per step, but each step must read the model weights and access the KV cache accumulated so far. As context grows, cache reads increase, compute units can no longer stay fully utilized, and the bottleneck shifts toward memory bandwidth and inter-device communication.

    Decode mainly affects TPOT (time per output token) — the interval between consecutive output tokens. Its typical characteristics include:

    • Relatively small per-step compute;
    • Frequent reads of weights and KV cache;
    • Sensitivity to memory capacity, bandwidth, and access locality;
    • Long-context requests significantly increasing per-step memory pressure.

    If prefill and decode share the same resource pool, long input requests may occupy all compute devices while in-flight generation requests need stable memory bandwidth, causing TTFT and TPOT to jitter simultaneously.

    3. Parallelism Dimensions: From Data to Expert Parallelism

    Data Parallelism

    Data parallelism assigns different requests to different replicas, each holding a complete or near-complete copy of the model. Its advantages are simple implementation, good request isolation, and the ability to scale overall throughput.

    For very large sparse models, however, fully replicating the model is expensive in memory. Data parallelism therefore usually needs to be combined with expert parallelism rather than scaling the model on its own.

    Tensor Parallelism

    Tensor parallelism splits individual layers’ matrices or attention heads across multiple devices so that each device holds only a portion of the parameters. This reduces per-device memory, but each layer’s computation typically involves frequent collective communication.

    Tensor parallelism suits architectures with regular layer structure and high-bandwidth interconnects within a node. Across nodes, communication latency can significantly hurt decode performance, especially in step-by-step token generation.

    Expert Parallelism

    Expert parallelism distributes parameters along the expert dimension: different devices own different experts. The router sends tokens to the devices hosting the experts selected for each token, then gathers the expert outputs back.

    The main benefits of expert parallelism include:

    • Reducing the expert weight footprint each device must hold;
    • Giving multiple experts larger aggregated compute batches;
    • Enabling distributed deployment at larger model scales;
    • Facilitating load scheduling based on expert access frequency.

    It also introduces new problems. If many tokens are routed to a few popular experts, expert load becomes skewed; if tokens are spread across devices, all-to-all communication can become a bottleneck. Expert parallelism must therefore be combined with load balancing, capacity limits, and communication optimization.

    Combined Parallelism

    Real deployments often use a combination of data parallelism and expert parallelism. For example, within a node, multiple devices host different experts; across nodes, several service replicas are replicated. This scales serving throughput while preventing a single replica’s expert weights from concentrating on a few devices.

    The parallel domain cannot grow indefinitely. As device count increases, per-device memory pressure falls, but communication volume, synchronization waits, and scheduling complexity rise. A reasonable parallel configuration is determined by:

    • Per-device memory capacity;
    • Inter-device bandwidth;
    • The difference between intra-node and inter-node communication;
    • Expert routing distribution;
    • Target request lengths and concurrency;
    • The independent resource needs of prefill and decode.

    4. Phase Separation: Avoiding Interference Between Workloads

    The core idea of prefill/decode separation is to place input processing and token-by-token generation in different resource pools. The prefill pool focuses on compute throughput; the decode pool focuses on memory bandwidth and response stability.

    This design typically delivers three benefits.

    First, clearer resource objectives. Prefill can use larger dynamic batches to make full use of matrix compute; decode can cap concurrent requests so each request gets stable memory bandwidth.

    Second, easier latency management. Online services typically care about both TTFT and TPOT. With phase separation, queueing policies and priorities can be set independently, preventing long input tasks from blocking requests that are already generating.

    Third, easier elastic scaling. When input traffic spikes, prefill resources can be scaled up first; when sustained generation load grows, decode resources can be added separately. Compared with a unified pool, this better fits workloads with shifting traffic patterns.

    Phase separation also introduces KV cache transfer. After prefill completes, the KV cache must be handed over to the decode pool. If the cache moves across devices or nodes, network bandwidth and cache layout directly affect the benefit. Phase separation must therefore be designed together with high-speed cache transfer, cache reuse, and request scheduling.

    5. Attention Compression and Cache Optimization

    One of the main pressures in long-context inference is the KV cache. Standard multi-head attention stores separate keys and values for each head, so cache size grows linearly with context length, number of layers, number of heads, and precision.

    When context reaches hundreds of thousands or even a million tokens, even a small per-token footprint accumulates into tens of GB. The bottleneck then shifts from model weights to cache capacity, bandwidth, and management efficiency.

    Common optimization directions include:

    1. Shared or Grouped Key-Value Heads

    Multiple query heads share a subset of key-value heads, reducing the number of cache copies. This lowers per-token cache footprint while preserving expressive capability reasonably well.

    2. Latent Representation Compression

    Key-value information is first mapped to a lower-dimensional latent space and then restored or used in computation when needed, further reducing cache storage. These methods typically require architectural changes to the model and cannot simply be enabled through runtime configuration.

    3. Cache Quantization

    Cache tensors are converted from high-precision formats to lower bit widths based on sensitivity, reducing both capacity and bandwidth consumption. Quantization error can affect long-text consistency, so it should be evaluated across layers, positions, and request types.

    4. Tiered Caching

    The cache can span device memory, host memory, and a larger external storage tier. Active requests stay in VRAM; suspended or infrequently accessed requests move to larger tiers.

    Tiered caching must address two core issues: data migration cost and cache hit rate. If the cache is swapped frequently between tiers, migration overhead can offset the capacity savings. The scheduler should therefore decide cache placement based on remaining generation length, activity level, and probability of reuse.

    6. Scheduling Policy and Batch Control

    Uniform batching is not suitable for every phase. Prefill benefits from aggregating multiple input requests into large batches, while decode is better served by continuous batching, where new requests join dynamically while existing requests are still generating.

    A practical system can expose the following control parameters:

    • Maximum prefill tokens per batch;
    • Maximum concurrent decode sequences;
    • Maximum context length per request;
    • Expert capacity factor;
    • Cache residency limit;
    • Request queue timeout;
    • Priority settings for short vs. long requests.

    These parameters are strongly coupled. Increasing prefill batch size improves compute utilization but lengthens wait times; increasing decode concurrency raises overall throughput but increases per-step cache read pressure; expanding expert capacity reduces token dropping or fallback but increases memory usage and communication.

    Tuning should therefore not rely on a single throughput metric. A better approach is a multi-objective metric system that at minimum tracks:

    • TTFT;
    • TPOT;
    • End-to-end latency;
    • Output tokens per second;
    • Memory usage;
    • Inter-device communication volume;
    • Expert load variance;
    • Cache hit rate;
    • Request completion rate and tail latency.

    7. Hardware and Cluster Deployment

    Before deployment, establish a resource estimation model. Weight memory can be approximated as:

    1. Weight memory ≈ total parameter count × bytes per parameter

    With expert parallelism, per-device expert weights are approximately:

    1. Per-device expert weights ≈ total expert weights ÷ expert parallelism degree

    Actual memory must also include shared layers, temporary activations, communication buffers, runtime workspace, and KV cache. Do not plan for memory to “just fit” the weights; leave a safety margin.

    Cluster design generally has three tiers:

    1. Intra-device parallelism: core computation relies on high-bandwidth device memory and on-device interconnects;
    2. Intra-node parallelism: high-speed inter-device networks carry expert exchange and tensor communication;
    3. Inter-node parallelism: mainly used to scale replica counts or place coarser-grained expert shards.

    High-frequency, fine-grained communication should stay within a device or a node. Cross-node communication is better suited to batchable, aggregated data exchange. If large-scale cross-node expert routing is unavoidable, focus on optimizing communication topology, message aggregation, and congestion control.

    8. Common Pitfalls in Performance Evaluation

    Performance numbers from different systems cannot be compared directly, because of differences in:

    • Input lengths;
    • Output lengths;
    • Concurrent request counts;
    • Whether cache reuse is enabled;
    • Whether speculative decoding is used;
    • Precision and quantization strategies;
    • Whether average or tail latency is reported;
    • Hardware and interconnect topology.

    Note especially that throughput and latency usually involve a trade-off. Larger batches may increase tokens processed per second while simultaneously lengthening per-request wait times; lower concurrency may improve TPOT while reducing overall device utilization.

    Determinism also matters in evaluation. Random sampling, dynamic routing, asynchronous communication, and different batch ordering can all cause variation. A rigorous benchmark should fix the model version, precision, input distribution, output lengths, concurrency pattern, and statistical methodology, and report both average and P95/P99 tail latencies.

    9. Implementation Recommendations

    Teams preparing to deploy large sparse MoE models can proceed in the following order:

    1. First estimate static memory from total parameter count and weight precision;
    2. Then estimate the KV cache upper bound from context length;
    3. Use expert access statistics to check for significant load imbalance;
    4. Validate expert parallelism and communication efficiency within a single node;
    5. Load-test prefill and decode separately, not just end-to-end averages;
    6. Decide whether to adopt phase separation based on business requirements;
    7. Finally introduce cache tiering, quantization, speculative decoding, and similar optimizations.

    Overall, deploying sparse expert models is not simply a matter of adding more devices. The key is to close the loop between model architecture, parallelism strategy, cache layout, communication topology, and scheduling. Total parameter count determines storage scale, activated parameters determine compute intensity, the differing workloads of prefill and decode determine how resources are organized, and context length and cache hit rate determine real-world stability.

    Only by establishing clear relationships among these factors can a deployment achieve a reasonable balance among memory cost, throughput, time to first token, and sustained generation speed.