Practical Guide to Training Large Models on Domestic GPUs: A 400-Step MoE Run Across 16 Devices
This article shares a practical methodology for bringing up a complete large-model training pipeline on domestic accelerator cards, using a two-node, 16-device, 400-step MoE training run as the reference scenario. It covers environment validation across hardware, communication libraries, and software stacks; combining data, tensor, pipeline, and expert parallelism to balance memory and communication; memory and numerical stability techniques such as recomputation, optimizer state sharding, mixed precision, and loss scaling; observability metrics and fault localization order; and a performance tuning checklist. The goal is not raw speed but a closed engineering loop that proves the pipeline works, problems can be located, and state can be recovered.
1. Background and Problem Definition
Large parameter-count Mixture-of-Experts (MoE) architectures have become one of the mainstream choices for large models in recent years. These models push parameter scale to a new order of magnitude while keeping inference cost manageable, but they also introduce significant challenges on the training side: high memory consumption, uneven expert routing load, heavy communication volume, and long per-step time. At the same time, more and more teams are focusing on how to run a complete training pipeline on domestic accelerator cards, rather than stopping at single-card operator validation.
“Bringing up the training pipeline” does not just mean the model can do one forward pass. It means satisfying all of the following conditions:
- Multiple nodes and devices can stably establish communication groups, with no hangs in collective communication;
- Forward, backward, optimizer update, gradient clipping, and learning rate scheduling all form a closed loop;
- Mixed precision and memory recomputation strategies take effect, and the loss curve decreases within a reasonable range;
- Hundreds of consecutive steps run without numerical overflow, allocation failures caused by memory fragmentation, or node dropouts.
This article uses the practical scenario of “two nodes and 16 devices completing 400 consecutive training steps” as a thread, and abstracts a reusable methodology from it. No specific vendor products or models are involved; all capability descriptions use industry-standard categories.
2. Environment Preparation: Consume Uncertainty Up Front
More than half of training pipeline failures come not from model code but from the environment. It is recommended to complete three layers of validation before formally launching a large-scale job.
The first layer is hardware and driver consistency. Across all nodes in the same cluster, the accelerator card model, driver version, and firmware version must be identical; otherwise collective communication performance can drop sharply or even hang randomly. A simple script can be used for batch verification:
for h in $(cat hosts.txt); dossh $h "accelerator-smi --version; accelerator-smi topo -m"done | sort | uniq -c
If the output does not converge to a single pattern, heterogeneous nodes exist and should be isolated first.
The second layer is the communication library and network. Multi-node training relies on high-speed interconnect, so link bandwidth, topology affinity, and NIC binding need to be confirmed. In practice, it is recommended to run a communication benchmark first and record the ratio of “theoretical bandwidth” to “measured bandwidth” as a baseline for later performance judgment.
The third layer is software stack alignment. The deep learning framework, communication library, operator library, and compiler versions should form a locked list, avoiding different nodes resolving to different versions.
3. Parallelism Strategy: The Triangle of Memory and Communication
The scale of two nodes and 16 devices means pure data parallelism is not enough. A common approach is to combine three types of parallelism:
- Data parallelism: responsible for scaling the global batch and synchronizing gradients;
- Tensor parallelism: splits a single layer’s matrices across devices to reduce per-device memory pressure, but with frequent communication, usually confined within a single node;
- Pipeline parallelism: splits layers across nodes to reduce cross-node communication volume, at the cost of bubbles.
For MoE structures, expert parallelism must be introduced additionally, distributing different experts across different devices. The most common problem here is uneven routing load: devices holding a few hot experts are tight on memory, while devices holding cold experts idle. General countermeasures include capacity factor limits, load-balancing auxiliary loss, and real-time monitoring of routing statistics.
A typical parallelism configuration is shown below (for structural expression only, not a specific framework interface):
config = {"tensor_parallel_size": 4, # confined within a single node"pipeline_parallel_size": 2, # split layers across nodes"expert_parallel_size": 2, # split along the expert dimension"recompute_granularity": "full","micro_batch_size": 1,"global_batch_size": 512,}
It must be emphasized that higher parallelism is not always better. Increasing tensor parallelism significantly amplifies the communication share, and increasing pipeline parallelism amplifies the bubble ratio. The correct approach is to start from “it fits” and gradually probe to the critical point where “communication overhead is acceptable.”
4. Memory and Numerical Stability
Completing 400 consecutive steps comes down to two things: memory can be allocated, and values do not diverge.
On the memory side, it is recommended to combine activation recomputation, optimizer state sharding, gradient accumulation, and memory pool reuse. Recomputation is not free; it brings about 20% to 30% additional forward overhead, but it is a necessary cost when the model does not fit.
On the numerical side, mixed precision is recommended, keeping high precision in the following places: optimizer master weights, gradient accumulation, normalization layers, and loss computation. Overflow detection and dynamic loss scaling should also be enabled. If the loss suddenly becomes non-numeric, check three places first: whether the learning rate is too large, whether expert routing shows an extreme distribution, and whether the gradient clipping threshold has failed.
5. Observability and Fault Localization
Long-pipeline training must be “observable.” It is recommended to collect at least four categories of metrics: per-step time breakdown (compute/communication/wait), per-device peak memory, expert load distribution, and loss and gradient norms. In engineering terms, this is a combination of a logging service and monitoring alerts, paired with object storage for checkpoint archiving.
The checkpoint strategy should follow “low frequency but reliable”: save at fixed step intervals, and keep the most recent several plus one baseline. Saving should be asynchronous to avoid blocking the main training loop. Once a job is interrupted, resume from the latest checkpoint and record the loss difference before and after resuming to verify that state recovery is complete.
Fault localization can proceed from the outside in: first confirm node liveness and network connectivity, then confirm the communication group is complete, then check whether a device has dropped or throttled, and only then move to the operator and numerical level.
6. Performance Tuning Checklist
- Communication and computation overlap: hide gradient synchronization behind backward computation;
- Operator fusion: reduce launch overhead and memory reads/writes from small operators;
- Data pipeline prefetch: prevent input from becoming the bottleneck, and watch the data wait share;
- Fix random seeds and record the configuration: ensure problems are reproducible;
- Establish a baseline: measure any tuning with both per-step time and the loss curve.
7. Conclusion
Completing large-scale MoE training on a domestic computing platform is essentially turning “environment consistency, parallelism strategy, memory budget, numerical stability, observability” into a closed engineering loop. The significance of two nodes, 16 devices, and 400 steps lies not in how fast it runs, but in proving the pipeline is usable, problems can be located, and state can be recovered. Once this loop is established, scaling to a larger scale is just repeated deduction of parameters and topology, not a rebuild from scratch. For teams planning to train models on domestic accelerator cards, it is recommended to first mature the above five areas at small and medium scale before committing to long-cycle jobs.
