LLM Training on Domestic GPUs: Engineering Practices for 400-Step Stability
This article examines the engineering behind adapting large language models to domestic full-function GPUs, using a trillion-parameter-class model that completed 400 consecutive, numerically stable optimizer updates on a 16-card, two-node cluster as the anchor case. It explains why training adaptation is a full-stack problem distinct from inference adaptation, walks through the six stages of a single optimizer update, and uses a memory ledger to show why fully sharded data parallelism (FSDP) is the default starting point. It then covers combined parallelism and topology-aware design, why long-stability testing matters more than a single passing step, how to make stability observable through monitoring, how to align operators and precision, and a five-phase checklist for moving from "can train" to "out-of-the-box training." Readers will gain a reusable methodology for evaluating and building stable large-model training on domestic hardware.
Recently, a domestic full-function GPU vendor announced that it had completed training adaptation for a trillion-parameter-class open-source flagship model. A cluster of two nodes with 16 flagship training-and-inference cards ran every training process through 400 consecutive optimizer updates. Loss and gradient norms stayed finite throughout, with no numerical overflow and no interruption.
From an engineering standpoint, this result carries more weight than “running a single forward pass.” It shows that a domestic compute stack can already support the hardest part of frontier large-model training: cross-node, long-running, numerically stable backpropagation training.
Behind this announcement is a direction that domestic compute vendors have been pushing hard recently: moving mainstream open-source large models on domestic full-function GPUs from “able to train” to “ready to train out of the box.” Setting aside specific products, this article breaks such work down into a reusable engineering methodology and answers three questions:
- Where is training adaptation hard?
- How do you verify that it is “stable”?
- How do you go from a single success to sustainable, stable training?
1. First, clarify the concepts: training adaptation, inference adaptation, and original pre-training compute
When discussing the relationship between domestic compute and large models, three concepts are easy to confuse: inference adaptation, training adaptation, and the source of original pre-training compute. They differ by orders of magnitude in difficulty.
| Dimension | Inference Adaptation | Training Adaptation | Original Pre-training Compute |
|---|---|---|---|
| Compute path | Forward only | Forward, backward, parameter update | Full training |
| Numerical requirement | Reasonable single output | Cross-step accumulation, long-term convergence | Fully controlled and reproducible |
| Memory pressure | Weights and KV cache | Parameters, gradients, optimizer states, activations | Same, at larger scale |
| Communication need | Mainly collectives | Gradient reduction, parameter sync, cross-node coordination | Same |
| Difficulty | Operator coverage, low-bit precision | Operators, precision, communication, stability stacked | Fully mature engineering and ecosystem |
Inference adaptation solves “the model can compute.” The operator set of mainstream solutions is relatively contained, and a missing operator can usually be covered by falling back to a general implementation, at a cost that is typically just lower performance.
Training adaptation solves “the model can learn.” Within a single optimizer update, the forward pass, backward pass, and parameter update run in sequence: every operator is called repeatedly in both directions, and errors accumulate as training steps go on. A gradient with only a one-in-ten-thousand deviation is harmless in a single step, but over hundreds of thousands of steps it is enough to push training off course or even cause divergence. In addition, training keeps the entire model resident in memory. 3D parallelism, mixed precision, operator fusion, and even the underlying communication topology—any weak link in this chain gets amplified. Training adaptation is therefore inherently a “full-stack problem.”
Original pre-training compute answers “where the model’s initial capability grows.” It is the compute used when the base model is trained, and it operates at a different level from the adaptation validation done later on different hardware.
Practical advice: When evaluating a compute solution, organizations should separate two goals:
- If you only want to run inference or fine-tuning with open-source models, focus on operator coverage and inference throughput.
- If you want to take on pre-training or continual pre-training, you must focus on long-stability, including operator precision consistency, cross-node communication efficiency, checkpoint-resume capability, and failure-recovery speed.
2. One optimizer update: a complete anatomy of the training pipeline
Completing one training step on a GPU means data flows through at least six stages. Adapting a new hardware platform usually requires connecting each of them one by one.
- Data preparation: tokenization, sample packing, and length balancing. An uneven length distribution causes fluctuations in the compute graph and lowers device utilization.
- Data distribution: each data-parallel replica reads a non-overlapping shard, and a distributed sampler guarantees consistent ordering across training rounds, so that data position can be restored exactly after a checkpoint resume.
- Forward computation: stacked Transformer layers compute in turn. When memory is tight, activation recomputation can trade extra forward cost for memory savings.
- Backpropagation: the chain rule produces a gradient for each parameter. With fully sharded data parallelism, sharded parameters are temporarily gathered per layer during the backward pass.
- Gradient reduction: data-parallel groups aggregate gradients via reduction collective communication, then hand them to the optimizer.
- Parameter update: the optimizer reads states such as first- and second-order moments, computes the update, and writes back parameters. The learning-rate scheduler advances in sync.
Each step maps to verifiable adaptation points: whether an operator has high-performance implementations in both directions, whether communication primitives complete correctly at multi-node, multi-card scale, and whether optimizer states and master weights can be saved and restored correctly. Fixing these checks in place keeps adaptation work from relying on repeated trial and error.
3. The memory ledger: why fully sharded data parallelism is the default choice
3.1 Memory composition of mixed-precision training
Take a dense model with N parameters. Using mixed-precision training, an Adam-class optimizer, and retaining FP32 master weights, the “model states” alone occupy roughly:
| Component | Precision | Bytes per parameter |
|---|---|---|
| Model parameters | Low precision (BF16/FP16) | 2 |
| Gradients | Low precision | 2 |
| Master weights | FP32 | 4 |
| First moment | FP32 | 4 |
| Second moment | FP32 | 4 |
| Total | — | 16 |
For a 3-trillion (3×10¹²) parameter model, the model states alone need about 48 TB of memory—and that does not count activations, temporary buffers, and memory fragmentation. Beyond capacity there is also a compute problem: with 3 trillion parameters, every one participates in forward and backward computation, and the per-step compute of dense training is enormous.
In practice, trillion-scale models generally adopt a Mixture-of-Experts (MoE) architecture: the total parameter count is large, but each token activates only a small subset of experts. Even so, the weights and optimizer states of expert parameters must all be stored. So trillion-scale training usually relies on expert parallelism, distributing different experts across devices and using All-to-All communication during routing to dispatch tokens and merge results.
3.2 How fully sharded data parallelism works
Fully Sharded Data Parallel (FSDP) offers a simpler starting point. The idea is intuitive:
- Shard parameters, gradients, and optimizer states evenly across compute units (ranks); each card keeps only its own share resident.
- When computing a layer, first temporarily gather that layer’s full parameters via All-Gather, then release them immediately after the computation.
- During backpropagation, gather parameters again, then use Reduce-Scatter to reduce gradients and scatter them to each card.
The effect: memory usage drops roughly linearly with data-parallel degree, while remaining mathematically equivalent to ordinary data parallelism—gradients are globally exact, and optimizer updates stay in lockstep.
# Pseudocode: core flow of a single FSDP training stepfor batch in data_loader:optimizer.zero_grad()# Forward: all-gather parameters per layer, release after useloss = model(batch) / grad_accum_steps# Backward: all-gather parameters layer by layer, then compute gradients# After reduction, reduce-scatter gradients so each card keeps only its shardloss.backward()if (step + 1) % grad_accum_steps == 0:# The optimizer updates only the local parameter shard; LR is globally consistentoptimizer.step()# All-gather again after the update to sync parameter shardsmodel.sync_params()
3.3 Key engineering details
- Gradient accumulation: it amortizes communication overhead, but the loss normalization coefficient must be identical across ranks. For example, when ranks have different effective sample counts, aggregate the sample counts first and then compute the coefficient; otherwise it amounts to secretly weighting some ranks’ gradients.
- Overlapping communication and computation: prefetch parameters per layer, and use bucketing to merge many small messages into larger ones. Larger messages better saturate link bandwidth.
- Computation-to-communication ratio: hidden dimensions are usually much larger than the data-parallel degree, so the matrix computations in the forward pass generally cover the communication time for parameter gathering, and overlap works well. The stage that really needs attention is the wait for parameter sync after the optimizer update, where devices easily idle.
- Memory allocator: repeatedly allocating and freeing buffers of different sizes early in training easily causes fragmentation. Setting a reasonable allocation strategy and reserving some memory for communication buffers is a prerequisite for long-stable operation.
4. A single parallelism strategy is not enough: combined parallelism and topology awareness
FSDP is good at sharding model states, but frontier large models often require several parallelism strategies combined, commonly “data + tensor + pipeline + expert parallelism”:
| Parallelism | Partition target | Main communication | Main cost |
|---|---|---|---|
| Data parallel | Data batch | Gradient All-Reduce or Reduce-Scatter | Redundant gradient copies (solved by FSDP) |
| Tensor parallel | Intra-layer weight matrices | All-Reduce, All-Gather | Frequent communication, keep within node |
| Pipeline parallel | Layers split into stages | Point-to-point between adjacent stages | Pipeline bubbles, needs micro-batch scheduling |
| Expert parallel | Expert modules | All-to-All dispatch and merge | Load imbalance, communication sensitive |
Designing a parallelism strategy is essentially a trade-off among memory capacity, per-step time, and scaling efficiency. One general principle: the parallelism dimension with the most frequent communication should be placed within the scope with the highest interconnect bandwidth.
Logical cluster topology (single node, 8 cards)┌──────────────────────── Node A ────────────────────────┐│ GPU0 GPU1 GPU2 GPU3 GPU4 ... GPU7 ││ └── tensor-parallel group (intra-node high-speed) ──┘ │└───────────────────────────┬────────────────────────────┘│ inter-node network┌───────────────────────────┴────────────────────────────┐│ Node B ││ └── adjacent pipeline stages / data-parallel group ─┘ │└────────────────────────────────────────────────────────┘
Intra-node interconnect has low latency and high bandwidth, suited to high-frequency communication like tensor parallelism. Inter-node links are relatively constrained and better suited to pipeline parallelism and data parallelism. If you ignore topology and slice tensor parallelism across nodes, a single matrix multiply can be dragged down by the network. Interconnect and NIC capabilities vary widely across domestic clusters, so adaptation should first map out the hardware topology and then decide the partition scheme.
5. Why “400 consecutive stable steps” matters more than “a single passing step”
Many adaptation efforts can pass within a step or two, yet crash after a few hours of training. The reason is that training failures often do not surface immediately but emerge gradually as steps accumulate:
- Memory leaks and fragmentation buildup: the caching allocator fails to reuse freed blocks promptly, peak memory rises wave by wave, and eventually triggers out-of-memory.
- Numerical drift and overflow: extremely large or small values under low precision; individual samples trigger special branches, such as very long sequences or special tokens; accumulated error makes the gradient norm blow up abnormally.
- Communication timeout and deadlock: conditional branches cause different ranks to execute a different number of collective communications, and processes wait on each other until timeout.
- Slow nodes: a card throttles down, a link jitters, or ECC corrections increase, dragging down the whole, since collective communication is gated by the slowest participant.
- Occasional hardware or environment errors: as training runs longer, it touches more abnormal paths.
Therefore, long-stability testing should design acceptance criteria around “continuity”:
- Consecutive steps: cross key paths such as activation recomputation, learning-rate warmup, and gradient clipping.
- Metric validity: finite loss, gradient norm within a reasonable range, and a learning-rate schedule that matches expectations.
- Resource stability: peak memory does not drift with steps, and throughput fluctuates within a reasonable band.
- Fault tolerance: after fault injection, training can recover from the latest checkpoint and resume correctly.
In the 16-card case above, 400 consecutive updates with no overflow and no interruption throughout indicate that the test already covered most of these failure modes. Teams are advised to fix similar standards as a hard admission threshold for new platforms.
6. Stability monitoring: turning “invisible crashes” into observable metrics
Long-stability presupposes observability. During training, at least the following metrics should be collected:
| Category | Key metrics | Anomaly signals and common causes |
|---|---|---|
| Numerical health | Loss, gradient norm, parameter norm | NaN/Inf; gradient norm spikes from too-high learning rate or bad data |
| Resource usage | Peak memory, utilization, temperature and power | Memory rising wave by wave (fragmentation); fluctuating utilization (communication wait or data bottleneck) |
| Communication | Collective communication time, link bandwidth | Time spikes (slow node); process hang (timeout or deadlock) |
| Throughput | Tokens/sec/card, per-step time | Continuous decline (thermal throttling or leak); jitter (checkpoint saving) |
| Fault tolerance | Checkpoint resume success rate, recovery time | Loss doesn’t connect after resume (incomplete state or misaligned RNG state) |
import math# Numerical health check: run every step or every few stepsdef check_health(loss, grad_norm, history):# Loss and gradient norm must be finiteif not (math.isfinite(loss) and math.isfinite(grad_norm)):return False# Compare against a sliding-window mean to catch sudden spikesif history and grad_norm > 5 * sum(history) / len(history):# Do not abort immediately; let gradient clipping handle it and raise an alertlog_alert("grad_norm spike", grad_norm)return True# Fault-tolerance sketch: trigger a cache clear when fragmentation is severe# allocator.empty_cache() synchronizes the device and is usually called only at phases like checkpoints
Exception handling follows “protect first, diagnose later”:
- When NaN or Inf appears, immediately save the scene, including the data-batch index and random-number state, so it can be reproduced.
- When the gradient norm spikes, rely first on gradient clipping; when it stays out of control, consider rolling back to the latest checkpoint.
- When memory keeps rising, use allocator statistics to judge whether it is a fragmentation problem, rather than simply shrinking the batch size.
7. Operator and precision alignment: the “hard bone” of adaptation
The training pipeline involves many operators, and each has a corresponding gradient implementation in the backward pass. Adaptation should verify layer by layer:
- Basic operators: matrix multiplication, LayerNorm/RMSNorm, Softmax, activation functions such as GELU/SiLU.
- Attention: efficient attention implementations must support both forward and backward; scenarios such as different sequence lengths, causal masking, and variable-length packing (padding-free) should be validated separately.
- Positional encoding: implementations such as Rotary Position Embedding (RoPE) require attention to details of mixed high/low precision.
- Expert modules: gating routing, token dispatch/merge, capacity limits, and load-balancing loss.
- Communication primitives: correctness of All-Reduce, All-Gather, Reduce-Scatter, and All-to-All at large scale.
For precision alignment, use a “layer-by-layer approximation” approach:
Reference (high-precision) baseline ──→ Target platform (low precision)① Single operator: fixed input → compare output relative error② Single layer: compare forward output and backward gradient③ Full model: compare loss curve and gradient norm over the first few steps
Concrete experience:
- Prefer BF16. Its exponent bits are the same as FP32 and its dynamic range is large, so large-scale training usually needs no loss scaling. FP16 has a narrow dynamic range and needs loss scaling, adding adaptation complexity.
- Verify fused operators separately. Training frameworks use fused kernels to accelerate normalization, activation, and attention; if the precision handling in a fused implementation differs from the reference, the error accumulates across layers.
- Missing operators need a fallback. Prefer falling back to a composite implementation rather than throwing an error and stopping, and log it so a high-performance kernel can be added later.
8. From “can train” to “out-of-the-box training”: a phased checklist
Break adaptation work into five phases, each with clear admission conditions, scaling up layer by layer:
| Phase | Core task | Admission criteria |
|---|---|---|
| 1. Single-card validation | Operator coverage scan, single-step forward/backward | No missing operators; single-step loss and gradient match reference |
| 2. Single-node multi-card | Data parallel, collective communication correctness | Loss curve aligns with single-card baseline; gradient reduction correct |
| 3. Cross-node validation | Topology-aware partition, cross-node communication | Throughput meets expectations; no deadlock, no timeout |
| 4. Long-stability test | Continuous hundreds of steps, fault injection | Loss and gradient norm finite throughout; memory stable; checkpoint resume succeeds |
| 5. Scale-up | Expand parallel scale, approach target model size | Reasonable scaling efficiency; stability metrics do not degrade |
Platform-level support is equally essential. Common baseline capabilities include:
- Resource scheduling: requesting and isolating GPU resources per training job through a container platform;
- Data supply: using object storage for training datasets and checkpoints, with data caching to accelerate hot-data reads;
- Observability: collecting training logs centrally through a logging service, and tracking loss, throughput, and resource metrics in real time through monitoring and alerting;
- Fault-tolerant recovery: combining with the scheduler’s failover capability to shorten recovery time after abnormal interruptions.
Cloud vendors in China have integrated these capabilities into AI compute platforms. For example, Baidu AI Cloud offers products such as the Baige AI computing platform, packaging compute scheduling, training acceleration, and operations monitoring so that development teams can focus on the models and algorithms themselves. According to public information, such platforms have stability practices in 10,000-card cluster scenarios. For organizations preparing to take on large-model training on domestic compute, platform-based solutions like these are worth including in the evaluation.
In addition, the industry has accumulated hands-on experience of “training domestic models on domestic compute” in several directions:
- Some teams have completed end-to-end training of a hundred-billion-parameter scientific foundation model on domestic GPUs;
- Some research institutions have completed native training of a multimodal world model on domestic compute.
Together with the trillion-scale model adaptation validation, these cases support a basic judgment: domestic compute supporting large-model training is moving from isolated validation toward scale and systematization.
Conclusion
Back to the 400 steps. Their real significance is not that a new model was made to run, but that they prove a complete training pipeline—loading, sharding, scheduling, synchronizing—can run continuously and reliably on domestic hardware. For developers, this rests on a reusable methodology: use the memory ledger to size parallelism, use topology awareness to design communication partitioning, use long-stability testing to replace single-step validation, and use observable metrics to guard the entire training process.
Competition in large-model training is, in the end, a competition of engineering systems. Operators are being filled in, toolchains are maturing, and stability standards are taking shape. The goal of “out-of-the-box training” for frontier large models on domestic full-function GPUs is moving, step by step, from vision to everyday reality.
