Getting the Training Pipeline Working on Domestic GPUs: A Practical Guide

    This article walks through the practical steps for establishing a complete, repeatable large model training pipeline on domestic GPU hardware. It explains why a closed-loop pipeline matters more than raw speed, how to use a two-node, sixteen-GPU, 400-step run as a minimal regression test, and how to prepare the environment, balance parallelism against memory and communication costs, stabilize the data pipeline, and collect observability metrics. It also covers checkpointing strategy, common failure modes with a troubleshooting order, and recommendations for making pipeline validation a mandatory part of the workflow.

    1. Why a Working Pipeline Matters More Than Speed

    When running large model pretraining on domestic accelerator hardware, the first obstacle a team hits is usually not performance but whether the pipeline closes end to end. A working pipeline means seven stages can all be executed repeatedly: data loading, model construction, parallel partitioning, backpropagation, optimizer updates, checkpoint saving and restoration, and metrics reporting. It also means training can resume without loss after an interruption. Only when the pipeline is stable do throughput tuning and scalability validation become meaningful.

    Two nodes with sixteen GPUs and 400 iterations make a typical “minimal verifiable unit”: the scale is large enough to expose multi-node communication issues, memory fragmentation, and uneven data sharding, while the limited step count keeps a full regression round short. Turning this unit into a standard test case is the most effective guardrail for hardware adaptation and framework upgrades.

    2. Environment Setup: Narrowing Down Uncertainty

    1. Align the driver and runtime. Confirm that the accelerator driver, runtime libraries, and communication libraries form a compatible set; upgrading any one of them alone can introduce hidden incompatibilities.
    2. Isolate dependencies. Build a unified image with a container platform, pinning the framework, operator libraries, and compilation toolchain inside the image to avoid the “runs on the host but not in the image” problem.
    3. Run an environment self-check. Before formal training, run a small-scale operator self-check script covering matrix multiplication, reduction, collective communication, and mixed-precision conversion.

    Illustrative self-check logic:

    1. # Pseudocode: minimal set of environment checks
    2. assert runtime.version_compatible(driver.version)
    3. check_ops(["matmul", "layer_norm", "softmax", "all_reduce"])
    4. check_collective(world_size=16, dtype_list=["fp16", "bf16"])

    3. Parallel Strategy: The First Trade-off Between Memory and Communication

    On a single node with eight GPUs, tensor parallelism usually comes first, splitting per-layer parameters and activations within the node and using high-bandwidth interconnects to keep communication costs low. Across nodes, add data parallelism or pipeline parallelism, since inter-node bandwidth is more limited and fine-grained synchronization should be minimized. A reusable rule of thumb: put high-frequency, small-payload partitions inside the node, and low-frequency, large-payload partitions across nodes.

    Budget memory in advance. A rough estimate with headroom reserved:

    1. Per-GPU memory ≈ parameters + gradients + optimizer states + activations + communication buffers + fragmentation overhead

    In mixed-precision training, optimizer states are typically several times the size of the parameters, and activations scale roughly linearly with batch size and sequence length. If the budget is exceeded, the order of preference is: enable activation recomputation, reduce per-GPU batch size while increasing gradient accumulation steps, and only then adjust the parallel partitioning dimensions.

    4. The Data Side: The Real Bottleneck for Stable Throughput

    Use a three-part structure for the data pipeline: sharded files + prefetching + local caching. Sharded files ensure reproducibility and resumability, prefetch threads hide read latency, and local caching reduces repeated remote access. Three things need particular verification: whether sample counts are balanced across shards, whether the random seed is fixed, and whether the data cursor aligns strictly with the model checkpoint when training resumes. A misaligned cursor is one of the most common causes of a suddenly abnormal loss curve.

    5. Stability and Observability

    Even a 400-step short run needs full observability. Collect at least: per-step loss and gradient norm, peak memory per GPU, share of time spent in collective communication, end-to-end time per step, and data wait time. When the data wait share stays high, the problem is on the input side rather than the compute side; when the communication share rises while compute time stays flat, the topology or partitioning strategy is usually a mismatch.

    For checkpoints, use periodic full saves with asynchronous writes so that saving overlaps with computation. Keep the most recent few checkpoints plus one fixed baseline for regression comparison.

    6. Common Issues and Troubleshooting Order

    1. Failure at initialization: suspect version alignment and communication backend configuration first.
    2. Normal for the first few dozen steps, then slowing down: usually accumulated memory fragmentation or cache growth; try periodic reclamation and fixed-shape inputs.
    3. Loss spikes: check the learning rate warmup, gradient clipping threshold, and data cursor.
    4. Inconsistent metrics after resuming: verify that the random seed, data order, and parallel topology match the original run exactly.

    7. Recommendations

    Make the “two nodes, sixteen GPUs, 400 steps” run a mandatory regression item in the pipeline, executed after any driver, framework, or parallel configuration change. Put the environment image, configuration templates, and monitoring dashboards under version control as well. On this basis, a container platform can support elastic scheduling, object storage can hold checkpoints, and logging and monitoring with alerting can automate problem localization. The general-purpose capability categories that Baidu AI Cloud provides for this kind of training engineering scenario can serve as a reference foundation for building a standardized validation process. Once the pipeline is stable, scaling and speedups become a sustainable optimization path.