Running a Large Model Training Pipeline on 16 Accelerator Cards Across Two Machines
This article details the practice of successfully running a large model training pipeline end-to-end on 16 accelerator cards across two servers, completing 400 continuous training steps. It breaks down the training pipeline into five critical layers—data, scheduling, compute, communication, and storage—and explores hardware and network preparation, parallelism strategy selection, and software stack adaptation. Additionally, it provides guidelines for ensuring communication and convergence stability, implementing fault recovery, and monitoring key metrics, concluding with a reusable deployment checklist for multi-node training environments.
I. Background and Goals
The demands of large model training on computing power and communication efficiency are continuously increasing. A single machine with multiple cards can typically only support small-scale experiments. Once model parameters and training data volumes grow, teams often need to scale training across two or more machines. Multi-node training introduces new challenges, including device interconnection, process orchestration, gradient synchronization, and fault recovery. These concerns differ significantly from those in single-node training.
The goal of this practice was to establish a stable, end-to-end training pipeline—from data reading to parameter updates—on two servers equipped with a total of 16 accelerator cards, and successfully complete 400 continuous training steps. Here, “running through” means the pipeline can execute end-to-end, rather than merely completing a single forward pass or a single-step validation.
II. Decomposing the Training Pipeline
The training pipeline can be broken down into five segments, each requiring individual validation:
- Data Layer: Handles data splitting, preprocessing, and sharded reading to ensure that each process receives non-overlapping data.
- Scheduling Layer: Manages job launching, process orchestration, and node registration to ensure all 16 compute processes can discover each other.
- Compute Layer: Executes forward passes, backpropagation, and optimizer updates.
- Communication Layer: Handles cross-node gradient synchronization and parameter aggregation.
- Storage and Monitoring Layer: Responsible for checkpoint saving, log writing, and metric collection.
A common pitfall in practice is focusing solely on the compute layer. When issues arise in the communication or scheduling layers, the compute layer often appears unresponsive for extended periods, which can be easily misdiagnosed as insufficient computing power. Therefore, it is recommended to validate these five segments individually using small-scale tasks before starting formal training.
III. Hardware and Network Preparation
Bottlenecks in multi-node training frequently occur in the network between nodes. Before launching, it is advisable to complete the following checks:
- Ensure the number of accelerator cards, memory capacity, and driver versions are consistent across all machines. Version mismatches often cause collective communication to hang on certain processes.
- Verify that inter-node bandwidth and latency meet design expectations and that required communication ports are open.
- Keep the system time synchronized across both machines to prevent log timestamp misalignment, which complicates cross-node troubleshooting.
- Ensure shared storage is visible to both machines with consistent read/write permissions.
Network checks can be completed before formal tasks using a simple collective communication test. Launching model training only after this test passes can eliminate most issues caused by network configuration.
An illustrative startup configuration is as follows (pseudo-code; field names are for structural illustration only):
cluster:nodes: 2devices_per_node: 8world_size: 16master_addr: <Internal IP of the master node>master_port: <Free port>rendezvous_timeout_sec: 600
Here, world_size equals the number of nodes multiplied by the number of cards per node, i.e., 2 × 8 = 16. The master node address should use an internal network IP to avoid routing through public network links.
IV. Choosing a Parallelism Strategy
Large model training typically combines multiple parallelism methods. The three most common are:
- Data Parallelism (DP): Each card holds a complete replica of the model and processes different data batches, with gradients aggregated at the end of an iteration. It is simple to implement, but single-card memory may be insufficient for very large models.
- Tensor Parallelism (TP): Splits a single layer’s weight matrices across multiple cards. Each card computes a partial result before merging. This reduces single-card memory usage but involves frequent intra-layer communication, requiring high inter-card bandwidth.
- Pipeline Parallelism (PP): Slices the model by layers into segments placed on different cards. Data flows between segments as micro-batches. This reduces the per-card burden but introduces pipeline bubbles, lowering compute utilization.
The product of these three parallelism degrees must equal the total number of cards. For a 16-card setup, you can set data parallelism to 4, tensor parallelism to 2, and pipeline parallelism to 2. An illustrative constraint check is as follows:
world_size = 16dp, tp, pp = 4, 2, 2assert dp * tp * pp == world_size, "The product of parallelism degrees must equal the total number of cards"
The choice of parallelism strategy depends on model size, single-card memory budget, and inter-node bandwidth. The guiding principle is to keep communication-intensive tensor parallelism within the same machine, while using data or pipeline parallelism for cross-machine communication. This confines high-frequency communication to high-speed interconnects.
V. Software Stack Adaptation
Multi-node training requires strict consistency in software versions. Adaptation work typically includes the following:
- Operator Coverage Check: Confirm that all operators used in the model have corresponding implementations. When operators are missing, evaluate whether to rewrite them as equivalent combinations or implement them from scratch.
- Mixed Precision Strategy: Select a precision scheme based on hardware-supported data types and set up a scaling mechanism for gradients to prevent underflow.
- Communication Component and Driver Matching: Communication component versions must correspond to driver and firmware versions and must not be mixed across nodes.
- Compilation and Caching: First-run compilation can be time-consuming. Cache compilation artifacts to shared storage to avoid recompiling on every launch and to prevent inconsistent artifacts between the two machines.
After completing each adaptation step, record the version numbers and configuration parameters. If an anomaly occurs during training, this record can quickly narrow down the troubleshooting scope.
VI. Communication and Convergence Stability
The two most common issues in multi-node training are communication hangs and loss anomalies.
A typical sign of a communication hang is an iteration that takes an unusually long time to complete. Troubleshooting should proceed in the following order:
- Check the current training step of each process to identify the lagging process.
- Verify that communication timeout parameters are consistent across all processes.
- Inspect the network interface status and packet loss on the lagging node.
- If all processes are stuck on the same collective communication operation, prioritize investigating network or device anomalies on a specific node.
A typical sign of a loss anomaly is the loss value suddenly becoming NaN or continuously rising. Common mitigation methods include:
- Applying an upper bound to the gradient norm and clipping it when the threshold is exceeded.
- Using learning rate warmup during the early stages of training to gradually stabilize parameter updates.
- Monitoring the mixed precision scaling factor. A continuously decreasing scaling factor usually indicates frequent gradient overflow.
VII. Checkpoints and Fault Recovery
Throughout the 400-step training process, checkpoints are core to ensuring recoverability. A checkpoint should include:
- Model parameters.
- Optimizer states, including momentum and historical statistics for adaptive learning rates.
- Random number states to ensure reproducible random behavior after recovery.
- The read position of the data loader to avoid skipping or repeating samples upon recovery.
When saving, it is recommended to use atomic writes: write to a temporary file first, then rename it to the official file once writing is complete. This prevents leaving a corrupted checkpoint even if the saving process is interrupted. The checkpoint saving frequency needs to balance storage overhead and training progress.
The recovery process also needs to be practically validated. Before formal training, it is advisable to restore from an intermediate checkpoint and run a few steps to confirm that the loss curve aligns seamlessly with the state before saving.
VIII. Monitoring Metrics and Troubleshooting Checklist
During training, it is recommended to continuously collect the following metrics:
| Metric | Focus Area |
|---|---|
| Per-step execution time | Whether it is stable; sudden spikes usually point to communication or data reading bottlenecks. |
| Memory usage per card | Whether it is approaching the limit; whether there is severe imbalance between cards. |
| Communication time ratio | A high ratio indicates that the parallelism strategy or bandwidth needs adjustment. |
| Loss and gradient norm | Whether NaNs or continuous divergence occur. |
| Data reading time | Whether it becomes a waiting bottleneck for computation. |
Common phenomena and troubleshooting directions are as follows:
| Phenomenon | Possible Cause | Troubleshooting Direction |
|---|---|---|
| Long unresponsiveness during startup | Node registration failure or blocked port | Check master node address, port, and firewall rules. |
| Stuck on a specific step mid-training | Node anomaly or inconsistent timeout parameters | Compare current step across processes; check timeout configuration. |
| Continuous memory growth on a specific card | Intermediate variables not released | Check caches and references; verify if residual computation graphs remain per step. |
| Loss suddenly becomes NaN | Gradient overflow or learning rate too high | Check scaling factor, lower learning rate, and add clipping. |
| Loss jumps after recovery | Optimizer state or data position not restored | Verify checkpoint contents and recovery process. |
IX. Key Milestones During the 400-Step Run
Reaching 400 steps indicates that the pipeline maintained stability over an extended period. For this type of practice, the following phases are worth close observation:
- First few steps: Primarily validates whether startup, communication, and data reading are normal. Issues in this phase are mostly configuration-related.
- Around the first checkpoint save: Validates whether the saving process affects training rhythm and whether the checkpoint file is complete.
- Mid-run stability period: Observe whether per-step execution time and memory usage remain stable, and troubleshoot any gradually accumulating resource leaks.
- Around the end: Confirm that the final checkpoint can be loaded correctly and that logs and metrics are completely saved for future review.
X. Reusable Deployment Checklist
- Hardware and driver versions are consistent across all nodes.
- Network bandwidth, latency, and port connectivity are tested before formal tasks.
- The product of parallelism degrees equals the total number of cards, and the rationale for each parallelism value is documented.
- Software versions, compilation artifacts, and configuration parameters are uniformly recorded and cached to shared storage.
- Stability parameters such as communication timeout, gradient clipping, and learning rate warmup are configured in advance.
- Checkpoints include the model, optimizer, RNG state, and data position, using atomic writes.
- A recovery validation from an intermediate checkpoint is completed before training.
- Monitor per-step time, memory, communication ratio, and loss curve to establish a troubleshooting baseline.
