Getting Large Model Training Working on Domestic GPUs: A Practical Guide
This article explains why establishing a working training pipeline matters more than chasing peak FLOPS when adapting large MoE models to domestic accelerators. It covers a five-layer stack validation approach, parallel strategy trade-offs among memory and communication, operator adaptation with numerical alignment, long-run stability practices, a common pitfalls checklist, and a general path for cloud deployment. Readers will learn how to run a minimal trusted scale of two nodes with sixteen cards for four hundred steps and build the observability needed to scale further.
1. Why Getting the Pipeline Working Matters More Than Peak Performance
When adapting large mixture-of-experts (MoE) models to domestic accelerator cards, the industry typically sets the first-phase goal as getting the training pipeline working end to end, rather than chasing theoretical peak compute. The reason is straightforward: training is a serial pipeline, and a missing link anywhere zeroes out the entire batch of work. A working pipeline means at least four conditions hold at the same time.
- Functional correctness: forward pass, backward pass, parameter updates, gradient clipping, and learning rate scheduling all execute, and the loss decreases over steps instead of turning into NaN.
- Numerical trustworthiness: alignment error against a known reference implementation falls within an acceptable range, with no overflow under mixed precision.
- Explainable performance: throughput, memory usage, and communication share are quantifiable, and bottlenecks can be traced to a specific stage.
- Reproducibility: with fixed random seeds and data order, repeated runs produce consistent results, and failures can be replayed.
Two nodes with sixteen cards and four hundred iterations is a typical “minimal trusted scale.” The step count does not need to be large, but it must cover warmup, a stable phase, and one learning rate change to expose scheduler and checkpoint logic issues. The node count does not need to be large either, but it must span nodes to trigger the real cross-node communication path.
2. Layered Design of the Cluster and Software Stack
It is advisable to split the environment into five layers, validate them one by one, and then stack upward, so you do not start by tuning the model without knowing whether the problem is hardware or framework.
- Hardware layer: accelerator cards, host memory, local high-speed storage, inter-card interconnect, and inter-node network. Cross-node training is most sensitive to the network, so bandwidth, latency, and topology affinity need to be confirmed.
- Driver and runtime layer: device drivers, runtime libraries, and collective communication library versions must match as a set; mixing versions is the most common hidden source of failures.
- Framework layer: the training framework and its distributed backend, responsible for orchestrating data parallelism, tensor parallelism, and pipeline parallelism.
- Model and operator layer: custom operators such as attention, normalization, expert routing and dispatch, and positional encoding.
- Job and observability layer: job scheduling, log collection, metrics monitoring, and alerting.
A schematic layered self-check script can look like this: first confirm “cards are visible and collective communication works,” then talk about training:
# Pseudocode: layered self-checkdef preflight():assert device_count() == 16, "device count mismatch"all_reduce(torch.ones(1) * rank_id) # verify collective communication worksbarrier() # verify synchronization semanticslog("topology", get_numa_affinity()) # record affinity for later tuning
3. Parallel Strategy: The Triangle of Memory and Communication Trade-offs
MoE models have large parameter counts and sparse activations. Memory pressure comes mainly from optimizer states and expert weights, while communication pressure comes mainly from the All-to-All introduced by expert routing. A common approach is to stack three types of parallelism.
- Data parallelism: split the batch, and use gradient accumulation to enlarge the global batch; sharding optimizer states can significantly reduce per-card memory.
- Tensor parallelism: split weights within a single layer, best placed inside a single node’s multiple cards to avoid frequent cross-node communication.
- Pipeline parallelism: split layers across different stages, and use micro-batch scheduling to hide bubbles; stage partitioning must be balanced, otherwise the slowest segment determines overall throughput.
- Expert parallelism: distribute experts across different cards, with routing results dispatched via All-to-All; communication volume grows with the number of experts and activations.
A rule of thumb: keep the most communication-intensive parallel dimension within a node, and let cross-node links carry only lower-frequency dimensions. If tensor parallelism is deployed across nodes, it will most likely be dragged down by network overhead within four hundred steps.
4. Operator Adaptation and Numerical Alignment
Custom operators are the main source of adaptation work. The recommended process is to first get the logic working with a high-precision reference implementation, then replace it with a high-performance implementation and compare layer by layer.
# Minimal validation framework for layer-by-layer numerical alignmentref = model_ref(x.float())got = model_opt(x.to(dtype))err = (ref - got.float()).abs().max()assert err < tol, f"layer {name} mismatch: {err}"
Points that need particular attention include: accumulation precision in normalization and softmax, boundary handling of attention masks, capacity factor and drop policy in expert routing, and scaling and unscaling of gradients under mixed precision. Any misalignment will show up as “it runs but the loss does not drop.” Such problems are the hardest to diagnose and must be located through layered comparison.
5. Stability and Long-Run Operation
Four hundred steps is only the starting point; going live means continuous runs of thousands of steps or more. Engineering requires three things:
- Periodic checkpoints: save the model, optimizer, and data loader state at fixed step intervals to guarantee complete semantics for resuming from a breakpoint.
- Self-healing from failures: configure failure retries and node isolation at the job scheduling layer, and have logging and monitoring cover signals such as card loss, communication timeouts, and memory overflow.
- Decoupled data pipeline: training data can live on object storage, with local caching and prefetching, so storage jitter does not translate directly into GPU idle time.
6. Common Pitfalls Checklist
- Collective communication library and driver versions do not match, showing up as random hangs rather than a clear error.
- Micro-batch size is not divisible by the number of pipeline stages, creating extra bubbles.
- Expert capacity factor set too high causes memory overflow; set too low, a large number of tokens are dropped and quality degrades.
- Random seeds are not unified, so multiple experiments cannot be aligned and problems cannot be reproduced.
- Log granularity is insufficient, making it impossible to tell whether a failure came from compute, communication, or storage.
7. A General Path to Running on the Cloud
If you choose a cloud environment, you typically request container platform and high-speed network resources on demand, freeze the image and dependencies, submit distributed jobs through job scheduling, connect metrics to unified monitoring and alerting, and keep checkpoints and datasets on object storage. The general capabilities Baidu AI Cloud provides in this kind of scenario (container platform, object storage, logging service, monitoring and alerting) can cover the above needs; for specific specifications and quotas, refer to the official documentation.
8. Conclusion
The core of getting the training pipeline working is not single-point performance, but four engineering disciplines: layered validation, aligning parallel dimensions with physical topology, layer-by-layer comparable numerics, and recoverable failures. Once the minimal trusted scale (two nodes, sixteen cards, four hundred steps) runs stably with complete observability data, most problems will be exposed and quantified in advance when scaling to larger sizes.
