Training Adaptation of Domestic AI Accelerators for Trillion-Parameter LLM Training: Practices and Verification
This article corrects a common misunderstanding: "training adaptation" is not the same as native pretraining. It shows how to judge whether a training-adaptation claim is credible by checking for a complete minimal training loop, breaks the challenge into three layers (operator coverage, parallelism strategy, and numerical stability), and provides a practical FSDP2 full-shard data-parallel training path with example code. It also covers cross-node numerical-stability verification, the engineering system required to move from "it runs" to "it trains stably," and the direction of scaling toward trillion-parameter models. Readers will find concrete acceptance criteria, a recommended debugging order, shard-granularity trade-offs, and monitoring metrics for evaluating whether a domestic software stack is genuinely ready for large-scale training.
Introduction: Training Adaptation Is Not Native Pretraining
When a domestic AI accelerator vendor announces that it has completed “training adaptation” for a flagship large model, observers often assume the model was pretrained from scratch on that chip. Strictly speaking, “training adaptation,” “successful integration,” and “native pretraining compute source” are three different concepts. Training adaptation focuses on one question: can the forward pass, backward pass, and optimizer updates stay numerically correct across continuous iterations on the target hardware and software stack? Native pretraining, by contrast, involves sustained investment in data, compute, training duration, and engineering systems.
Therefore, judging whether a training adaptation is trustworthy cannot rely solely on “did it run.” It depends on whether a minimal training loop has been completed. A reference minimum acceptance checklist includes:
- The forward pass produces output whose shape and precision mode match expectations;
- Backpropagation computes gradients with no missing operators and no unexpected dtype;
- Optimizer updates execute and parameters actually change;
- The loss stays within a reasonable range and decreases as steps increase;
- The gradient norm (grad_norm) stays finite, with no NaN or Inf;
- Multi-node communication completes collective operations such as all-reduce, reduce-scatter, and all-gather;
- Checkpoint resume restores the model, optimizer, and training progress;
- Continuous multi-step training runs without interruption, with monitoring metrics that are interpretable and reproducible.
These acceptance items reflect the true level of training adaptation more accurately than a single successful inference.
1. Three Technical Challenges of Training Adaptation
Migrating a trillion-parameter model to domestic AI accelerators for training requires crossing three thresholds at once: the operator layer, the parallelism strategy layer, and the numerical stability layer. Any one of them can become the dividing line between “it runs” and “it trains stably.”
1.1 Operator Layer: Training Adds Backward and Numerical Stability Requirements Beyond Inference
Inference only requires the forward pass, while training also requires backward gradient computation, mixed-precision conversion, loss scaling, gradient accumulation, and optimizer state updates. If even one backward operator has a precision defect, incomplete coverage, or an implementation difference, the error can be amplified over many iterations, eventually showing up as loss divergence, gradient explosion, or NaN.
1.2 Parallelism Strategy Layer: Parameters, Gradients, and Activations All Need Sharding
The total volume of parameters, gradients, optimizer states, and activations in a trillion-parameter model far exceeds the memory of a single card. In practice, engineers typically combine strategies such as FSDP, tensor parallelism, pipeline parallelism, and expert parallelism. Because interconnect topology, collective communication libraries, memory bandwidth, and scheduling differ across hardware, one parallelism configuration does not transfer naturally.
1.3 Numerical Stability Layer: Differences Amplify Nonlinearly Over Long Training
In mixed-precision training, the loss, gradient norm, and parameter update magnitude can all accumulate error over long iterations. The underlying operator implementations, accumulation precision, and communication reduction order of a domestic software stack may differ subtly from those of a mainstream GPU stack. These differences are not obvious in short runs, but they can gradually amplify in large-scale long training.
| Layer | Main Risk | Recommended Verification | Common Mistake |
|---|---|---|---|
| Operator layer | Missing backward operators, inconsistent precision | Single-operator comparison, gradient checking, small-model training | Testing only the forward pass without the backward; ignoring dtype and scale |
| Parallelism strategy layer | Uneven sharding, mismatched communication topology | Multi-card scaling tests, peak memory checks, communication profiling | Directly reusing parallelism configs from other hardware |
| Numerical stability layer | Loss/grad anomalies after long iterations | Continuous training over hundreds of steps, gradient-norm monitoring | Declaring stability after only a few steps |
Recommended debugging order for domestic-card-specific issues:
- Check operator coverage: confirm whether the backward operators, fused operators, and communication operators required for training are supported;
- Check the precision mode: whether bf16, fp16, and fp32 master weights take effect as expected;
- Check the communication reduction order: whether gradient reduction across different ranks is consistent and whether it affects reproducibility;
- Check the interconnect topology: whether intra-node and inter-node bandwidth, RDMA, and the collective communication backend match;
- Check memory bandwidth and peak: whether sharding granularity, activation recomputation, and cache release cause memory fluctuation.
2. Building an FSDP2 Full-Shard Data-Parallel Training Path
FSDP (Fully Sharded Data Parallel) is one of the mainstream memory-optimization approaches in large-model training today. Its core idea is to slice model parameters, gradients, and optimizer states along the data-parallel dimension, so that each card stores only one shard. During the forward pass, the full parameters are gathered on demand and released after computation, which lowers the per-card memory peak.
FSDP2 further simplifies state management, making sharding, computation graphs, and debugging information clearer. The code below is an illustrative structure demonstrating the complete chain of model loading, process-group initialization, device binding, sharding, gradient synchronization, and optimizer updates. For actual deployment, the import paths and device interfaces need to be adjusted to match the PyTorch version, the domestic accelerator software stack, and the communication backend.
import osimport torchimport torch.distributed as dist# Note: the import path and capabilities of fully_shard vary with the PyTorch / domestic software stack version; verify before deployment.try:from torch.distributed.fsdp import fully_shard # new FSDP2 or composable interfaceexcept ImportError:from torch.distributed._composable.fsdp import fully_shard # some early experimental interfacesdef setup_distributed():rank = int(os.environ.get("RANK", "0"))world_size = int(os.environ.get("WORLD_SIZE", "1"))local_rank = int(os.environ.get("LOCAL_RANK", "0"))# Domestic cards usually require replacing this with the vendor's communication backend, e.g., a custom backend other than CUDA/NCCL.backend = "nccl" if torch.cuda.is_available() else "gloo"dist.init_process_group(backend=backend, rank=rank, world_size=world_size)# Domestic accelerators need the corresponding device type; CUDA style is used here as an illustration.device = torch.device(f"cuda:{local_rank}") if torch.cuda.is_available() else torch.device("cpu")if torch.cuda.is_available():torch.cuda.set_device(local_rank)return rank, world_size, devicedef build_model_and_optimizer(device, rank):# In real engineering, replace with the model-loading interface supported by the domestic software stackmodel = AutoModelForCausalLM.from_pretrained(MODEL_PATH,torch_dtype=torch.bfloat16)model = model.to(device)# Phase 1: load the model and shard layer by layer to lower the per-card memory peakfor module in model.modules():if isinstance(module, TransformerBlock):fully_shard(module)# Shard the root module as a whole to uniformly split parameters, gradients, and optimizer statesfully_shard(model)# The optimizer should be created after sharding so it binds to the sharded parameter viewsoptimizer = torch.optim.AdamW(model.parameters(), lr=1e-4)return model, optimizerdef train_step(model, optimizer, batch, device):batch = {k: v.to(device) for k, v in batch.items()}# Phase 2: shard scheduling -- all-gather on demand in the forward pass, aggregate gradients on demand in the backward passoutput = model(**batch)loss = compute_loss(output)loss.backward()grad_norm = torch.nn.utils.clip_grad_norm_(model.parameters(), max_norm=1.0)if not torch.isfinite(loss):raise RuntimeError(f"loss is not finite; training anomaly at the current step")if not torch.isfinite(grad_norm):raise RuntimeError(f"grad_norm anomaly; training anomaly at the current step")# Phase 3: gradient synchronization -- reduce-scatter reduces each rank's gradient shardoptimizer.step() # each rank updates only the parameter shard it holdsoptimizer.zero_grad()return loss.item(), grad_norm.item()if __name__ == "__main__":rank, world_size, device = setup_distributed()model, optimizer = build_model_and_optimizer(device, rank)for step, batch in enumerate(dataloader):loss_value, grad_norm_value = train_step(model, optimizer, batch, device)if rank == 0 and step % 10 == 0:log_metrics(step=step,loss=loss_value,grad_norm=grad_norm_value,rank=rank,world_size=world_size)
The difficulty of this chain lies in connecting the three phases. The model-loading phase must determine the sharding granularity: too coarse wastes memory, too fine increases communication overhead. The shard-scheduling phase requires collective communication to run efficiently over the hardware interconnect. The gradient-synchronization phase must guarantee a consistent reduction order across ranks, otherwise non-reproducible numerical drift can be introduced.
How to choose FSDP2 shard granularity?
Judge from three dimensions:
- Memory pressure: if a single card lacks memory, prioritize sharding smaller modules such as TransformerBlock;
- Communication overhead: if shards are too fine and all-gather is called too frequently, appropriately enlarge the shard boundaries;
- Debugging needs: during development, a smaller granularity is recommended to make it easier to locate single-layer numerical anomalies.
What are common training-adaptation mistakes?
Common problems include: testing only the forward pass without the backward, testing only a single node without multi-node, running only a few steps without observing long-range stability, ignoring optimizer state restoration, ignoring differences between communication backends and interconnect topologies, and directly reusing parallelism configurations from other hardware.
How to judge whether training is stable?
It cannot be judged only by whether there are no errors. It is recommended to observe simultaneously: whether the loss decreases overall, whether grad_norm is finite and its fluctuation is explainable, whether memory stays stable, whether per-step latency is stable, and whether checkpoint resume is consistent. Continuous stable training over hundreds of steps or more is more convincing than a single success.
3. Cross-Node Joint Training and Numerical Stability Verification
Running on a single node does not mean multi-node will work. Real large-scale training always happens in a cross-node environment, where inter-node network latency, bandwidth fluctuation, and fault reconnection all affect training continuity. Training-adaptation verification is therefore usually carried out under a multi-node, multi-card-per-node topology.
One example scenario: across a total of 16 accelerators in multiple nodes, let all training processes collaboratively complete hundreds of consecutive optimizer updates while continuously monitoring the loss and gradient norm. The ideal result is that both stay finite throughout, with neither numerical overflow nor abnormal interruption.
It must be emphasized that this example is not a universal standard. To form a verifiable conclusion, the following verification details should be added:
- Chip model: e.g., a certain model of domestic AI accelerator;
- Software stack version: driver version, runtime version, deep-learning framework version;
- Parallelism strategy: the specific combination of FSDP2, TP, PP, and EP;
- Precision configuration: bf16, fp16, fp32 master weights, or mixed precision;
- Hyperparameters: batch size, sequence length, learning rate, optimizer type;
- Communication library: the collective communication backend and topology-aware strategy;
- Measurement criteria: per-step latency, peak memory, communication time, recovery time.
The reason for emphasizing “continuous” and “throughout” is that training-stability problems often do not surface at step 1 but appear after dozens or hundreds of steps. Gradient accumulation, the dynamic range of mixed precision, and optimizer momentum-term updates all need enough iterations to trigger potential boundary cases. A validation of only a few steps very likely just happens to avoid the problem zone.
A stability-monitoring logic can look like this:
for step, batch in enumerate(dataloader):loss, grad_norm = train_step(model, optimizer, batch, device)if not torch.isfinite(loss):raise RuntimeError(f"loss is not finite, step={step}")if not torch.isfinite(grad_norm):raise RuntimeError(f"grad_norm anomaly, step={step}")log_metrics(step=step,loss=loss,grad_norm=grad_norm,rank=rank,timestamp=time.time())
In actual training, gradient clipping is not only used to control the update magnitude but is also often used as a “probe.” If the gradient norm before clipping already shows Inf or NaN, it indicates a possible defect in the underlying operators, precision mode, or communication reduction, which needs to be located promptly.
4. Engineering System: From “It Runs” to “It Trains Stably”
A one-time successful verification and sustainably supporting frontier-model training are separated by an entire engineering system. More mature teams usually build capabilities around the following:
- Observability: unified collection of metrics such as loss, gradient norm, memory usage, communication time, per-step latency, and data-loading time;
- Fault tolerance and checkpoint resume: periodically saving model shards, optimizer states, the learning-rate scheduler, and random-number states;
- Communication and scheduling optimization: tuning collective communication for different parallelism strategies and combining container platforms for resource isolation and elastic scheduling;
- Full-chain portability: turning training scripts, parallelism configs, operator patches, and precision strategies into reusable templates.
A reproducible training-monitoring template can include:
| Metric | Description | Recommended Frequency |
|---|---|---|
| loss | Judge whether training is decreasing | Log every step, aggregate every 10 steps |
| grad_norm | Judge whether gradients are abnormal | Log every step |
| param_norm | Judge the magnitude of parameter updates | Log every 100 steps |
| mem_peak | Judge the memory peak | Log every 100 steps |
| step_time | Judge whether throughput is stable | Log every step |
| comm_time | Judge the communication bottleneck | Log every 100 steps |
| restore_time | Judge checkpoint recovery efficiency | Log during fault recovery |
A checkpoint-resume template should save at least: model parameters, optimizer states, the gradient-scaling factor, the learning-rate scheduler state, the current step, data-loading progress, and random-number states. After recovery, the same validation samples should be used to check whether the loss is consistent, avoiding the situation of “recovered but not equivalent.”
5. Scaling Evolution Directions
Complete training from scratch is the touchstone for the true value of training adaptation. Compared with fine-tuning or continued training on existing weights, training a base model from random initialization requires the software stack to remain numerically correct across hundreds of thousands of iterations, with difficulty rising by orders of magnitude. New architectures such as world models and embodied-intelligence “brains” often contain special structures like multimodal inputs and spatiotemporal modeling, which place additional demands on operators and parallelism strategies and have become important scenarios for validating the general-purpose nature of domestic compute.
For trillion-parameter scale, the challenge further concentrates on three directions:
- Extreme memory and communication optimization: breaking through the single-card capacity limit through finer-grained sharding, activation recomputation, and efficient parallelism combinations;
- Linear scaling efficiency of ultra-large-scale clusters: after adding nodes, throughput should increase approximately linearly, with attention to the communication proportion;
- Long-training stability and recoverability: at a scale of thousands of cards over several weeks, training should still run reliably and recover quickly.
Recommended scaling metrics should include at least: linear scaling efficiency, per-step latency, communication proportion, peak memory, fault recovery time, task interruption rate, and effective-training-step proportion. These metrics reflect real engineering capability better than “did it run once.”
Conclusion
The essence of large-model training adaptation is a systematic engineering effort that runs from operators to parallelism, from a single node to a cluster, and from “it runs” to “it trains stably.” Clarifying the boundary between inference adaptation and training adaptation is the prerequisite for understanding the real progress of domestic compute; and getting the full FSDP2 chain working while maintaining continuous numerical stability in a multi-node environment is the yardstick for whether a software stack is truly mature.
It must be emphasized that stability conclusions are conditional. Stable training over hundreds of steps or even longer depends on model scale, parallelism strategy, data distribution, hardware conditions, software-stack version, and acceptance criteria. Different scenarios should adopt different acceptance criteria. For developers, what matters is not how many steps a given demonstration ran, but whether this capability is reusable, scalable, and sustainable in supporting the birth of the next generation of trillion-parameter models.
