Practical Guide to Training Large Models on Domestic GPUs: A Two-Node, 16-GPU Walkthrough

    This article explains how to establish a stable and reproducible large-model training pipeline on domestic GPU platforms, using a two-node, 16-GPU run of 400 iterations as the validation milestone. It breaks the training stack into layers, discusses parallelism choices across nodes, operator adaptation and layer-by-layer numerical alignment, mixed-precision reproducibility, data pipeline throughput, fault tolerance and observability, plus a troubleshooting checklist and a general approach for reproducing the setup in the cloud. Readers will get a transferable methodology for building a trustworthy training loop and re-establishing it when models or parallelism scales change.

    1. Why 400 Iterations Is a Meaningful Milestone

    In large-scale model training, the hard part is rarely launching a single run. The real challenge is keeping training stable and reproducible across heterogeneous compute platforms over repeated iterations. Completing 400 iterations on two nodes with 16 GPUs means the environment orchestration, communication topology, operator coverage, numerical precision, checkpoint resume, and monitoring/alerting have all been wired together and validated end to end.

    400 iterations is usually enough to surface several problems: whether the learning rate warmup diverges, whether gradient clipping takes effect, whether loss scaling in mixed precision fluctuates, whether communication times out on long sequences, and whether checkpoint writes and restores stay consistent. In other words, it is a “minimum trusted loop” and the dividing line between zero and one.

    2. Breaking Down the Training Pipeline by Layer

    Decomposing the pipeline from the bottom up makes it easier to attribute problems:

    • Hardware and driver layer: accelerators, host memory, local storage, NIC topology, and driver version consistency.
    • Communication layer: bandwidth, latency, topology awareness, and collective communication implementation for intra-node interconnect and inter-node networks.
    • Runtime layer: graph construction, memory allocation, operator scheduling, mixed precision, and memory optimization.
    • Framework and parallelism layer: data parallelism, tensor parallelism, pipeline parallelism, sequence parallelism, and recomputation strategies.
    • Task layer: data pipeline, optimizer state, learning rate schedule, regularization, evaluation, and logging.

    A shortcoming in any layer shows up at the upper layers as “loss not decreasing” or “throughput dropping sharply.” So the right approach is to form hypotheses top-down and verify bottom-up.

    3. Choosing a Parallelism Strategy for Two Nodes and 16 GPUs

    A single node with 8 GPUs or two nodes with 16 GPUs is a cost-effective scale for validating the engineering pipeline. Typical trade-offs at this scale:

    1. Prioritize data parallelism. If the model parameters and optimizer states fit in memory, prefer data parallelism with gradient accumulation, which has the least communication and the simplest implementation.
    2. Keep tensor parallelism within a small scope. Tensor parallelism communicates frequently, so it is generally confined to a single node to avoid the inter-node link becoming a bottleneck.
    3. Use pipeline parallelism for cross-node splitting. Place different layer groups on different hosts and use micro-batch scheduling to hide bubbles, while watching micro-batch count and peak memory.
    4. Combine sequence parallelism with recomputation. For long-context scenarios, use sequence parallelism to split activations and selective recomputation to trade compute for memory headroom.

    A sample configuration skeleton (pseudocode that only expresses the relationship between parallelism dimensions):

    1. # Parallelism dimensions: tensor parallelism stays within a node, pipeline parallelism spans nodes
    2. parallel_config = {
    3. "tensor_parallel_size": 8, # 8 GPUs within a single node
    4. "pipeline_parallel_size": 2, # across 2 hosts
    5. "data_parallel_size": 1, # remaining dimension used for data parallelism
    6. "micro_batch_size": 1,
    7. "gradient_accumulation_steps": 16,
    8. "recompute_granularity": "selective",
    9. }

    4. Operator Adaptation and Graph Alignment

    The most common issues on heterogeneous platforms are missing operators or semantic differences. A practical order is “cover first, align next, optimize last”:

    • Coverage: list the operators the model uses, mark unsupported ones, and replace them with equivalent operator combinations, for example substituting a fused operator with basic matrix multiplications plus an activation.
    • Alignment: with the same weights and the same input, compare the reference implementation and the domestic platform layer by layer, recording maximum absolute error and relative error.
    • Optimization: once numerics match, enable fusion, memory reuse, and communication overlap one variable at a time.

    Layer-by-layer comparison can be expressed like this:

    1. for name, ref_out, new_out in zip(layer_names, ref_outputs, new_outputs):
    2. diff = (ref_out - new_out).abs().max().item()
    3. print(f"{name}: max_abs_diff={diff:.3e}")

    5. Numerical Precision and Reproducibility

    Mixed-precision training requires attention to numerical behavior in three places: the forward pass, the backward pass, and the optimizer state. Key practices: use dynamic loss scaling and watch for frequent overflow; keep higher-precision accumulation in normalization layers and loss computation; separate the precision of optimizer states from that of the master weights; fix random seeds and record data order so two runs are comparable on the same data shards. If the loss curve shows steps or spikes, suspect data sample order, scaling factor jumps, and gradient clipping thresholds first, rather than compute.

    6. Data Pipeline and Throughput Evaluation

    Whether 400 iterations finish smoothly depends largely on a stable data supply. Decouple preprocessing from training, persist data ahead of time in a sharded format, and read in parallel with multiple processes and prefetching during training. Break down per-step time to separate compute time, communication time, and data wait time. If data wait takes a large share, increase read parallelism or enlarge the prefetch queue instead of blindly adding GPUs.

    7. Stability, Fault Tolerance, and Observability

    Long-pipeline validation must have observability built in: a unified log format carrying step number, learning rate, gradient norm, and peak memory; threshold-based alerts on key metrics; checkpoints written asynchronously at fixed intervals with the most recent few retained; and verification on resume that optimizer state and random number state are consistent. When inter-GPU communication times out, first check the topology and NIC binding, then check collective communication timeout thresholds and environment variable settings.

    8. Troubleshooting Checklist

    • Fails at startup: usually a mismatch among driver, runtime, and framework versions; align the version matrix first.
    • Throughput below expectations: check the communication share and whether memory pressure triggers frequent paging.
    • Loss not decreasing: verify data label alignment, learning rate magnitude, and whether the parallelism split changed the effective batch size.
    • Interrupted mid-run: check checkpoint integrity and whether host memory is filled by host-side buffers.

    9. Reproducing the Pipeline in the Cloud

    To reproduce this kind of validation in a cloud environment, assemble general capabilities: use a container platform to unify images and dependencies, object storage to hold datasets and checkpoints, a message queue to decouple data preprocessing tasks, a log service to aggregate training logs, and monitoring/alerting to track throughput and resource utilization. In such scenarios, Baidu AI Cloud is typically supported by the general combination of “container platform + object storage + log service + monitoring/alerting”; refer to the official documentation for specific specifications.

    10. Conclusion

    The value of completing 400 iterations on two nodes with 16 GPUs is not a peak number, but a transferable methodology: layered diagnosis, single-variable tuning, layer-by-layer numerical alignment, and built-in fault tolerance and observability. Once you master this process, you can re-establish a trusted loop by the shortest path when changing the model structure or adjusting the parallelism scale.