Getting Large Model Training Working on Domestic GPUs: A Practical Guide

    This article walks through the practical steps for validating a large model training pipeline on domestic GPU accelerators, using a two-node, 16-GPU run of 400 uninterrupted steps as the baseline. It covers why a working pipeline matters more than benchmark numbers, how to standardize the software stack with containerized delivery, how to choose tensor, pipeline, and data parallelism under divisibility constraints, the three main pitfalls of mixed-precision training, checkpointing and fault tolerance, and how to read performance through three ratios instead of a single throughput figure. Readers will get a reusable checklist for adapting training workloads to new accelerator hardware.

    1. Why Getting the Pipeline Working Matters More Than Chasing Metrics

    When adapting large-scale pre-training to domestic accelerators, the first obstacle a team hits is usually not accuracy but the pipeline itself: whether the compute cards can be kept fed, whether communication overlaps with computation, and whether checkpoints are written and restored correctly. A run described as “two nodes and 16 GPUs completing 400 steps without interruption” is essentially a validation of a minimal viable loop — data goes in, gradients come back, state is saved, and the job can resume. Four hundred steps is an empirical threshold: it is long enough to cover learning rate warmup, several gradient accumulation boundaries, at least one checkpoint write, and one log aggregation cycle, while not consuming too much machine time.

    Four hard criteria are useful for judging whether the pipeline is genuinely working:

    • All 16 processes finish initialization and the communication domain is established successfully;
    • 400 consecutive steps with no process exits and no silent skipped steps;
    • A monotonically explainable loss curve with no step-like jumps;
    • After restoring from the latest checkpoint, the loss over the first few steps stays within noise range of the original trajectory.

    2. The Environment Baseline: Drivers, Communication Libraries, and Containerized Delivery

    The first gate is software stack consistency. The most reliable practice is to package the driver, communication library, collective communication implementation, and training framework into a single image, orchestrated by a container platform, avoiding the occasional hangs caused by “one minor version difference on each machine.” The elements to pin and verify include the accelerator driver and firmware version, the collective communication library version, the network plugin version, and the framework and its operator library versions. Any drift can surface as communication timeouts or operators falling back to inefficient paths.

    On the network side, separate the two channels: the high-bandwidth intra-node interconnect handles tensor parallelism inside a machine, while the inter-node network handles data parallelism and pipeline communication. Bind inter-node traffic to the high-speed NICs and specify the NIC list explicitly, so traffic does not fall back to the management port and collapse bandwidth.

    1. # Example: pin NICs and enable debug logs to locate communication bottlenecks
    2. export COMM_IFNAMES=eth0,eth1
    3. export COMM_DEBUG=INFO
    4. export FRAMEWORK_LOG_LEVEL=INFO

    3. Parallelism Strategy: Splitting 16 GPUs Along the Right Dimensions

    Two nodes with 16 GPUs is a small-scale validation configuration, and the strategy choice directly determines success. The empirical order is: first use tensor parallelism within a node to reduce per-layer memory pressure, then use pipeline parallelism to split layers, and finally add data parallelism across nodes to raise throughput. If the number of model layers is divisible by the pipeline degree and the number of attention heads is divisible by the tensor parallel degree, the split incurs no padding overhead.

    1. # Example: degree constraints for 3D parallelism
    2. tensor_parallel = 4 # must divide the number of attention heads
    3. pipeline_parallel = 2 # must divide the number of model layers
    4. data_parallel = world_size // (tensor_parallel * pipeline_parallel) # 16 / 8 = 2
    5. assert world_size == 16 and data_parallel >= 1

    Estimate the memory budget across five separate items — parameters, gradients, optimizer states, activations, and communication buffers — and leave headroom for fragmentation. Activation recomputation is the most cost-effective lever: it trades roughly 30% extra compute for a large reduction in activation memory, usually a better deal than lowering batch size.

    4. Numerical Stability: Three Pitfalls Under Mixed Precision

    Mixed-precision training gives a significant speedup but needs supporting measures. First, loss scaling: the dynamic scaler should avoid frequent overflow that wastes steps. Second, reduction precision: keep higher-precision accumulation for gradients and optimizer states to prevent error buildup during multi-GPU reduction. Third, randomness control: data sampling order and non-deterministic operator implementations both affect reproducibility, so the validation phase should fix random seeds and enable deterministic operator options.

    A practical self-check snippet:

    1. # Example: minimal checks inside a training step
    2. for step, batch in enumerate(loader):
    3. with autocast():
    4. loss = model(batch) / accum_steps
    5. loss.backward()
    6. if (step + 1) % accum_steps == 0:
    7. clip_grad_norm_(model.parameters(), 1.0)
    8. optimizer.step(); optimizer.zero_grad(set_to_none=True)
    9. if step % 50 == 0:
    10. logger.info({"step": step, "loss": float(loss) * accum_steps,
    11. "lr": scheduler.get_last_lr()[0]})

    5. Checkpoints and Fault Tolerance: Making 400 Steps Re-runnable

    A long pipeline must assume failure. A checkpoint should save the model, optimizer, scheduler, and data loader progress together, written asynchronously to object storage or a parallel file system so synchronous writes do not stall training on I/O. On restore, verify tensor shapes and step consistency, and keep the last few checkpoints rather than only one, so an interrupted write cannot leave a truncated file. At the job level, let the container platform handle health probes and automatic restarts, and pair this with logging and monitoring alerts, turning “which step it stalled on, which GPU is slow” into observable metrics.

    6. Reading Performance: Three Ratios Instead of a Single Number

    Judging pipeline quality by single-GPU throughput alone is easy to misread. Three ratios are more meaningful: communication time as a share of step time, pipeline bubble ratio, and data loading wait ratio. If any one exceeds 20%, the bottleneck is in how work is organized, not in compute. Diagnosis involves per-stage timing, collective communication timing statistics, and tuning input pipeline prefetch depth. In related work, Baidu AI Cloud typically recommends collecting monitoring metrics and training logs together, which makes it easier to compare different parallelism configurations side by side.

    7. Implementation Checklist

    • Pin all versions inside the image; only configuration differs across nodes;
    • Satisfy the divisibility constraints for parallel degrees, intra-node before inter-node;
    • Pair mixed precision with loss scaling and high-precision reduction;
    • Keep multiple asynchronous checkpoints, and compare the loss trajectory after restore;
    • Locate bottlenecks with the three ratios rather than chasing a single throughput number.

    Following this process, two nodes and 16 GPUs completing 400 steps is only the starting point; the real payoff is a transferable adaptation method, so later training at larger scale does not have to start from trial and error.