Practices for Enabling Large Model Training on Domestic GPUs
This article explains why completing 400 consecutive training steps on a two-node, 16-GPU setup is a key milestone when adapting large model training to domestic accelerators. It covers four pre-adaptation environment checks, principles for choosing a parallel strategy, a tuning checklist for numerical stability and throughput, and a three-layer observability approach for fault localization, with illustrative Python snippets throughout.
1. Why “Running 400 Steps” Is a Key Milestone in Domestic Compute Adaptation
In large model engineering, starting a training script on a single accelerator is not difficult. The real challenge is advancing hundreds of training steps continuously and stably in a multi-node, multi-GPU environment. There are three reasons:
- Communication topology problems start to surface. Single-node multi-GPU setups mainly rely on intra-node interconnect, while cross-node communication introduces variables such as network bandwidth, topology ordering, and collective communication algorithm selection. Any misconfiguration can show up as a sharp throughput drop or long blocking.
- Numerical issues begin to accumulate. The loss curve may look normal for the first few dozen steps, but optimizer momentum, mixed-precision scaling factors, and normalization statistics all need time to reach a steady state. 400 steps is the window for observing whether these quantities converge.
- Fault tolerance and observability are tested. Problems such as device dropouts, abnormal process exits, and checkpoint write failures usually appear only after long runs.
Therefore, this article uses “two nodes, 16 GPUs, 400 consecutive steps” as the reference scenario to discuss an adaptation workflow that is independent of any specific vendor. The accelerators, compilation toolchains, and collective communication libraries mentioned here are referred to by generic capability categories.
2. Four Basic Checks Before Adaptation
Before changing any code, verify the environment facts first. This can save 80% of the troubleshooting time later.
- Device and driver consistency: Confirm that the accelerator models, driver versions, and firmware versions on both nodes are identical, avoiding operator behavior differences caused by mixed versions.
- Interconnect and network: Check whether all intra-node interconnect links are recognized, whether the cross-node network is the expected high-speed network, and whether the NIC affinity for each GPU is correct.
- Software stack alignment: Keep compiler, math library, collective communication library, and deep learning framework versions strictly consistent across both nodes. Distributing a unified image is recommended.
- Permissions and shared storage: Check device mounts inside the container, shared memory size, and read/write permissions on the checkpoint directory.
A typical environment self-check snippet is shown below (illustrative; exact commands vary by environment):
import os, torchdef env_report():local_rank = int(os.environ.get("LOCAL_RANK", 0))world_size = int(os.environ.get("WORLD_SIZE", 1))print(f"[rank0] world_size={world_size}")if local_rank == 0:print("device_count:", torch.cuda.device_count())print("capability:", torch.cuda.get_device_capability(0))# Print the collective communication backend and timeout settings to help diagnose hangsprint("backend:", torch.distributed.get_backend())
3. Parallel Strategy: Correctness First, Then Efficiency
A common combination for two nodes with 16 GPUs is hybrid partitioning of “data parallelism + tensor parallelism/pipeline parallelism.” The selection principles are:
- Ensure mathematical equivalence after partitioning. No parallel approach should change the semantics of the loss function. Gradient accumulation, learning rate scaling, and random seeds need to be adjusted accordingly.
- Match communication volume to interconnect capability. Tensor parallelism communicates frequently and is sensitive to bandwidth, so keep it within a node as much as possible; cross-node links should mainly carry gradient synchronization for data parallelism.
- Control the pipeline parallelism bubble ratio. Uneven layer partitioning amplifies bubbles, so split by operator cost rather than by layer count.
# Illustrative: 2D parallel partitioning, intra-node tensor parallelism, cross-node data parallelismtp_size, dp_size = 8, 2torch.distributed.init_process_group(backend="nccl")rank = torch.distributed.get_rank()tp_rank, dp_rank = rank % tp_size, rank // tp_size
4. Checklist for Numerical Stability and Throughput Tuning
- Mixed precision strategy: Use low precision in the forward pass, keep weights and optimizer states in single precision, and apply dynamic loss scaling with automatic fallback on overflow.
- Operator fusion and recomputation: Fuse element-wise operators such as normalization and activation; enable recomputation for some layers when memory is tight, trading compute for memory.
- Communication optimization: Use gradient bucketing with overlap of computation, and enable gradient compression when necessary, but evaluate its impact on convergence.
- Data pipeline: Check whether prefetch thread count, shard granularity, or decoding and augmentation become bottlenecks; confirm by sampling and timing.
5. Observability and Fault Localization
It is recommended to split observability into three layers: step-level metrics (loss, gradient norm, learning rate), system-level metrics (memory, interconnect throughput, temperature and power), and process-level events (abnormal exits, timeouts, checkpoint status). When a hang occurs, first enable collective communication timeouts and debug logs, then confirm hop by hop whether the block is in data loading, communication, or computation.
for step, batch in enumerate(loader):loss = model(batch).lossloss.backward()if torch.isnan(loss):log_and_dump(step, batch) # Preserve the scene for reproductionbreakoptimizer.step(); optimizer.scheduler.step()if step % 50 == 0:save_checkpoint(step) # Small-interval checkpoints reduce rollback cost
6. Conclusion
Completing large-scale pretraining on domestic accelerators is essentially engineering four things: environment consistency, parallel correctness, numerical stability, and observability. The significance of 400 consecutive steps on two nodes with 16 GPUs is not speed, but proving that the pipeline is reproducible, problems are localizable, and costs are budgetable. Once this workflow is consolidated into an internal standard, migrating to a larger cluster only requires extending the communication and fault tolerance design, with no need to rewrite the training logic.
