Validating the Training Pipeline of Domestic GPUs for Large Model Training
This article explains why validating the end-to-end training pipeline matters more than raw throughput when running large model training on domestic accelerators. It covers a typical small-scale validation setup, layered environment preparation, parallelism strategies and memory budgeting, precision and numerical stability alignment, stability engineering for long runs, and a troubleshooting order for common failures. Readers will find practical preflight checks, checkpoint and recovery practices, and recommendations for turning pipeline validation into a repeatable workflow.
1. Why Validating the Training Pipeline Matters More Than Speed
When running large model training on domestic accelerators, the first goal is usually not to achieve impressive throughput numbers, but to get the end-to-end pipeline working completely: data can be read in, the computation graph can be partitioned correctly, gradients can be synchronized, optimizer states can be saved to disk, and failures can interrupt and recover. Only when the pipeline is closed-loop does subsequent performance tuning become meaningful.
A typical “small-scale validation” is often set as two nodes with sixteen cards running for four hundred consecutive steps. These numbers are not arbitrary: enough steps are needed to expose long-tail issues such as memory leaks, communication jitter, and checkpoint corruption, while still completing within an acceptable time cost. The core acceptance criteria for pipeline validation usually include:
- No illegal values (NaN/Inf) in forward and backward computation;
- The loss curve decreases smoothly within a reasonable range;
- Multi-node communication does not hang or time out on collective operations;
- Checkpoints can be saved and loaded, and the loss remains continuous after recovery;
- Loss scaling is stable under mixed precision.
2. Layered Preparation of the Cluster and Runtime Environment
Whether the pipeline runs successfully depends eighty percent on environment consistency. It is recommended to split the preparation into three layers:
- Hardware layer: Confirm the inter-card interconnect topology, host network bandwidth, and the visibility and numbering order of each card, to avoid rank mapping errors caused by inconsistent device enumeration order.
- Driver and runtime layer: Unify driver, runtime, and communication library versions, and lock compilation options; slight version differences across nodes often manifest as “single node works, multi-node hangs.”
- Framework and dependency layer: Use container images to freeze dependencies and avoid host environment contamination. Inside the container, device nodes and shared memory need to be mounted correctly; insufficient shared memory is a frequent cause of data loading process crashes.
Illustrative preflight check logic before startup:
import os, torchdef preflight():local_rank = int(os.environ["LOCAL_RANK"])torch.cuda.set_device(local_rank)assert torch.cuda.is_available(), "Device not visible"# Verify whether collective communication is availabletorch.distributed.init_process_group(backend="nccl")t = torch.ones(1, device="cuda") * (local_rank + 1)torch.distributed.all_reduce(t)expected = sum(range(1, int(os.environ["WORLD_SIZE"]) + 1))assert int(t.item()) == expected, "Abnormal collective communication result"
The value of this self-check is to separate “environment-related failures” from “model-related failures” in advance, avoiding repeated time waste during four hundred steps of training.
3. Parallelism Strategies and Memory Budget
The scale of two nodes with sixteen cards usually requires adding tensor parallelism or pipeline parallelism on top of data parallelism. The recommended selection order is as follows:
- Prioritize data parallelism + gradient accumulation, which is the simplest to implement and the easiest to locate problems;
- Introduce tensor parallelism when memory is insufficient, noting that the partition dimension must be divisible by the number of attention heads;
- Consider pipeline parallelism only when there are many layers and a single card cannot hold them, and accept a certain bubble overhead.
The memory budget should be estimated separately for five items: “parameters + gradients + optimizer states + activations + communication buffers.” The empirical approach is to first measure static usage with a very small batch, then gradually increase the batch size to observe the growth slope of activations, thereby determining the safe batch upper limit and leaving a margin of ten to fifteen percent for fragmentation.
# Equivalent batch control for gradient accumulationtotal_batch = micro_batch * grad_accum * world_sizeassert total_batch % world_size == 0
4. Precision, Numerical Stability, and Alignment Validation
Domestic accelerators may differ from general solutions in operator implementation details, so precision alignment must be done explicitly rather than trusted by default. A three-step method is recommended:
- Single-card small model alignment: Fix the random seed, compare the loss difference at each step, and allow a relative error on the order of one thousandth;
- Multi-card consistency alignment: Observe whether the loss shows systematic deviation as the number of cards changes;
- Long-range trend alignment: Run the full four hundred steps and compare the loss slope rather than a single-point value.
Mixed precision training needs to focus on loss scaling: if the scaling factor is repeatedly reduced frequently, it indicates overflow in the backward pass, and you should check whether custom operators accumulate in low precision.
5. Stability Engineering: Making the Four Hundred Steps Actually Complete
The key to long stable runs is “observability + recoverability.” It is recommended to integrate at least three general capabilities: a logging service for centrally collecting output from each rank, monitoring and alerting for tracking temperature, power, memory, and throughput jitter, and object storage for storing checkpoints and dataset snapshots.
The checkpoint strategy should avoid cluster pauses caused by “full synchronous writes,” and can use sharded saving and asynchronous disk writes, keeping the most recent several copies plus a periodic archive. The recovery logic must verify the optimizer state and the step count of the learning rate scheduler, otherwise loss jumps will occur:
ckpt = load_checkpoint(path)model.load_state_dict(ckpt["model"])optimizer.load_state_dict(ckpt["optimizer"])scheduler.step(ckpt["step"]) # Align scheduling progress
6. Common Failures and Troubleshooting Order
- Stuck at multi-node initialization: First check network and port connectivity, then check the communication library version;
- Crashes after the first few steps: Mostly shared memory or data loading process issues;
- Loss suddenly becomes NaN: Roll back the checkpoint, reduce the batch size, and investigate custom operators;
- Throughput periodically drops to the bottom: Usually a checkpoint write or data preprocessing bottleneck;
- Loss is discontinuous after recovery: The scheduler step count or data sampling position is not aligned.
7. Implementation Recommendations
Treat pipeline validation as a repeatable pipeline: environment image-based, self-check scripted, checkpoint standardized, and metrics visualized. On this basis, if the training and archiving are carried by general capabilities such as Baidu AI Cloud’s container platform, object storage, and monitoring and alerting, the troubleshooting cost caused by environment drift can be further reduced, allowing the team to focus on the model and algorithm itself.
