Adapting Trillion-Parameter Multimodal Model Training Pipelines for Domestic Accelerator Cards

    This article explains the key challenges of training trillion-parameter MoE-based multimodal models on domestic accelerator cards, and how to verify that a training pipeline truly works. It covers the four critical links of a training pipeline—operator forward and backward implementations, sharding management, cross-node communication, and numerical stability—along with monitoring logic and an interpretation of published validation results from a 16-card, 400-step training run.

    Background: Why Trillion-Parameter Multimodal Models Are Hard to Train

    Multimodal large models have reached the trillion-parameter scale and commonly adopt Mixture-of-Experts (MoE) architectures. The difficulty of training these models lies not in the raw compute of a single card, but in how multiple cards work together. The routing mechanism dispatches different samples to different experts, so both computation and communication volume change dynamically with the input at every step. Sparse attention makes the attention operator’s compute pattern deviate from conventional dense implementations. The vision encoder and the language backbone share a single optimization pipeline, gradients flow back between the two branches, and memory usage becomes harder to predict.

    Therefore, the key question in evaluating whether a hardware platform or training solution can support this class of models is whether the training pipeline can run end to end while maintaining numerical stability in a distributed environment.

    1. Single-Card Peak Performance vs. a Working Pipeline

    Single-card peak performance measures theoretical compute capability and has limited direct impact on whether training can complete. Whether a training job runs successfully depends on all four of the following capabilities being present at once:

    • Operator coverage: forward and backward implementations must exist and be numerically correct for attention, routing, and expert computation.
    • Distributed state management: parameters, gradients, and optimizer states must be sharded according to well-defined rules and synchronized correctly at every step.
    • Cross-node communication: inter-node bandwidth and latency determine whether communication can overlap with computation.
    • Numerical stability: no overflow, gradient explosion, or silent computation errors over long training runs.

    If any one of these is missing, training typically fails at startup or within the first few dozen steps. Running continuously for hundreds of steps without interruption indicates that the pipeline is essentially working.

    2.1 Forward and Backward Operator Implementations

    The core operations of an MoE layer are routing and expert dispatch. The router computes each expert’s score for every token, selects the Top-K experts, and dispatches tokens to them. During backpropagation, gradients flow back along the same path. Common implementation issues include:

    • Load imbalance, where some experts receive too many tokens and slow down the overall step time;
    • Inconsistency between the drop or truncation policy applied on expert capacity overflow and the forward computation, causing gradient bias;
    • Sparse attention masks and block partitioning producing different numerical errors on different hardware.

    During validation, each operator should be compared element by element against a reference implementation, with error ranges recorded.

    2.2 Sharding Management

    Fully sharded data parallelism partitions parameters, gradients, and optimizer states across devices. With mixed precision and an Adam-family optimizer, each parameter typically requires about 16 bytes of associated state during training under common configurations, depending on the precision scheme. The total state of a trillion-scale model far exceeds the memory of a single card, so sharding is mandatory.

    Sharding must solve two problems. First, shard boundaries and indices must be consistent across devices, otherwise gradients become misaligned. Second, during checkpoint save and restore, sharded states must either be reassemblable or resharding into a new layout must be supported.

    2.3 Cross-Node Communication

    Expert parallelism in MoE introduces all-to-all communication: tokens are exchanged between nodes at every step. Communication cost is directly related to the number of experts, the number of tokens, and inter-node bandwidth. Three common optimization approaches are:

    • Overlapping communication with computation, hiding forward communication within the computation of adjacent batches;
    • Partitioning communication groups according to node topology, so high-frequency exchanges complete within a node first;
    • Using bucketing and asynchronous launches for gradient synchronization to reduce waiting time.

    2.4 Numerical Stability and Monitoring

    Loss, gradient norm, learning rate, and peak memory usage should be recorded continuously throughout training. The following signals require immediate investigation: loss becoming NaN or Inf, sudden spikes in gradient norm, or certain experts having near-zero load over extended periods.

    Below is an illustrative monitoring snippet; actual thresholds should be determined based on the model and data:

    1. import math
    2. def check_step(step, loss, grad_norm, mem_peak_gib):
    3. # Terminate immediately on non-finite loss to avoid wasting resources on invalid computation
    4. if not math.isfinite(loss):
    5. raise RuntimeError(f"step {step}: non-finite loss detected")
    6. # Log a warning when gradient norm exceeds the preset threshold
    7. if grad_norm > GRAD_NORM_LIMIT:
    8. log.warning(f"step {step}: grad norm {grad_norm:.2f} exceeds threshold")
    9. log.info(f"step={step} loss={loss:.4f} mem_peak={mem_peak_gib:.2f}GiB")

    3. Interpreting the Trimmed-Configuration Validation Results

    A publicly disclosed validation used the following configuration: two machines with 16 cards in total, training continuously for 400 steps with no numerical overflow or abnormal interruption. To control cost, the language backbone was trimmed to 13 layers, with 16 experts of which 8 were activated per token. The vision encoder retained its full 27 layers and trained together with the cross-modal projection module. Training data was a medical image-text question-answering dataset, and the model was trained from random initialization.

    The validation results are as follows:

    Metric Start End Notes
    Training loss 8.9365 (mean of steps 21–70) 2.1802 (mean of final 50 steps) Averaged to reduce single-step fluctuation
    Validation loss 6.5297 4.6873 Reflects model performance on untrained samples
    Peak memory 44.80 GiB — Measurement follows the original disclosure