Training Large Language Models Across Two Servers with 16 Domestic AI Accelerator Cards: An End-to-End Pipeline Walkthrough
This guide walks through a two-server, 16-accelerator-card setup for large language model training, covering hardware and network preparation, software stack layering, parallelism strategy, checkpointing, monitoring, and validation over 400 training steps. It also lists common failure modes and where to start troubleshooting them.
1. Background and Goals
The compute demands of large language model training keep growing. A single server holds only a limited number of accelerator cards, so multi-node collaboration has become standard practice. A complete training pipeline typically includes hardware and network preparation, runtime environment installation, data loading, model parallel partitioning, the training loop, checkpoint saving, and metric monitoring. A failure in any one of these stages can stall training.
This case uses two servers with 16 accelerator cards in total. The goal is to run the full training pipeline end to end and stably complete 400 training steps. “Running successfully” means more than the program finishing without errors. It also requires the following:
- The loss decreases in a normal trend as training steps progress;
- Gradients do not contain NaN or Inf values continuously;
- Checkpoints saved mid-training can be restored correctly;
- Communication between nodes has no timeouts or hangs.
Only when all four conditions hold can the pipeline be considered usable in a multi-node setup.
2. Hardware and Network Topology
2.1 Node Layout
The 16 cards can be distributed in several ways. A common configuration places 8 cards in each of two machines. The actual layout should match the hardware you have. The core principle is to keep the most communication-intensive operations within a single machine.
Card-to-card links inside a node usually have much higher bandwidth than the network between nodes. Tensor parallelism, which exchanges data at every layer, is therefore best kept inside a node. Cross-node communication mainly handles gradient synchronization for data parallelism, or data transfer between adjacent stages in pipeline parallelism.
2.2 Network Requirements
The cross-node network must meet the following requirements:
- Enough bandwidth to support the volume of data exchanged during gradient synchronization;
- Low latency, ideally with support for remote direct memory access (RDMA) to reduce CPU overhead;
- Full network connectivity between the two machines, with firewalls open for the port range that training requires.
2.3 Pre-Deployment Checklist
- Confirm that both machines have the same accelerator model, card count, and driver version;
- Synchronize the system clocks of both machines with a time synchronization service. Large clock offsets make logs hard to align and can also contribute to some communication timeouts;
- Mount shared storage at the same path on both machines, and store checkpoints and datasets there;
- Record the network interface name and IP address of each machine. The launch parameters need them later.
3. Software Stack Layers
A training environment can be divided into five layers by responsibility. Checking each layer in order makes problems easier to locate than running the training script directly.
| Layer | Main Responsibility | Common Issues |
|---|---|---|
| Driver layer | Manages accelerator hardware and its interaction with the kernel | Kernel version mismatch |
| Runtime layer | Provides device memory management and basic operators | Incompatible with the driver version |
| Communication layer | Runs collective operations such as all-reduce and all-gather | Wrong network interface selected, communication timeouts |
| Framework layer | Builds computation graphs, performs automatic differentiation, and handles optimizer updates | Dependency conflicts, interface version changes |
| Application layer | Training scripts, configuration files, and data loading logic | Configuration parameter errors |
Version mismatch is the most common source of failures. The driver, runtime, communication library, and training framework depend on one another. Before installing, check the version compatibility of each component, record the results in a matrix, and then install everything against that matrix. Upgrading components one at a time without records makes rollbacks difficult when something breaks.
4. Key Stages of the Training Pipeline
4.1 Data Preparation
In multi-node training, the main goal of data management is to prevent different processes from reading duplicate samples, while ensuring that each epoch covers the full dataset.
- Complete data preprocessing offline. During training, only lightweight reads should happen, so data loading does not become a bottleneck;
- Each data-parallel process reads its own shard, based on its rank number;
- Derive random seeds from the process rank. This keeps runs reproducible and prevents all processes from following exactly the same data order.
The following example code shows the basic approach to splitting sample indices by process rank:
def shard_indices(num_samples, world_size, rank):# Split sample indices by process rank so that no two processes overlapper_rank = num_samples // world_sizestart = rank * per_rank# The last process takes the remaining samples so that no tail data is droppedend = num_samples if rank == world_size - 1 else start + per_rankreturn range(start, end)
4.2 Parallelism Strategy
When a model is too large for a single card, its weights or computation must be split across multiple cards. There are three common parallelism approaches:
- Data parallelism: Each card holds a full copy of the model, processes different data, and synchronizes gradients at the end of each step. It is simple to implement but uses more memory per card.
- Tensor parallelism: The weight matrices of a single layer are split across multiple cards. It is computationally efficient but requires communication at every layer, so it is best placed within a node.
- Pipeline parallelism: The model is split by layers into several stages, with each stage placed on a different card. It reduces the memory pressure on each card, but the pipeline bubbles cause idle time that must be managed.
One way to divide 16 cards is to set tensor parallelism to 4, pipeline parallelism to 1, and data parallelism to 4. The product of the three equals 16. This layout confines tensor parallelism to a single node, so only gradient synchronization crosses nodes. The actual split should be tuned based on the model architecture, memory capacity, and network bandwidth. The card count alone is not enough to decide it.
4.3 Mixed Precision and Numerical Stability
Low-precision computation reduces memory use and speeds up computation, but reduced precision also introduces numerical problems. In practice, pay attention to the following:
- Use loss scaling to prevent gradients from underflowing to zero in low precision;
- Set a gradient clipping threshold to limit the size of each update;
- Check the loss and gradients for NaN or Inf values every few steps. If either appears, stop immediately and preserve the current state for debugging;
- Use learning rate warmup to reduce oscillation early in training. This matters especially for large-batch training.
4.4 Checkpoint Management
A checkpoint is more than the model weights. A complete checkpoint should include model parameters, optimizer state, random number generator state, and the data loading position. If any of these is missing, the loss may jump after restoration.
Save checkpoints at a fixed step interval, and keep only the most recent few versions to limit storage use. The following is an example configuration:
checkpoint:save_dir: /shared/ckpt/run_001interval_steps: 50keep_last: 3save_optimizer_state: truesave_data_position: true
After resuming training, compare the loss over several steps before and after the interruption and confirm that the curve stays continuous. This is the most direct way to verify that a checkpoint is complete.
4.5 Monitoring Metrics
During training, observe at least the following metrics:
- Loss and learning rate, to judge the convergence direction;
- Per-step time and throughput (for example, tokens processed per second), to judge whether performance is stable;
- Memory usage on each card, to catch memory leaks or uneven allocation early;
- The share of per-step time spent on communication, to judge whether the parallelism strategy is reasonable;
- Device temperature and power draw, to detect cooling or power supply problems.
Write these metrics to logs or connect them to a unified monitoring and alerting system. Set anomaly thresholds so that alerts fire automatically when progress stalls for an extended period.
5. Multi-Node Launch Example
Both machines must use the same training configuration and point to a shared master node address and port. The commands below are placeholders. The actual commands depend on the launch tool of the training framework you use:
# Node 0 (master node)launch_train --nodes 2 --node-rank 0 \--master-addr "${MASTER_ADDR}" --master-port "${MASTER_PORT}" \--gpus-per-node 8 --config train.cfg# Node 1launch_train --nodes 2 --node-rank 1 \--master-addr "${MASTER_ADDR}" --master-port "${MASTER_PORT}" \--gpus-per-node 8 --config train.cfg
Pass the master node address and port through environment variables instead of hardcoding them in scripts, so the setup is easier to move between environments. For startup order, launch the master node first, then the other nodes. Confirm that all nodes have finished process group initialization before the training loop begins.
6. Running and Validating 400 Steps
400 steps is a suitable scale for validating the pipeline. It is long enough to expose intermittent communication problems and memory growth, and short enough to finish in a single test run. Observe the run in three phases.
6.1 Startup Phase (First 10 Steps or So)
Focus on whether all processes are ready, whether memory is allocated as expected, and whether the first collective communication completes successfully. If there is no output for several steps, the most likely causes are an unreachable address or port between nodes, or a process on one node that failed to start.
6.2 Stable Phase (Middle Steps)
Focus on the loss trend and fluctuations in per-step time. If per-step time spikes periodically, the cause is often checkpoint saving, blocking data reads, or high load on one node. The overall loss should trend downward. Short-term fluctuations are normal, but a sustained rise or a sudden change to NaN requires immediate investigation.
6.3 Completion Phase
Confirm that the final checkpoint has been saved, and verify the integrity of the checkpoint files. If feasible, pick a mid-run checkpoint, resume training from it for several steps, and compare the resumed curve with the original curve.
A stricter validation method involves two steps. First, fix the random seed, run twice, and compare the loss difference over the first several dozen steps. Second, interrupt the run deliberately around step 200 and test whether recovery is correct. These tests distinguish a pipeline that merely runs from one that is reliable.
7. Common Failures and Troubleshooting Directions
| Symptom | Possible Cause | Troubleshooting Direction |
|---|---|---|
| No output for a long time after launch | Master node not ready, address or port unreachable | Check the firewall and address configuration, and confirm the master process is running |
| Communication timeout at the first step | Wrong network interface selected, clocks out of sync across the two machines | Specify the correct communication interface, and synchronize the system clocks |
| Loss becomes NaN | Learning rate too high, mixed-precision overflow, abnormal data | Lower the learning rate, check loss scaling, filter out abnormal samples |
| Out-of-memory error | Batch size too large, activations not recomputed, parallelism split not suited to the model | Reduce the batch size, enable activation recomputation, recalculate parallelism parameters |
| Loss jumps after resuming | Optimizer or random state not saved, data position misaligned | Check |
