Connecting the Training Pipeline for Large Language Models on Domestic GPUs: A Practical Guide
This article walks through a practical validation of running large language model training on domestic GPU accelerators across two nodes with sixteen cards, completing 400 consecutive iterations. It explains why sustained multi-step stability matters more than single-step peak compute, outlines the topology and interconnect prerequisites, and compares data, pipeline, and tensor parallelism trade-offs. It also covers numerical stability with mixed precision, data pipelines and checkpointing, observability for tuning, common pitfalls, and how to reproduce the validation in a cloud environment.
1. Why Completing 400 Steps Is a Meaningful Milestone
In large-scale pretraining, the ability to complete hundreds of iterations stably is often a better indicator of pipeline health than single-step peak compute. A single successful step only proves that the operators work; 400 consecutive steps mean that data supply, communication, memory management, checkpointing, logging, and fault tolerance have all reached a steady state. Here, “a domestic accelerator card” refers to a class of general-purpose domestic graphics processing accelerator devices. Their software stack typically includes device drivers, a runtime, communication libraries, collective communication operators, and a framework adaptation layer. The core of engineering validation is getting these layers to work together on the same computation graph.
The significance of 400 steps can be broken down into three layers:
- Functional layer: forward pass, backward pass, optimizer update, gradient clipping, and learning rate scheduling all run through, with no illegal memory access and no operator fallback.
- Performance layer: single-step time enters a stable range and fluctuation converges, indicating that communication and computation are sufficiently overlapped.
- Stability layer: the loss curve shows no spikes, no gradient explosion, and no occasional failures caused by memory fragmentation.
2. Topology and Interconnect Prerequisites for Two Nodes with Sixteen Cards
Two nodes with sixteen cards means each machine hosts eight accelerator cards. Within a machine, cards are usually connected through a high-bandwidth interconnect bus; across machines, they are connected through a high-speed network (such as one supporting remote direct memory access). Before validation, three things must be confirmed:
- Topology visibility: whether each card’s index, the device node it belongs to, and its proximity to the network interface are correctly enumerated.
- Bandwidth measurement: whether collective communication bandwidth within and across machines meets expectations, avoiding a situation that is “multi-card in logic but serial in physical layout.”
- Version consistency: drivers, runtime, and communication libraries on all devices are strictly identical in version, avoiding hidden hangs caused by mixed versions.
A typical topology probing approach (illustrative, not tied to a specific tool):
# Pseudo-flow: confirm device count and interconnect relationshipsenumerate_devices() -> [0..15]group_by_host() -> {hostA: [0..7], hostB: [8..15]}probe_collective_bw(within_host, across_host)assert across_host_bw > threshold
If inter-machine bandwidth is significantly lower than expected, prioritize checking network configuration, NIC binding, and hang timeout settings rather than blindly adjusting parallelism.
3. Parallelism Strategy: Trade-offs Among Data, Pipeline, and Tensor Parallelism
With sixteen cards under a single-machine eight-card constraint, a common combination is “data parallelism + pipeline parallelism,” with tensor parallelism added when necessary. The selection principles are as follows:
- Data parallelism: split the global batch across cards and synchronize gradients via all-reduce. It is the simplest to implement, but communication volume grows linearly with the number of cards.
- Pipeline parallelism: split by layers across devices and fill the pipeline with micro-batches to reduce per-card memory pressure, at the cost of pipeline bubbles.
- Tensor parallelism: split matrix operations of a single layer across multiple cards. It involves frequent communication and is generally used only within the high-bandwidth domain of a single machine.
An empirical configuration example:
# Structure illustration only; parameters must be tuned by model size and measured bandwidthparallel = {"data_parallel_size": 2, # across machines"pipeline_parallel_size": 4, # across cards within a machine"tensor_parallel_size": 2, # nearby cards within a machine"micro_batch_size": 1,"global_batch_size": 512,}assert parallel["data_parallel_size"] * \parallel["pipeline_parallel_size"] * \parallel["tensor_parallel_size"] == 16
The key constraint is that the product of the three equals the total number of cards, tensor parallelism does not cross machines, and pipeline parallelism is aligned as much as possible with the high intra-machine bandwidth. The global batch must be divisible by the data parallelism degree, which determines the number of gradient accumulation steps.
4. Numerical Stability and Mixed Precision
The most common failure within 400 steps is not a hardware fault but a numerical issue. Mixed precision training should focus on:
- Loss scaling: dynamic scaling automatically adjusts when gradients underflow, preventing updates from being zeroed out.
- Reduction precision: gradient all-reduce is recommended to accumulate in higher precision to reduce cross-card error accumulation.
- Normalization and residuals: normalization layers and residual connections keep master weight precision to prevent activation drift.
- Optimizer states: first- and second-order momentum stay at the same precision as master weights to avoid distortion of the update direction.
It is recommended to enable anomaly detection as a preliminary switch and expose problems with dozens of steps before a formal long run:
# Illustration: pre-training self-checkenable_anomaly_detection(True)for step in range(50):loss = train_step(batch)if not is_finite(loss):raise RuntimeError(f"non-finite loss at step {step}")
5. Data Pipeline and Checkpointing
Data supply must keep up with the consumption speed of sixteen cards. Practical points include sharded reading, prefetching and parallel decoding, reproducible sample ordering, and matching the number of data loading threads to device compute power. For checkpointing, although 400 steps is short, periodic saving should still be configured, and the loss continuity of “save—reload—continue training” should be verified. Distributed checkpoints are recommended to be stored in shards by parallelism dimension to avoid single-point writes becoming a bottleneck.
6. Observability and the Tuning Loop
Without observability, it is impossible to locate “why it is slow.” The minimum viable set includes: single-step time breakdown (compute/communication/data wait), peak memory and fragmentation, the proportion of collective communication time, loss and gradient norm curves, and device temperature and throttling events. Tuning proceeds in this order: first eliminate data waiting, then improve communication and computation overlap, and finally adjust parallel partitioning and batch size.
7. Common Pitfalls Checklist
- Version drift: the adaptation layer on the device side does not match the framework side, manifesting as random hangs.
- Topology misjudgment: tensor parallelism crosses machines, and bandwidth becomes a hard bottleneck.
- Batch not divisible: the number of gradient accumulation steps is calculated incorrectly, and the effective batch does not match expectations.
- Silent degradation: operators fall back to generic implementations, performance drops sharply but no error is reported.
- Unusable checkpoints: saving succeeds but the loss jumps after reloading.
8. Reproducing This Validation in the Cloud
To reproduce a similar validation in a cloud environment, you can assemble it from general capabilities: use a container platform to deliver the runtime and dependencies uniformly, use object storage to hold datasets and checkpoints, use a message queue to decouple data preprocessing, and use log services and monitoring alerts to build an observability loop. Baidu AI Cloud can provide the above general-purpose capabilities in such scenarios, helping teams focus their energy on the aspects that truly determine success or failure, such as parallelism strategy and numerical stability.
In summary, the value of completing 400 iterations on two nodes with sixteen cards lies not in getting it to run, but in establishing a reusable validation methodology: first confirm topology and bandwidth, then fix the parallel partitioning, then tackle numerical stability and data supply, and finally use observability to drive tuning. Once you master this path, migrating to a larger-scale cluster only requires scaling up the parameters, without having to retrace the detours.
