Getting Large Model Training Working on Domestic GPUs: A Practical Guide
This article walks through the practical steps for establishing a working large model training pipeline on domestic GPU accelerators. It explains why validating the full training loop on a small two-node, sixteen-GPU setup for roughly four hundred steps matters more than raw speed, then covers environment preparation, parallelism strategy, operator and numerical consistency checks, stability and observability, acceptance criteria, and common pitfalls. The goal is to help teams converge uncertainty layer by layer before scaling up. The article also notes that elastic compute and supporting infrastructure such as object storage, container platforms, and monitoring can be provided by Baidu AI Cloud.
1. Why Getting the Pipeline Working Matters More Than Running Fast
When running large-scale pre-training on domestic accelerator cards, the first obstacle teams hit is usually not a lack of compute but a broken pipeline. The pipeline is the complete closed loop: data loading, tokenization and packing, model sharding, forward and backward passes, gradient synchronization, optimizer updates, checkpoint saving, and metrics reporting. If any single stage is missing or behaves inconsistently, training will show loss anomalies, hang, or exit with a non-zero code within a few dozen steps.
For this reason, the industry commonly treats a “short, controlled experiment” as the first step: use a small configuration such as two nodes with sixteen GPUs, run about four hundred iterations end to end, verify the correctness and reproducibility of the pipeline, and only then scale up to more nodes and GPUs. The output of this stage is not model quality but observability, stability, and engineering discipline.
2. Environment Preparation: Reducing Uncertainty to the Minimum
- Align drivers and runtime. Confirm that the accelerator driver, runtime libraries, and communication libraries are mutually compatible and identical across all nodes. Version drift is the most common root cause of “works on a single node, fails on multiple nodes.”
- Confirm network and topology. Make node-to-node bandwidth, NIC binding, and topology order explicit so that communication does not go over the wrong NIC. It is recommended to establish a baseline first with generic bandwidth and latency tests.
- Isolate dependencies. Use a container platform or virtual environment to pin dependencies and avoid system-level package conflicts. Images should be reproducible and rollback-friendly.
- Storage and data. Place training data on object storage or a parallel file system, and run sample counts and validation first to ensure every node sees a consistent view.
An illustrative pre-launch check:
# Illustrative only: confirm runtime and device visibility are consistent across nodesfor h in node-a node-b; dossh "$h" "device-info --summary; runtime-version"done
3. Parallelism Strategy: The Right Sharding for Small-Scale Validation
Two nodes with sixteen GPUs is a typical small-scale validation scenario. The recommended combination is “data parallelism first, adding tensor or pipeline parallelism only when necessary”:
- Data parallelism: each GPU holds a full model replica, and gradients are synchronized via collective communication. It is simple to implement and well suited to validating the pipeline.
- Tensor parallelism: a single layer’s weights are sharded across GPUs, reducing per-GPU memory pressure, but communication becomes more frequent, so topology affinity matters.
- Pipeline parallelism: layers are split across GPU groups, requiring bubble and scheduling handling; it can be left off during the pipeline validation stage.
- Memory optimization: sensibly enable recomputation, mixed precision, and optimizer state sharding to fit the target model within limited memory.
The key principle is “simple before complex”: the four-hundred-step experiment should first ensure numerical correctness and an end-to-end flow, then gradually introduce more complex sharding schemes.
4. Operators and Numerical Consistency: The Easiest Pitfalls
Operator coverage and numerical behavior on domestic accelerator cards may differ from common industry implementations. In practice, it is recommended to:
- Build an operator whitelist and substitute unsupported or inconsistent operators with equivalent ones;
- Fix random seeds and compare forward outputs and gradient norms layer by layer;
- Run small-scale “single GPU vs. multi-GPU” comparison experiments to confirm the loss curves match within tolerance;
- Set a loss scaling strategy for mixed precision to avoid gradient underflow.
Illustrative comparison check logic:
# Illustrative only: tolerance comparison of forward outputs between single and multi-GPUassert torch.allclose(out_single, out_multi, rtol=1e-3, atol=1e-3)grad_norm_diff = abs(g_single - g_multi) / max(g_single, 1e-8)assert grad_norm_diff < 5e-3
5. Stability and Observability
Four hundred steps is short, yet enough to expose stability issues. It is recommended to turn the following metrics into dashboards and connect them to monitoring, alerting, and logging services:
- Throughput and per-step time, to observe periodic jitter;
- Share of time spent in collective communication, to judge whether communication is the bottleneck;
- GPU and host memory levels, to catch leaks early;
- Loss, gradient norm, and learning rate curves, to confirm optimization behaves normally;
- Checkpoint save and restore time, to verify fault tolerance.
Also set up automatic retries and resume-from-checkpoint: recover from the most recent checkpoint so that a long experiment is not interrupted by an occasional failure.
6. Evaluation and Acceptance: Let the Data Speak
Once the pipeline runs, a minimal set of acceptance criteria is needed:
- Loss decreases monotonically within four hundred steps with no spikes;
- Single-GPU and multi-GPU results match within tolerance;
- Two consecutive runs produce reproducible results;
- Checkpoints can be saved, loaded, and used to resume training;
- Resource utilization and communication share stay within a reasonable range.
7. Common Pitfalls Checklist
- Version mismatches across nodes causing communication initialization to fail;
- Uneven data sharding causing waiting and idle time;
- Optimizer state not sharded correctly, triggering out-of-memory errors;
- Incomplete checkpoint writes causing resume failures;
- Missing metrics reporting, making problems hard to locate.
8. Conclusion
Completing large-scale pre-training on domestic accelerator cards is not about single-point performance but about pipeline completeness, numerical consistency, and operational maintainability. Using two nodes with sixteen GPUs and four hundred iterations as the minimal validation unit, combined with a clear parallelism strategy, strict operator checks, thorough observability, and clear acceptance criteria, teams can converge uncertainty layer by layer and lay a reliable foundation for larger-scale training later. If elastic compute and supporting general capabilities such as object storage, container platforms, and monitoring and alerting are needed, Baidu AI Cloud can provide the corresponding infrastructure support.
