Stable Full-Pipeline Large Model Training on Domestic AI Accelerators: A Practical Guide
Training large models on domestically produced AI accelerators (GPUs and NPUs built on local hardware stacks rather than NVIDIA GPUs) often fails not because of a single faulty component, but because operator porting, distributed communication, numerical precision, the data pipeline, and observability are treated as separate problems instead of one closed engineering loop. This guide explains the difference between porting a model to an accelerator and pretraining a base model on it, breaks a usable training pipeline into six stages, walks through multi-node multi-GPU communication bottlenecks and numerical stability, provides a runnable PyTorch/FSDP example with gradient accumulation, gradient clipping and finiteness checks, and gives tables for judging whether training is genuinely stable and for diagnosing common failures such as NaN loss, exploding gradient norms, communication timeouts, OOM and non-reproducible multi-node results.
1. First, the Direct Answer: Why Is Training on Domestic Accelerators Unstable?
The short version: instability in large model training on domestic accelerators is rarely a single hardware problem. It is an engineering systems problem made up of operator adaptation, distributed communication, numerical precision, the data pipeline, and operations and monitoring.
The symptoms people usually see on domestic accelerators look like this: loss suddenly becomes NaN, the gradient norm spikes, communication times out partway through a run, the device runs out of memory, one card slows down, a step hangs indefinitely, or the same script produces different results on different machines. On the surface these are “training failures.” In practice, most of them mean the engineering pipeline was never closed end to end.
This article addresses three long-tail questions:
- How is training enablement different from base model pretraining?
- Why is training on domestic accelerators unstable?
- How do you determine whether training is actually stable?
2. How Is Training Enablement Different from Base Model Pretraining?
One common misconception needs clearing up first: getting a model to train on a given accelerator card is not the same as the model’s base weights having been pretrained on that hardware.
These are different technical layers:
- Base model pretraining: training at scale from randomly initialized parameters on a very large corpus. This determines the model’s capability ceiling.
- Training enablement / post-training: on top of an existing model architecture or set of weights, wiring up the engineering path — operator mapping, distributed parallelism changes, fine-tuning, continued pretraining, and so on.
When you read a technical report, separate “operator validation” from “where the compute came from.” A report may present inference operator validation, training enablement validation, and fine-tuning results all at once, and that still does not mean the base model was pretrained from scratch on domestic accelerators. The more accurate statement is: this hardware and software stack already has the potential to support that class of large model training work.
3. What Does a Full-Pipeline Training Stack Include?
A training pipeline that is genuinely usable has to close the loop from data all the way to parameter updates. It can be broken into six stages:
- Model loading and operator mapping: the model definition must map correctly onto the target hardware’s operator implementations, preserving forward-pass semantics.
- Data loading and preprocessing: reading, aligning, caching, and sharding text, image, and multimodal data.
- Parameter sharding and scheduling: in multi-card, multi-node setups, parameters, gradients, and optimizer states are sliced to reduce per-device memory pressure.
- Forward computation and backpropagation: every step must keep the computation graph correct and propagate gradients correctly.
- Gradient synchronization and optimizer updates: collective communication such as All-Reduce and Reduce-Scatter aggregates updates across cards and across nodes.
- Observability and self-healing: logs, metrics, checkpoint resume, fault alerting, and abnormal-state recovery.
Among these, sharded data parallelism is a key approach for large-scale training. Parameters, gradients, and optimizer states are split across different ranks; when a layer is computed, the full parameters are gathered on demand and released once done. Each device then holds only one shard of the model, which is what makes it possible to train very large models on limited hardware.
4. Breaking Through Multi-Node, Multi-GPU Communication and Stability Bottlenecks
When the scale grows from a single node to multiple nodes — for example, two nodes with 16 cards total — the hard parts surface quickly.
4.1 Communication Can Become the Bottleneck
Cross-node communication goes over the network, where bandwidth and latency are generally worse than intra-node high-speed interconnect. If computation and communication are not overlapped, the GPU or NPU spends a large share of its time waiting on communication. Common engineering measures include:
- Overlapping computation and communication: trigger the next step’s communication early while the current layer is still being computed.
- Gradient bucketing: merge many small gradients into large buckets to reduce the number of communication calls.
- Choosing a sensible shard granularity: shards that are too fine increase communication overhead; shards that are too coarse fail to relieve memory pressure.
- Picking the right parallelism strategy: data parallelism, tensor parallelism, pipeline parallelism, and expert parallelism have to be combined according to the model structure and the hardware topology.
4.2 Numerical Stability Is the Lifeline
The most common anomaly in large model training is not a crashed process — it is loss turning into NaN or Inf. Typical triggers include:
- Learning rate set too high;
- Exploding gradients;
- Overflow under mixed precision;
- Numerical implementation differences for the same operator across different hardware;
- Problems with initialization, data distribution, or loss function design.
The robust practice is to check that loss and gradient norm are finite values before and after each optimizer update, and to constrain the update magnitude with gradient clipping.
5. How Do You Prevent Numerical Overflow? A Runnable Example
Below is a minimal runnable example. It uses PyTorch with FSDP and demonstrates gradient accumulation, gradient clipping, and finiteness checks. The example is written against an NVIDIA CUDA environment; on domestic platforms you need to replace the device interfaces and the communication backend according to the vendor’s documentation. Do not blindly copy nccl.
# File name: train_stability_demo.py# Requirements: Python>=3.10, PyTorch>=2.3# Launch example:# torchrun --nproc_per_node=2 --nnodes=1 --node_rank=0 \# --master_addr=127.0.0.1 --master_port=29500 train_stability_demo.pyimport osimport torchimport torch.nn as nnimport torch.distributed as distfrom torch.distributed.fsdp import FullyShardedDataParallel as FSDPdef main():# This example uses CUDA by default. On domestic platforms, replace it with# the vendor device interfaces and communication backend.if not torch.cuda.is_available():raise RuntimeError("This example uses CUDA/NCCL as the reference environment. ""On domestic platforms, replace the device interfaces and ""communication backend according to the vendor documentation.")# NCCL mainly applies to NVIDIA GPUs; on domestic platforms it must be# replaced with the corresponding communication backend.backend = os.environ.get("DIST_BACKEND", "nccl")dist.init_process_group(backend=backend)rank = dist.get_rank()local_rank = int(os.environ.get("LOCAL_RANK", "0"))# In multi-node, multi-GPU setups, use LOCAL_RANK to bind the in-node device# index rather than binding the device directly with the global rank.torch.cuda.set_device(local_rank)device = torch.device(f"cuda:{local_rank}")# Toy model and toy data: convenient for minimal reproduction, not a# representation of real business training.torch.manual_seed(1234 + rank)model = nn.Sequential(nn.Linear(8, 16),nn.ReLU(),nn.Linear(16, 1),).to(device)model = FSDP(model, use_orig_params=True)optimizer = torch.optim.AdamW(model.parameters(), lr=1e-4)grad_accum_steps = 2batches = [(torch.randn(2, 8, device=device),torch.randn(2, 1, device=device),)for _ in range(8)]micro_step = 0optimizer_step = 0accumulated_loss = 0.0optimizer.zero_grad(set_to_none=True)for x, y in batches:loss = torch.nn.functional.mse_loss(model(x), y) / grad_accum_stepsloss.backward()accumulated_loss += loss.detach()micro_step += 1# Validate and update only after grad_accum_steps micro batches# have been accumulated.if micro_step % grad_accum_steps == 0:grad_norm = model.clip_grad_norm_(max_norm=1.0)avg_loss = accumulated_loss / grad_accum_stepsif rank == 0:assert torch.isfinite(avg_loss), \f"loss is not a finite value @ step {optimizer_step}"assert torch.isfinite(grad_norm), \f"grad_norm is not a finite value @ step {optimizer_step}"optimizer.step()optimizer.zero_grad(set_to_none=True)optimizer_step += 1accumulated_loss = 0.0if rank == 0:print(f"step={optimizer_step}, "f"loss={avg_loss.item():.6f}, "f"grad_norm={grad_norm.item():.6f}")dist.destroy_process_group()if __name__ == "__main__":main()
Three things in this example matter most:
- Correct gradient accumulation counting:
micro_stepis used as the counter, andoptimizer.step()pluszero_grad()run only once everygrad_accum_stepsbatches. - Device binding via LOCAL_RANK: in multi-node, multi-GPU scenarios,
LOCAL_RANKis the in-node device index. Binding a GPU or NPU with the global rank is a mistake. - Platform-specific communication backend:
ncclmainly applies to NVIDIA GPUs. On domestic platforms, replace it with the corresponding communication backend through an environment variable or through the training framework instead of copy-pasting.
6. How Do You Tell Whether Training Is Actually Stable?
“Running” and “training stably” are not the same thing. From an engineering standpoint, judge along the following dimensions:
| Dimension | Metric to observe | Healthy behavior |
|---|---|---|
| Convergence trend | Loss curve | Overall downward or flat, no abnormal spikes |
| Update health | grad_norm | Stable within a bounded range, no sustained blow-up |
| Numerical robustness | NaN/Inf checks | Finite throughout, no overflow |
| Continuity | Consecutive optimizer update steps | Hundreds of steps without interruption |
| Reproducibility | Multiple seeds / multiple machines | Results are comparable, no arbitrary drift |
| Resource stability | Memory, utilization, communication time | No violent fluctuation, no sustained waiting |
One point needs emphasis: “completing several hundred consecutive optimizer updates — 400 steps, for example — with loss and gradient norm finite throughout” can serve as an example validation criterion, but it must not be read as a universal standard across all models, all hardware, and all data conditions. To really judge stability, you have to fill in the conditions, for example:
- Model size;
- Card type and number of cards;
- Single node or multiple nodes;
- Parallelism strategy;
- Precision mode, for example bf16, fp16, or fp32;
- Batch size and sequence length;
- Dataset size;
- Whether gradient checkpointing is enabled;
- Whether long context is used;
- Training framework version and communication backend version.
Only stability results stated under explicit conditions carry real engineering reference value.
7. Common Failures and a Troubleshooting Checklist
When training is unstable, use the table below to localize the problem quickly:
| Symptom | Likely cause | What to check |
|---|---|---|
| Loss becomes NaN/Inf | Learning rate too high, gradient explosion, precision overflow | Loss, grad_norm, learning rate, mixed precision configuration |
| Loss spikes | Bad data, corrupted samples, learning rate too high | Data shards, anomalous samples, optimizer state |
| grad_norm keeps exploding | Gradient clipping not effective, abnormal loss function | clip_grad_norm_, loss normalization |
| Communication timeout | Network fault, a hung card, mismatched communication backend | Network interface, NCCL or vendor backend, connectivity between ranks |
| OOM | Uneven sharding, batch too large, memory fragmentation | Parallelism strategy, activation recomputation, optimizer states |
| Training slows down | Communication waiting, slow data loading, resource contention | GPU/NPU utilization, dataloader, network bandwidth |
| Inconsistent results across nodes | Random seeds, data ordering, abnormal communication aggregation | Fix seeds, align data, verify all-reduce logic |
| Single card slows down | Hardware downclocking, abnormal temperature, PCIe or network fault | Device logs, temperature, link status |
8. From “It Trains” to “Out-of-the-Box Training”: Three Layers of Engineering Capability
Making large model training on domestic accelerators solid requires building up three layers of capability.
8.1 Operator Adaptation Layer
Operators used in a model — attention, normalization, activations, mixed precision computation — need correct and high-performance implementations on the target hardware. Incorrect operators lead to abnormal loss; insufficient performance makes training cycles unacceptable.
8.2 Multi-Card Coordination Layer
Data parallelism, tensor parallelism, pipeline parallelism, and expert parallelism have to be combined according to the model structure, cluster topology, and communication bandwidth. The goal of multi-card coordination is not simply to spread the workload out, but to make the cluster work efficiently, stably, and scalably.
8.3 Automation Toolchain Layer
Long-running training needs checkpoint resume, fault self-healing, log collection, metric monitoring, alerting, and job recovery. Without a toolchain, large-scale training easily falls into an inefficient state of “humans watching dashboards and restarting failed runs.”
“Out-of-the-box training” is an engineering goal, not an unconditional guarantee across every domestic hardware platform, every model, and every task. It means that a user with standard scripts, a standard image, and standard configuration can complete stable training on the target platform — while the actual outcome still depends on model size, data quality, hardware condition, and cluster environment.
9. Typical Use Cases and What Readers Take Away
This set of capabilities transfers to several scenarios:
- Pure text foundation models: validating the full pretraining path from data loading to parameter updates.
- Multimodal models: exercising loading, alignment, and shard scheduling for heterogeneous sources such as images, text, and video.
- World models / embodied AI models: longer temporal sequences and more complex structures, with higher demands on numerical stability and long-horizon training continuity.
Readers should take away three things:
- Corrected mental model: training enablement is not base model pretraining. When reading technical reports, distinguish “operator validation” from “where the compute came from.”
- A method framework: the stability methodology of “sharded parallelism + communication optimization + numerical validation + observability and monitoring.”
- Reproducible practice: judge whether training is stable using loss, grad_norm, consecutive update steps, resource curves, and a troubleshooting table — rather than concluding from the fact that the job started.
The essence of large-scale training is putting uncertainty in a cage. Through rigorous operator adaptation, robust parallelism strategies, a platform-level communication backend, and continuous numerical monitoring, domestic accelerators can genuinely carry frontier-scale large model training with stability.
