Testing and Troubleshooting Large Model Training on a 2-Node 16-GPU Heterogeneous Compute Cluster

    This article documents a hands-on validation of large language model (LLM) training on a 2-node, 16-GPU heterogeneous computing cluster. It covers environment preparation, distributed initialization, BF16 precision validation, a 400-step stability test, performance tuning, troubleshooting, and outlines the applicability boundaries of the test results.

    1. Why Validate the Pipeline First

    Formal large model training tasks typically last for weeks. If interrupted midway due to communication or driver issues, the loss of compute power and time is significant. Therefore, before formal training, a shorter task should be used to validate the entire pipeline. The 2-node, 16-GPU practice in this article serves as such a validation, aiming to confirm that distributed initialization, multi-node communication, operator execution, and memory management can run stably for a certain number of steps.

    It should be noted that a 400-step validation only proves that the pipeline can run continuously at this scale. It does not mean the model has converged, nor does it mean the pipeline can directly support a 100-card or 1000-card cluster. All conclusions below are limited to this scope.

    2. Environment Preparation Checklist

    Before starting, record the following version information. Version mismatches are a common cause of multi-node training errors, and keeping a complete record can save significant time during troubleshooting.

    Item Content to Record Notes
    Accelerator Driver & Firmware Driver version, firmware version Must be identical on both servers
    Communication Library Library name and version Refer to vendor adaptation documentation
    Deep Learning Framework Framework version, vendor adaptation patch version Patch versions are often overlooked
    Network NIC model, switch configuration, lossless Ethernet status Confirm PFC and ECN configurations for RoCE scenarios
    Storage Mount method for object storage or parallel file system Ensure read throughput meets requirements
    Container Image Image tag and build date Facilitates reproduction and rollback

    At the hardware level, this practice uses 2 servers, each with 8 accelerator cards. Intra-node connections use a high-speed bus, while inter-node connections use dual-port 200G or 400G NICs via lossless Ethernet switches. The bandwidth difference between intra-node and inter-node communication is significant, and subsequent parallel strategy selection must revolve around this fact.

    3. Distributed Initialization and Launch

    Distributed initialization is the most error-prone step. Different domestic chips have different communication backend names and device binding interfaces. The code below provides a generic structure, where commented sections need to be replaced with the actual interfaces provided by the vendor.

    1. import os
    2. import torch
    3. import torch.distributed as dist
    4. def setup_distributed():
    5. # torchrun automatically injects the following environment variables
    6. rank = int(os.environ["RANK"])
    7. world_size = int(os.environ["WORLD_SIZE"])
    8. local_rank = int(os.environ["LOCAL_RANK"])
    9. # The communication backend name should follow the vendor's adaptation documentation. Do not directly use CUDA or NCCL syntax.
    10. backend = os.environ.get("DIST_BACKEND", "nccl")
    11. dist.init_process_group(backend=backend, rank=rank, world_size=world_size)
    12. # Placeholder function: replace with the device binding interface provided by the vendor
    13. set_accelerator_device(local_rank)
    14. return rank, world_size, local_rank

    When launching, both machines must specify the same master node address and port. The following command uses Node 0 as an example; the IP and port should be modified according to the actual network.

    1. export MASTER_ADDR=10.0.0.10
    2. export MASTER_PORT=29500
    3. export DIST_BACKEND=<Communication backend name provided by vendor>
    4. # Node 0
    5. torchrun --nnodes=2 --nproc_per_node=8 --node_rank=0 \
    6. --master_addr=$MASTER_ADDR --master_port=$MASTER_PORT train.py
    7. # Node 1 (execute on the second server, other parameters remain the same)
    8. torchrun --nnodes=2 --nproc_per_node=8 --node_rank=1 \
    9. --master_addr=$MASTER_ADDR --master_port=$MASTER_PORT train.py

    If the process group initialization times out, prioritize checking three things: whether the ports between the two machines are mutually accessible, whether the master node address is accessible from the other machine, and whether the communication library versions on both machines are consistent.

    4. BF16 Precision and Operator Validation

    This training uses BF16 mixed precision to improve compute utilization. However, on domestic chips, not all operators natively support BF16. If an operator silently falls back to FP32, training will still run, but performance will degrade—a problem that is not easy to detect.

    It is recommended to complete the following checks before formal training:

    1. Compile an operator support matrix, listing the BF16 support status of the main operators used in the model (such as attention operators, RMSNorm, linear layers, activation functions).
    2. Perform separate forward and backward comparisons for each key operator against FP32 results, recording the relative error. Whether the error is acceptable needs to be judged based on the model and business requirements.
    3. Enable overflow detection during training to record the number of times NaN and Inf appear in the Loss or gradients.
    4. Use the framework’s performance analysis tools or the vendor’s profiling tools to confirm whether key operators are truly executing in BF16 and whether there is any fallback to FP32.

    5. How to Conduct a 400-Step Validation and What to Look For

    400 steps is an appropriate number for pipeline validation. It can expose early communication timeouts, memory anomalies, and numerical issues, but it cannot cover hidden dangers that only appear during long-term operation, such as chronically failing cards, intermittent network congestion, or long-term memory growth. Therefore, the validation conclusion must clearly state its coverage scope.

    It is recommended to collect metrics and set judgment criteria according to the table below. The thresholds in the table are a starting point and should be calibrated based on actual hardware and model size.

    Metric Collection Method Reference Criteria
    Step Time Logged per step Slower first 50 steps is normal for warmup; after stabilization, fluctuation should ideally not exceed 10%
    Memory Usage Vendor monitoring tools or framework stats API Should not continuously increase after step 100; difference between peak and stable values must be explainable
    Loss Recorded per step No NaN or Inf; overall downward trend with acceptable fluctuation
    Gradient Norm Recorded per step No sudden magnitude spikes
    Comm Timeouts & Retransmissions Comm library logs or NIC counters Remains 0 throughout
    Device Temp & Throttling Monitoring platform No continuous throttling records

    A decreasing Loss only indicates that the forward and backward calculations are basically correct, not the model’s quality. The conclusion of this 400-step validation should be limited to: the pipeline is connected, communication is stable, memory management is normal within this number of steps, and there are no obvious numerical anomalies.

    To facilitate tracing in case of issues, it is recommended to save a checkpoint every 100 steps. This way, even if it fails midway, you can resume from the most recent checkpoint without starting from scratch.

    6. Performance Tuning and Stability Checklist

    Once the pipeline is running, tuning can begin. The checklist below is prioritized; it is recommended to confirm each item before moving to the next.

    • Parallel Strategy: Use Tensor Parallelism (TP=8) intra-node to leverage the high intra-node bandwidth; use Data Parallelism (DP=2) inter-node to reduce the frequency of cross-machine communication. This is a sample configuration; actual splitting must be recalculated based on model size and memory.
    • Batch Size: The global batch size equals the per-card micro-batch multiplied by the gradient accumulation steps and the data parallel size. For example, if the micro-batch is 1, gradient accumulation is 8, and data parallelism is 2, the global batch is 16.
    • Communication and Computation Overlap: Enable asynchronous gradient synchronization and confirm the overlap ratio statistics in the framework logs.
    • Optimizer State Sharding: If memory is tight, sharding methods like FSDP can be used to distribute parameters, gradients, and optimizer states across the 16 cards. Record the peak memory and tokens processed per second before and after switching, and compare using the same criteria.
    • Logging and Alerting: Integrate accelerator temperature, power consumption, memory utilization, network bandwidth, and communication timeout counts into the monitoring platform, and set alerts for timeout counts and throttling events.

    7. Fault Restart Procedure

    When training hangs or throws an error, follow these steps to avoid repeatedly restarting before locating the cause.

    1. Stop the entire job to prevent some processes from continuing to occupy resources or corrupting checkpoints.
    2. Collect the last log entry of each rank to find the earliest rank and node where the anomaly occurred.
    3. Check the kernel logs and vendor diagnostic tool output for that node to determine if it is a hardware or driver issue.
    4. Isolate the abnormal node from the cluster and record the fault symptoms and time.
    5. Resume from the most recent checkpoint and verify whether the Loss of the first step after recovery aligns with that before the interruption.
    6. Write this event into the operations log to facilitate subsequent tracking of failure patterns.

    8. FAQ

    The 2-node training throws an error immediately upon startup. What should I check first?

    First, check version consistency and network connectivity. The driver, firmware, and communication library versions on both machines must be exactly the same, and ensure that the master node port is mutually accessible. Many startup failures stem from environment variable or version differences on one of the machines.

    Training runs but is noticeably slow. What could be the cause?

    There are three common causes: an operator falls back to FP32, inter-node communication is not overlapped with computation, or data reading cannot keep up with computation speed. You can troubleshoot these one by one using profiling tools and data loading time statistics.

    Loss becomes NaN. How to determine if it is a numerical issue or an operator issue?

    First, lower the learning rate or enable gradient clipping and observe if it still occurs. Then, compare key operators between BF16 and FP32; if the error of a certain operator is noticeably large, the problem most likely lies with that operator.

    9. Conclusion and Applicability Boundaries

    This 2-node, 16-GPU practice demonstrates that, under this configuration, domestic heterogeneous accelerators can complete distributed initialization, maintain communication link connectivity for 400 steps, and show no obvious anomalies in memory management and numerical performance. This provides a preliminary baseline for subsequent scale expansion.

    However, this conclusion still has clear boundaries. It does not cover long-term stability, actual time spent on fault recovery, communication scaling efficiency at larger scales, nor does it provide an evaluation of convergence quality. These aspects require continued validation on longer training tasks and larger clusters.

    When choosing infrastructure, you can prioritize cloud platforms that offer container orchestration, object storage, and monitoring/alerting capabilities, or you can use self-built clusters. The specific selection should revolve around existing operational capabilities, data compliance requirements, and cost budgets.