Engineering Practices for Training Trillion-Parameter Multimodal MoE Models on Chinese-Made AI Accelerators
This article describes how to train trillion-parameter multimodal Mixture-of-Experts (MoE) models on Chinese-made AI accelerators. It explains the main system challenges, including memory pressure, all-to-all communication, and the differences between vision and language branches. It then presents a four-layer verification approach covering operators, parallelism and sharding, communication, and convergence, and describes how reduced-scale configurations help find problems before full-scale training.
1. Why Training Trillion-Parameter Multimodal MoE Models Is Hard
For very large models, the main difficulty usually lies in coordinating the system, not in single-device compute. The Mixture-of-Experts (MoE) architecture activates only some experts for each input, which lowers the compute required per step. However, it also introduces three new problems.
The first is memory pressure. The total parameter count is very large. Even when only some experts are active in each step, optimizer states and gradients must still be stored in full or in sharded form. Peak memory usage is often determined by the optimizer states rather than by the model weights.
The second is complex communication. Expert routing distributes data across different devices, which creates all-to-all communication. The communication volume changes dynamically with the routing results, so it is difficult to estimate precisely in advance.
The third is the heterogeneity of the multimodal branches. The vision encoder and the language backbone differ in computation pattern, sequence length, and data distribution. Both need a unified strategy for gradient synchronization and parameter updates. If the vision branch does not take part in parameter updates, training cannot achieve true joint multimodal optimization.
In addition, sparse attention operators are usually implemented differently from standard attention. They require custom forward and backward computations, which makes them one of the most common failure points in the pipeline.
2. Four Levels of Checks for the Training Pipeline
Split the entire training pipeline into four layers and verify each layer in turn. This makes problems easier to locate than running the full task directly.
2.1 Operator Layer: Verify Forward and Backward Passes Together
Custom operators are the most common source of failure. A correct forward result does not guarantee correct backward gradients, so compare the results against numerical gradient checks.
The recommended approach is as follows:
- Fix the random seed, and compare the output difference between the custom implementation and a reference implementation on small inputs.
- For the backward computation, estimate gradients with finite differences, and check whether the relative error falls within an acceptable range.
- Under mixed precision, test the low-precision and high-precision paths separately, and record where the error comes from.
Numerical overflow is another frequent problem. In low-precision training, activations or gradients can exceed the representable range and produce infinity or NaN (Not a Number) values. Common remedies include dynamic loss scaling, gradient clipping, and higher-precision computation for sensitive operators such as softmax.
2.2 Parallelism and Sharding Layer: Calculate Memory First, Then Choose a Strategy
In sharded training, parameters, gradients, and optimizer states are divided evenly across devices according to the number of shards. A rough estimate is:
Memory per device ≈ (parameter count × state bytes per parameter) / number of shards + activation memory + communication buffers
In mixed-precision training, the state cost per parameter is usually much higher than the size of the parameter itself, because the optimizer also stores first and second moments and a master copy of the weights. Use this basis for estimates. Do not rely only on the size of the model weight files.
The MoE layer also requires expert parallelism. After the experts are distributed across devices, the routing results for each batch determine which devices receive data. The ratio of total experts to devices, together with the number of experts activated per token, jointly determines the communication volume.
2.3 Communication Layer: Topology Sets the Performance Ceiling
Bandwidth between devices within the same node is usually higher than bandwidth across nodes over the network. When experts are distributed across nodes, all-to-all communication can easily become the main bottleneck.
There are three main optimization directions:
- Place experts that interact frequently within the same node whenever possible.
- Overlap communication with computation. While waiting for communication results, run computation that does not depend on them.
- Control the amount of data communicated per step. For example, merge small messages before sending them to reduce launch overhead.
During validation, record the breakdown of each step’s time into computation time, communication time, and wait time. If communication consistently takes a larger share than computation, adjust the topology or the parallelism strategy.
2.4 Convergence Layer: A Run That Completes Is Not Necessarily a Correct Run
Running several steps without errors only shows that the pipeline is connected. To judge whether training is correct, watch the trends in loss and gradients and compare them with the expected behavior.
3. Reduced-Configuration Validation: Purpose and Design
Full-scale pretraining is expensive, and a failed run is costly. Before committing resources, teams often validate the pipeline with a reduced configuration. The principle is to keep every module that could introduce new engineering risk, and to shrink only the parts that affect model size alone.
The reduced configuration can be designed as follows:
- Reduce the number of layers in the language backbone, but keep the structure within each layer unchanged, so the full forward and backward computation of the attention and MoE layers still runs.
- Scale down the number of experts proportionally, while keeping the routing property that the number of experts activated per token is smaller than the total number of experts.
- Keep the vision encoder as complete as possible, because cross-modal projection and the multimodal data flow are most likely to fail during integration.
- Use a smaller public image-text dataset, and train from random initialization.
A reduced-configuration run trained from random initialization can only verify functionality and trends. It does not represent the accuracy of the final model. A validation report should state clearly the scope in which its conclusions apply.
4. Key Metrics and How to Read Them
Group validation metrics into five categories, and set an anomaly criterion for each category.
| Metric | Focus | Abnormal Signal |
|---|---|---|
| Training loss | Overall downward trend | NaN values appear, or the loss does not decrease for a long period |
| Validation loss | Whether it moves in the same direction as the training loss | Training loss keeps falling while validation loss keeps rising, which suggests overfitting or a data issue |
| Peak memory | Whether there is headroom | Close to the limit, causing intermittent failures |
| Step time | Balance between computation and communication | Step time |
