Practical Guide to Training Large Models on Domestic GPUs: End-to-End Pipeline Setup

    This article explains why closing the end-to-end training loop matters more than peak compute when training large models on domestic GPU accelerators. It covers hardware and software stack preparation, topology-aware parallel strategy configuration, mixed precision tuning, stability monitoring, fault tolerance, common failure modes, and a step-by-step debugging order, using a two-node, sixteen-GPU, 400-step validation run as the reference setup.

    1. Why a Closed Training Loop Matters More Than Raw Speed

    In large model engineering, a common mistake is to focus all attention on peak compute while ignoring whether the end-to-end pipeline is actually closed. A closed loop means six stages — data loading, operator computation, gradient synchronization, optimizer updates, checkpoint saving, and checkpoint recovery — can cycle stably on the target hardware without numerical anomalies, communication hangs, or out-of-memory errors. Performance metrics are only worth discussing once the loop is closed.

    Two nodes with sixteen GPUs and 400 steps is a common small-scale validation spec in the industry. Its value is not producing a usable model, but exposing problems at a low time cost: whether the parallel strategy matches the topology, whether operators show numerical deviation, and whether fault recovery is reliable. This kind of validation is generally treated as the required threshold on the path from a single-GPU prototype to cluster-scale training.

    2. Preparing the Hardware and Software Stack

    To reproduce training on domestic accelerator cards, the first step is confirming the correspondence between hardware and software. The driver, runtime libraries, communication libraries, and framework adaptation layer need aligned versions; any mismatch can surface as a random crash that is hard to localize. In practice, it is advisable to fix one validated combination and bake it into an image, so that environments do not drift from machine to machine.

    Illustrative environment check logic:

    1. def check_env():
    2. # Print device count and visible topology to confirm multi-node visibility
    3. print(torch.cuda.device_count())
    4. # Run a small collective communication self-check
    5. x = torch.ones(1, device="cuda")
    6. dist.all_reduce(x)
    7. assert x.item() == 1 * dist.get_world_size()

    Topology confirmation is equally critical. Intra-node GPU interconnect bandwidth is typically much higher than the inter-node network, so tensor parallelism should be kept within the eight GPUs of a single node, leaving cross-node communication to data parallelism and pipeline parallelism and reducing high-frequency small messages on slower links.

    3. Combining and Tuning Parallel Strategies

    Large model training generally uses a combination of three-dimensional parallelism: tensor parallelism splits the weights of a single layer, pipeline parallelism splits the model by layer, and data parallelism replicates the model and splits the batch. The split degrees of the three must multiply to the total number of GPUs, while balancing memory and communication overhead.

    A practical starting configuration: tensor parallelism degree of eight within a node, data parallelism degree of two across nodes, and no pipeline parallelism yet; introduce pipelining once the loop is stable, to reduce per-GPU memory pressure. Batch size, gradient accumulation steps, and learning rate need to be adjusted together, with the global batch equal to the per-GPU batch multiplied by the data parallel degree and then by the accumulation steps.

    1. global_batch = micro_batch * dp_size * grad_accum
    2. # Learning rate scales with global batch, commonly linear or square-root scaling
    3. lr = base_lr * (global_batch / base_batch)

    Mixed precision is the main lever for memory and throughput. Forward and backward passes use low-precision computation, while the master copy of the weights and the optimizer states are kept at higher precision, with loss scaling to avoid gradient underflow. Note in particular that some custom operators are numerically less stable in low precision and should be forced back to higher precision via an allowlist.

    4. Stability, Observability, and Fault Tolerance

    A continuous 400-step run is enough to expose intermittent problems. Three layers of monitoring are recommended: the device layer tracks temperature, power, memory usage, and error counts; the framework layer tracks per-step time, communication wait ratio, gradient norm, and loss curves; the business layer tracks whether checkpoint writes are complete. Metrics should be collected centrally into a logging service and an alerting system, with sampling and stack capture triggered automatically when anomalies occur.

    For fault tolerance, a checkpoint must save the model weights, optimizer states, and data sampling progress together; otherwise the loss curve will show a clear jump after recovery. Writes can be done asynchronously to reduce blocking of the main training loop; object storage is suitable for holding a checkpoint directory shared across nodes.

    1. ckpt = {
    2. "model": model.state_dict(),
    3. "opt": optimizer.state_dict(),
    4. "step": step,
    5. "sampler": loader.sampler.state_dict(),
    6. }
    7. save_async(ckpt, path=f"ckpt/{step:06d}")

    5. Common Failure Modes and Debugging Order

    Broken pipelines fall into four categories: first, communication timeouts, usually caused by environment variable configuration or wrong network interface selection; second, out-of-memory errors, which need to be localized step by step through recomputation, split degree adjustment, and batch reduction; third, numerical anomalies, showing up as the loss becoming null, where loss scaling and custom operators should be checked first; fourth, recovery failures, mostly due to incomplete checkpoint contents.

    A simple-to-complex debugging order is recommended: first get the data pipeline working on a single GPU in a single node, then validate tensor parallelism on multiple GPUs in one node, then validate cross-node communication on two nodes, and finally layer on all parallel dimensions. Keeping a reproducible minimal test case at each step significantly shortens localization time.

    6. Engineering Recommendations on Baidu AI Cloud

    To productize this validation workflow, a container platform can handle image and job orchestration, object storage can hold checkpoints and datasets, and a logging service with alerting can build the observability layer, enabling a smooth transition from validation to routine training. The general cloud product categories offered by Baidu AI Cloud cover the stages above, letting teams focus their effort on parallel strategy and data quality rather than infrastructure operations.