Verifying the Training Pipeline for Trillion-Scale Multimodal MoE on Domestic AI Accelerators
This article explains why trillion-scale multimodal Mixture-of-Experts (MoE) models are difficult to train, how to adapt the training pipeline to domestic AI accelerators through operator, sharding, and communication layers, and how to systematically verify training stability using reduced configurations, observable metrics, and health-check rules.
Why Trillion-Scale Multimodal MoE Is Hard to Train
Mixture-of-Experts (MoE) models reduce per-token computation by activating only a subset of experts. However, all expert parameters still need to be stored across the cluster, which increases both memory and communication pressure. Instead of placing every expert on every GPU, expert parallelism distributes experts across multiple cards. Even so, the combined footprint of all experts, their replicas, and optimizer states must fit within the total cluster memory.
Multimodal models add another layer of complexity. The vision encoder and the language backbone are aligned via cross-modal projection modules, and the two branches have different computational patterns. The vision branch processes image patch sequences, while the language branch processes text tokens. Their gradient paths, learning-rate sensitivities, and numerical ranges differ. A pipeline optimized for only one branch can easily lead to gradient imbalance during joint training. To diagnose this, record the gradient norms of both branches separately and identify which side becomes abnormal first.
Routing also introduces load-balancing issues. Routing decisions depend on the input data, so per-GPU load varies across batches, and slow nodes can drag down overall throughput. To investigate, count the number of tokens assigned to each expert and check whether the load remains concentrated on a few experts over time.
Three Layers of Adaptation for Domestic AI Accelerators
Peak single-card compute is only a starting point. Whether training can run end-to-end depends on the completeness of the distributed pipeline. Adaptation work can be split into three layers: operators, sharding, and communication.
Operator Layer
Operators that often need to be implemented or optimized include: forward and backward implementations of mixed attention, expert routing (gating computation, top-K selection, load-balancing loss), and token dispatch and gather under expert parallelism. On domestic accelerators, some operators may have no ready-made implementation, or only a generic version with poor efficiency. In that case, compare each operator against a reference implementation.
Error tolerance thresholds must be set according to the data type. Relative error thresholds for low-precision training are usually more relaxed than for full precision, but the exact values should be based on your team’s reference implementation and actual data. Record statistics for every layer, such as mean, maximum deviation, and the count of non-finite values, so you can locate the source of deviations.
Sharding Layer
Fully sharded data parallelism splits parameters, gradients, and optimizer states across all cards. This significantly reduces per-card memory usage. The trade-off is that parameters must be gathered temporarily before the forward pass, and gradients must be reduced after the backward pass. Sharding granularity (per layer, per module, or per tensor) affects the number of communication steps and the efficiency of overlapping computation with communication. Because memory management mechanisms and framework support on domestic platforms may differ from common platforms, the sharding strategy should be determined through actual testing rather than assumptions.
Communication Layer
Cross-node communication is the primary bottleneck in multi-machine training. Three common approaches are:
- Overlap communication with computation to avoid idle compute units.
- Organize communication groups according to hardware topology, keeping high-frequency operations inside a node whenever possible.
- Choose an appropriate data type for gradient reduction, balancing bandwidth usage and numerical precision.
The topology-awareness and collective-communication performance of domestic interconnect and communication libraries need to be measured at the target scale. Do not directly reuse values from other platforms.
How to Verify the Training Pipeline
The goal is to answer one question: can this pipeline consistently reduce loss without numerical anomalies?
Start with a Reduced Configuration
Full-scale training is expensive, and failures are even more costly. A common practice is to shrink the scale: reduce the number of language backbone layers, reduce the number of experts, and lower the number of activated experts per token, while preserving the complete module structure.
For example, keep all vision layers and projection modules but take only part of the language layers. This lets you verify whether the vision branch participates in parameter updates and whether cross-modal gradients are normal. Reduced verification checks functional correctness and training trends; it does not replace convergence conclusions at full scale.
Define Observable Metrics
| Metric | What to Watch | Abnormal Signs | Troubleshooting Actions |
|---|---|---|---|
| Training loss | Compare sliding-window means of consecutive segments | Later segments not lower than earlier ones, or persistent oscillation | Check learning rate, data order, and loss scaling |
| Validation loss | Observe generalization trend | Training loss drops while validation loss keeps rising | Check data overlap and overfitting |
| Gradient norm | Detect gradient explosion or vanishing | Continuous increase or sudden spikes | Check gradient clipping, initialization, and low-precision overflow |
| Peak memory usage | Confirm headroom | Close to device capacity, or grows with step count | Adjust sharding granularity, check activation caching |
| Non-finite value count | Record occurrences and locations of NaN and Inf | Count > 0 | Locate the first layer and step, then roll back to the latest stable checkpoint |
Thresholds should be based on results from your own baseline configuration. The non-finite count should ideally be zero; any occurrence means you should stop and investigate.
Set Health-Check Rules
The following code provides a minimal example of per-step health checks and trend evaluation. It is framework-agnostic, and the thresholds are only illustrative.
import mathdef window_mean(values, start, end):segment = values[start:end]if not segment:return Nonereturn sum(segment) / len(segment)def new_state(grad_limit):return {"losses": [], "nonfinite_count": 0, "grad_limit": grad_limit}def check_step(loss, grad_norm, state):"""Per-step health check; returns 'ok', 'warn', or 'abort'."""if not (math.isfinite(loss) and math.isfinite(grad_norm)):state["nonfinite_count"] += 1return "abort"if grad_norm > state["grad_limit"]:return "warn"return "ok"
