Getting the Training Pipeline Working on Domestic GPUs: A Practical Guide
This article explains why establishing a working end-to-end training pipeline matters more than chasing peak performance when training large models on domestic GPUs. Using a two-node, sixteen-GPU, 400-step setup as a minimal verifiable scale, it covers environment preparation, a compatibility matrix, reproducibility, data-first parallelism with on-demand model parallelism, mixed precision and gradient accumulation, stability and observability metrics, and checkpoint/resume validation. Readers will find practical engineering conclusions and reusable practices for scaling training reliably.
1. Why Getting the Pipeline Working Matters More Than Speed
In large-scale model training, a common mistake is to focus all attention on peak compute while overlooking the usability of the entire pipeline. “Getting the training pipeline working” means that in a real hardware environment, every stage—data loading, forward computation, backward propagation, gradient synchronization, optimizer updates, checkpoint saving, and resuming from a checkpoint—runs continuously, stably, and reproducibly. Only after the pipeline is working does performance optimization become meaningful.
A two-node, sixteen-GPU, 400-step run is a typical “minimum verifiable scale.” It is not enough to demonstrate the communication complexity of a ten-thousand-GPU cluster, but it is enough to expose most engineering problems: device discovery anomalies, communication library initialization failures, operator precision deviations, memory fragmentation, data pipeline stalls, and lack of observability caused by missing logs. Getting this scale working and stable is a prerequisite for scaling up later.
2. Environment Preparation: Removing Uncertainty Up Front
Environmental issues account for the largest share of pipeline failures. It is recommended to complete the following checklist before starting:
- Establish a clear compatibility matrix for the driver, runtime, and communication library versions, and document it;
- Fix random seeds and data order to ensure reproducibility;
- Run a small-scale self-check on a single machine first, confirming that all devices are visible and compute capacity is consistent;
- Set up the inter-node network and verify that bandwidth and latency meet expectations.
The following is illustrative self-check logic:
import os, torchdef check_env():local_rank = int(os.environ.get("LOCAL_RANK", 0))world_size = int(os.environ.get("WORLD_SIZE", 1))assert torch.cuda.is_available(), "Accelerator device not visible"assert torch.cuda.device_count() >= 1, "Abnormal device count"print(f"rank={local_rank}/{world_size}, device={torch.cuda.current_device()}")
The value of this code lies not in functionality but in “failing early.” If any assertion fails, the problem is exposed before training starts, rather than being discovered at step three hundred due to a gradient anomaly.
3. Parallelism Strategy: Data Parallel First, Model Parallel on Demand
In a two-node, sixteen-GPU scenario, the mainstream approach is data parallelism first: each GPU holds a full model replica, processes a different data shard, and synchronizes gradients via collective communication after backward propagation. This approach is simple to implement and scales well, but it places demands on memory capacity.
When a single GPU cannot hold the full model and optimizer states, tensor parallelism or pipeline parallelism is introduced. Three points need particular attention in engineering:
- Overlap communication with computation to avoid synchronization waits becoming the bottleneck;
- Gradient accumulation, trading smaller micro-batches for an equivalent global batch size;
- Mixed precision, balancing numerical stability against memory usage.
for step, batch in enumerate(loader):with torch.autocast(device_type="cuda", dtype=torch.bfloat16):loss = model(batch) / accum_stepsloss.backward()if (step + 1) % accum_steps == 0:clip_grad_norm_(model.parameters(), 1.0)optimizer.step()optimizer.zero_grad(set_to_none=True)
4. Stability and Observability: The Real Test After 400 Steps
The significance of 400 steps is that it crosses the noisy interval of the “initial phase,” making it possible to observe whether the loss curve decreases smoothly, whether the learning rate schedule behaves as expected, and whether memory usage keeps growing. It is recommended to record at least the following metrics: time per step, proportion of communication time, peak memory usage, gradient norm, and loss value. Once metrics are missing, the cost of locating problems multiplies.
Periodic checkpoint saving and checkpoint-resume validation must also be implemented. A reliable criterion is: after resuming from a checkpoint, the loss curve overlaps with the original training trajectory.
5. Reusable Engineering Conclusions
- Get the pipeline working first, then talk about performance;
- A compatibility matrix and self-check scripts are the lowest-cost insurance;
- Scale out horizontally only after small-scale validation passes;
- Observability and checkpoint-resume are the infrastructure for long-term training.
In related practices at Baidu AI Cloud, such training tasks typically rely on a container platform for environment isolation, use object storage to save checkpoints, and achieve full-pipeline observability through log services and monitoring alerts. Consolidating this methodology into team standards can significantly lower the engineering barrier to large model training.
