Multi-Node Distributed Training: Running an LLM Training Pipeline on 16 GPUs Across Two Servers
This article walks through setting up a large language model training pipeline on two servers with 16 GPUs in total. It covers how to combine parallelism strategies, reduce memory use with mixed precision, ZeRO, and activation recomputation, and fix common failures such as communication hangs and unstable loss. It also explains how to validate the setup with a 400-step run, using throughput, MFU, checkpoint recovery, and monitoring.
Scaling a large language model beyond one machine is now standard practice. Single-GPU and single-machine multi-GPU setups can no longer supply enough compute or memory for pretraining models with tens or hundreds of billions of parameters. Moving from one server to several adds network communication topology, memory partitioning, compute scheduling, and training stability to the engineering work. This article uses a two-server, 16-GPU setup as an example to describe the architecture, optimization strategies, and validation methods for getting a distributed training pipeline running, so developers can avoid common detours.
1. Architecture Design for Multi-Node Distributed Training
In a 16-GPU setup across two servers, usually with 8 GPUs per server, the architecture must account for the difference in bandwidth between communication inside a node and communication between nodes. GPUs within a node are typically linked by high-bandwidth NVLink. Nodes are usually connected by high-speed networking, such as 100G or 200G RoCE or InfiniBand.
Choosing a parallelism strategy
A single parallelism strategy often falls short for models with tens or hundreds of billions of parameters. A common approach is 3D parallelism:
- Data parallelism: Replicate the same model onto different GPUs. Each replica processes a different data batch, and gradients are synchronized with All-Reduce.
- Tensor parallelism: Split a single matrix multiplication across multiple GPUs. This suits the high-bandwidth environment inside a node.
- Pipeline parallelism: Split the model layer by layer across GPUs or nodes to reduce memory pressure on each GPU.
In a two-node, 16-GPU setup, a common combination is 8-way tensor parallelism within each node, with 2-way data parallelism or pipeline parallelism across the nodes.
Optimizing the communication network
Communication between nodes is the main bottleneck in multi-node training. RDMA, such as RoCEv2, must be enabled, and GPUDirect RDMA should be configured. This lets GPU memory transfer directly through the network interface and bypasses CPU memory copies. Network congestion control also needs tuning so that collective operations such as All-Reduce keep low latency and high throughput.
2. Memory Management and Compute Optimization
Training large models is not only a compute problem. It also requires careful memory management. To load a large model and run training across 16 GPUs, you need several memory optimization techniques.
Mixed-precision training
Using BF16 or FP16 instead of FP32 halves the memory needed for model weights and activations. It also lets training use Tensor Cores for faster matrix operations. BF16 has the same dynamic range as FP32, which helps avoid the gradient overflow problems common with FP16. For this reason, BF16 is the current preferred choice for large model training.
ZeRO optimizer
Standard data parallelism keeps a full copy of the model parameters, gradients, and optimizer states on every GPU, which creates heavy redundancy. ZeRO partitions these states across GPUs to reduce the memory used per GPU:
- ZeRO-1 partitions the optimizer states.
- ZeRO-2 partitions the gradients in addition to the optimizer states.
- ZeRO-3 also partitions the model parameters. It gives the largest memory savings but adds communication overhead.
On a 16-GPU setup, choose ZeRO-2 or ZeRO-3 based on model size. The goal is to find the best balance between communication cost and memory use.
Activation recomputation
Instead of storing activations in memory, this technique recomputes them during the backward pass by rerunning the forward pass. It trades compute time for memory. The technique is especially useful for very deep Transformer models, and it helps prevent out-of-memory (OOM) errors.
3. Getting the Training Pipeline to Run: Core Challenges and Troubleshooting
After the multi-node environment is set up, the first engineering milestone is getting the pipeline to run, meaning it completes several training steps without errors. The following issues are common at this stage.
Hangs during communication
The most frequent failure in multi-node training is a hang during initialization. It usually comes from blocked network ports, an incorrect master node IP address, or an NCCL backend that cannot establish P2P connections. Check the firewall settings, and make sure the
NCCL_SOCKET_IFNAMEenvironment variable points to the high-speed network interface. You can use benchmark tools such asnccl-teststo check inter-node bandwidth and latency before training starts.Gradient explosion and abnormal loss
On the first run, poor weight initialization or an improper learning rate can cause the loss to become NaN. Add a learning rate warmup that raises the learning rate linearly at the start of training. Also configure gradient clipping, which proportionally rescales gradients when their norm exceeds a set threshold.
Distributed data loading
In a multi-node setup, make sure each GPU receives non-overlapping data. Use a data loader that supports distributed sampling, and configure enough DataLoader worker processes so that data I/O does not become a training bottleneck.
4. Validation: What a 400-Step Run Shows
After the basic configuration is complete, set a goal of running 400 steps to validate the pipeline. The step count has a specific engineering purpose.
Validation metrics
- Throughput and MFU: Record the number of tokens processed per second, and calculate Model FLOPs Utilization (MFU). On a two-node, 16-GPU setup, MFU should typically stay above 40%.
- Loss trend: Even though this run validates the pipeline, the loss should show a clear downward trend over the first 400 steps. If the loss oscillates sharply, the hyperparameters or data preprocessing likely need work.
- Communication share: Use a profiling tool to measure how much time goes to computation versus communication. If communication takes more than 30% of the time, the parallelism strategy or network configuration needs further tuning.
Fault tolerance and checkpoint resumption
Node failures are routine in long training runs. During the 400-step validation, test checkpoint resumption. For example, interrupt training manually at step 200, then restore from a checkpoint. Confirm that the model weights, optimizer states, and learning rate scheduler state are all restored correctly.
Monitoring and alerting
Deploy a monitoring platform, such as a log service or alerting system, to collect metrics in real time. Useful metrics include GPU temperature, memory usage, power draw, and network bandwidth. If a GPU drops out or its compute performance falls, the fault can be located quickly and the affected node isolated.
5. Summary
Running a large language model training pipeline across two servers with 16 GPUs is a key step from a single-card prototype toward training on large clusters. It confirms that the hardware interconnects work together, and it tests a developer’s skills in distributed architecture, memory optimization, and troubleshooting. With a sound parallelism design, careful memory management, and a systematic validation process, developers can shorten the engineering timeline for large model training and build a solid base for larger commercial applications. In production, public cloud platforms such as Baidu AI Cloud, which offer elastic compute and container platforms, can further reduce the operational burden of multi-node clusters and support more efficient compute scheduling and model iteration.
