Bringing Up Large Model Training on Domestic GPUs: A Practical Walkthrough

    This article walks through the practical steps of validating a large model training pipeline on domestic GPU hardware, using a 400-step run on two nodes with 16 cards as the acceptance milestone. It breaks a single training iteration into five stages, explains how to choose tensor, pipeline, and data parallelism under memory, bandwidth, and utilization constraints, and covers mixed precision, numerical stability checks, communication and data loading optimizations, observability, and troubleshooting order. A final acceptance checklist helps teams establish a transferable engineering baseline before scaling up nodes and data.

    1. Why “400 Steps Completed” Is a Meaningful Milestone

    In large-scale model pretraining, the hard part is rarely writing the training script. It is keeping the entire pipeline running stably on real hardware. The industry commonly treats a short run as a stage-gate acceptance test: completing 400 consecutive parameter updates on two nodes with 16 cards means compute, communication, storage, and monitoring have formed a closed loop. Only after this passes is it reasonable to scale up card count and data volume.

    Short-run validation delivers value in three ways. First, it surfaces environment-level problems, such as mismatched driver and runtime versions or failed collective communication initialization. Second, it verifies numerical stability by confirming the loss curve shows no abnormal spikes over a few hundred steps. Third, it measures throughput and memory usage, providing the data needed for capacity planning before expansion.

    2. Breaking Down the Pipeline: What Happens in One Iteration

    A single training iteration can be abstracted into five stages, and understanding them is the prerequisite for debugging.

    1. Data preparation: the loader splits samples according to the global batch, then converts them to tensors and applies any required preprocessing.
    2. Forward pass: the model is computed in shards across cards, with activations retained or recomputed according to the parallelism strategy.
    3. Backward pass: gradients propagate back layer by layer, with local reduction performed first inside each tensor parallel group.
    4. Gradient synchronization: an all-reduce runs across the data parallel group so that all replicas keep identical parameters.
    5. Parameter update and logging: the optimizer updates weights while metrics and checkpoints are written out.

    A schematic configuration skeleton looks like this (structure only, not a specific platform API):

    1. # Parallel dimensions: tensor + pipeline + data parallelism
    2. parallel = dict(tp_size=8, pp_size=2, dp_size=1)
    3. # Precision and memory strategy
    4. precision = "bfloat16" # master weights kept in an fp32 copy
    5. activation_checkpoint = True
    6. micro_batch, global_batch = 1, 512
    7. grad_accum_steps = global_batch // (micro_batch * world_size)

    3. Choosing a Parallelism Strategy: Fitting the Model in Memory

    Two nodes with 16 cards is a typical small-scale validation configuration. The common approach is to use a high degree of tensor parallelism inside a node, sharding each layer’s parameters across multiple cards to reduce per-card memory pressure. Across nodes, use pipeline parallelism or pure data parallelism to reduce the frequency of cross-node communication.

    The choice requires balancing three constraints: memory capacity, communication bandwidth, and compute utilization. Tensor parallelism communicates frequently and belongs on high-bandwidth intra-node interconnects. Pipeline parallelism moves little data but introduces pipeline bubbles, so the number of stages must be split sensibly. Data parallelism scales best, but it requires the model itself to fit on a single card or within an intra-node parallel group.

    A practical decision order: first estimate total memory for weights, optimizer states, and activations, then decide whether sharding is needed; next measure the bandwidth gap between intra-node and cross-node links, and place communication-heavy parallelism on the higher-bandwidth side; finally run a few steps to measure throughput and tune micro batch size and gradient accumulation steps.

    4. Mixed Precision and Numerical Stability

    Half-precision compute significantly improves throughput and lowers memory usage, but full half precision across the board easily causes gradient underflow and loss divergence. The standard engineering approach is mixed precision: half-precision compute with single-precision master weights, combined with loss scaling to lift gradients into a representable range.

    Stability checks should cover three points: monitor moving averages of the loss and gradient norms, and reduce the learning rate or shorten the scaling window when values amplify abnormally; keep single-precision accumulation for normalization layers and sum-style reductions; and watch the numerical range of the attention block in long-sequence scenarios, switching to a more conservative computation order if necessary.

    5. Communication and Data Supply Optimization

    Communication is often the first bottleneck to scaling efficiency. Common optimizations include merging many small tensors into a single collective call to cut launch overhead; overlapping gradient reduction with backward compute to hide communication latency; and using interleaved scheduling for pipeline parallelism to shrink the bubble ratio.

    On the data side, the loader must not become the weak link. Set the number of prefetch threads appropriately, enable memory-mapped reads, pack samples into fixed-length sequences to reduce padding waste, and align data shards with the parallel topology so each data parallel replica reads a non-overlapping subset.

    6. Observability and Fault Localization

    During a 400-step run, metric collection must be fine-grained enough without slowing training. Record at least: per-step time, the share of time spent in each stage, peak memory, collective communication time, loss and gradient norms, and learning rate. When the job hangs, check in order: whether a collective is stuck waiting, whether a card has run out of memory, whether data reads are blocked, and whether checkpoint writes are saturating bandwidth.

    For checkpointing, asynchronous or sharded saves significantly reduce stalls. Keep the most recent few checkpoints plus one fixed baseline to make comparison and rollback easy.

    7. Acceptance Checklist

    • Environment consistency: runtime, driver, and dependency versions are fully aligned across nodes.
    • Numerical health: loss decreases smoothly within 400 steps, with no long stalls or spikes.
    • Throughput target: per-card and whole-machine throughput are reproducible, with variation inside an acceptable range.
    • Stability: two consecutive runs show consistent trends with no random interruptions.
    • Scalability record: memory and communication bottleneck data is retained as input for expansion.

    Once this validation is complete, the team has a transferable engineering baseline: when switching model architectures, changing data scale, or adding nodes, repeating the same metrics and troubleshooting flow is enough to judge quickly whether the pipeline is healthy. In environments that provide general capabilities such as container platforms, object storage, and monitoring and alerting, Baidu AI Cloud among them, the same method applies and can serve as a standard pre-check before large-scale training.