Adapting Multi-Node LLM Training: Stable 16-Accelerator Operation Across Two Machines

    This article explains how to adapt large model training to a target accelerator platform across two machines with 16 accelerators in total. It distinguishes inference adaptation, training adaptation, and pretraining from scratch, and states the validation scope each one requires. It then covers the five stages of a large-scale training pipeline, the challenges of multimodal training, communication and topology in cross-node setups, criteria for judging stable continuous operation, common failure patterns with troubleshooting steps, and a staged rollout plan.

    1. Three Levels of “Model Support”: Adaptation, Training Bring-Up, and Pretraining From Scratch

    In large model deployment, “supporting a model” can refer to three different levels of work:

    • Inference adaptation: The model loads and generates outputs on the target hardware. The focus is operator coverage and output accuracy alignment.
    • Training adaptation: The model can be fine-tuned or continued from a checkpoint on the target hardware. The focus is whether forward and backward computation, optimizer updates, and gradient synchronization work correctly.
    • Pretraining from scratch: Model weights start from random initialization and the entire training run completes on that hardware.

    Each level has different validation criteria. Successful training adaptation shows that the training pipeline works, but it does not reveal which compute platform produced the original base weights. Technical write-ups should state the validation scope of each conclusion so that partial results are not extrapolated into claims about overall capability.

    2. The Five Stages of a Training Pipeline

    A complete large-scale training pipeline typically includes the following five stages:

    1. Model loading: Build the model structure without filling device memory, then read the weights shard by shard. A common approach initializes the structure on the meta device, which allocates no actual storage, and then loads parameters one shard at a time.
    2. Shard scheduling: Split parameters, gradients, and optimizer states across compute processes. Shard granularity can follow layers or modules. Finer granularity reduces per-device memory pressure but increases the number of communication operations.
    3. Forward and backward computation: Gather parameters on demand before computation, then release them immediately after. This keeps peak memory usage under control.
    4. Gradient synchronization: Reduce gradients through collective communication, overlapping with backward computation where possible to reduce waiting time.
    5. Checkpoint saving and recovery: Save sharded state periodically so that training can resume from the most recent saved step after an interruption.

    The following illustrative code shows the main loop structure of a single optimizer update:

    1. # Illustrative: main loop for a single optimizer update
    2. for step, batch in enumerate(loader):
    3. loss = forward(model, batch)
    4. loss.backward() # Sharded gradient reduction is triggered during backward computation
    5. grad_norm = clip_grad_norm(model, max_norm)
    6. if not is_finite(loss) or not is_finite(grad_norm):
    7. handle_numeric_anomaly(step) # Record the current state, then skip or roll back according to policy
    8. optimizer.zero_grad()
    9. continue
    10. optimizer.step() # Each process updates only the shards it holds locally
    11. optimizer.zero_grad()
    12. if step % save_interval == 0:
    13. save_sharded_checkpoint(model, optimizer, step)

    The key point of this code is that the finiteness check runs before the parameter update. When a non-finite value appears, catching it first and then handling it prevents abnormal gradients from contaminating every shard.

    3. Special Challenges in Multimodal Training

    Multimodal models typically consist of an encoder and a language backbone. The two differ substantially in parameter scale and computation pattern, so their sharding strategies should be designed separately:

    • Encoders often contain many small operators, so communication overhead makes up a large share of their cost. Merge shard units where appropriate to reduce the number of synchronizations.
    • Backbone layers have large parameter counts and are compute-intensive. They suit per-layer sharding combined with communication overlap.

    Data flow has two common pitfalls. First, input lengths differ across modalities, so the computation per batch fluctuates. Load balancing must be handled at the scheduling level. Second, some branches may not take part in backward computation for certain samples. If the computation graphs differ across processes, collective communication can hang while waiting. The fix is to add a participation check for each modality branch, and to explicitly zero or skip synchronization for unused parameters. This ensures that all processes enter the same communication sequence.

    4. Communication and Topology in Cross-Node Training

    Interconnect bandwidth between accelerators within one machine is usually higher than the network bandwidth between nodes. In a setup with two machines of 8 accelerators each, the communication characteristics inside and across nodes differ as follows:

    Dimension Intra-node Cross-node
    Bandwidth Higher Relatively lower
    Latency Lower Higher
    Suitable strategy Fine-grained sharding with communication-computation overlap Fewer global synchronizations and hierarchical reduction

    Hierarchical reduction is a common approach for cross-node training. First, reduce within each node. Then, have a representative process from each node reduce across nodes. Finally, broadcast the result back within each node. This keeps cross-node traffic low.

    Check the following items during deployment:

    • The device IDs each process sees match the topology description;
    • Communication is bound to the correct network interface and does not run over the management network;
    • Collective communication timeouts are set reasonably: short enough to detect deadlocks promptly, but not so short that transient jitter triggers false alarms;
    • Environment variables, dependency versions, and random seed settings are consistent across all nodes.

    5. Judging Whether a Run Is Stable and Continuous

    Stable operation requires clear pass criteria. At minimum, cover the following four checks:

    Check How to verify Handling when abnormal
    Process integrity All processes complete the optimizer update at the same step, and no process exits Check process logs to identify the exit cause and the last completed step
    Numerical finiteness Loss and gradient norm stay finite throughout, with no NaN or Inf values Trace back to the first abnormal step, then check the learning rate and mixed-precision settings
    Step counting convention Clearly distinguish data batches from optimizer updates State the convention in reports. For example, with gradient accumulation, one optimizer update covers multiple micro-batches
    Resource stability Memory usage does not grow continuously, and throughput fluctuations stay within an acceptable range Investigate memory leaks, and check whether data loading has become a bottleneck

    For example, a test of 16 accelerators across two machines running 400 consecutive optimizer updates can show that the cross-node communication and gradient synchronization path works, with no numerical overflow or abnormal interruption. However, 400 steps is a short validation and does not demonstrate convergence quality. Long-term training still requires checking that the learning rate schedule is correct, that data stays continuous after checkpoint recovery, and that memory usage remains stable over a multi-day training period.

    6. Common Issues and Troubleshooting

    1. Numerical overflow: Under mixed precision, gradients can underflow or overflow because the numerical range is insufficient. Enable dynamic loss scaling, review the learning rate and gradient clipping threshold, and record activation ranges layer by layer to find the first module that becomes abnormal.
    2. Process hang: In most cases, some processes never enter a particular collective communication call. For example, a branch may not take part in backward computation for the current sample. To troubleshoot, set a communication timeout and print each process’s current step and call stack to find where the processes diverge.
    3. Out of memory: Activations are usually the main consumer of memory. Options include activation recomputation, reducing the micro-batch size, or adjusting shard granularity to balance communication overhead against memory usage.
    4. Accuracy deviation: The same operator may be implemented slightly differently on different hardware. Compare the outputs of key operators layer by layer, set an explicit relative error threshold, and log and alert when the threshold is exceeded.

    7. A Staged Rollout Plan

    Advance training adaptation from small to large scale. Each stage must pass before the next one begins:

    1. Single-device stage: Validate key operators and forward and backward results, aligning layer by layer with a reference implementation.
    2. Single-machine, multi-device stage: Validate the correctness of sharded loading, parameter gathering, and gradient synchronization.
    3. Cross-node stage: Validate the network topology and communication performance, and gradually increase the number of training steps.
    4. Long-running stability stage: Rehearse a complete training cycle, including mid-run interruption and checkpoint recovery.