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

    This article walks through the practical steps for validating a large model training pipeline on domestic accelerator cards, using a 400-step stable run as the first acceptance milestone. It breaks a single training iteration into six stages, maps tensor, pipeline, and data parallelism across a two-node, 16-card topology, and covers communication and topology tuning, numerical stability under mixed precision, observability and self-healing, and a final acceptance checklist. Engineers working on hardware adaptation will find concrete debugging criteria and configuration patterns they can reuse. The setup described here can be combined with general-purpose container platforms, object storage, and monitoring and alerting services from Baidu AI Cloud to build a complete training infrastructure.

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

    Why a 400-Step Run Is a Meaningful Milestone

    When adapting large-scale pretraining to domestic accelerator cards, the industry commonly treats short, stable iteration as the first gate for pipeline acceptance. A 400-step run is not about chasing peak throughput. It verifies that the entire pipeline closes the loop under a real workload: data keeps flowing, the computation graph is partitioned correctly, gradients synchronize across nodes, optimizer state updates properly, and exceptions are caught and recovered. Four hundred steps is usually enough to cover data loader warm-up, communication buffer setup, memory allocator stabilization, and the learning rate schedule entering its active range, which makes it a highly informative acceptance point.

    The gap between a short successful run and long-duration stable training is significant. The former answers “can it move,” while the latter answers “can it keep moving with trustworthy results.” In practice, treat 400 steps as the baseline, then extend gradually to several thousand steps and watch whether the loss curve stays smooth, whether the gradient norm converges, and whether memory usage creeps upward over time.

    Breaking Down the Pipeline: What Happens in One Iteration

    A single training iteration can be split into six stages, and a problem in any of them shows up as a hang or a numerical anomaly:

    1. Data pipeline: shard reading, decoding, tensor conversion, cross-process prefetching;
    2. Forward pass: operator execution after partitioning according to the parallel strategy;
    3. Backward pass: layer-by-layer gradient propagation, triggering cross-card reduction;
    4. Communication and synchronization: intra-group reduction for tensor parallelism, all-reduce across data parallel groups, point-to-point send and receive for pipeline parallelism;
    5. Optimizer update: momentum and second-moment state updates, parameter write-back;
    6. Monitoring and checkpointing: metric reporting, checkpoint saving, exception detection.

    The first step in debugging is locating which stage is stuck. A common practice is to enable per-stage timing and instrument data wait time, compute time, and communication time separately. If data wait time dominates, the problem is on the input side. If communication time grows linearly with the step count, the topology or buffer configuration is usually at fault.

    Parallel Strategy for Two Nodes and 16 Cards

    Under a topology of eight cards per node and 16 cards across two nodes, map the parallel dimensions as follows: keep tensor parallelism inside a single node so that high-frequency reductions use the high-bandwidth intra-node interconnect; split pipeline parallelism across nodes to reduce the frequency of inter-node communication; place data parallelism at the outermost layer and synchronize gradients with a single all-reduce. This “bandwidth decreasing from the inside out” mapping principle is a widely accepted general practice in the industry.

    Illustrative configuration (pseudocode, expressing partitioning intent only):

    1. # Parallel dimensions: tensor (intra-node) / pipeline (inter-node) / data (outermost)
    2. parallel = {
    3. "tensor_parallel_size": 8, # limited to 8 cards within one node
    4. "pipeline_parallel_size": 2, # layers split across two machines
    5. "data_parallel_size": 1, # 16 / (8 * 2)
    6. }
    7. # Key: ensure the partitioned layers divide evenly to avoid load skew
    8. assert num_layers % parallel["pipeline_parallel_size"] == 0

    The most common partitioning mistake is a pipeline stage count that does not divide the layer count evenly, leaving one stage with extra layers and creating a bucket effect. The second is letting a tensor parallel group span nodes, which pushes high-frequency reductions onto a slow link and causes throughput to drop sharply.

    Communication and Topology Tuning

    • Affinity binding: bind processes in the same tensor parallel group to the same physical machine and the same interconnect domain to avoid high-frequency inter-node communication;
    • Buffer reuse: pre-allocate and reuse communication buffers to reduce jitter from repeated allocation and release;
    • Compute-communication overlap: split gradient reduction into small chunks and interleave it with the backward pass to hide communication latency;
    • Topology-aware ordering: generate the communication order from measured bandwidth rather than default rank order;
    • Timeouts and retries: set reasonable timeouts for collective communication so a single faulty process does not leave the whole group waiting indefinitely.

    A practical rule of thumb: if moving tensor parallelism from intra-node to inter-node drops throughput by more than 30 percent, affinity configuration is not taking effect, and the process-to-device mapping should be checked first.

    Numerical Stability and Precision Strategy

    Domestic accelerator cards may differ subtly from general-purpose solutions in operator implementations and mixed precision strategies, so numerical validation cannot be skipped:

    1. Start with single-card, small-model alignment and confirm the loss is in the same range as the reference implementation;
    2. Scale to multiple cards and watch for abnormal spikes in the gradient norm;
    3. Under mixed precision, keep critical reductions and optimizer state at higher precision, and use dynamic loss scaling;
    4. Prefer well-validated implementations for attention and normalization layers to reduce deviations introduced by custom operators.

    If the loss suddenly becomes non-numeric, check three places first: whether loss scaling has overflowed, whether gradient clipping is in effect, and whether the optimizer state in the checkpoint is complete.

    Observability and Self-Healing

    Long-duration stable training depends on a solid observability system. Cover at least four categories of metrics: throughput and step time, memory usage and fragmentation, communication volume and wait ratio, and numerical metrics such as loss, gradient norm, and learning rate. Feeding these metrics into a general logging service and monitoring and alerting system, with sliding-window anomaly detection, can surface slow degradation within a few hundred steps.

    For self-healing, combine periodic checkpointing with automatic restart: when a process exits abnormally, the scheduling layer brings it back up, training resumes from the latest checkpoint, and the data read position is verified to avoid repeating or skipping samples. On the data side, hosting the training sample set in object storage with a local cache layer helps reduce jitter from remote reads.

    Acceptance Checklist

    • Environment consistency: driver, runtime, and operator library versions are fully aligned across all nodes;
    • Reproducibility: with a fixed random seed, two short runs produce essentially overlapping loss curves;
    • Stability: 1,000 consecutive steps without a restart, with step time fluctuation within an acceptable range;
    • Recovery: after manually terminating one process, training resumes automatically and metrics stay continuous;
    • Resource efficiency: memory usage stays flat with no sustained growth, and the communication wait ratio stays below the configured threshold.

    Following this approach, you can validate the training pipeline on domestic hardware at relatively low cost and build a reusable engineering foundation for larger-scale, longer-duration training jobs. If additional elastic compute and supporting capabilities are needed, the general-purpose container platform, object storage, and monitoring and alerting services from Baidu AI Cloud can be used to assemble a complete training infrastructure.