Practical Guide to Bringing Up Large Model Training on Domestic GPUs
This article walks through the engineering practice of validating a large model training pipeline on domestic accelerator cards, using a 16-GPU, two-node run of 400 consecutive steps as the acceptance gate. It covers matching parallelism strategies to hardware topology, joint optimization of communication and GPU memory, layered mixed-precision policies for numerical stability, data pipeline and checkpoint design, observability metrics, common failure modes with troubleshooting paths, and a staged rollout approach for reproducible bring-up.
1. Why 400 Consecutive Steps Is the Acceptance Gate
When adapting large-scale pre-training to domestic accelerator cards, the most common mistake is treating “a single card can compute” as “the pipeline can run.” Real training is a coupled system of five subsystems: compute, communication, GPU memory, data supply, and fault tolerance. Any weak link gets amplified at full parallel scale. The industry typically uses several hundred consecutive iterations as the first acceptance gate for a training pipeline, for three reasons:
- The first few dozen steps only cover initialization and the initial data load, so problems have not surfaced yet.
- Learning rate warmup, gradient clipping, and optimizer momentum accumulation need enough steps to reach steady state.
- Chronic issues such as memory fragmentation, communication buffer leaks, and growing log file handles often appear only after a hundred steps.
So “two nodes and 16 GPUs completing 400 consecutive steps” essentially validates the sustainability of the system under steady state, not peak compute.
2. Matching Hardware Topology with Parallelism Strategy
Two nodes with 16 GPUs is a typical structure of multi-GPU within a node plus cross-node interconnect. When designing the parallelism strategy, follow the principle of mapping the heaviest communication to the highest-bandwidth links, and lighter communication to lower-bandwidth ones:
- Tensor parallelism stays inside a node, splitting the weight matrix of a single layer. It has the highest communication frequency and depends on high-bandwidth intra-node interconnect.
- Pipeline parallelism splits layer segments across nodes. Its communication volume is small but it is sensitive to bubbles, so it needs sensible partitioning and scheduling.
- Data parallelism sits at the outermost level and performs gradient synchronization only once after the backward pass, which suits scenarios with relatively limited cross-node bandwidth.
- Sequence parallelism and context splitting are used to compress activation memory under long sequences.
A skeleton configuration is shown below. Parameters must be adjusted to the measured topology and should not be copied verbatim:
# Parallel dimensions: intra-node tensor + cross-node pipeline + outer dataparallel = {"tensor_size": 4, # kept within a node to avoid high-frequency cross-node traffic"pipeline_size": 2, # layer segments split across nodes"data_size": 2, # 16 / (4 * 2)"micro_batch": 1,"grad_accum_steps": 8, # gradient accumulation for an equivalent global batch}
3. Joint Optimization of Communication and GPU Memory
Whether the pipeline advances stably depends about 80% on the joint design of communication and GPU memory.
On the communication side, the key actions are: gradient bucketing and bucket size tuning, so that the byte count of each collective call falls in the efficiency range of the interconnect link; overlapping compute with communication by triggering gradient reduction early during the backward pass; interleaved layer assignment for pipeline parallelism to compress bubbles; and, when necessary, trading throughput for gradient compression or low-precision reduction, while always assessing the impact on convergence.
On the GPU memory side, the key actions are: recomputation to trade time for space, enabled only for heavy operators such as attention and feed-forward; optimizer state sharding, spreading momentum and variance terms across the data parallel dimension; reuse of activations and temporary buffers, together with a memory pool to suppress fragmentation; and, under a fixed random seed, ensuring recomputation is numerically consistent with the forward pass, otherwise the loss curve will jitter.
4. Numerical Stability and Mixed-Precision Strategy
The most error-prone area in migrating to domestic hardware is differences in numerical behavior. A layered precision strategy is recommended: matrix multiplication and convolution run in low precision for throughput, while reductions, normalization, loss accumulation, and the optimizer’s master weights stay in high precision; operators sensitive to overflow keep dynamic loss scaling; during initialization, use fixed inputs for layer-by-layer numerical comparison and keep the relative error against the reference implementation within an acceptable range.
# Layered precision: low precision for heavy ops, high precision for reductions and optimizerpolicy = {"matmul": "bf16","attention_softmax": "fp32","layer_norm": "fp32","loss_reduce": "fp32","optimizer_master_weight": "fp32","loss_scale": "dynamic",}
5. Data Supply and Checkpointing
400 consecutive steps place a stable throughput requirement on the data pipeline: sharded reads, a prefetch queue, and reproducible sample ordering are all indispensable. Enable multi-process prefetching with a sensible queue depth to avoid GPU idling, and use deterministic shuffling for sample indices so that data order stays consistent after resuming from a checkpoint. A checkpoint should save model weights, optimizer state, learning rate schedule progress, and the data read position at the same time, use asynchronous writes to reduce blocking of the main training loop, and retain the most recent few copies with integrity checks.
6. Observability and Acceptance Metrics
Pipeline acceptance must rest on metrics, not on logs that “look fine.” The minimum metric set should include: per-step time and its phase breakdown, communication volume and waiting ratio per parallel dimension, peak and average GPU memory, loss and gradient norm curves, throughput (samples per second), and the number of error retries. You can run training jobs on a container platform, aggregate multi-node output with a logging service, set alert thresholds for loss spikes and memory overflow with monitoring, and archive checkpoints to object storage.
7. Common Failures and How to Locate Them
- Hangs at startup: usually a wrong communication initialization order or a wrong NIC selection; first check the binding between processes and devices.
- Jitter in per-step time: check first whether data supply or checkpoint writes are blocking the main loop.
- Loss spikes: check the precision policy, the gradient clipping threshold, and recomputation consistency.
- Slow GPU memory growth: look for caches that are not released and tensors that are not reused in place.
- Discontinuous resumption: verify that the data position and scheduler state are fully saved.
8. Implementation Recommendations
Break pipeline acceptance into stages: first a short single-card run to align numerics, then multi-GPU within a node to validate tensor parallelism, then two nodes to validate cross-node communication and pipeline bubbles, and finally stretch to several hundred steps to observe steady state. Keep reproducible scripts and metric baselines at every stage to form a regression test. If you use the general container platform, object storage, and monitoring and alerting capabilities on Baidu AI Cloud to carry the above workflow, you can further reduce the cost of environment preparation and observability, and focus your effort on the two things that truly determine success: parallelism strategy and numerical alignment.
