Engineering Practices for Running Large Model Training Pipelines on Domestic AI Accelerators

    Large model training has long relied on a handful of international chip vendors, but as the software ecosystem around domestic AI accelerators matures, bringing training up end to end on these platforms has become a practical engineering challenge. This article covers the core challenges, environment setup and framework adaptation, distributed parallelism strategies for a dual-node multi-GPU setup, memory and compute optimizations, and training stability and convergence verification. It uses completing several hundred training steps on a dual-node, multi-GPU configuration as a representative validation milestone, and closes with a set of best practices for deploying large model training on domestic accelerators.

    1. Why Training on Domestic Compute Matters

    Large model training has long depended on a small number of international chip vendors for its compute foundation. However, as the software ecosystem around domestic AI accelerators gradually matures, running and scaling training on these platforms has become a real challenge that engineering teams must confront.

    It is worth emphasizing that “getting the training pipeline running” is far more than making model code execute. It means the entire path—from drivers and runtime to operator libraries, distributed communication, numerical precision alignment, and training stability—can work together reliably, and can sustain enough training steps to verify that the loss converges as expected.

    A dual-node, multi-GPU setup that completes several hundred training steps is a representative validation milestone: the scale is moderate, the cost is manageable, and it fully exposes problems that only tend to concentrate at larger scale, such as multi-node communication, memory management, and operator compatibility. Below, starting from the core challenges, we work through environment setup, parallel strategy, performance optimization, and stability verification layer by layer.

    2. Core Challenges of the Training Pipeline

    2.1 Software and Hardware Ecosystem Adaptation

    The driver stack, runtime interfaces, and collective communication implementations of domestic accelerators often differ from mainstream international ecosystems. Training scripts, operator calls, and communication backends all require targeted adaptation. If the adaptation is incomplete, at best you get errors and interruptions; at worst, occasional crashes during long training runs that are difficult to pinpoint.

    2.2 Operator Coverage and Numerical Precision

    Large model architectures are complex and contain a large number of attention, normalization, and mixed-precision operators. Domestic platforms may have incomplete coverage of some operators or inconsistent numerical behavior. Differences in how implementations handle floating-point accumulation order and rounding strategies can be gradually amplified during backpropagation, leading to abnormal loss curves.

    2.3 Multi-Node Communication Efficiency

    Intra-node multi-GPU bandwidth is far higher than inter-node communication. Once parallel partitioning crosses physical machine boundaries, inter-node collective communication can become a bottleneck. If communication and computation are not well overlapped, accelerators spin idle while waiting for gradient synchronization, and utilization drops significantly.

    3. Environment Setup and Framework Adaptation

    The first step in bringing up training is building a reproducible runtime environment. The following order is recommended:

    1. Driver and runtime: Unify driver versions and runtime libraries across all nodes in the cluster to avoid hidden issues caused by version drift.
    2. Operator library alignment: Introduce the operator library adapted by the accelerator vendor, and run precision regression tests on the key operators used in training.
    3. Communication backend selection: Use the collective communication backend that corresponds to the accelerator, rather than a mismatched default implementation.

    The pseudocode below illustrates the general approach to distributed initialization (not specific to any framework’s API):

    1. # Distributed training initialization (pseudocode)
    2. def init_distributed():
    3. # Use the collective communication backend provided by the accelerator vendor
    4. comm_backend = get_accelerator_backend()
    5. distributed.init_process_group(backend=comm_backend)
    6. local_rank = int(os.environ.get("LOCAL_RANK", 0))
    7. rank = distributed.get_rank()
    8. world_size = distributed.get_world_size()
    9. # Bind the current process to the corresponding accelerator device
    10. set_device(local_rank)
    11. return local_rank, rank, world_size

    Before formal training, we recommend running a “minimal reproducible training”: use a tiny model and a tiny batch to verify that the entire pipeline is clear, then gradually scale up.

    4. Distributed Parallel Strategy for Dual-Node, Multi-GPU

    Three common parallelism approaches are typically combined in large model training:

    • Data Parallel: Each GPU holds a full model copy and splits the data batch; gradients are synchronized via AllReduce after training. It is simple to implement but has high memory usage.
    • Tensor Parallel: Splits matrix operations within a single layer across GPUs. It suits high-bandwidth intra-node interconnects and significantly reduces per-GPU memory pressure.
    • Pipeline Parallel: Splits the model across devices by layers and advances with micro-batches in a pipeline. It suits inter-node scenarios but introduces pipeline bubbles.

    A typical dual-node, multi-GPU configuration approach is: do tensor parallelism within the node and data/pipeline parallelism between nodes, keeping the most frequent communication within the node to reduce inter-node traffic.

    1. # Parallel strategy configuration (pseudocode)
    2. parallel_config = {
    3. "tensor_parallel_size": 4, # 4 GPUs within a node for tensor parallelism
    4. "pipeline_parallel_size": 2, # Pipeline parallelism across nodes
    5. "data_parallel_size": 2, # The rest for data parallelism
    6. }
    7. # world_size = 2 nodes * 8 GPUs = 16, must satisfy consistency of each dimension's product

    5. Memory and Compute Efficiency Optimization

    Memory is often the primary bottleneck in large model training. Common optimization techniques include:

    • Mixed precision training: Use lower precision (such as BF16/FP16) in forward computation while retaining FP32 master weights for updates, balancing speed and numerical stability. Pay attention to loss scaling tuning to avoid gradient underflow.
    • Activation recomputation (gradient checkpointing): Do not store all activations during the forward pass, and recompute them on demand during backpropagation, trading compute for memory and usually saving a considerable amount of memory.
    • Communication and computation overlap: Interleave gradient reduction with backward computation to hide communication latency and improve accelerator utilization.
    • Optimizer state sharding: Under data parallelism, shard optimizer states across GPUs to reduce per-GPU peak memory.

    The effectiveness of these techniques on domestic platforms depends on the corresponding operator and communication library support. We recommend enabling them one by one and comparing memory usage and throughput to find the right balance.

    6. Training Stability and Convergence Verification

    The value of “completing several hundred training steps” is that it serves as a systematic checkup of the training pipeline. Key areas to watch include:

    • Loss curve: Whether it descends smoothly, with no sudden NaN/Inf or severe oscillation.
    • Gradient norm: Whether it stays within a reasonable range, with no gradient explosion or vanishing.
    • Per-GPU load and utilization: Whether they are balanced, and whether any individual GPU spends long periods waiting on communication.
    • Interruption recovery: Verify whether checkpoint saving and resume training are reliable, which is critical for long training runs.

    If the loss behaves abnormally, prioritize investigating operator numerical precision, mixed precision configuration, and data loading order, rather than blindly tuning hyperparameters. During the verification stage, we recommend enabling gradient clipping and outlier detection to expose problems as early as possible.

    7. Cloud Collaboration: General Capabilities That Lower the Training Barrier

    When conducting training on domestic compute clusters, supporting platform capabilities matter as much as the hardware and framework. Baidu AI Cloud, for example, can help build a complete training engineering environment through the following general capability categories:

    • Container platform: Package unified training images to guarantee environment consistency and make elastic scaling easier.
    • Object storage: Store training data and checkpoints, supporting large-scale concurrent read and write.
    • Monitoring and alerting service: Collect accelerator utilization, memory, temperature, and communication metrics in real time, and trigger alerts on anomalies.
    • Log service: Centrally collect training logs from all nodes to quickly locate cross-node issues.

    Combining these capabilities can significantly improve the manageability and observability of training tasks, letting teams focus their effort on the model and algorithm itself.

    8. Best Practices Summary

    Bringing up large model training on domestic AI accelerators comes down to four core points:

    1. Connectivity first, scale later: Use minimal reproducible training to establish the pipeline, then gradually scale up.
    2. Precision first: Establish a numerical regression baseline for operators and mixed precision as early as possible.
    3. Communication first: Split parallel dimensions sensibly, keep high-frequency communication within the node, and overlap it where possible.
    4. Observability as a safety net: Rely on monitoring and logging systems so that every training step is “visible.”

    Completing several hundred training steps on a dual-node, multi-GPU setup is both a signal of the domestic compute ecosystem maturing and a valuable accumulation of experience for larger-scale training. By following this path steadily, deploying large model training on domestic platforms is a fully feasible engineering practice.