Heterogeneous Compute for LLM Training: A Two-Node, 16-Accelerator Implementation

    This article examines how to run a large language model training pipeline on heterogeneous compute using a two-node, 16-accelerator cluster. It covers interconnect topology, 3D parallelism choices, operator and collective-communication library adaptation, memory management, and a 400-step validation run. It also reviews throughput, memory usage, loss behavior, and long-tail latency monitoring, and discusses cloud-native directions for elastic training clusters.

    As large language model (LLM) parameter counts rise from tens of billions to hundreds of billions, a single compute supply chain can no longer meet growing training demand. Introducing heterogeneous compute hardware, including domestic accelerator platforms, to build diversified AI infrastructure has become an industry trend. However, heterogeneous hardware must support the full training pipeline before it can be used for LLM production. This requires not only high compute performance but also a mature low-level software stack and adaptation of distributed training frameworks. This article uses a two-node, 16-accelerator environment running 400 steps of large-scale pretraining as an example to analyze the technical practices and optimization paths involved.

    1. Cluster Topology and Hardware Interconnect Design

    In a two-node, 16-accelerator training environment, the cluster topology directly determines communication efficiency. A typical architecture contains two compute nodes, each equipped with 8 accelerators. Within a node, accelerators are usually connected through a high-speed PCIe Switch or a dedicated high-speed interconnect bus equivalent to NVLink, providing high point-to-point bandwidth and low latency. This is critical for tensor parallelism.

    Between nodes, interconnection usually relies on 200G or 400G high-speed Ethernet with RoCE v2 support or InfiniBand. For LLM training, cross-node communication often carries gradient synchronization for data parallelism or activation transfer for pipeline parallelism. To prevent inter-node communication from becoming a bottleneck, configure RDMA-capable SmartNICs and optimize routing policies to avoid network congestion.

    2. Distributed Parallelism Strategy Design and Implementation

    With only two nodes and 16 accelerators, training large models requires carefully designed parallelism strategies. The industry commonly uses 3D parallelism—data parallelism, tensor parallelism, and pipeline parallelism—to balance compute and communication overhead.

    1. Tensor Parallelism (TP): To minimize communication latency, tensor parallelism is usually limited to within a single node. With 8 accelerators per node, TP can be set to 8. This means the weight matrix of each model layer is split across 8 accelerators. During the forward pass, each accelerator independently computes partial results, which are then combined through All-Reduce communication. High-speed intra-node interconnect can support this frequent communication demand.

    2. Pipeline Parallelism (PP): When model parameters are too large for a single node’s memory to hold all model weights, gradients, and optimizer states, pipeline parallelism is needed. Different layers of the model are split across different nodes. In a two-node scenario, the first half of the model can be placed on Node A and the second half on Node B.

    3. Data Parallelism (DP): The same model copy is replicated across multiple accelerators or nodes, and different data batches are processed. Combined with ZeRO optimization techniques such as ZeRO-1 or ZeRO-2, optimizer states and gradients can be sharded, greatly reducing per-accelerator memory usage.

    Overall, a reasonable two-node, 16-accelerator parallelism configuration can be TP=8 within a node and PP=2 across nodes, or TP=8 and DP=2 across nodes with ZeRO-3 full sharding.

    3. Software Stack Adaptation and Communication Optimization

    The core difficulty in running the training pipeline on heterogeneous compute lies in software stack adaptation. Mainstream deep learning frameworks such as PyTorch are often deeply optimized for specific hardware ecosystems. Migrating to a heterogeneous platform requires addressing the following key issues:

    1. Operator library adaptation: LLM training involves extensive matrix multiplication (GEMM) and attention computation. A heterogeneous platform needs a complete, high-performance operator library to replace libraries such as cuBLAS and cuDNN. During adaptation, validate computation precision and performance for tensors of various shapes, especially low-level support for FP16/BF16 mixed precision training.

    2. Collective communication library adaptation: Distributed training relies heavily on collective communication such as All-Reduce, All-Gather, and Reduce-Scatter. A heterogeneous platform needs an efficient communication library similar to NCCL and support for the underlying hardware’s RDMA features. The key to communication optimization is overlapping computation and communication. By bucketing gradients and asynchronously triggering All-Reduce during backpropagation, communication latency can be effectively hidden.

    3. Memory management and allocator: The framework’s default memory allocator may not be suitable for a new hardware architecture. A customized memory allocator is needed to reduce memory fragmentation and support Pinned Memory to accelerate data copies between host and device.

    4. Practice Validation: 400-Step Training Analysis on Two Nodes with 16 Accelerators

    After hardware and software adaptation, running an LLM training task for 400 steps in a two-node, 16-accelerator environment is a key milestone for verifying pipeline stability and performance.

    1. Launch configuration example:

    The following is a generic example of distributed training launch configuration logic:

    1. # Node 1 launch command
    2. python -m torch.distributed.run \
    3. --nproc_per_node=8 --nnodes=2 --node_rank=0 \
    4. --master_addr="192.168.1.1" --master_port=29500 \
    5. train.py --model_config config.json \
    6. --tensor_parallel_size 8 --pipeline_parallel_size 2 \
    7. --use_flash_attention --bf16
    1. Monitoring metrics analysis:

    During the 400-step training process, closely monitor the following core metrics:

    • Throughput: tokens processed per second. By comparing theoretical compute with actual throughput, you can evaluate the efficiency of operator libraries and communication optimization. If throughput remains stable over many training steps, the compute-communication overlap design is reasonable.
    • Memory usage: observe peak memory during training. If a memory leak occurs, it usually leads to OOM (Out of Memory) after hundreds of steps. Completing 400 steps smoothly verifies the stability of the low-level memory allocator.
    • Loss convergence curve: Although 400 steps are not enough for a large model to fully converge, the loss should show a clear downward trend. If the loss has abnormal spikes or fails to decrease, it may indicate problems in low-level data type conversion or gradient synchronization. Monitoring a smooth loss decline is direct evidence of training correctness.
    1. Long-tail latency handling:

    In a two-node environment, network jitter can significantly increase the time of some steps. Collect All-Reduce latency data and analyze the long-tail latency distribution. If frequent communication blocking is observed, adjust the RoCE network configuration, such as PFC credit deadlock prevention, or increase communication buffers.

    5. Summary and Outlook

    Successfully running a full large language model training pipeline on a heterogeneous compute platform and completing hundreds of stable training steps with two nodes and 16 accelerators indicates that the platform has reached a basic production-ready threshold in low-level operators, communication libraries, and ecosystem compatibility. This practice not only demonstrates the technical feasibility of diversified compute for LLM training but also provides a practical path for enterprises to reduce dependence on a single compute supply and optimize infrastructure costs.

    In the future, with deeper cloud-native integration, enterprises can combine public cloud container platforms, object storage, and monitoring and alerting capabilities to build more elastic LLM training clusters. For example, on cloud platforms such as Baidu AI Cloud, container services can schedule heterogeneous compute resources, object storage can manage massive training data, and log services can monitor the training process. This can further lower the operational overhead of LLM training, improve overall compute utilization, and support efficient AI deployment.