Trillion-Parameter Multimodal Training Pipeline Adaptation on Domestic Chinese GPUs: Practices and Validation

    This article examines how engineering teams can adapt trillion-parameter multimodal training pipelines to domestically developed Chinese GPUs. Based on a publicly disclosed validation case, it explains the main challenges of large multimodal models, including sparse Mixture-of-Experts computation, dynamic sparse attention, low-precision numerical stability, memory pressure, and distributed communication. It then presents a five-layer adaptation framework, a cropped validation strategy, key implementation details for MoE layers and parameter sharding, guidance for interpreting training results, and the remaining work required before full-scale pretraining. The goal is to give teams a reusable validation approach for operators, gradient correctness, numerical stability, convergence, and reproducibility before scaling up.

    1. Introduction: The Hard Part Is the Training Pipeline, Not a Single GPU

    Trillion-parameter native multimodal models are becoming a major focus in large-model training. These models typically consist of a language backbone, a vision encoder, and a cross-modal projection module. On the language side, they often adopt a hybrid attention structure combined with sparse Mixture-of-Experts (MoE) layers.

    Recently, a domestic Chinese GPU vendor publicly disclosed validation results for a model of this type. The validation used a deliberately cropped configuration, ran on two nodes with 16 GPUs in total, and completed 400 consecutive steps without numerical overflow or abnormal interruption. The significance of this result is not a higher peak performance number. Instead, it moves the discussion beyond “Can domestic GPUs be used for training?” toward a more systematic question: “How can the full training pipeline be connected and validated?”

    In a training context, the “pipeline” refers to the complete loop from data loading, forward computation, and backward propagation to parameter sharding, gradient reduction, and optimizer updates. For domestic GPUs, the main challenges usually fall into three areas:

    • Whether operator coverage is complete;
    • Whether multiple devices can collaborate efficiently;
    • Whether numerical behavior remains stable under low-precision formats.

    Using this public case as a starting point, this article abstracts a reusable adaptation method and validation framework for teams migrating large-model training workloads to domestic compute platforms.

    2. Why Trillion-Parameter MoE Multimodal Models Are Hard

    Before discussing adaptation work, it is useful to understand how the structural features of these models become engineering constraints.

    2.1 Sparse Activation: Only a Small Fraction of Parameters Is Updated per Step

    MoE layers use a gating network to select the top-k experts for each token. For example, in the cropped configuration with 16 routed experts and top-8 activation, only about half of the expert parameters in a single MoE layer are activated per step. At full scale, the activated ratio is usually only a single-digit percentage.

    Sparse activation decouples model capacity from computation, but it also introduces new constraints:

    • During backward propagation, only activated experts produce gradients;
    • Gradient norm statistics differ from those of dense models;
    • Many entries in optimizer states may remain unchanged for long periods.

    2.2 Dynamic Sparse Attention: A Data-Dependent Computation Graph

    Some trillion-parameter models introduce dynamic sparse attention in the attention layers. The sparse pattern is determined by the input or routing result. This creates two major challenges:

    • Fused attention kernels often assume a fixed sparse pattern;
    • Dynamic routing requires kernels to handle variable-length sequences aggregated according to routing results, while also ensuring that the backward pattern exactly matches the forward pattern. Otherwise, subtle gradient errors may appear and become difficult to diagnose.

    In addition, a 27-layer vision tower and cross-modal projection modules split images into a large number of patch tokens. This further increases sequence length and amplifies memory and bandwidth pressure during attention computation.

    2.3 Numerical Stability: The Hidden Killer in Low-Precision Training

    Low-precision formats such as bf16 and fp16 have limited dynamic range. In deep residual networks, activations can grow layer by layer and eventually exceed the representable range. Once Inf or NaN appears, the error can quickly contaminate gradients.

    MoE introduces two additional risks:

    • The precision of gating logits;
    • The relative weight of the load-balancing auxiliary loss with respect to the main training loss.

    Common industry countermeasures include:

    • Using low precision in the forward pass, while using higher precision for softmax, normalization, and loss computation;
    • Enabling automatic loss scaling;
    • Monitoring gradient norms to identify abnormal steps.

    2.4 Communication and Memory: Two Coupled Cost Centers

    Parallelism Strategy Core Communication Primitive Main Cost
    Data Parallelism (DP) Gradient AllReduce Communication volume scales with parameter count
    Tensor Parallelism (TP) AllReduce / AllGather Frequent communication tightly coupled with computation; usually limited to high-bandwidth intra-node links
    Pipeline Parallelism (PP) Point-to-point transfer between adjacent stages Pipeline bubbles
    Expert Parallelism (EP) All-to-All Communication volume grows with sequence length and top-k; load imbalance is common

    Memory usage can be divided into three parts:

    • Persistent memory: parameters, gradients, and optimizer states, roughly 16 to 18 times the parameter count. For mixed-precision training, each parameter requires 2 bytes for fp16 parameters, 4 bytes for fp32 master weights, 4 bytes each for first-order and second-order moments, plus another 2 to 4 bytes for gradients.
    • Activation memory: grows with sequence length and batch size, and is often the main source of peak memory usage.
    • Temporary buffers: communication buffers and memory fragmentation.

    When using Adam-like optimizers, optimizer states alone can account for roughly 12 times the parameter count. This means that trillion-parameter models must be partitioned across devices. As a result, memory constraints and communication overhead become a central tradeoff in parallel strategy design.

    3. A Five-Layer Framework for Domestic GPU Training Pipeline Adaptation

    Based on the challenges above, adaptation work can be organized into five layers, validated from the bottom up:

    1. Hardware and base library layer: Check numerical consistency of core operators such as matrix multiplication, normalization, and reduction across multiple hardware generations. Also verify whether fused element-wise operations, such as multiply-then-add ordering, behave consistently.
    2. Operator and kernel layer: Complete model-specific operators such as MoE routing and dispatch, dynamic sparse attention, and cross-modal projection. Each operator should have a numerical reference implementation.
    3. Parallel and distributed layer: Determine the combination of DP, TP, PP, and EP. Implement sharding for parameters, gradients, and optimizer states, along with topology-aware collective communication.
    4. Numerical stability layer: Define mixed-precision policies, loss scaling, gradient clipping, anomaly detection, and automatic step skipping.
    5. Observability and reproducibility layer: Track training loss, validation loss, gradient norms, peak memory, throughput, communication ratio, parameter update magnitude, and other metrics. Support checkpoint resume and random seed management.

    A common mistake is to validate only the second layer, operator correctness, and then immediately launch large-scale training. In practice, most “training will not start” problems occur in layers three through five:

    • Improper sharding and state management can cause out-of-memory failures;
    • Poor communication scheduling can severely reduce efficiency;
    • Missing numerical monitoring can allow overflow or instability to appear only after several hours or even days of training.

    This is why the public case emphasizes the forward and backward implementations of hybrid attention and MoE operators. The operator layer is only the starting point. The real engineering effort and risk lie in parallelism and numerical stability.

    4. Cropped Validation: Why Not Run the Full Configuration Immediately?

    4.1 Design Principles

    The public case uses a deliberately designed cropped configuration. The design follows four clear engineering principles:

    Dimension Configuration Purpose
    Language backbone 13 layers Cover the full structure of dense layers, MoE layers, and attention layers with low iteration cost
    MoE structure 16 routed experts, top-8 activation Preserve routing, dispatch, and load-balancing logic while reducing parameter scale
    Vision side Full 27-layer vision tower plus cross-modal projection Avoid cropping to ensure the multimodal gradient path is realistically tested
    Data Public image-text question-answering dataset with random initialization Eliminate pretraining cost and demonstrate pipeline portability with publicly reproducible data
    Parallelism FSDP-style sharding with collective communication across nodes Validate parameter sharding, gradient reduction, and cross-node communication correctness

    This approach can be summarized in three points:

    • Crop aggressively where it is safe, and never crop where it matters. The vision tower and projection modules are what distinguish a native multimodal model from a pure language model. They are also the parts most likely to expose a “language side works, multimodal gradient path fails” problem. Therefore, they are kept intact.
    • Validate the pipeline, not the model quality. With random initialization, there is no pretrained quality baseline. What is being tested is the pipeline itself: whether the forward pass completes, whether gradients flow backward, whether loss decreases, and whether numerics remain stable.
    • Fix issues at small scale before scaling up. A two-node, 16-GPU setup is easy to iterate on and makes it easier to isolate issues in operators, sharding, or communication as soon as they appear.

    4.2 An Easily Missed Detail: Gradient Reduction Changes Meaning Under Sharding

    Once parameters, gradients, and optimizer states are sharded, the definition of “gradient” becomes more subtle. Consider a simple example where parameters are split into a 2×2 grid with four shards.

    Sharding Approach Gradient State on Devices in the Same Group After Backward Reduction Method Result After Reduction
    Split only along the inter-node dimension (4 cards per node) The same shard is identical within each node; different shards correspond to different gradient blocks of the corresponding weights Sum only along the node dimension Each card holds complete and correct gradients
    Two-dimensional split across inter-node and intra-node dimensions (16 cards) Each shard exists in both intra-node and inter-node copies First reduce within each node, then sum along the node dimension Equivalent to the unsharded case; communication volume is roughly 1 divided by the number of intra-node cards compared with no sharding

    Common failure mode: performing a global all-reduce over sharded gradients. This can accumulate the same shard multiple times and effectively scale the learning rate by the number of nodes. In a cropped setup, this may only show up as faster loss reduction and be easily missed. At larger scale, however, it can lead to divergence.

    Recommended validation: compare the parameter difference between sharded and unsharded modes on a small model after a few steps. This helps quantify whether the reduction logic is correct.

    A simplified diagram is shown below:

    1. No sharding:
    2. Each card has the full gradient -- global sum --> all cards update to exactly the same parameters
    3. Sharded (2x2):
    4. Gradients for the same shard within a node are identical -- sum only along the node dimension --> each card holds complete and correct gradients
    5. (Incorrect approach: global sum --> the same shard is accumulated repeatedly, effectively scaling the learning rate)

    5. Key Implementation Details and Code Examples

    5.1 MoE Layer: Routing, Dispatch, and Expert Computation

    The forward pass of an MoE layer usually consists of four steps: gating scores, top-k selection and normalization, token dispatch to experts, and expert computation with weighted aggregation. The dispatch step is tightly coupled with the parallel strategy. Once experts are partitioned across devices through expert parallelism, dispatch becomes an All-to-All communication operation.

    1. # Example code: MoE layer forward flow (pseudocode, only expresses design points)
    2. TOP_K = 8
    3. CAPACITY_FACTOR = 1.25 # Capacity factor reserves headroom to absorb routing imbalance
    4. def moe_forward(tokens, router, experts, ep_group):
    5. # 1. Routing: compute logits and softmax in higher precision to reduce low-precision numerical risk
    6. logits = router(tokens.float()) # [N, E]
    7. scores = softmax(logits, dim=-1)
    8. top_scores, top_idx = topk(scores, k=TOP_K, dim=-1)
    9. weights = top_scores / top_scores.sum(-1, keepdim=True) # Normalization
    10. # 2. Capacity control: each expert has an upper processing limit; tokens exceeding capacity go through residual connection (token dropping)
    11. capacity = ceil(tokens.shape[0] * TOP_K * CAPACITY_FACTOR / ep_group.size())
    12. counts = bincount(top_idx, minlength=num_experts)
    13. # 3. Dispatch: reorder tokens by target expert and perform All-to-All across EP devices
    14. payload = pack(tokens, top_idx, weights) # Flatten into payload for transmission
    15. recv = all_to_all_v(payload, splits=counts, group=ep_group)
    16. # 4. Expert computation: grouped matrix multiplication by expert (grouped GEMM)
    17. out_local = grouped_gemm(recv.hidden, experts.weights, group_ids=recv.expert_id)
    18. # 5. Send results back and aggregate with weights; backward gradients also return to source devices through All-to-All
    19. out = all_to_all_v(out_local, splits=recv.recv_splits, group=ep_group)
    20. y = scatter_weighted_sum(out, top_idx, weights)
    21. aux_loss = load_balance_loss(counts.float(), tokens.shape[0] * TOP_K)
    22. return y + tokens, aux_loss # Residual connection + load-balancing auxiliary loss

    Key implementation points:

    • Routing precision: In bf16 training, it is safer to compute the gating in fp32. Keeping logits in higher precision significantly reduces training disturbance caused by rank flips when two expert scores are close.
    • Capacity factor: This determines the upper processing limit per expert and directly controls the token dropping ratio under load imbalance. It requires a tradeoff between efficiency and quality.
    • All-to-All overlap with computation: Communication cannot be fully hidden, or it becomes a throughput bottleneck. A common approach is pipelining: while the All-to-All for one batch of tokens is in progress, compute the expert matrix multiplications for the current batch.
    • Load-balancing monitoring: Track the number of tokens received by each expert at every step. Persistent skew indicates routing collapse and may require adjusting the auxiliary loss weight.

    5.2 Parameter Sharding and Gradient Reduction

    The public case uses a sharding approach similar to Fully Sharded Data Parallel (FSDP): parameters, gradients, and optimizer states are partitioned across devices. During the forward pass, parameters are AllGathered layer by layer. During the backward pass, gradients are processed with ReduceScatter.

    1. # Example code: forward and backward under fully sharded data parallelism (pseudocode)
    2. mesh = init_device_mesh(shape=(dp_replicate, dp_shard)) # Device mesh: replication dimension x sharding dimension
    3. for layer in model.layers:
    4. # Parameter sharding: each parameter is split along dimension 0 across the dp_shard dimension
    5. for p in layer.parameters():
    6. shard_tensor(p, mesh_dim=mesh["dp_shard"])
    7. # Forward: AllGather parameters layer by layer -> compute -> release immediately after use
    8. for layer in model.layers:
    9. all_gather_params(layer, mesh["dp_shard"])
    10. out = layer(out)
    11. free_params(layer) # Release full parameters and keep only the shard
    12. # Backward: ReduceScatter gradients -- sum while scattering across shards
    13. # Optimizer: only update the shard held by the current device; optimizer state memory is also sharded

    Common engineering adjustments include:

    • Sharding granularity: Use Transformer blocks as the unit instead of treating the whole model as one shard group. This makes computation and communication overlap easier.
    • Hybrid partitioning: Use tensor parallelism within a node to reduce single-device memory pressure, and fully sharded data parallelism across nodes to concentrate inter-node communication on parameter gathering and gradient reduction.
    • Overlap with forward: Prefetch the next layer’s parameters to hide AllGather latency.

    5.3 Numerical Stability Safeguards

    1. # Example code: numerical health check during a single training step (pseudocode)
    2. def train_step(batch):
    3. loss = model(batch) / grad_accum_steps
    4. loss.backward()
    5. flags = []
    6. if not all_finite(loss):
    7. flags.append("NON_FINITE_LOSS")
    8. grad_norm = clip_grad_norm_(model.parameters(), max_norm=1.0)
    9. if not all_finite(grad_norm):
    10. flags.append("NON_FINITE_GRAD") # Inf/NaN detected: skip this step
    11. zero_grad(model)
    12. return loss, grad_norm, flags
    13. if grad_norm > SPIKE_THRESHOLD: # Gradient spike: optionally skip
    14. flags.append("GRAD_SPIKE")
    15. zero_grad(model)
    16. return loss, grad_norm, flags
    17. optimizer.step()
    18. zero_grad(model)
    19. if is_master():
    20. log(step=cur_step, loss=loss, grad_norm=grad_norm,
    21. flags=flags, mem_peak=get_max_memory())
    22. return loss, grad_norm, flags

    The key point of these safeguards is that the training job should skip abnormal steps rather than crash. In large-scale training over hundreds of millions of tokens, occasional abnormal steps are normal. The ability to skip them automatically directly determines whether a large-scale run can continue reliably. The conclusion in the public case that “no numerical overflow or abnormal interruption occurred” depends precisely on this kind of monitoring and handling mechanism.

    6. How to Interpret Validation Results

    Metric Observed Result Engineering Interpretation
    Training loss Mean of steps 21–70: 8.9365; mean of the last 50 steps: 2.1802 The optimization objective is decreasing, and the forward/backward loop is working
    Validation loss 6.5297 to 4.6873 No obvious sign of overfitting; the data pipeline is functioning normally
    Peak memory 44.80 GiB Sharding and activation management fit within the target GPU memory budget
    Numerical stability No overflow throughout Mixed precision and operator numerical implementations are controllable
    Continuity 400 steps without interruption Basic long-run stability is initially validated
    Gradient check Passed Backward implementation and sharded reduction logic are correct

    When interpreting these numbers, four points should be noted:

    1. Loss reduction does not mean the pipeline is 100% correct. Some implementation errors can make the model appear to train faster. For example, an incorrect reduction logic may effectively amplify the learning rate, or an MoE layer may incorrectly route all tokens through the residual path. The first case often appears as faster convergence in short validation runs. The second case may only be detected by checking the gradient norm ratio of the MoE layer. Therefore, gradient checks and parameter update checks cannot be skipped.
    2. Do not compare absolute loss values across configurations. The cropped configuration has different layer counts, expert counts, sequence lengths, and data scale than the full configuration. Loss can only be compared within the same configuration and cannot be used to infer convergence speed for full-scale training.
    3. Training and validation loss decreasing together is a good signal. It suggests there is no obvious overfitting and that data preprocessing and label alignment are not misaligned.
    4. Peak memory reflects methodology, not an absolute limit. It shows that the memory budget is sufficient under the current sharding approach, but larger models, longer sequences, or larger batch sizes require re-estimating memory usage.
    Validation Level Pass Criteria Main Methods
    Operator level Numerical error within threshold against reference implementation Unit tests, comparison with random inputs
    Single-machine model level Loss decreases monotonically over several steps End-to-end test with a small model
    Multi-machine pipeline level Loss converges, no overflow, memory remains controllable Continuous training with the cropped configuration
    Full pretraining Long-term stability, throughput, and scaling efficiency meet expectations Checkpoint resume, fault injection, scale-up testing

    7. What Still Needs to Be Solved Before Full-Scale Pretraining

    It is important to be clear: validating the pipeline with a cropped configuration proves that “this pipeline can run and learn.” It does not mean that full-scale pretraining can start immediately. At least four additional challenges must be addressed.

    7.1 Cluster Scale-Up

    In the public case, cross-node communication is handled by a collective communication library. At hundreds or thousands of GPUs, however, several new issues appear:

    • Communication complexity: With ring or tree algorithms, the communication volume of AllReduce scales logarithmically with the number of devices, while latency increases with scale.
    • Long-tail effect: The slowest node determines when the entire collective communication finishes. At large scale, this is a major source of reduced scaling efficiency.
    • Topology matching: The mapping of parallel groups, such as which GPUs form a TP group or an EP group, must align with the physical interconnect topology. Otherwise, a large amount of communication may cross lower-bandwidth links.

    7.2 Parallel Strategy Re-Tuning

    The cropped configuration only uses data-parallel-style sharding and cross-node collective communication. This is a minimal validation setup. In full-scale training, when a single GPU cannot hold the full parameters and optimizer states, tensor parallelism, expert parallelism, and even pipeline parallelism may be required. Each additional parallelism strategy requires re-validation of numerical correctness and communication efficiency.

    7.3 Long-Run Stability and Fault Tolerance

    A continuous 400-step run demonstrates short-term stability, while full pretraining often lasts for weeks or even months. During that period, the system must handle:

    • Hardware failures: node crashes, GPU loss, network jitter;
    • Silent data errors: computations may become wrong without raising an error, potentially contaminating thousands of training steps;
    • Checkpoint save, load, and recovery speed.

    These require supporting fault-tolerance mechanisms, such as hot standby nodes, asynchronous checkpointing, and periodic numerical verification.

    7.4 Efficiency and Cost

    Metric Definition Reference Range
    Model FLOPs Utilization (MFU) Achieved model throughput divided by the theoretical peak compute of the hardware Large-scale industry training often cites 40%–50% as a strong level
    Effective Training Rate The proportion of total runtime actually spent on training A publicly disclosed fully domestic Chinese chip cluster reported about 97%

    These two metrics measure training efficiency from two perspectives: “compute quickly” and “do not idle.” The public case emphasizes that the key point is not single-GPU peak performance, but the systematic completion of the distributed training pipeline. This is because in full-scale training, total time is often determined not by peak compute alone, but by communication efficiency and downtime caused by failures.

    8. A Reusable Checklist for Developers

    Stage Check Item Pass Criteria
    Operator alignment MoE routing and dispatch, dynamic sparse attention, cross-modal projection Error within threshold against reference implementation
    Numerical consistency Layer-wise activation and gradient precision comparison No systematic offset; error magnitude is reasonable
    Parallel correctness Sharded gradient reduction, communication group mapping Sharded and unsharded results match on small-scale tests
    Numerical stability Mixed precision, loss scaling, gradient clipping Abnormal steps can be detected, skipped, and recovered
    Pipeline convergence Continuous training with cropped configuration Loss keeps decreasing, no overflow, no interruption
    Reproducibility Fixed random seeds, reproducible data ordering Loss curves align under the same configuration
    Scale and stability Checkpoint resume, fault injection, scale-up testing Recovery time is acceptable and scaling efficiency meets expectations

    From a broader perspective, domestic AI chip ecosystems in China are entering a large-scale deployment phase. Cloud providers in China are combining containerized GPU compute, monitoring and alerting, and logging services with heterogeneous training clusters to provide resource scheduling and observability for training workloads. Training pipeline adaptation is also moving from isolated breakthroughs toward engineering-grade, reusable practices.

    The public disclosure of a 400-step continuous run, together with loss curves and gradient check details, provides a useful engineering reference for reproducibility in domestic GPU training. It answers the question: “Can the pipeline run correctly?” It does not answer: “Can the model be trained well?” From a cropped configuration to full pretraining of a complete trillion-parameter model, two major challenges remain: cluster scale-up and long-run stability.

    For teams planning to train large models on domestic compute, a practical approach is to start with operator alignment and gradient checks, then validate progressively layer by layer. This ensures that every scale-up step is supported by data.