Large Model Training Adaptation on Domestic GPUs: Practical Engineering for Stable Training
This article explains what large-model training adaptation means on domestic GPUs and why it is different from base-model pre-training. It covers core training paths such as data parallelism, tensor parallelism, pipeline parallelism, expert parallelism, and fully sharded parallelism, then discusses how to keep multi-node training numerically stable through monitoring, checkpointing, and fault recovery. It also highlights challenges from multimodal models and mixture-of-experts architectures, compares inference adaptation with training adaptation, and offers practical recommendations for teams moving from inference deployment to end-to-end stable training.
In this article, “domestic” refers to locally developed or manufactured GPUs and AI accelerators in China.
What Is Large Model Training Adaptation: Concept and Value
In large-model deployment, “training adaptation” is often confused with “completing pre-training.” They are different in engineering scale and goal.
- Base-model pre-training: Building model weights from randomly initialized parameters using massive corpora on a specific compute cluster. This requires extremely large compute investment and a very complex engineering chain.
- Training adaptation: Making an already designed model structure, optimizer logic, and parallel strategy run correctly and stably through the full training pipeline on target hardware and software stacks. It validates whether the model is trainable and can converge.
It is important to note that successful adaptation or integration does not mean the model was pre-trained from scratch on that chip. In industry, multiple hardware routes are sometimes validated side by side, for example by validating inference operators across accelerators with different architectures. Such validation often focuses on operator correctness and inference performance, rather than the original source of base weights. Therefore, understanding the real boundary of adaptation is the first step to avoid misinterpretation when assessing the maturity of domestic compute.
Core Technical Path: Sharded Parallelism
Large models often contain hundreds of billions of parameters, or nearly a trillion. A single GPU cannot hold the complete parameters, gradients, and optimizer states. To make training possible, distributed parallel strategies are required. Common approaches include:
- Data parallelism (DP): Each GPU holds a complete model replica, data batches are split across devices, and gradient synchronization keeps the replicas consistent.
- Tensor parallelism (TP): Individual operators, such as matrix multiplication, are split across multiple GPUs to reduce per-GPU computation and memory pressure.
- Pipeline parallelism (PP): Model layers are split across devices to form a forward and backward execution pipeline.
- Expert parallelism (EP): For mixture-of-experts (MoE) architectures, different experts are distributed across devices.
- Fully sharded parallelism (parameter sharding, similar to FSDP): Parameters, gradients, and optimizer states in data parallelism are further sharded and gathered only when needed, greatly reducing per-GPU memory usage.
When doing training adaptation on domestic AI accelerators, fully sharded data parallelism is often a common starting point for building a native training path because it is friendly to GPU memory and more controllable from an engineering perspective. It requires connecting three parts: model loading and sharding, shard scheduling, and gradient synchronization.
The following pseudocode illustrates the key structure of a sharded training loop. It is not tied to a specific framework API.
# Illustrative pseudocode for a full training loop with sharded parallelism# 1. Load and shard the full model according to the sharding policymodel = load_and_shard(full_model, shard_policy="full_shard")# 2. Build the optimizer; each process only holds part of the parameter statesoptimizer = build_optimizer(model, lr=1e-4, weight_decay=0.01)for step, batch in enumerate(dataloader):# 3. Forward pass; sharded parameters are gathered as neededoutput = model(batch)# 4. Compute loss; in multimodal scenarios this may be a weighted combination of multiple lossesloss = compute_loss(output, batch.target)# 5. Backward pass; gradients are synchronized according to the sharding rulesloss.backward()# 6. Gradient clipping and optimizer updategrad_norm = clip_grad_norm_(model.parameters(), max_norm=1.0)optimizer.step()optimizer.zero_grad()# 7. Numerical health monitoringmonitor(loss, grad_norm, step)
Whether this pipeline can run stably for thousands of steps without interruption is a key indicator of adaptation quality.
Cross-Node Stability: Keeping a 400-Step Training Run From Breaking
In small-scale cross-node scenarios, such as two nodes with 16 accelerators in total, the validation goal is not to achieve the highest throughput. Instead, it is to verify the correctness of the pipeline and numerical stability. A mature technical report usually focuses on the following observations:
- Loss remains finite throughout the run: No NaN or Inf appears, indicating that the forward and backward computation chain is numerically healthy.
- Gradient norm stays controlled: No sudden spikes or collapse occur, indicating that gradient clipping and mixed-precision scaling are configured reasonably.
- The optimizer updates continuously: Hundreds of consecutive updates complete without interruption, indicating that communication, checkpointing, and fault-tolerance mechanisms do not expose fatal issues.
Compared with single-node training, cross-node training is most likely to encounter problems in collective communication. Operations such as AllReduce, AllGather, and ReduceScatter across nodes are highly sensitive to network bandwidth, topology, and communication library stability. Common issues include:
- Communication timeouts causing training to hang.
- Compute and communication clocks across nodes being out of sync, leading to numerical inconsistency.
- Occasional link jitter during long-running training being amplified into a training interruption.
Engineering measures for these issues include:
- Setting reasonable communication timeouts and retry policies.
- Using gradient accumulation to smooth batch-level fluctuations.
- Adding periodic checkpoints and resume-from-checkpoint support.
- Performing real-time monitoring of key metrics.
The following is illustrative monitoring code:
import mathdef monitor(loss, grad_norm, step, tol=1e6):# Check whether the loss is finiteif not math.isfinite(loss):raise FloatingPointError(f"step {step}: invalid loss -> {loss}")# Check whether the gradient norm is abnormalif not math.isfinite(grad_norm) or grad_norm > tol:raise FloatingPointError(f"step {step}: abnormal gradient norm -> {grad_norm}")# Log metrics for later analysislog_metric(step=step, loss=loss, grad_norm=grad_norm)
Numerical stability may look like a small issue, but at nearly trillion-parameter scale, any overflow or precision mismatch can invalidate a long training run. This is why mature solutions emphasize a seemingly simple but highly important conclusion: loss and gradient norm should remain finite throughout training.
Additional Challenges from Multimodal and Complex Architectures
Frontier large models are moving from pure text to multimodal processing, combining text, images, audio, and video, and toward mixture-of-experts (MoE) structures. These changes create higher requirements for training adaptation:
- Multi-task loss balancing: Multimodal models usually optimize multiple subtask losses at the same time. Poor loss weighting can let one gradient dominate and cause training to diverge.
- Dynamic routing and expert load balancing: MoE expert selection is sparse and dynamic. Uneven load across devices can leave some devices idle and create communication bottleneck effects.
- Heterogeneous operator adaptation: Multimodal encoders, attention variants, normalization layers, and other components often require many custom or partially custom operators. If any operator is missing or numerically inconsistent on the target hardware, the training pipeline can be blocked.
Therefore, building a native multimodal training path is essentially a comprehensive test of operator completeness, combinations of parallel strategies, and numerical consistency.
From Fast Inference Deployment to End-to-End Stable Training
Many early domestic compute adaptation efforts focused on inference because inference has relatively lower sensitivity to numerical precision and less demand for long-running stability. However, moving from inference to training represents a substantial increase in complexity:
| Dimension | Inference Adaptation | Training Adaptation |
|---|---|---|
| Core goal | Correct single forward pass; meet throughput targets | Forward, backward, and update pipeline converges |
| Numerical requirement | Tolerate some error | No overflow over long runs; model can converge |
| Parallelism complexity | Usually relatively simple | Data, tensor, pipeline, and expert parallelism combined |
| Long-run requirement | Second-level response | Continuous runs from hundreds to tens of thousands of steps |
| Fault tolerance | Request-level retry | Checkpoints, resume from checkpoint, fault recovery |
A mature training engineering system needs both fast inference deployment capability and end-to-end stable training capability. Both are essential.
Methodology: Operator Adaptation, Multi-GPU Coordination, and Automation Tooling
To move large-model training on domestic full-function GPUs from “can train” to “ready out of the box,” three layers usually need to be improved:
- Operator adaptation layer: Build complete operator coverage and precision validation mechanisms. Missing operators should be replaced with equivalent implementations or custom implementations, and consistency tests should ensure numerical alignment with reference implementations.
- Multi-GPU coordination layer: Optimize collective communication, combinations of parallel strategies, and memory scheduling. Reduce communication overhead, improve device utilization, and support stable cross-node execution.
- Automation toolchain layer: Provide one-click training startup, configuration management, metric collection, checkpointing, and fault recovery. This reduces user complexity by encapsulating complexity inside the tooling.
In cloud environments, these capabilities often work together with container-based compute scheduling, distributed storage, logging, and monitoring alerts to form reusable training platform capabilities. Baidu AI Cloud, for example, has engineering experience in heterogeneous compute scheduling, distributed training framework support, and monitoring and alerting. It can provide integrated support from environment preparation to training monitoring for enterprise users. This is only a general capability description and does not involve specific collaboration details.
Practical Recommendations
For teams planning to run large-model training on domestic compute, the following recommendations are actionable:
- Start with small-scale validation: Use two nodes with a dozen or more accelerators and run hundreds of continuous training steps to verify pipeline correctness and numerical stability before scaling up.
- Establish metric baselines: Create comparable baselines for loss, gradient norm, throughput, and GPU memory usage. Any deviation should be traceable to a specific change.
- Prioritize checkpoints and fault tolerance: Long-running training must include periodic checkpoints and resume-from-checkpoint support to avoid losing long training runs due to a single-point failure.
- Verify operator consistency first: Before expanding parallel strategies, ensure that basic operators are numerically aligned on the target hardware. Otherwise, small errors may accumulate and amplify across layers.
- Turn operations into tooling: Turn startup, monitoring, and recovery procedures into an automation toolchain so that “ready out of the box” becomes a repeatable engineering capability rather than a one-time experience.
Conclusion
Training adaptation for large models on domestic AI accelerators is a system engineering task that spans concept clarification, operator integration, sharded parallelism, cross-node coordination, and automation tooling. Its goal is not to chase benchmark rankings, but to achieve stability, convergence, and reproducibility. When loss and gradient norm remain healthy across hundreds or even tens of thousands of steps, and when training teams can rely on a mature toolchain to deploy the full process from environment setup to monitoring, domestic full-function GPUs have truly completed the key transition from “can train” to “ready out of the box.” This process is not only a validation of compute power, but also a concentrated reflection of software-hardware co-engineering capability.
