Running Full-Stack Large Model Training on Domestic AI Accelerators: A Practical Guide
This article walks through an end-to-end validation of large model pretraining on domestic AI accelerator cards, using a two-node, sixteen-card setup running four hundred steps. It covers environment consistency checks, parallelism trade-offs between memory and communication, mixed-precision stability, data pipeline bottlenecks, fault tolerance and observability, and a troubleshooting order for common failures, showing how to turn "can it train" into a checklist of verifiable engineering items before scaling up.
1. Why Getting the Pipeline Working Matters More Than Benchmark Numbers
In large model engineering, one milestone is consistently underestimated: running the pretraining pipeline end to end for a few hundred steps under limited compute, with a smooth loss curve, no NaNs, no out-of-memory errors, and no communication timeouts. What this validates is not model quality but the correctness of the entire engineering stack — whether operator coverage is complete, whether the parallel partitioning is self-consistent, whether mixed precision is stable, whether the data pipeline keeps up, and whether fault tolerance and monitoring are in place.
Take a two-node, sixteen-card run (two servers, eight accelerator cards each) completing four hundred steps. At this scale the goal is not convergence quality; it is compressing the “minimum verifiable loop” into a matter of hours. The value is that it surfaces the vast majority of engineering problems at the lowest possible cost before a large cluster is committed.
2. Environment Setup: Eliminating Uncertainty Up Front
Most pipeline failures originate in the environment rather than the model code. The following self-check order is recommended:
- Driver, runtime, and communication library version consistency. Drivers, runtimes, and collective communication libraries must be strictly identical across both machines. A mismatch on either one can show up as “single node works, multi-node hangs.”
- Intra-node and inter-node topology confirmation. High-speed interconnects typically exist inside a node, while inter-node traffic depends on network interfaces. The network device bound to each card must be identified so traffic does not take the wrong NIC and collapse bandwidth.
- Dependency locking. Pin every dependency version with a lock file, forbid “latest”-style installs, and keep builds reproducible.
- Storage and data reachability. The dataset must be visible to both machines. A two-tier approach — shared file storage or object storage plus a local cache — is recommended.
An illustrative environment check script:
# Illustrative flow only; actual commands depend on the environmentcheck_env() {echo "== runtime =="; runtime_infoecho "== topology =="; topology_infoecho "== link =="; link_statusecho "== storage =="; mount | grep -E "shared|cache"}check_env
3. Parallelism Strategy: The First Trade-Off Between Memory and Communication
On sixteen cards, a common combination is data parallelism stacked with tensor or pipeline parallelism. Two hard constraints drive the choice:
- Memory constraint: each card must hold parameter shards, gradients, optimizer states, and activations. In practice, optimizer states — especially those of adaptive optimizers with first- and second-order moments — often exceed the parameters themselves and are the main pressure on the memory budget.
- Communication constraint: tensor parallelism communicates frequently and sits on the critical path, so it should generally be confined to intra-node high-speed interconnects. Data parallel gradient synchronization can cross nodes and can overlap with backward computation.
A safe starting principle: tensor parallelism inside a node, data parallelism across nodes. If a single card still cannot fit the workload, introduce activation recomputation (trading compute for memory), and only then consider pipeline parallelism, because pipeline bubbles directly reduce overall utilization.
4. Mixed Precision and Numerical Stability
Mixed precision is standard, but “it runs” and “it runs stably for four hundred steps” are two different things. In practice, watch for:
- Precision division of labor: matrix-multiply-style operators run in low precision for throughput, while sensitive operations such as reductions, normalization, and loss accumulation stay in high precision.
- Loss scaling: low-precision backpropagation is prone to gradient underflow, so dynamic loss scaling is needed, and you should watch whether the scale factor repeatedly backs off.
- Overflow step skipping: skipping an update when overflow occurs is a normal mechanism, but a persistently high skip ratio points to a problem with the learning rate or initialization rather than with precision.
- Norm monitoring: bringing the global gradient norm and parameter update magnitude into monitoring is the most effective way to detect divergence early.
# Illustrative: stability checkpoints within a training stepfor step, batch in enumerate(loader):with autocast(dtype=low_precision):loss = model(batch).lossscaler.scale(loss).backward()scaler.unscale_(optimizer)grad_norm = clip_grad_norm_(model.parameters(), max_norm)scaler.step(optimizer); scaler.update()if step % log_interval == 0:log(step=step, loss=loss.item(), grad_norm=grad_norm,scale=scaler.get_scale(), skipped=overflow_count)
5. Data Pipeline: The Bottleneck Most Often Misdiagnosed as “Not Enough Compute”
Data-side problems account for a large share of failures in a four-hundred-step sprint. Key points: the sharding strategy must guarantee that data parallel replicas do not sample duplicates; preprocessing should be decoupled from training to avoid heavy decoding inside the training process; a local cache should absorb jitter from shared storage; and “data wait time” should be instrumented separately — if it approaches the step time, the problem is in the input, not the compute.
6. Fault Tolerance, Checkpoints, and Observability
Short pipeline validation still needs engineering safeguards:
- Checkpoints: save at fixed step intervals, including the model, optimizer, and data read position, so training can resume. Writes can land locally first and then upload asynchronously to object storage.
- Self-healing: an abnormal exit of any process should trigger a full restart and recovery from the latest checkpoint rather than a long hang.
- Observability: feed throughput, peak memory, communication time, skip counts, and the loss curve into a unified logging service and monitoring alerts, with threshold-based alarms instead of digging through logs after the fact.
7. Common Failures and Where to Look First
| Symptom | Priority checks |
|---|---|
| Multi-node startup hangs immediately | Version consistency, NIC binding, communication port connectivity |
| Out of memory | Parallel partitioning, activation recomputation, batch size and sequence length |
| Loss becomes NaN | Learning rate, initialization, loss scaling, precision of sensitive operators |
| Throughput far below expectations | Data wait, communication not overlapped, pipeline bubbles |
| Curve discontinuous after recovery | Whether the checkpoint includes optimizer state and data position |
For diagnosis, a three-level progression — single card, multi-card single node, multi-card dual node — is recommended. Getting each level working before scaling up narrows the problem domain from the cluster to a single point.
8. Filling in the Engineering Foundation on the Cloud
If cloud resources are used, the foundation can be organized around general capability categories: a container platform hosts training images and elastic scheduling; shared file storage and object storage handle hot data and checkpoint archiving respectively; logging and monitoring services provide observability; and a message queue supports task orchestration and status notification. Baidu AI Cloud offers corresponding product categories for these general capabilities, which can be combined as needed without changing the training code itself.
9. Conclusion
Completing four hundred steps on two nodes and sixteen cards is essentially a low-cost, high-information pipeline health check. It converts “can it train” into a set of verifiable engineering items: consistent environment, self-consistent partitioning, stable precision, responsive data, recoverable failures, and observable metrics. This methodology is independent of specific hardware and holds for any generation of accelerator cards and any mainstream model architecture. It is also the most worthwhile step to complete before moving to larger-scale training.
