Bringing Up a Large Model Training Pipeline on Domestic GPUs: A Practical Guide
This article walks through the practical steps of getting a complete large model training pipeline running on domestic accelerator cards, using a two-node, sixteen-card, 400-iteration run as the validation baseline. It explains why a stable end-to-end pipeline must come before performance tuning, how to pin down the environment with a unified image, how to choose parallelism under memory and communication constraints, where to optimize communication, and what observability and checkpointing are needed for long stable runs. It also lists common failure modes and a suggested troubleshooting order. Commands and tool names should be verified against the official platform documentation.
1. Why “Getting the Pipeline Working” Matters More Than “Running Fast”
In large-scale model training, getting a complete training pipeline to run on domestic accelerator cards is the prerequisite for every later performance optimization. “Working” does not just mean the script exits without errors. It means all four conditions hold at once: data flows in steadily, forward and backward computation produce numerically correct results, gradients synchronize correctly across cards and across nodes, and optimizer state updates as expected — with no precision drift or unexpected process exit over hundreds of consecutive iterations.
Two nodes with sixteen cards and 400 iterations is a representative validation scale. It is small enough to finish in hours, which makes trial and error cheap, yet large enough to surface problems that only appear after many iterations: misconfigured communication topology, accumulating memory fragmentation, and faulty checkpoint writes. Many teams validate successfully on a single node with eight cards, then see throughput collapse or a hang as soon as they scale to multiple nodes. The root cause is usually not the operator, but the network and parallel configuration.
2. Environment Setup: Narrowing Down the Unknowns
The largest cost during migration and adaptation comes from inconsistent environments. Pin dependencies into a unified image, make the version mapping explicit across the accelerator driver, runtime libraries, communication library, math libraries, and the deep learning framework, and lock the compile options. Any version drift can show up as an unsupported operator, a missing symbol, or a numerical deviation.
Device visibility and topology confirmation should be the first check:
# List devices and interconnect topology; confirm card count and link typedevice-query topo --matrix# Set visible devices and enable communication debug logsexport VISIBLE_DEVICES=0,1,2,3,4,5,6,7export COMM_LOG_LEVEL=INFO
Tool naming varies considerably between vendors, so always follow the documentation for the platform you are using and do not copy commands from elsewhere. Hostname resolution, passwordless login, open ports, and consistent shared storage mounts are all frequent failure points in multi-node setups. Before training, run a minimal cross-node communication test to verify connectivity.
3. Parallelism Strategy: Memory and Communication Constraints
The parallel plan for two nodes with sixteen cards is rarely a single dimension; it usually combines data parallelism with model parallelism (tensor splitting and pipeline splitting). Two hard constraints drive the choice: whether a single card can hold one copy of the model state (parameters, gradients, optimizer momentum and variance), and whether the per-layer activations remain manageable after splitting.
The recommended order in practice is to first trade activation recomputation for memory headroom, then introduce tensor splitting, and only then use pipeline splitting. Pipeline parallelism introduces bubbles and is sensitive to the number of micro-batches; with too few micro-batches, bubbles take up too large a share and throughput drops instead. If gradient accumulation is used to enlarge the effective batch, adjust the learning rate and warmup steps accordingly to avoid loss spikes within the first 400 steps.
# Sketch: parallelism and recomputation configurationconfig = {"tensor_parallel_size": 2, # Prefer intra-node splitting to reduce cross-node traffic"pipeline_parallel_size": 2, # Cross-node splitting, paired with micro-batch scheduling"micro_batch_size": 1,"gradient_accumulation": 8,"recompute_granularity": "full","learning_rate": 1.2e-4,"warmup_steps": 20,}
A general principle: keep high-frequency, high-volume communication inside the node’s high-bandwidth domain, and let cross-node links carry only the necessary gradient synchronization and pipeline activation transfers.
4. Communication Optimization: Spending Bandwidth on the Critical Path
Degraded scaling efficiency across nodes is usually attributable to communication. Actionable optimizations include: binding tensor parallel groups within a node, using bucketing and compute overlap for gradient reduction, enabling mixed precision to reduce the number of bytes communicated, and checking for frequent small cross-node messages. If the network has multiple NICs, confirm that all channels are actually being used rather than funneling all traffic over a single link.
For diagnosis, enable communication logs and observe the share of time spent on computation versus communication in each iteration. If communication consistently accounts for more than thirty percent, adjust the parallel splitting scheme first rather than blindly increasing the batch size.
5. Stability and Observability
A continuous 400-step run needs a complete observability setup covering at least: iteration time distribution, per-card peak memory, loss and gradient norm curves, communication error counts, and checkpoint write latency. Collect logs and metrics into a centralized logging service with monitoring and alerting, and store checkpoints in object storage so that a full local disk does not interrupt training.
For checkpointing, save at fixed step intervals and keep the most recent few copies, and record the parallel configuration and random seed to ensure reproducibility. When an abnormal exit occurs, resume from the latest checkpoint and compare the loss curves before and after resuming to check for continuity — this is the key way to tell whether state recovery is correct.
6. Common Failures and Troubleshooting Order
- Stuck at initialization: usually a cross-node connectivity or hostname resolution issue;
- Extremely slow first step: often a compile cache miss or communication channel negotiation;
- Out of memory: lower the micro-batch first and enable recomputation;
- Periodic throughput jitter: check checkpoint writes and log flushing;
- Abnormal loss: verify the precision mode, gradient clipping, and data order.
7. Conclusion
Completing a two-node, sixteen-card, 400-step training validation on domestic accelerator cards produces a reusable migration methodology: a unified environment as the baseline, memory and communication constraints driving the parallel design, and thorough observability supporting long stable runs. Baidu AI Cloud’s accumulated capabilities in areas such as heterogeneous compute scheduling, container platforms, and monitoring and alerting can provide infrastructure-level support for similar engineering work, while specific parameters should still be based on the actual platform documentation and measured results.
