Building a Complete LLM Training Pipeline on Heterogeneous Compute: A Two-Node, 16-GPU Distributed Training Practice

    This article examines the engineering practices behind successfully running hundreds of training iterations for a large language model on a heterogeneous computing platform across two nodes with 16 accelerators. It covers RDMA-based networking, hybrid parallelism strategies, deep learning framework adaptation for non-mainstream accelerators, memory optimization with ZeRO, common training failures and troubleshooting, and performance tuning through compute-communication overlap and system monitoring—providing practical guidance for distributed training on heterogeneous hardware.

    As the parameter counts of large language models (LLMs) grow exponentially, the compute and memory of a single GPU have long ceased to meet training demands, making multi-node, multi-GPU distributed training an indispensable part of the infrastructure. In an era where heterogeneous computing power is flourishing, the core challenge for developers is ensuring deep compatibility between the underlying hardware and upper-layer deep learning frameworks in order to build out the full LLM training pipeline. Recently, a general-purpose heterogeneous computing platform successfully completed hundreds of training iterations of an LLM in a two-node, 16-GPU environment, marking a closed loop of its basic training pipeline. This article takes this milestone as an opportunity to analyze the engineering practices and tuning strategies of multi-node, multi-GPU distributed training.

    1. Distributed Training Architecture and Communication Optimization

    In a two-node, 16-GPU configuration, the physical topology consists of two compute nodes, each equipped with 8 accelerators. To achieve efficient distributed training, the first task is to build a low-latency, high-bandwidth communication architecture.

    1.1 Communication Network Foundations

    The bottleneck in multi-node training usually lies in cross-node network communication. The industry widely adopts networks based on RDMA (Remote Direct Memory Access) technology, such as InfiniBand or RoCE v2. RDMA allows the NIC to directly read from and write to remote memory, bypassing the CPU and operating system kernel, thereby significantly reducing communication latency and improving throughput. During deployment, it is essential to ensure the switch is configured with lossless network parameters (such as PFC and ECN) to handle the network congestion caused by collective communication operations like AllReduce.

    1.2 Hybrid Parallelism Strategy

    For a two-node, 16-GPU environment, pure data parallelism (DP) may result in insufficient per-GPU memory, while pure tensor parallelism (TP) would incur enormous cross-node communication overhead. The best practice is to adopt a hybrid parallelism strategy:

    • Intra-node tensor parallelism (TP): Group the 8 GPUs within a single node into one TP group, with different matrix slices of the model distributed across the 8 GPUs of the same node. Since intra-node interconnects typically support high-bandwidth links such as NVLink, TP communication overhead can be effectively hidden.
    • Cross-node data parallelism (DP): Each of the two nodes maintains a complete model replica (constructed via TP). After the forward pass, gradients are synchronized through AllReduce operations across the DP group.

    2. Framework Adaptation in Heterogeneous Computing Environments

    Getting LLM training to run on non-mainstream or emerging heterogeneous computing platforms makes deep learning framework adaptation a top priority. This involves not only operator-level support but also a robust communication foundation.

    2.1 Operator Libraries and Graph Compilation

    LLMs rely on numerous complex operators, such as FlashAttention and RMSNorm. Heterogeneous hardware vendors must provide equivalent high-performance operator libraries and ensure compatibility with the operator dispatch mechanisms of mainstream deep learning frameworks (such as PyTorch). When encountering unsupported custom operators, developers often need to bridge the performance gap through operator fusion or by writing low-level kernels by hand.

    2.2 Reconstructing Communication Primitives

    Distributed training heavily depends on collective communication primitives. A heterogeneous platform must provide a communication library functionally equivalent to NCCL (NVIDIA Collective Communications Library). This requires not only implementing basic operations such as AllReduce, Broadcast, and AllGather, but also supporting topology-aware optimization so that communication traffic is properly split between intra-node and inter-node paths. The following is a typical distributed initialization pseudocode example showing how to switch between different backends:

    1. import torch
    2. import torch.distributed as dist
    3. def setup_distributed(rank, world_size, backend='custom_backend'):
    4. # Initialize the process group with the specified communication backend
    5. # (the heterogeneous platform must provide the corresponding backend implementation)
    6. dist.init_process_group(backend=backend, rank=rank, world_size=world_size)
    7. # Set the device used by the current process
    8. torch.cuda.set_device(rank % 8) # Assuming 8 GPUs per node
    9. def cleanup():
    10. dist.destroy_process_group()

    3. Training Pipeline Stability Verification: From Initialization to 400 Steps

    In the early stages of distributed training, the first few hundred steps (e.g., 400 steps) are a critical window for verifying the stability of the entire system. Completing 400 steps means the full pipeline—model initialization, data loading, forward and backward propagation, gradient synchronization, and optimizer updates—has been successfully established.

    3.1 Memory Optimization in Practice

    LLM training often faces OOM (Out Of Memory) issues. Beyond adopting mixed-precision training (BF16/FP16) to reduce baseline memory usage, ZeRO optimization is key. By sharding optimizer states, gradients, and model parameters across different GPUs, per-GPU memory pressure can be significantly reduced. In a two-node, 16-GPU environment, properly configuring the ZeRO Stage (such as Stage 2 or Stage 3) alongside the TP dimension is central to balancing compute efficiency and memory footprint.

    3.2 Troubleshooting Training Anomalies

    Common anomalies encountered during the 400-step training process include:

    • Gradient explosion/vanishing: Check the learning rate warm-up strategy and gradient clipping threshold.
    • Communication deadlock: Usually caused by certain operators not correctly implementing backpropagation on the specific hardware, leading some ranks to exit early or block. Logs must be analyzed to identify the stalled node.
    • Precision overflow: Under the BF16 format, some exponential operations may overflow, requiring forced conversion to FP32 computation at critical operators.

    4. Performance Tuning and System Monitoring

    Getting the pipeline running is only the first step; achieving high MFU (Model FLOPs Utilization) is the ultimate goal.

    4.1 Compute-Communication Overlap

    In LLM training, gradients produced by backpropagation can be synchronized across nodes immediately. By making gradient computation and AllReduce operations asynchronous, computation and communication can overlap in time, hiding network latency. This requires the framework to provide fine-grained gradient hook mechanisms.

    4.2 System-Level Monitoring and Fault Tolerance

    Distributed training runs for long durations, making a comprehensive monitoring and alerting system essential. General-purpose container platforms and logging services can be used to collect, in real time, the compute utilization, memory headroom, temperature, and network ingress/egress bandwidth of every GPU. When hardware throttling or network packet loss is detected, alerts can be raised promptly.

    In addition, distributed clusters are vulnerable to single-point failures. Checkpoints are typically saved at fixed intervals (e.g., every 100 steps). When a node goes down, the cluster can automatically restart from the most recent checkpoint and resume training, avoiding a restart from scratch.

    5. Conclusion

    Successfully building a complete LLM training pipeline on heterogeneous computing power in a two-node, 16-GPU environment—and completing hundreds of stable iterations—is an important milestone signaling the maturation of the underlying compute ecosystem. From communication network topology planning and hybrid parallelism design to framework operator adaptation and performance tuning, every stage tests the low-level engineering capabilities of the team. As related technologies continue to accumulate and the open-source ecosystem thrives, heterogeneous computing power will play an increasingly critical role in the LLM era, driving the broader adoption of AI technology across a wider range of industry scenarios.