Deploying Trillion-Parameter MoE Models on Dual Ascend Nodes: A Practical Guide
This guide walks through deploying a trillion-scale multimodal MoE model across two Ascend nodes with eight cards each. It covers capacity budgeting for W4A8 weights, combining tensor, pipeline, and expert parallelism, preparing images and sharded weights, key launch parameters, performance and stability tuning, and a checklist of common deployment pitfalls.
1. Why Ultra-Large-Scale MoE Is Hard to Deploy
Native multimodal MoE (Mixture of Experts) models are pushing inference engineering to new extremes. Consider a typical configuration: roughly 2.8T total parameters, about 104B activated parameters per token, native support for both visual and text inputs, and a context window of up to 1M tokens. Behind these numbers sit three conflicting constraints:
- Capacity constraint: Total parameters set the lower bound for weights that must stay resident in memory, while activated parameters determine the compute per token. The nearly 27x gap between them means the ratio of compute to memory must be redesigned.
- Bandwidth constraint: Each MoE layer activates only a few experts, and routing is data-dependent, making memory access patterns irregular. Measured performance is often bound by HBM bandwidth rather than peak compute.
- Context constraint: Million-token contexts make the KV Cache a major memory consumer in its own right. For long sequences, it can even exceed the size of the weights themselves.
Running these models on domestic accelerators (typically two nodes with eight high-end training/inference cards each) is less about “can it run” and more about aligning memory, parallelism strategy, and quantization format in a single pass.
2. Capacity Budget: Do the Math First
Before deployment, build a memory ledger. With W4A8 quantization (4-bit weights, 8-bit activations), the theoretical weight size for 2.8T parameters is roughly:
2.8e12 params × 0.5 byte ≈ 1.4 TB
This matches the actual size of community quantized weights (about 1.47TB, including a small number of unquantized embedding layers, normalization layers, and routing biases). Two nodes with sixteen cards at 64GB HBM each provide about 1.024TB total, which is not enough. Such deployments therefore typically require more than 96GB HBM per card, or a single eight-card node combined with weight offloading. Add up the budget in this order:
- Resident weights: quantized size × 1.05 (alignment and metadata overhead);
- KV Cache: determined by layer count, KV heads, head_dim, sequence length, and batch size;
- Activations and temporary buffers: correlated with max_num_seqs and chunked prefill block size;
- Communication and framework reserve: generally 8%–12%.
A reusable estimation snippet:
kv_bytes = 2 * layers * kv_heads * head_dim * seq_len * batch * dtype_bytesheadroom = weights * 0.05 + kv_bytes * 1.2 + activation_bufferassert headroom < total_hbm * 0.92, "Insufficient capacity; reduce concurrency or shorten context"
3. Parallelism Strategy: A Three-Dimensional Split Across Tensor, Pipeline, and Experts
Parallelism for ultra-large-scale MoE is not a single dimension but three stacked layers:
- Tensor Parallelism (TP): Splits attention and linear layers. Communication concentrates on all-reduce, making it suitable for high-bandwidth intra-node interconnects. It generally should not exceed the number of cards in a single node.
- Expert Parallelism (EP): Distributes experts across cards, turning communication into all-to-all. This is the key MoE-specific dimension. Too small an EP leaves too many experts per card and exhausts memory; too large an EP makes all-to-all the bottleneck.
- Pipeline Parallelism (PP): Splits layers across nodes with the least communication, which suits dual-node setups, but introduces bubbles that must be offset with finer micro-batch splitting.
A recommended starting point for dual-node deployment: TP=8 within each node, PP=2 across nodes, and EP sharded redundantly within each node. If throughput falls short, tune EP and the all-to-all communication group topology first rather than blindly increasing TP.
4. Environment and Weight Preparation
- Base image: Use a general-purpose inference framework image built for domestic accelerators, and confirm it includes the matching operator and communication library versions to avoid missing operators caused by self-compilation.
- Obtaining weights: Pull the W4A8 quantized version from public model hosting channels, and verify that the shard count matches the index file.
- Storage: Store 1.4TB-class weights on object storage or a parallel file system and mount them at container startup, rather than baking them into an image layer.
- Faster loading: Prefer multi-process sharded loading with memory mapping, which can cut cold-start time from tens of minutes to a few minutes.
# Example: mount weights and verify shard integritymount -t nfs /shared/models /modelspython - <<'PY'import json, osidx = json.load(open('/models/quant/index.json'))missing = [f for f in set(idx['weight_map'].values()) if not os.path.exists(f'/models/quant/{f}')]print('missing shards:', missing)PY
5. Service Launch: Key Parameters and Template
The tunable options in the launch script fall into four areas: parallelism, quantization detection, context and concurrency, and scheduling. An example:
launch = dict(model="/models/quant",tensor_parallel_size=8,pipeline_parallel_size=2,expert_parallel_size=8,quantization="w4a8",max_model_len=262144, # reduced from 1M as needed, significantly saving KV memorymax_num_seqs=32,enable_chunked_prefill=True,gpu_memory_utilization=0.90,trust_remote_code=True,)
Key points: max_model_len does not need to be maxed out immediately. Start with 260K–520K to verify correctness, then scale up gradually. Leave 5%–10% of gpu_memory_utilization for communication buffers. Enabling chunked prefill prevents long prompts from blocking decoding.
6. Performance Tuning and Stability
- Time to first token: Most affected by prefill length and expert routing. Compressing prompts and enabling prefix caching yield clear gains.
- Throughput: Confirm KV memory headroom before raising concurrency. If necessary, trade a more aggressive quantization or shorter context for a larger batch.
- Long-run stability: All-to-all can jitter under prolonged operation. Enable communication timeouts and retries, and feed NPU/CPU utilization, memory levels, and request queue length into logging, monitoring, and alerts.
- Canary rollout: Validate the multimodal input path (image preprocessing, token alignment) with a small traffic share before opening to full traffic.
7. Common Pitfalls Checklist
- Missing weight shards or a mismatched index, which surfaces as an error mid-load;
- A parallelism product that does not match the total card count, causing the framework to fail at startup;
- Maxing out the context and overflowing KV memory, leading to OOM under long requests;
- Multimodal preprocessing not aligned with the text template, producing garbled output;
- Cross-node networking without huge pages and RDMA enabled, halving throughput.
8. Conclusion
Running trillion-scale MoE on dual domestic accelerator nodes is fundamentally a triangle of balance among capacity, bandwidth, and context. Calculate the memory budget clearly, pair the three parallelism dimensions correctly, and leave headroom for context and concurrency. Combined with thorough monitoring and canary rollout, ultra-large-scale multimodal inference can be deployed reliably. The same approach applies to similar inference services built on container platforms and object storage on Baidu AI Cloud.
