Getting Large Model Training Running on Domestic AI Accelerators: A Practical Guide
This article walks through the practical process of validating a complete large model training pipeline on domestic AI accelerator cards. It covers why end-to-end pipeline validation matters more than benchmark numbers, how to prepare the driver, framework, and communication layers, how to choose and split parallelism strategies for a two-node, sixteen-card setup, which metrics to watch during a 400-step run, and a troubleshooting table for common failures. It closes with recommendations for turning short validation runs into a repeatable production pipeline.
1. Why Getting the Pipeline Running Matters More Than Benchmark Numbers
In large-scale model training, teams tend to focus on the final loss curve and throughput figures. In practice, however, the first obstacle is usually not the algorithm but the pipeline itself failing to run. The training pipeline is the full closed loop: data loading, preprocessing, tokenization, forward computation, backpropagation, gradient reduction, optimizer updates, and checkpoint saving. If any stage has a protocol mismatch, a missing operator, or a communication fault, the whole job stalls at startup.
For this reason, the industry commonly uses a “small-scale, short-step validation” as the first gate before launch: run roughly 400 training steps at a moderate scale such as two nodes with sixteen cards, then check whether the loss decreases monotonically, whether memory usage stays stable across cards, and whether communication times out. Only after this passes does it make sense to scale up.
2. Preparing the Hardware and Software Stack
Reproducing training on a domestic accelerator platform requires attention to three layers of compatibility:
- Driver and runtime layer: the driver version, runtime libraries, and communication libraries must be matched as a set. Mixing binaries from different sources is the most common cause of failure.
- Framework adaptation layer: the training framework needs a corresponding device backend, and operator coverage determines whether the model runs at all. When an operator is missing, substitute an equivalent combination of operators first, then replace it with a high-performance implementation step by step.
- Communication and topology layer: confirm the inter-card interconnect bandwidth and the link types inside and between hosts, and bind processes to the nearest device under topology-aware scheduling.
A sample environment self-check script can look like this:
import runtime, commdef preflight():assert runtime.device_count() >= 16, "Not enough devices"runtime.set_visible_devices(range(16))comm.init_process_group(backend="native", rank_from_env=True)x = runtime.ones(1024, device="cuda_like:0")y = comm.all_reduce_sum(x)print("allreduce ok:", float(y))
The point of this code is not the specific interfaces but verifying three things at once: device visibility, process group initialization, and collective communication availability. This avoids discovering problems halfway through a long job.
3. Choosing and Splitting the Parallelism Strategy
A two-node, sixteen-card setup is well suited to validating two-dimensional parallelism: tensor parallelism inside each host to exploit high-bandwidth interconnect, and data parallelism or pipeline parallelism between hosts to reduce cross-node communication pressure. A few rules of thumb apply when splitting:
- The tensor parallel degree generally should not exceed the number of cards in a single host, otherwise cross-node communication becomes the bottleneck.
- Under data parallelism, the global batch size equals the per-card batch size multiplied by the number of cards, and the learning rate should be scaled accordingly based on empirical rules.
- If pipeline parallelism is used, divide the layers across stages sensibly so that computation time on each device is as aligned as possible, reducing bubbles.
- Mixed-precision training can significantly reduce memory usage, but the loss scaling strategy must stay stable to avoid numerical overflow.
4. Metrics to Watch During the 400-Step Validation
The value of a short validation run is exposing problems quickly. It is worth recording the following signals:
- Whether the loss drops noticeably within the first few dozen steps, and whether NaN or Inf appears;
- Peak memory and fragmentation per rank, and whether there is a gradual leak;
- The share of time spent in collective communication, to tell whether the bottleneck is compute or communication;
- Whether checkpoint saving and restoration are reversible, and whether the loss is continuous after resuming;
- The variance of per-step time; a sudden spike in variance often means a card is throttling or a link is jittering.
If the loss oscillates, first check whether the data order is consistent, whether random seeds are aligned, and whether gradient clipping is in effect, rather than rushing to change the model structure.
5. Common Failures and How to Locate Them
| Symptom | Common cause | Approach |
|---|---|---|
| Hangs at startup | Process group not initialized correctly, address unreachable | Run a small-scale point-to-point communication self-check first |
| Operator unsupported error mid-run | Insufficient operator coverage in the backend | Replace with an equivalent combination of operators |
| Out of memory | Batch size or sequence length too large | Enable recomputation and mixed precision |
| Throughput drops sharply | Poor topology binding | Rebind processes according to affinity |
| Loss jumps after resuming | Optimizer state not fully saved | Verify the completeness of checkpoint fields |
6. Moving From Validation to Production
Getting a short run working is only the starting point. For production, validation should be turned into a pipeline: environment self-check, communication self-check, short-step training, and checkpoint verification run automatically, and any failure blocks the release. At the same time, set up a unified logging, monitoring, and alerting system that brings device temperature, memory usage, and communication time into routine observation. Training data and checkpoints are best stored on object storage, with job scheduling handled by a container platform to enable elastic scaling and self-healing.
In related practice at Baidu AI Cloud, this “validate at small scale first, then scale up gradually” approach has repeatedly proven effective: it breaks uncontrollable large-scale risk into several measurable, rollback-able small steps, significantly lowering the adaptation cost of domestic compute platforms. For developers, mastering this methodology has more long-term value than memorizing the parameter combination from any single successful run.
