Practical Guide to Training Large Language Models on Domestic GPUs: Validating the Full Pipeline

    This article explains how to validate an end-to-end training pipeline for large language models on domestic GPU accelerators before attempting long-running pretraining. Using a two-node, 16-GPU setup with 400 iterations as a practical example, it covers cluster topology and parallelism strategy, mixed-precision training and numerical stability, data pipeline bottlenecks, observability and fault localization, checkpointing, and a checklist of common failure modes. The goal is to turn an unpredictable "does it run?" question into a measurable, reproducible engineering process that surfaces most risks at low cost.

    1. Why Validating the Pipeline Matters More Than Chasing Metrics

    When pretraining large models on domestic accelerator cards, teams often hit pipeline problems before algorithmic ones. The pipeline is the complete loop: data loading, tokenization, operator execution, gradient synchronization, and checkpoint saving and restoration. If there is a break anywhere in this loop, all subsequent tuning is meaningless.

    A typical pipeline validation goal has three layers. First, functional closure: forward and backward passes run continuously for several hundred steps without interruption. Second, numerical trustworthiness: the loss curve decreases monotonically and gradient norms stay within a reasonable range. Third, reproducibility: repeated runs with the same configuration produce similar curve shapes. Two nodes with 16 GPUs and 400 iterations is a scale that keeps costs manageable while exposing most engineering issues.

    The value of short-run validation is exposing problems, not proving performance. Four hundred steps is not enough to show final model quality, but it is enough to reveal communication timeouts, memory fragmentation, operator precision deviations, and data pipeline jitter.

    2. A Vendor-Neutral View of the Hardware and Software Stack

    Before discussing implementation, it helps to define each layer in generic terms, avoiding ties to any specific vendor:

    • Compute layer: several general-purpose accelerator cards per node, connected by high-bandwidth interconnects within the node; nodes are linked by a high-speed network such as RDMA.
    • Platform layer: a container platform handles image distribution and process orchestration, while a job scheduler handles resource allocation and fault restarts.
    • Storage layer: object storage holds raw corpora and checkpoints, while a parallel file system handles high-throughput random reads.
    • Observability layer: a logging service collects training logs, and a monitoring and alerting system tracks card temperature, power, memory, and network bandwidth.

    In practice on Baidu AI Cloud, these capabilities are typically offered as general cloud product categories, such as container platforms, object storage, logging services, and monitoring and alerting. Users can set up a training environment without worrying about underlying implementation details.

    3. Cluster Topology and Parallelism Strategy

    Two nodes with 16 GPUs means eight cards per node, with the two nodes forming one communication domain. The core of the parallelism strategy is deciding how to split work across data parallelism, tensor parallelism, and pipeline parallelism.

    If the model fits in a single card’s memory, the simplest option is pure data parallelism with gradient accumulation: global batch size = per-card micro batch × number of cards × accumulation steps. If it does not fit, use tensor parallelism within the node (leveraging the high-bandwidth intra-node interconnect) and data parallelism across nodes (reducing dependence on inter-node bandwidth). This principle of “shard within the node, replicate across nodes” is key to controlling communication overhead.

    Illustrative configuration (pseudocode, showing only the split relationships):

    1. # Parallel dimensions: tensor parallelism 8 within node, data parallelism 2 across nodes
    2. tp_size, dp_size = 8, 2
    3. global_batch = micro_batch * dp_size * grad_accum_steps
    4. # Communication groups: tp group is confined to a single node to avoid frequent cross-node sync
    5. tp_group = build_group(ranks_within_same_node())
    6. dp_group = build_group(ranks_across_nodes())

    Gradient accumulation is essential under limited compute: it trades time for memory, allowing the global batch size to far exceed what the hardware can hold at once while keeping the optimizer update frequency unchanged.

    4. Numerical Stability and Mixed Precision

    Whether the pipeline can run 400 steps continuously depends largely on numerical stability. Common practices include:

    1. Mixed-precision training: use low precision in forward and backward passes for speed and memory savings, while keeping a high-precision master copy of weights and optimizer states.
    2. Loss scaling: dynamically adjust the scale factor to avoid gradient underflow in low precision; on overflow, skip that update and back off the scale factor.
    3. Gradient clipping: clip by global norm to suppress gradient explosions caused by occasional abnormal samples.
    4. Normalization layer choice: keep a high-precision computation path for normalization operators that are sensitive to precision.

    The indicators of numerical health are simple: whether loss keeps decreasing, whether gradient norms stay stable, and whether the scale factor backs off frequently. If the scale factor halves repeatedly within a few dozen steps, it usually points to operator precision or data anomalies rather than a learning rate issue.

    5. The Data Pipeline: The Most Underestimated Bottleneck

    In a 400-step short run, data pipeline jitter often disguises itself as “insufficient compute.” The recommended troubleshooting order is to first confirm whether input throughput is saturated, then check whether compute is truly saturated.

    1. # Pseudocode: prefetch + sharding + deterministic shuffle
    2. loader = DataLoader(
    3. dataset=ShardedDataset(global_rank=dp_rank, num_shards=dp_size),
    4. batch_size=micro_batch,
    5. num_workers=8,
    6. prefetch_factor=4,
    7. pin_memory=True,
    8. shuffle=True,
    9. persistent_workers=True,
    10. )

    Three points matter: shards must be split by data-parallel rank with no overlap; shuffling must be reproducible to meet reproducibility requirements; and prefetch depth must be enough to hide per-step read latency. It is advisable to convert the corpus ahead of time into a compact binary shard format to avoid repeated tokenization during training.

    6. Observability and Fault Localization

    A training job without observability is a black box. A minimal usable set includes per-step loss and learning rate, gradient norm, per-step time breakdown (data wait / compute / communication), peak memory, and cross-node network bandwidth utilization.

    A practical localization method is to split per-step time into three parts. If data wait consistently exceeds 20%, the problem is in the pipeline; if communication share rises abnormally, check whether the parallelism split crosses a low-bandwidth link; if compute time rises step by step, it is usually memory fragmentation or cache invalidation.

    Checkpoint strategy is also part of the pipeline: save asynchronously at fixed step intervals, and the saved content must cover model weights, optimizer states, learning rate schedule, and data loading position. Otherwise, the curve will show unexplained jumps after restoration.

    7. Common Issues Checklist

    • Process hangs at the first synchronization: usually an improper communication backend or network interface choice; confirm the NIC and port configuration are consistent.
    • Memory overflows suddenly after a few dozen steps: a typical fragmentation issue; adjust the allocation strategy or lower the micro batch.
    • Loss spikes and does not recover: roll back to the most recent checkpoint first, then investigate abnormal samples and warmup length.
    • Uneven speed across nodes: confirm each node has the same card count and symmetric topology, and avoid mixing different card models.

    8. Conclusion

    Completing a two-node, 16-GPU, 400-step pipeline validation on domestic accelerator cards is essentially turning the uncontrollable question of “will it run?” into a measurable, reproducible engineering process. Ensure functional closure first, then numerical trustworthiness, and only then throughput optimization. With clear parallelism principles, a robust mixed-precision strategy, and a solid observability system, teams can surface most risks early at very low cost and build a reliable foundation for longer training runs.