Trillion-Parameter Multimodal MoE Training on Domestic AI Chips: An Engineering Implementation Guide
This article is an engineering guide for training trillion-parameter, native multimodal MoE models on domestic AI chips. It first distinguishes pipeline validation from full-scale pretraining, then breaks down the three core challenges of native multimodal MoE: dynamic sparse attention, expert routing and load balancing, and extreme memory pressure. It covers memory-reduction strategies, combined parallelism (FSDP/ZeRO, tensor, pipeline, expert, and sequence parallelism), MoE All-to-All optimization, mixed precision and numerical stability, and how to judge whether a training pipeline is trustworthy. It also explains the gap between trimmed validation and full-scale training, compares dense and MoE multimodal models, and offers a step-by-step roadmap for going from getting training to run to making it run well.
1. Start with the conclusion: A working pipeline is not the same as production-scale capability
When domestic AI chips move from inference to training, the real difficulty is not “can you launch a single training run,” but whether the system can maintain semantically correct forward and backward passes, controllable communication, manageable memory, and long-run stability under trillion-parameter, native multimodal, and MoE sparse structures.
It helps to split the evaluation into two layers:
| Dimension | Pipeline validation | Full-scale pretraining |
|---|---|---|
| Goal | Verify that operators, gradients, and the data pipeline are correct | Verify scaling efficiency, communication overhead, and long-run stability |
| Scale | Few devices, trimmed config, short step count | Thousands to tens of thousands of devices, full model, long runtime |
| Key metrics | Loss decreasing, grad norm stable, memory reasonable | Effective training rate, checkpoint recovery, slow nodes, communication ratio |
| Main risks | Operator implementation errors, silent gradient anomalies | Scaling collapse, fault rescheduling, precision drift |
So when you see claims like “dual-node multi-GPU completed several hundred steps with smoothly converging loss,” you should first assess whether this is pipeline validation rather than proof of full-scale training capability. The value of pipeline validation is to move problems forward: first prove that the operators are correct, the gradients are correct, and the memory budget is accounted for, and only then discuss scale.
2. Three engineering challenges of native multimodal MoE
Native multimodal MoE stacks sparse experts on top of cross-modal inputs. The training system does not face a single model, but several workload patterns at once.
2.1 Dynamic sparse attention
Sparse attention reduces computational complexity by dynamically selecting tokens, windows, or blocks, but “dynamic” means the shape of the computation graph changes with the input. Two things deserve close attention:
- Forward sparse operators must have semantically consistent backward implementations; otherwise the loss may decrease while the gradients have already learned the wrong thing.
- Sparse indexing introduces irregular memory access, which places higher demands on the domestic chip’s memory access units, cache scheduling, and operator fusion.
Multimodal inputs make this worse: image, video, and audio branches introduce different sequence lengths and different masking patterns, further amplifying the scheduling complexity of dynamic shapes.
2.2 Expert routing and load balancing
One of the core problems of MoE is load balancing. If a few experts are over-activated, you get expert collapse, communication skew, memory long tails, and throughput degradation. Here is corrected, standard illustrative code:
import torchimport torch.nn.functional as Fdef moe_forward(x, experts, router, top_k=2, capacity_factor=1.25, aux_weight=0.01):# x: [tokens, hidden]logits = router(x) # [tokens, num_experts]num_experts = logits.shape[-1] # Get the number of experts inside the function to avoid an undefined referenceprobs = F.softmax(logits, dim=-1) # [tokens, num_experts]topk_probs, topk_idx = torch.topk(probs, top_k, dim=-1)# Standard load balancing loss: L = N * sum_i(f_i * P_i)# f_i: fraction of tokens dispatched to expert i# P_i: average probability the router assigns to expert ione_hot = torch.zeros_like(probs)one_hot.scatter_(1, topk_idx, 1.0)# If counting all top-k assignments, use tokens * top_k as the denominator# If counting only top-1 hits, change to one_hot.sum(dim=0) / x.shape[0]f = one_hot.sum(dim=0) / (x.shape[0] * top_k)P = probs.mean(dim=0)load_balance_loss = num_experts * (f * P).sum()# Capacity control: cap the upper limit each expert receives to mitigate communication skewcapacity = int(x.shape[0] * top_k * capacity_factor / num_experts)y = dispatch_and_combine(x, topk_idx, experts, capacity) # Illustration: needs to integrate the vendor's operator implementationreturn y, aux_weight * load_balance_loss
The key point here is not the formula itself, but that readers should not copy an incorrect implementation. The standard auxiliary loss should be based on the product of the mean softmax probability and the dispatch fraction, not on the sum of squares of the mean raw logits. The latter produces incorrect gradients; engineers may think it looks “professional,” but the model will actually learn the wrong thing.
2.3 Extreme memory management pressure
Even stored in BF16, the parameters of a trillion-parameter model occupy TB-scale memory. Add gradients, optimizer states, and activations, and a single device’s memory is nowhere near enough. The memory budget should at least be broken down as follows:
| Memory item | Does it decrease linearly with FSDP sharding? |
|---|---|
| Parameters | Usually yes |
| Gradients | Usually yes |
| Optimizer states | Usually yes |
| Activations | Usually not linear |
This is also where many teams misjudge the situation: FSDP or ZeRO sharding mainly addresses model states, not activation peaks. Long sequences, multimodal visual tokens, and MoE routing buffers all add activation pressure.
3. Core engineering points for training pipeline adaptation
3.1 What to do when domestic chip training memory is insufficient?
When memory is insufficient, don’t first ask “can I enable a larger batch.” Instead, troubleshoot in order:
- Use FSDP/ZeRO to shard parameters, gradients, and optimizer states.
- Enable activation recomputation, focusing on attention, MoE dispatch, and the vision encoder.
- Use sequence parallelism or context parallelism to reduce long-sequence activations.
- Apply expert parallelism to MoE experts to avoid fitting all experts on a single device.
- Set different parallelism strategies for the vision tower and the language backbone to avoid over-replicating small modules.
A common misconception is that “after parameter sharding, single-device memory decreases proportionally.” In reality, activation memory does not decrease linearly with data parallelism. If activations still OOM, you need activation recomputation, sequence parallelism, or operator fusion to solve it together.
3.2 How to combine FSDP and parallelism strategies?
Modern large-model training usually adopts combined parallelism: FSDP/ZeRO, tensor parallelism, pipeline parallelism, expert parallelism, and sequence parallelism. Different modules can use different strategies.
# Illustrative config: field names vary across vendor training frameworksmodel:language_backbone:tp: 2pp: 2fsdp: full_shardactivation_checkpoint: truesequence_parallel: truevision_tower:tp: 1pp: 1fsdp: full_shardactivation_checkpoint: truecross_modal_proj:fsdp: replicatemoe:ep: 4capacity_factor: 1.25aux_weight: 0.01runtime:precision: bf16accum_dtype: fp32checkpoint_interval_steps: 500eval_interval_steps: 500effective_training_rate_slo: 0.9
The above config is only a logical example. Before production, you must lock down the training framework, collective communication library, and operator library versions, and run benchmarks across different device counts and interconnect topologies. Version dependency mismatches cause hard-to-reproduce differences in operator semantics, communication behavior, or numerical results.
3.3 How to optimize MoE All-to-All communication?
One of the main scaling bottlenecks of MoE training is All-to-All. Experts are distributed across different devices, so tokens must be routed to the corresponding devices; otherwise expert computation cannot complete. Optimization directions include:
- Topology awareness: try to keep replicas of the same expert, or related shards, close to the high-speed interconnect domain.
- Hierarchical communication: first aggregate within a small scope inside a node, then transfer between nodes, reducing cross-node traffic.
- Communication-computation overlap: execute dispatch, compute, and combine in chunks to hide communication latency.
- Capacity factor tuning: too small drops tokens or adds fallback paths; too large wastes memory and bandwidth.
- Load balancing loss: suppress expert collapse and avoid a few nodes staying hot for long periods.
Without topology awareness and capacity control, MoE may appear to run fine on dual nodes, but once scaled to thousands of devices, communication waiting rises rapidly.
3.4 Mixed precision and numerical stability
Training usually uses BF16/FP16 mixed precision to save bandwidth and memory, but the two carry different risks:
| Precision | Numerical risk | Common handling |
|---|---|---|
| BF16 | Dynamic range close to FP32, relatively low overflow risk | Usually no loss scaling needed, but still monitor gradient norms |
| FP16 | Narrower dynamic range, prone to underflow or overflow | Requires loss scaling |
| FP32 | Stable but high bandwidth and memory cost | Used for critical accumulation paths |
“Critical-path FP32 accumulation” should generally cover at least softmax, LayerNorm, attention logits, loss computation, and the critical accumulations in gradient reduction. If the vendor stack provides a mixed precision config, be explicit about which operators keep FP32 and which allow BF16/FP16.
4. How to judge whether a training pipeline is trustworthy?
Judging whether a training validation is trustworthy is not just about “loss decreasing,” but about whether it provides verifiable metric definitions. If materials contain loss or memory numbers, you should fill in the source and measurement criteria, for example:
| Metric | Information that needs to be provided |
|---|---|
| Training loss | Dataset, trimmed config, number of experts, GPU type, GPU count, steps, context length, optimizer, smoothing window |
| Validation loss | Validation set source, sample size, token length, evaluation method, whether it includes multimodal samples |
| Peak memory | Parallelism strategy, activation recomputation, batch/seq, optimizer precision, framework version |
| Gradient checks | grad norm, gradient comparison on key layers, presence of NaN/Inf, comparison against a reference implementation |
If the original disclosure shows an abnormal relationship like “starting training loss higher than starting validation loss,” it also needs an explanation. Possible causes include: the training set contains more multimodal samples, the training loss definition is broader, the validation set distribution is narrower, different smoothing windows, or different data duplication. If it cannot be explained, it cannot simply be treated as strong evidence.
For multimodal models, additionally check whether the vision branch is participating in updates. If the language branch loss decreases normally but the vision tower or cross-modal projection has no effective gradients, the model degrades into a pure language model and cannot validate native multimodal capability.
A simplified training health check can be written as:
def check_step(loss, grad_norm, mem_peak, vision_grad_norm=None):assert not math.isnan(loss) and not math.isinf(loss) # Numerical overflow detectionassert grad_norm < GRAD_NORM_THRES # Gradient explosion detectionif vision_grad_norm is not None:assert vision_grad_norm > 0 # Whether the vision branch is participating in updateslog_metrics(step=step,loss=loss,grad_norm=grad_norm,mem_peak_GiB=mem_peak,vision_grad_norm=vision_grad_norm)
5. The gap between trimmed validation and full-scale training
After pipeline validation succeeds, entering full-scale training still requires crossing four barriers.
5.1 Scaling efficiency
Running on a small config does not mean communication is controllable at thousands or tens of thousands of devices. Scaling efficiency depends on:
- Whether per-step time improves approximately linearly with device count.
- Whether All-to-All, All-Reduce, and Reduce-Scatter become the main waiting items.
- Whether expert load is balanced and whether the capacity factor introduces too much wasted computation.
- Whether data loading, checkpoint saving, and validation evaluation block training.
5.2 Long-run stability
Full-scale pretraining often runs for weeks, so long-run stability must be a first-class concern:
- Checkpoint frequency: set it based on per-step time and fault recovery cost; it is recommended to keep both a local snapshot and a remote copy.
- Slow node detection: monitor per-step time P50/P95 and isolate abnormal nodes promptly.
- Fault rescheduling: jobs should support resuming from the most recent stable checkpoint, not training from scratch.
- Data integrity: validate data shards to avoid silent corruption that causes abnormal training trajectories.
5.3 Effective training rate
What really measures cluster output is not peak compute, but the effective training rate. It can be defined as:
Effective training rate = effective training tokens / theoretical trainable tokens of the cluster
You need to continuously monitor idle time caused by communication waiting, load imbalance, fault rescheduling, and data loading bottlenecks. If you only focus on the loss curve and not the effective training rate, you may end up with a job that “converges but is expensive.”
5.4 Precision alignment
Large-scale training should also be compared for precision against industry-recognized baselines. A domestic training stack may introduce systematic bias, such as operator approximations, different reduction orders, or inconsistent mixed precision strategies. The comparison should include at least:
- Same data subset, same seed, same optimizer config.
- Gradient norm comparison on key layers.
- Short-range loss curve comparison.
- Small-scale end-to-end precision validation.
6. Engineering differences between dense models and MoE multimodal
| Dimension | Dense model | MoE native multimodal |
|---|---|---|
| Compute activation | Each token usually passes through all backbone parameters | Each token only activates a subset of experts |
| Memory pressure | Mainly parameters, gradients, optimizer | Also stacks routing, capacity buffers, and expert shards |
| Communication type | Mainly gradient synchronization | Gradient synchronization + All-to-All + multimodal cross-branch synchronization |
| Load balancing | Relatively simple | Expert collapse and routing skew are core problems |
| Scaling bottleneck | Communication and memory | Communication topology, expert parallelism, dynamic shapes, long-run operations |
7. Implementation recommendations: from trainable to well-trained
For teams that want to land trillion-parameter native multimodal MoE training on domestic chips, the following order is recommended:
- Get the pipeline working first: use a trimmed config to validate forward/backward semantics, loss trends, grad norm, and peak memory.
- Establish gates: turn NaN/Inf detection, grad norm thresholds, vision branch gradient checks, and gradient comparison into automated gates.
- Do the memory budget: separately account for parameters, gradients, optimizer, activations, and communication buffers, avoiding estimating only model states.
- Attack communication first: All-to-All and gradient synchronization are the main bottlenecks of MoE scaling; apply topology awareness, hierarchical communication, and computation-communication overlap.
- Combine parallelism: choose TP/PP/EP/FSDP/sequence parallelism based on model structure; don’t rely on a single parallelism strategy.
- Prioritize long-run stability: from day one, build checkpoints, slow node detection, fault recovery, and effective training rate monitoring.
- Trustworthy data and evaluation: all public or semi-public metrics should include source, GPU type, config, steps, and criteria, avoiding unverifiable statements.
The key to training trillion-parameter multimodal MoE on domestic chips is not a one-time “get it running,” but making operators, sharding, communication, mixed precision, and long-run operations into a reproducible, monitorable, and scalable engineering system. Pipeline validation is the starting point; what really determines success is scaling efficiency and long-cycle stability at full scale.
