LLM Training Adaptation on Domestic AI Accelerators: A Practical Engineering Guide

    This article explains what it actually takes to run large language model training on domestically developed AI accelerators, as opposed to simply serving inference on them. It compares the inference and training adaptation stacks, walks through the technical layers that must be validated (operators, parallelism strategies, numerical behavior, collective communication, and scheduling/fault tolerance), and provides a reusable design template for a two-node, 16-card stability experiment covering four hundred optimizer updates. It also covers numerical robustness risks such as overflow, gradient explosion, reduction-order differences, and optimizer state initialization, common performance optimization levers, and the engineering work needed to move from "it trains" to "ready to train out of the box."

    Introduction: From “a Single Step Works” to “the Whole Pipeline Trains Stably”

    Over the past few years, enterprises building large-model infrastructure have kept running into the same pattern: vendor selection is easy, production adoption is hard. Accelerators with similar numbers on public benchmarks can behave very differently in real training workloads. Some can serve inference but cannot complete several thousand training steps stably. Some run fine on a single node with multiple cards, then become communication-bound the moment you scale across nodes. Others produce NaN loss after a few dozen steps, and the root cause is hard to trace back to a specific operator.

    Publicly reported progress on large-model training adaptation for domestically developed AI accelerators has recently raised the bar for what counts as a successful validation. The target has moved from “a single step runs” to “two nodes with multiple cards completing several hundred consecutive optimizer updates with numerically sound results throughout.” Validations of this kind are valuable precisely because they exercise almost every systemic problem that surfaces in real training.

    This article abstracts the case of “a domestically developed AI accelerator completing training adaptation for a trillion-parameter-class open-source large model” into a general engineering problem, and breaks down the technical stack and the acceptance methodology behind it, for teams that are currently planning or implementing training platform adaptation.

    1. Clarifying the Concepts: Why Training Adaptation Is Much Harder Than Inference Adaptation

    Many teams treat “the chip supports open-source model X on day 0” and “training adaptation on that chip is complete” as the same thing. This is the most common misconception in practice. The two differ substantially in terms of the technology stack:

    Dimension Inference adaptation Training adaptation
    Core pipeline Model loading → forward pass → sampling output Model loading → forward → backward → gradient reduction → optimizer update
    Operator scope Mostly forward operators, executed once Forward + backward + gradient/optimizer operators, executed in a loop
    Memory pressure Weights + KV cache Weights + gradients + optimizer states + activations + communication buffers
    Numerical requirements A reasonable single output is enough Gradients, loss, and update magnitudes must stay finite and stable over thousands of steps
    System complexity A single card or tensor parallelism may suffice Data/tensor/pipeline/expert parallelism combined, cross-node communication
    Validation cycle Hours Hundreds to thousands of steps, or longer

    The memory accounting makes the point most clearly. Assuming an Adam-class optimizer, mixed-precision training, and FP32 master weights, each parameter requires roughly 4 bytes for master weights, 4 bytes for gradients, 4 bytes for the first moment, and 4 bytes for the second moment — about 16 bytes in total, plus FP16/BF16 compute copies and activations. That works out to about 1.6 GB of pure state memory per 100 million parameters and about 160 GB per 10 billion parameters. A hundred-billion-parameter model no longer fits in a single node and must rely on sharding and cross-node communication.

    Conceptual boundaries matter just as much. Training adaptation answers the question: given a parallelization strategy and a set of hyperparameters, can pretraining or continual pretraining complete stably on the target hardware? It does not mean that the base weights of the model in question were pretrained on that hardware. Between adaptation and full pretraining sits an entire body of engineering: large-scale cluster scheduling, data cleaning and data mixture design, training strategy design, and long-run stability assurance. Some open-source model technical reports now publish validation results across multiple hardware paths, mostly at the level of inference operators and fine-grained parallelization strategies, while the original compute used for base pretraining is not necessarily disclosed.

    Understanding this boundary is what lets you set the right goal for adaptation work: first achieve “numerically correct, end-to-end complete,” then pursue “long-run stable, efficient, ready to train out of the box.”

    2. The Training Adaptation Stack: From Operators to End to End

    2.1 Operator layer: from “it computes” to “it computes correctly and fast”

    The operators involved in large-model training fall into roughly five categories:

    1. Basic compute operators: matrix multiplication, convolution, element-wise operations, reductions, normalization, activation functions, and so on.
    2. Attention-related operators: attention with causal masking, efficient attention implementations for long sequences, KV cache writes, and so on.
    3. Normalization and residual operators: layer normalization, RMS normalization, Dropout, and similar — these must handle the difference between training mode and inference mode correctly.
    4. Gradient and optimizer operators: gradient accumulation, global gradient norm computation, gradient clipping, first-moment and second-moment updates, and so on.
    5. Communication and collective operators: AllReduce, ReduceScatter, AllGather, All-to-All, point-to-point send/receive, and so on.

    Three classes of problems show up during adaptation:

    • Missing coverage: forward operators are all present, but backward operators or in-place update variants are missing, so the training script fails during the backward phase.
    • Numerical inconsistency: custom kernels use low-precision accumulation or approximate implementations. The error per inference call is negligible, but across thousands of iterations it accumulates and eventually shows up as loss jitter or divergence.
    • Performance collapse: some operators lack fused implementations, a single step is dragged down by a large number of small kernels, and GPU utilization stays low for long stretches.

    The practical recommendation is to build an operator reconciliation table: take the training framework’s operator list as the baseline, annotate how each operator is implemented on the target hardware (native, framework fallback, or custom kernel), and run error-comparison tests against a reference implementation for the critical operators.

    2.2 Parallelism layer: data parallelism first, sharding schemes second

    When adapting on domestic accelerators, introduce parallelization strategies from simple to complex:

    Step 1: data parallelism (including sharded data parallelism). This is the most mature to implement and has the simplest communication pattern. Fully sharded schemes (along the lines of FSDP/ZeRO-3) split parameters, gradients, and optimizer states across cards along the data parallel dimension: parameter shards are AllGathered as needed during the forward and backward passes, gradients are ReduceScattered during the backward pass, and each card updates its own local shard. This scheme keeps memory usage low and scales easily to multiple nodes, which makes it the preferred starting point for trillion-parameter-class model adaptation.

    Step 2: tensor parallelism. Suitable when individual layer parameters are too large to fit in one node. It splits matrix multiplications across cards and inserts AllReduce operations, and it is sensitive to inter-card interconnect bandwidth, so it should be kept within a single node wherever possible.

    Step 3: pipeline parallelism. Splits the model by layer and uses micro-batch pipelining to reduce bubbles; scheduling and load balancing need to be solved.

    Step 4: expert parallelism and sequence/context parallelism. Targeted at mixture-of-experts (MoE) and long-sequence scenarios. Expert parallelism relies on All-to-All communication, and sequence parallelism relies on attention splitting for long sequences; both place higher demands on the communication library and topology adaptation.

    For the vast majority of adaptation projects, the recommendation is to get the full pipeline working under data parallelism / sharded data parallelism first, then introduce other parallelization dimensions one at a time, so that multiple variables are not changed at once and problems remain attributable.

    2.3 Numerical layer: validate “it runs” and “it runs correctly” separately

    Training is an iterative process, and correctness at a single step does not imply correctness overall. Three things deserve attention during adaptation:

    • Precision strategy: BF16 has a wide dynamic range and suits large-model training; FP16 needs loss scaling and is more sensitive to overflow; FP32 master weights are the foundation for long-term convergence stability.
    • Error metrics: build tests for critical operators that compare against a reference implementation, using metrics such as relative error and cosine similarity, define thresholds, and fold them into regression testing.
    • Long-horizon evolution: watch the trends of loss, gradient norm, and weight norm over hundreds of steps rather than checking single-point values.

    2.4 Communication layer: topology awareness and overlap

    For cross-node training, the performance bottleneck is usually communication. During adaptation, confirm the following: whether the choice of collective algorithm matches the topology (intra-node high-speed interconnect should be prioritized for tensor parallelism, cross-node links for data parallelism); whether compute/communication overlap is supported; whether communication buffers are reused; and whether the gradient accumulation bucket size is tunable. If communication cannot overlap with computation, overall throughput will suffer even when single-card compute is abundant.

    2.5 Scheduling and fault tolerance layer

    Long-run stable training also depends on process launch, health checks, failure detection, and automatic restart. At minimum, the adaptation phase should verify: whether a single card exiting abnormally can be detected and trigger a restart; whether the job can resume from the most recent checkpoint after restart; and whether loss is continuous with the values observed before the interruption.

    3. Two-Node, 16-Card Validation: A Reusable Stability Experiment Design

    “Two nodes, 16 cards in total, completing 400 consecutive optimizer updates” is a common form of adaptation acceptance in the industry. It is not a performance test but a stability and correctness test: it covers, in a short time, the parts of real training where problems are most likely to surface. The design template below can be reused.

    3.1 Experiment objectives

    • Numerical health: loss and the global gradient norm across all training processes remain finite throughout, with no NaN/Inf and no abnormal interruptions.
    • Pipeline completeness: model loading, parameter sharding, forward pass, backward pass, gradient synchronization, optimizer update, and checkpoint saving all work end to end.
    • Controlled memory: steady-state memory usage stays stable with no continuous growth (ruling out memory leaks).
    • Communication correctness: the cross-node gradient reduction result matches the single-node reference implementation (within tolerance).

    3.2 Topology and parallel configuration recommendations

    • 2 nodes × 8 cards; high-bandwidth interconnect within a node, RDMA-class network across nodes.
    • Keep the tensor parallelism degree within a single node (for example TP=4 or TP=8), with data parallelism across nodes (for example DP=2).
    • Use sharded data parallelism to carry the main parameter updates, reducing per-card memory pressure.
    • Set sequence length and batch size so that per-step memory usage stays under 80%, leaving headroom for fragmentation.

    3.3 Acceptance metrics

    Metric Expected behavior Anomaly signal
    Loss Finite throughout, flat or gently decreasing trend Abrupt NaN/Inf, step-like jumps
    Global gradient norm Finite, fluctuating within a reasonable range Continuous climb, sudden jump of several orders of magnitude
    Per-step time Stable, fluctuation < 10% Periodic spikes (communication or checkpoint stalls)
    Memory usage Flat steady-state plateau Monotonic increase (leak)
    Process liveness All 16 processes online throughout Any process exits, communication timeouts

    3.4 Staged rollout

    Verify progressively from a single card → 8 cards on one node → 16 cards on two nodes → 32/64 cards on multiple nodes, running a fixed number of steps and recording metric curves at each level. The benefit is that if numerical anomalies appear at the two-node stage, you can quickly fall back to the single-node stage to determine whether the problem lies in operator implementation or in cross-node communication.

    4. Numerical Robustness: The Most Undervalued Part of Training Adaptation

    Numerical problems in large-model training are rarely “one operator computed the wrong result.” More often, several approximations stack up and lose their balance over long iterative sequences. At least the following risks should be addressed during adaptation.

    1) Overflow and underflow. BF16 uses the same number of exponent bits as FP32, so its dynamic range is wide and overflow is generally not a concern; FP16 requires loss scaling. If loss frequently becomes Inf during adaptation, first check whether FP16 is being used without scaling enabled, or whether the scale-update policy fits the hardware in question.

    2) Gradient explosion and vanishing. Deep models tend to accumulate abnormal values during backpropagation. Common mitigations include global gradient norm clipping, attention logit scaling, residual branch scaling, and numerical protection of the epsilon value in normalization layers.

    3) Numerical differences in communication reductions. Different parallelization strategies sum gradients in different orders, and the non-associativity of floating-point arithmetic introduces small differences. This is usually harmless, but the validation stage should define a reasonable tolerance rather than requiring bit-exact equality; if the difference exceeds that tolerance, the communication implementation may be defective.

    4) Optimizer state initialization. Under sharded data parallelism, optimizer state initialization on each card must be deterministic and consistent, otherwise a subtle bug appears in which update magnitudes differ across cards. One way to verify is to compare the first-step update between distributed and single-node training under the same random seed.

    5) Anomaly detection and automatic skipping. In engineering practice, it is advisable to insert a lightweight finiteness check into the training loop and, when an anomaly is detected, skip that update and log it rather than crashing the whole job. The following is illustrative code (pseudo-code, not a specific framework API):

    1. # Illustrative pseudo-code: numerical health checks and anomaly skipping in the training loop
    2. for step, batch in enumerate(train_loader):
    3. loss = model.forward(batch)
    4. if not is_finite(loss):
    5. logger.warn("non-finite loss at step=%d, skip", step)
    6. optimizer.zero_grad()
    7. continue
    8. loss.backward()
    9. grad_norm = compute_global_grad_norm(model.parameters())
    10. if not is_finite(grad_norm) or grad_norm > MAX_NORM:
    11. logger.warn("bad grad norm %.3f at step=%d, skip", grad_norm, step)
    12. optimizer.zero_grad()
    13. continue
    14. optimizer.step()
    15. optimizer.zero_grad()
    16. if step % LOG_INTERVAL == 0:
    17. metrics.log(loss=loss.item(), grad_norm=grad_norm,
    18. mem=memory_stats(), step_time=elapsed(step))

    This code reflects three practical points: checks happen before the update, anomalies are skipped rather than crashing, and metric collection is decoupled from training. Early in an adaptation effort, it converts hard-to-diagnose failures like “it crashed at step 300” into “an anomaly was detected and skipped at step 300,” which substantially shortens debugging time.

    5. Performance Optimization: Making Adapted Training Practically Useful

    Once stability targets are met, performance determines whether the adaptation has real value in deployment. Common optimization directions:

    • Operator fusion: fuse small operators such as normalization + activation and additive residuals to reduce kernel launch and memory access overhead.
    • Recomputation (activation checkpointing): trade compute for memory; suitable when activations dominate memory usage, but it adds roughly 20%–30% recomputation overhead and requires a tradeoff.
    • Communication optimization: tune the gradient accumulation bucket size, overlap communication with computation, and tune the prefetch depth of sharded data parallelism.
    • Batch size and sequence length tuning: find the sweet spot between memory and throughput; there is usually a range where per-step time barely changes while throughput improves markedly.
    • Mixed-precision strategy: keep numerically sensitive layers in FP32 and run the rest in BF16, balancing speed and stability.

    When evaluating results, use a composite metric of “single-card throughput × number of cards × scaling linearity” rather than looking only at single-card peak compute.

    6. From “It Trains” to “Ready to Train Out of the Box”: Four Engineering Levers

    Completing adaptation is only the starting point. To bring domestic accelerators into production training scenarios, the following engineering capabilities still need to be filled in:

    1. One-click environment delivery: package the driver, communication library, framework, and operator packages into a unified image to avoid environments drifting apart from machine to machine.
    2. Automated regression: turn operator precision, single-node training, and two-node training into pipeline jobs so every upgrade is regression-tested automatically.
    3. Observability: collect metrics covering loss, gradient norm, memory, throughput, and communication time, and configure tiered alerting.
    4. Fault tolerance and checkpoint resume: save sharded checkpoints periodically, and support automatic restart after node failures with recovery from the most recent checkpoint.

    When running this kind of training workload in the cloud, general cloud infrastructure capabilities can be combined: a container platform handles GPU resource pooling and job orchestration, object storage holds datasets and checkpoints, a logging service aggregates output from each training process, and monitoring and alerting provide real-time warnings on memory, temperature, and communication anomalies. General cloud product capabilities such as the GPU cloud servers, container services, object storage, and monitoring/alerting offered by providers like Baidu AI Cloud can serve as building blocks for such a training foundation.

    7. Illustrative Code: A Minimal Two-Node Training Skeleton

    The pseudo-code below is framework-agnostic and shows the key steps of two-node training:

    1. # Illustrative pseudo-code: two-node multi-card training skeleton
    2. init_process_group(backend=COMM_BACKEND, world_size=16, rank=global_rank)
    3. # 1) Parallel topology: tensor parallelism inside a node, data parallelism across nodes (with parameter sharding)
    4. tp_group = make_group(ranks=within_node_group, size=8)
    5. dp_group = make_group(ranks=cross_node_group, size=2)
    6. # 2) Model and optimizer: sharded data parallelism carries parameter updates
    7. model = build_model(config).to(device)
    8. model = shard_parameters(model, dp_group, sharding="param_grad_optimizer")
    9. optimizer = build_adamw(model, lr=LR, weight_decay=WD, betas=(0.9, 0.95))
    10. scaler = GradScaler() if PRECISION == "fp16" else None
    11. # 3) Training loop: full pipeline + numerical checks + metric reporting
    12. for step in range(MAX_STEPS):
    13. loss = model.train_step(next_batch(), tp_group=tp_group)
    14. if scaler:
    15. loss = scaler.scale(loss)
    16. loss.backward()
    17. clip_grad_norm(model, max_norm=1.0) # global clipping across shards
    18. if scaler:
    19. scaler.step(optimizer); scaler.update()
    20. else:
    21. optimizer.step()
    22. optimizer.zero_grad(set_to_none=True)
    23. if step % 50 == 0:
    24. report(rank=global_rank, step=step, loss=loss.item(),
    25. grad_norm=global_norm(model), mem=memory_stats())
    26. # 4) Checkpointing: saved per shard, supporting resume from interruption
    27. save_sharded_checkpoint(model, optimizer, step)

    Note that real projects should use the mature APIs provided by the framework; the code above only illustrates how the key steps are organized.

    8. Common Pitfalls and How to Avoid Them

    Pitfall Consequence Recommendation
    Treating “a single step works” as adaptation complete Numerical divergence after long training, costly rework Set several hundred consecutive updates as the acceptance bar
    Only doing precision alignment, no long-run stability validation The first few hundred steps look fine, then it breaks after a few thousand Build tiered, long-cycle regression testing
    Reusing existing hyperparameters unchanged across hardware Learning rate and batch size mismatches prevent convergence Retune against hardware characteristics and keep records
    Ignoring the data pipeline and randomness Data loading becomes the bottleneck, and reproduction is difficult Fix random seeds, overlap data loading with computation
    Focusing only on compute metrics Actual throughput falls far short of expectations Use end-to-end throughput and scaling linearity as metrics
    Equating adaptation with pretraining Inaccurate external messaging, leading to misunderstanding Clearly distinguish “adaptation validation” from “full pretraining”

    Conclusion

    Adapting domestically developed AI accelerators for large-model training is fundamentally a systems engineering effort: the operators must be complete, the numerics must be stable, the communication must flow, and the scheduling must be reliable. The validation pattern represented by “two nodes and 16 cards completing 400 consecutive updates with finite loss and gradient norms throughout” has become a common acceptance method in the industry because it covers, at limited cost, the parts of training where problems are most likely to occur.

    For enterprises and developers, the actionable path is clear: start with operator reconciliation and precision regression, then validate single-node, two-node, and multi-node training step by step, and finally fill in observability and fault tolerance to form a training foundation that is reproducible, regression-tested, and scalable. As operator adaptation, multi-card coordination, and automated toolchains continue to mature, large-model training on full-featured domestic GPUs is moving from “it trains” to “ready to train out of the box” — and that requires sustained collaboration across hardware, frameworks, models, and cloud infrastructure.