Two-Node 16-Accelerator LLM Training Pipeline: Setup and 400-Step Validation
This article describes how to build and validate a two-node, 16-accelerator training pipeline for large language models. It defines validation criteria, then covers topology planning, environment consistency checks, parallel strategy selection, multi-node launch and process grouping, data pipeline design, training-loop numerical stability, and a staged 400-step validation checklist.
1. Background and Validation Goals
Multi-node, multi-accelerator training is usually not limited by single-accelerator compute. The difficulty typically comes from three areas: a single accelerator cannot hold the full model and optimizer states; gradient and parameter synchronization across accelerators introduces communication overhead; and data reading and preprocessing must keep up with compute. These problems compound as the number of nodes increases.
“Getting the training pipeline running” needs clear criteria. This article uses the following four standards:
- Startup correctness: all processes join the same communication group, and each process’s rank matches its device assignment.
- Computational correctness: loss values across accelerators are numerically consistent, with no NaN or infinity.
- Runtime stability: within the target number of steps, no process hangs, no out-of-memory errors occur, and throughput does not show obvious jitter.
- Recoverable state: intermediate checkpoints can be loaded correctly, and the training curve remains continuous after recovery.
The target scenario is two machines, eight accelerators per machine, 16 accelerators total, running 400 training steps. The methods below apply to other scales, with parallel parameters adjusted for the topology.
2. Hardware Topology and Environment Consistency
2.1 Topology Planning
The first step in multi-node training is to draw the topology and clarify the bandwidth differences among three types of connections:
- Intra-node interconnect: connections among the eight accelerators within the same machine. This has the highest bandwidth and lowest latency.
- Inter-node network: the high-speed network between the two machines. Bandwidth is usually lower than intra-node interconnect.
- Storage access: shared storage for training data and checkpoints, which determines whether data reading becomes a bottleneck.
The topology planning principle is to place the most frequent communication operations on the highest-bandwidth links.
2.2 Environment Consistency Check
The most common problem in multi-node training is environment inconsistency between nodes, such as different driver versions, different dependency library versions, or missing environment variables. These problems often appear as an initialization error on one machine, with error messages unrelated to the code.
Before launching training, use a script to check key information on both machines in a unified way:
#!/usr/bin/env bash# Run on each node and compare the outputsecho "hostname: $(hostname)"echo "kernel: $(uname -r)"echo "driver: $(get_accelerator_driver_version)"echo "device_count: $(list_visible_accelerators)"echo "python: $(python3 --version)"echo "framework: $(python3 -c 'import deep_learning_framework; print(deep_learning_framework.__version__)')"echo "comm_lib: $(get_collective_communication_library_version)"
The placeholder commands in the script need to be replaced with the commands actually used in the current environment. The key checks are: driver, runtime, deep learning framework, and communication library versions must be pairwise consistent, and each node must see eight accelerators.
Package the confirmed environment into a unified image or environment description file for later experiments, avoiding deviations caused by manual installation.
3. Parallel Strategy Selection
Large model training usually requires combining multiple parallelism methods. Four common ones are:
| Parallelism method | Split object | Main communication | Suitable placement |
|---|---|---|---|
| Data parallelism | Sample batch | Gradient synchronization | Cross-node |
| Tensor parallelism | Matrix operations within a layer | Activation synchronization before and after each layer | Intra-node |
| Pipeline parallelism | Model split by layers | Activation transfer between adjacent stages | Intra-node or cross-node |
| Optimizer state sharding | Optimizer states and gradients | Parameter gathering and scattering | Cross-node |
For a two-node, 16-accelerator scenario, a common combination is: tensor parallelism within a node (8-way) and data parallelism across nodes (2-way). The reasons are:
- Tensor parallelism communication occurs during computation in every layer, has the highest frequency, and needs to be placed on high-bandwidth intra-node links.
- Data parallelism gradient synchronization happens only once at the end of each training step. Its bandwidth requirement is relatively lower, making it suitable for the inter-node network.
Note that the tensor parallel degree must divide the model’s attention head count and hidden dimension. If the model structure does not satisfy the divisibility requirement, adjust the degree rather than forcing it to run.
Parallel configuration correctness can be verified with a simple check function:
function validate_parallel_config(total_accelerators, tensor_parallel, pipeline_parallel, data_parallel):assert tensor_parallel * pipeline_parallel * data_parallel == total_acceleratorsassert model_attention_heads % tensor_parallel == 0assert model_layers % pipeline_parallel == 0return pass
4. Multi-Node Launch and Process Grouping
4.1 Launch Flow
Multi-node training launch requires three elements: a master address accessible by all nodes, a free communication port, and a unique node rank for each node. The core logic of the launch script is as follows:
#!/usr/bin/env bash# Usage: NODE_RANK=0 MASTER_ADDR=10.0.0.1 bash run_train.sh# Set NODE_RANK=0 and NODE_RANK=1 on the two machines, with the same MASTER_ADDRset -euo pipefail: "${NODE_RANK:?Please specify the node rank (0 or 1)}": "${MASTER_ADDR:?Please specify the master address}"export MASTER_PORT=29500export NNODES=2export NPROC_PER_NODE=8export WORLD_SIZE=$((NNODES * NPROC_PER_NODE))run_distributed_job \--nnodes "${NNODES}" \--nproc-per-node "${NPROC_PER_NODE}" \--node-rank "${NODE_RANK}" \--master-addr "${MASTER_ADDR}" \--master-port "${MASTER_PORT}" \train.py --config configs/train_16card.yaml
Here, run_distributed_job represents the distributed launch tool in the current environment; the actual name depends on the platform in use. The purpose of set -euo pipefail is to exit immediately if any step fails, avoiding a half-hung state where one machine has started and the other is still waiting.
4.2 Common Launch Issues
- Communication timeout: most often caused by a port being occupied or blocked by a firewall. First use a simple network connectivity test to confirm that both machines can reach the master port, then troubleshoot the training code.
- Insufficient processes: if processes on one node do not start, other nodes will wait indefinitely. After launch, check that each node has eight processes.
- Hostname resolution failure: if hostnames are used instead of IP addresses, confirm that both machines can resolve them correctly. Using IP addresses reduces this type of problem.
- Clock skew: some distributed components are sensitive to timestamps. Large clock skew between nodes can cause confusing logs or incorrect timeout decisions. Enable a time synchronization service consistently.
5. Data Pipeline Design
The data pipeline must satisfy two requirements: each process reads non-overlapping data, and the entire training process remains reproducible.
5.1 Data Sharding
In a 16-accelerator data parallel scenario, processes within the same data parallel group should read different subsets of the same batch. Implementation usually shards by the data parallel group rank:
function get_process_data_indices(dataset_size, data_parallel_rank, data_parallel_world_size, seed, epoch):index_list = randomly shuffle [0 .. dataset_size - 1] using (seed + epoch)per_group_count = dataset_size // data_parallel_world_sizestart = data_parallel_rank * per_group_countreturn index_list[start : start + per_group_count]
The key point is that the random seed is provided by the global configuration and bound to the epoch. This way, even if training is interrupted, the data order after recovery matches the original run exactly.
5.2 Prefetching and Caching
If data reading runs serially with computation, accelerators will idle while waiting for data. A common practice is to enable multi-threaded prefetching so that the next batch is ready while the current batch is computing. The prefetch queue length should be set according to the time required to read a single batch. If it is too long, it consumes too much memory; if it is too short, waiting still occurs.
For storage, training data should be placed on shared storage, and both machines should read the same path. If data is stored on the local disk of one machine, processes on the other machine cannot access it and will report an error at the first step.
6. Training Loop and Numerical Stability
6.1 Single-Step Training Flow
A training step usually includes the following stages. The pseudocode below uses general interfaces; specific APIs depend on the framework in use:
for step from start_step to total_steps - 1:batch = get next batch from data iteratorforward_output = model(batch) # computed under mixed precisionloss = compute_loss(forward_output)scale loss by loss scaling factor and backpropagateunscale gradientsgrad_norm = clip_gradients(model_parameters, max_norm=1.0)optimizer.update_parameters()lr_scheduler.step()global_loss = average loss within data parallel grouplog(step, global_loss, grad_norm, current_lr, throughput, peak_memory)if step % checkpoint_interval == 0:save_checkpoint(model, optimizer, scheduler, data_state, step)
6.2 Numerical Stability Measures
- Mixed precision and loss scaling: low-precision computation reduces memory usage and improves throughput, but gradients may underflow. Loss scaling mitigates this. If the loss suddenly becomes NaN, first check whether the scaling factor is too large.
- Gradient clipping: limiting the gradient norm to a threshold can suppress severe fluctuations in early training. The threshold is generally around 1.0 and should be adjusted based on the actual gradient norm curve.
- Learning rate warmup: using a smaller learning rate for the first several steps and gradually increasing it can prevent randomly initialized parameters from being updated too aggressively early on. Warmup steps are often a small fraction of total steps.
6.3 Metrics to Record
Monitoring metrics determine whether problems can be detected in time. At minimum, record the following:
- Global loss and differences among per-accelerator losses, to confirm data parallelism synchronization.
- Gradient norm, to identify gradient explosion or vanishing.
- Per-step latency and tokens processed per second, to detect throughput degradation.
- Peak memory, to anticipate out-of-memory risk.
- Learning rate, to verify that the scheduler works as expected.
These metrics should be written to a unified logging system, with alerts for abnormal values. For example, trigger a notification when the gradient norm exceeds a threshold for several consecutive steps or when throughput drops by more than a certain percentage.
7. 400-Step Validation Method
Validation should not only check whether training finishes; it should check in stages.
7.1 Staged Checks
- Steps 0 to 10: confirm that all processes have entered the training loop and that first-step latency is reasonable. The first step usually includes initialization overhead; record it separately and exclude it from stable throughput.
- Steps 10 to 50: observe whether loss begins to decrease, whether per-accelerator losses are consistent, and whether NaN appears.
- Steps 50 to 200: observe whether throughput is stable and whether peak memory grows over time. If memory continues to rise, there may be a memory leak.
- Around step 200: save a checkpoint.
