Deploying Ultra-Large Sparse Mixture-of-Experts Models: Parallelism, Caching, and Capacity Planning
Deploying ultra-large sparse Mixture-of-Experts (MoE) models is not just a parameter-count problem. It requires balancing model weights, activation data, attention and KV caches, communication overhead, and request scheduling across device and storage resources. This article explains how sparse expert routing changes deployment design, compares the compute-bound prefill phase with the memory-bandwidth-bound decode phase, and reviews data, tensor, expert, and pipeline parallelism. It then covers weight and KV cache tiering, prefill/decode disaggregation, prefix cache reuse, capacity estimation, and metrics such as TTFT, TPOT, and tail latency. It concludes with common production issues—expert hotspots, communication overhead, oversized batches, and inconsistent benchmarking—and outlines a layered approach to building stable, efficient deployments.
1. Background: Deployment Tensions as Model Size Scales
Deploying ultra-large language models is difficult for more than the obvious reason of holding many parameters. A real system must simultaneously manage model weights, activation data, attention caches, communication overhead, and request scheduling. Sparse expert models also have computation and routing patterns that differ clearly from those of dense models, so a single multi-device partitioning scheme cannot simply be reused.
A sparse MoE model typically consists of shared modules and multiple expert modules. For each input token, the router selects only a small number of experts to participate. For example, a model may contain hundreds of experts while each token activates only a small subset. This preserves a large parameter capacity while reducing per-token computation.
However, fewer activated parameters do not necessarily mean lower device memory requirements. An inference node often still has to store complete expert weights, or manage nonresident weights through remote storage, tiered caching, and on-demand loading. Model deployment must therefore answer at least three questions together:
- How are all weights distributed across devices?
- Which experts should each token be sent to?
- How should compute and cache resources be shared across stages and requests?
If these questions are not addressed through co-design, the system may suffer from out-of-memory errors, communication congestion, idle devices, excessive first-token latency, or unstable generation speed.
2. Two Main Inference Loads
2.1 Prefill: The Compute-Intensive Phase
Prefill processes the entire user input context. If a request contains thousands of input tokens, the system performs a large number of matrix operations in parallel during this phase and builds the corresponding attention cache.
This phase typically has the following characteristics:
- A large number of input tokens;
- Large matrix multiplication workloads;
- High utilization of accelerator compute units;
- Relatively lower sensitivity to device memory bandwidth;
- A primary impact on time to first token (TTFT).
When input length is long, prefill computation grows quickly. If multiple long inputs arrive at the same time, compute queues can form easily. Prefill is therefore better suited to larger batches, with dynamic batching used to improve compute-unit utilization.
2.2 Decode: The Memory-Bandwidth-Intensive Phase
Decode generates output token by token in an autoregressive manner. Each step usually adds only one or a few tokens, but it must read model weights and the accumulated attention cache.
The main characteristics of this phase are:
- Small per-step computation;
- Access to historical KV cache at every step;
- High sensitivity to device memory capacity and bandwidth;
- Improved device utilization through concurrent requests;
- A primary impact on TPOT, the time between adjacent output tokens.
Decode is not well suited to simply pursuing very large batches. Although a larger batch can improve throughput, it increases per-request waiting time and may cause cache usage to grow rapidly. Production systems therefore usually need to balance throughput, response latency, and concurrency limits.
3. Parallelism Strategies and Their Use Cases
3.1 Data Parallelism
Data parallelism is the most straightforward approach: multiple devices or device groups each hold a copy of the model and process different requests to improve overall throughput.
Its advantages include:
- Isolation between requests;
- Relatively simple scheduling;
- Friendly horizontal scaling for online services;
- Lower communication pressure within a single replica.
However, data parallelism requires each replica to accommodate the complete model, or at least one complete parallel shard. As the memory requirement for one replica grows, the minimum deployment size for data parallelism also increases.
3.2 Tensor Parallelism
Tensor parallelism splits matrix operations across multiple devices. For example, the weights of a linear layer can be split by column or row, with different devices performing local computation and then merging results through collective communication.
Tensor parallelism is suitable for the following scenarios:
- A single layer’s weights cannot fit on one device;
- Per-device compute pressure needs to be reduced;
- The cluster has high-speed interconnects;
- The task batch is large enough to amortize communication costs.
Its main problem is frequent communication. Each network layer may require synchronization or aggregation operations. When devices span different nodes, communication latency and bandwidth can significantly affect overall performance. Tensor parallelism is therefore usually deployed first among devices with high-speed interconnects.
3.3 Expert Parallelism
Expert parallelism is a key strategy for sparse expert models. The system places different experts on different devices or device groups, and the router sends inputs to the corresponding experts based on each token’s expert selection.
A typical flow is as follows:
Input tokens|vRouter computes expert selection|vRedistribute tokens by expert placement|vEach device runs local expert computation|vAggregate expert outputs and restore token order
Expert parallelism reduces the expert weights that each device must store and increases overall concurrency for expert computation. However, it also introduces significant communication overhead, especially when experts are distributed across nodes. If many tokens concentrate on a small number of experts, expert hotspots will occur, overloading some devices while others sit idle.
Expert parallelism is therefore not simply a matter of distributing experts evenly. It also needs to be combined with:
- Routing capacity limits;
- Expert load balancing;
- Token permutation and merge optimization;
- Communication and computation overlap;
- Replication of hot experts;
- Dynamic scheduling and overflow strategies.
3.4 Pipeline Parallelism
Pipeline parallelism partitions the model by network layers, with different devices responsible for different stages. It reduces per-device memory pressure and is suitable for scenarios with deeper models and larger model sizes.
However, pipeline parallelism creates bubbles: while one micro-batch has not yet reached later stages, some devices may be waiting. Increasing the number of micro-batches can reduce bubbles, but it raises scheduling complexity and cache requirements. For online inference, imbalanced pipelines caused by varying request lengths must also be considered.
4. Weights, KV Cache, and Storage Hierarchy
4.1 Weight Management
Model weights usually reside in a multi-tier storage hierarchy:
- Accelerator memory: lowest access latency, limited capacity;
- Host memory: larger capacity, but lower access speed;
- Local high-speed storage: suitable for weight prefetching and cold-data caching;
- Remote object storage: large capacity, suitable for model distribution and persistence, but not for direct high-frequency inference access.
For online inference, core weights should remain resident in accelerator memory whenever possible. For experts that are temporarily inactive, tiered residency, prefetching, or on-demand loading can be used, but it is necessary to evaluate whether loading latency offsets the benefits of sparse computation.
4.2 KV Cache Management
KV cache is a critical resource in long-context inference. As input and output grow, the cache occupied by each request continues to increase. When cache capacity is insufficient, the system may be forced to reduce concurrency or even evict caches frequently.
Engineering techniques include:
- Using paged cache management to reduce constraints from contiguous memory allocation;
- Bucketing requests by different lengths;
- Reusing cached session prefixes;
- Applying expiration policies to low-frequency request caches;
- Migrating cold cache to host memory;
- Using more compact data types to reduce capacity usage.
Note that cache compression creates trade-offs among capacity, precision, and access overhead. A higher compression ratio saves more device memory, but may add conversion cost during decoding and may even affect output quality.
5. Disaggregated Prefill and Decode Deployment
In mixed deployments, prefill and decode share the same set of devices, which can easily lead to resource contention. For example, long-input requests consume substantial compute resources, while requests that are already generating need stable device memory bandwidth. When the two types of tasks run together, both first-token latency and inter-token generation intervals may deteriorate.
The basic idea of prefill/decode disaggregation is to place the two phases in different resource pools:
- The prefill cluster focuses on compute capability and large-batch processing;
- The decode cluster focuses on memory capacity, bandwidth, and stable scheduling;
- The two exchange state through request queues or an intermediate transfer mechanism;
- Each scales independently according to traffic changes.
This architecture improves resource isolation, but it also brings additional costs, including inter-stage data transfer, scheduling complexity, and failure recovery. Design should focus on the following:
- How input context and cache state are transferred;
- How the capacity of the two resource pools is matched;
- Whether rate limiting is needed during request bursts;
- How requests queue when decode resources are insufficient;
- How to retry after cache migration failure.
6. Cache Reuse and Long-Context Optimization
When many requests share the same system prompt, template, or historical prefix, the computation results for the common prefix can be reused to reduce repeated prefill. A cache key usually needs to account for the model version, precision configuration, token sequence, and relevant runtime parameters to avoid incorrect reuse across different configurations.
The cache system can be divided into:
- Hot cache: resident in accelerator memory, with fast access;
- Warm cache: resident in host memory, with larger capacity;
- Cold cache: located in local or remote storage, suitable for low-frequency data;
- Persistent cache: used for reuse across processes or instances.
A higher cache hit rate is not always better. Occupying large amounts of accelerator memory to retain low-frequency prefixes may instead reduce overall concurrency. Decisions should therefore combine access frequency, context length, recomputation cost, and cache migration cost.
7. A Core Method for Deployment Planning
Capacity estimation can be performed before deployment using the following steps.
Step 1: Estimate Weight Capacity
Weight capacity can be approximated as:
Weight capacity ≈ parameter count × bytes per parameter
In practice, quantization metadata, alignment space, router modules, shared layers, and runtime buffers should also be included.
Step 2: Estimate Cache Capacity
KV cache usage is usually related to the following factors:
KV cache capacity ≈ number of requests × sequence length × per-token cache size
The per-token cache size is affected by the number of layers, attention head size, data type, and cache compression method. For long-context services, maximum concurrency should be derived from cache capacity first, rather than planning device count only from peak compute.
Step 3: Determine the Parallelism Domain
A parallelism domain is the set of devices that cooperate to compute one model replica. The larger the model, the more devices a single replica requires, and the larger the minimum granularity of data parallelism becomes. When choosing a parallelism domain, consider:
- Per-device memory capacity;
- Device interconnect bandwidth;
- Expert placement method;
- Tensor split granularity;
- Number of nodes;
- Fault domains and scaling requirements.
Step 4: Establish Stage-Specific Metrics
A system should not be evaluated only by total throughput. At minimum, record the following separately:
- TTFT: time to first token;
- TPOT: time per output token;
- End-to-end latency;
- Input and output throughput;
- Device memory utilization;
- Compute utilization;
- Communication share;
- Cache hit rate;
- Expert load balance;
- Latency at different percentiles.
Pay particular attention to tail-latency metrics such as P95 and P99, because user experience in online services is often determined by slow requests.
8. Common Issues and Optimization Directions
8.1 Uneven Expert Load
Some experts are selected frequently, causing hot devices to become bottlenecks. This can be mitigated through routing constraints, capacity factors, expert replication, and dynamic migration.
8.2 Communication Becomes the Main Overhead
When tokens move frequently across nodes, expert parallelism may fail to deliver the expected benefits. Frequent communication should occur within high-speed interconnect domains whenever possible. Waiting can be reduced through communication fusion, batched transfers, and computation-communication overlap.
8.3 Oversized Batches Degrade Latency
Batching can improve throughput, but it extends queueing time and cache usage. Online systems should dynamically adjust batch limits based on request priority, context length, and target latency.
8.4 Focusing Only on Averages
Good average throughput does not mean the system is stable. Testing should be stratified by input length, concurrency level, and cache hit or miss scenarios, with long-tail requests analyzed separately.
8.5 Inconsistent Benchmarking Methodologies
Different systems may differ in precision, quantization method, sampling parameters, input and output lengths, cache state, and parallel scale. Comparing results directly can lead to incorrect conclusions. Rigorous benchmarking requires a fixed test set, concurrency model, timing scope, and hardware environment.
9. Conclusion
Deploying ultra-large sparse MoE models is fundamentally a systems engineering problem spanning compute, device memory, communication, and scheduling. Expert parallelism addresses parameter distribution and scaling of expert computation; data parallelism scales replica-level throughput; tensor parallelism and pipeline parallelism address single-replica scale; and prefill/decode disaggregation and multi-tier caching address inter-stage resource contention and repeated computation.
A sound solution is usually not a choice of one parallelism method, but a layered combination: use tensor or expert parallelism within high-speed interconnect domains inside nodes, use replica expansion or pipeline partitioning across nodes, and apply independent prefill/decode scheduling and caching policies to control end-to-end performance. Ultimately, deployment quality should be evaluated in terms of first-token latency, generation speed, throughput, tail latency, device memory usage, cache hit rate, and communication overhead. A design has production value only when it remains stable under realistic workloads.
