Getting Large-Model Distributed Training Working on Domestic AI Accelerators: A Practical Verification Guide
This guide walks through how to bring up and verify large-model distributed training on domestic (locally developed) AI accelerators. It defines what a trustworthy training pipeline actually requires, then covers building a hardware and runtime checklist across the driver, firmware, runtime, operator library, and collective communication library; scaling from a minimum reproducible unit up to a two-node, sixteen-card setup; migrating training frameworks and operators with coverage and semantic-consistency checks; configuring data, tensor, and pipeline parallelism and their replica boundaries; diagnosing collective communication and gradient-sync bottlenecks; aligning numerical precision; and setting measurable verification criteria, logging, and rollback plans. Readers will learn how to move from "the script starts" to a pipeline that is numerically correct, stable over hundreds of steps, and reliable at scale.
1. From “It Starts” to “It Computes Correctly”: Define Your Verification Goals First
When migrating large-model training to domestic AI accelerators, a common mistake is treating “the script starts” as proof that the pipeline works. A practical, verifiable standard is whether training forms a complete closed loop — data loading, forward pass, backward pass, gradient reduction, parameter update, and checkpoint saving — and whether the numbers can be trusted. Engineers usually ask: How do I check whether the communication library is compatible with a domestic accelerator? How do I know whether an operator is missing? How do I save and roll back checkpoints? All of these questions need to be answered ahead of time during pipeline verification.
Take a typical “two-node, sixteen-card” topology — two servers, eight accelerators each. It covers both the inter-card bandwidth needed for intra-node tensor parallelism and the cross-node gradient synchronization, making it a representative scenario for validating distributed training. To judge whether the pipeline is stable, don’t stop after a few dozen steps; run several hundred training steps continuously and observe whether loss decreases smoothly, memory stays stable, and throughput is predictable.
A serious pipeline verification should cover at least four layers:
- Runnability: The training script starts, and forward, backward, and parameter update produce no errors.
- Numerical correctness: Loss decreases as expected, and no NaN/Inf propagates through gradients and activations.
- Communication correctness: Multi-card and multi-node gradient synchronization matches the single-card baseline, with no “seemingly training but actually each computing on its own.”
- Stability and performance: Several hundred continuous iterations without crashing, with stable memory and throughput.
2. Hardware and Runtime Adaptation: Build an Executable Checklist First
Adapting heterogeneous accelerators typically follows the chain “driver → firmware → runtime → operator library → collective communication library.” Don’t jump straight to a full large model. First build an executable checklist and rule out environment risks layer by layer.
2.1 Version matrix check
Maintain a version matrix before starting the training job:
| Component | What to check | Common risks |
|---|---|---|
| Driver | Driver version, kernel module load status | Cannot enumerate devices, training interruption |
| Firmware | Firmware version, ECC, power policy | Reduced stability, device dropouts |
| Runtime | Runtime version and driver compatibility | Device visible but computation abnormal |
| Operator library | Coverage of matmul, normalization, attention, etc. | Missing operators, fallback to generic graph |
| Collective communication library | AllReduce, AllGather, ReduceScatter support | Communication fallback, insufficient bandwidth |
| OS and kernel | OS and kernel versions, PCIe/network drivers | Enumeration failure, topology anomalies |
2.2 Device enumeration and topology check: command examples
The following commands are generic naming examples; replace them with the management tools provided by your accelerator vendor:
# View device status, driver, firmware, and runtime versionsaccel-smi info# View intra-node device topology to confirm the interconnect structureaccel-smi topo -m# View device link status to identify any fallback to a slow channelaccel-smi link -s# Check whether PCI devices are enumerated correctlylspci | grep -Ei 'accelerator|vendor'# View device initialization and error messages in the kernel logdmesg | grep -Ei 'accel|xpu|pcie|link|ecc'
The point isn’t just “the devices are visible.” It’s that every node can stably enumerate the expected number of accelerators, and the topology links match the design. For example, in a two-node, sixteen-card setup, each machine should stably see eight cards, intra-node high-bandwidth interconnect should be healthy, and cross-node communication should use the high-speed network rather than falling back to a slow channel.
2.3 Collective communication baseline test
Before running the model, run a basic collective communication test:
- Is single-node multi-card AllReduce bandwidth normal?
- Are multi-node AllGather and ReduceScatter stable?
- Is there any automatic fallback to a low-bandwidth channel?
- Do timeouts, jitter, or packet loss appear during long-running communication?
If the communication baseline is already abnormal, don’t proceed to debug model accuracy — otherwise you may misattribute a communication problem to operators.
3. Minimum Reproducible Unit: Scale from Single Card to Multi-Card Step by Step
During adaptation, don’t start with a full large model. A safer approach is to build a “minimum reproducible unit”: first get a single-layer forward and backward pass working, then expand to multiple layers, single card, multiple cards, and multiple nodes.
Recommended path:
- Single card, single layer forward/backward: confirm basic operators work.
- Single card, full small model: confirm the loss, gradient, and parameter-update chain is complete.
- Two-card AllReduce: confirm gradient synchronization is correct.
- Multi-node, two-card: confirm cross-node communication is correct.
- Two-node, sixteen-card: confirm the combination of tensor, pipeline, and data parallelism runs.
- Long run of several hundred steps: confirm stability, memory, throughput, and loss curve.
In the minimum-unit stage, focus on whether operators are missing, computation graphs fall back, results deviate, or performance drops sharply. If a layer’s forward pass is fine but its backward pass is abnormal, suspect the backward operator, the gradient accumulation path, or mixed-precision scaling first.
4. Training Framework and Operator Migration: Fill Coverage and Semantic-Consistency Gaps
When integrating a mainstream distributed training framework with domestic accelerators, you typically need three steps: device backend adaptation, operator registration, and precision alignment. Focus on:
4.1 Operator coverage
Does the target backend have a corresponding implementation for the custom operators, fused operators, normalization operators, and attention operators your model uses? If not, record the missing list and decide whether to substitute with composed operators or fall back to the generic computation graph. Fallback can be a short-term fix, but it may significantly hurt performance and may also introduce numerical differences.
4.2 Semantic consistency
The same operator may have boundary differences across backends — for example, the position of epsilon in normalization, the numerical stability strategy of softmax, the random number generation of dropout, and the gradient accumulation scaling factor. In a long run, tiny differences can accumulate into noticeable deviations.
Build operator-level comparison tests: fix the input and random seed, compute on the reference backend and the target backend separately, and compare outputs element by element. This narrows “precision is wrong” down to a specific operator rather than vaguely blaming the hardware.
4.3 Automatic mixed-precision support
For half-precision training, verify whether loss scaling, gradient scaling, and gradient unscaling are reliable. If gradients overflow before unscaling, or if the clipping threshold differs after unscaling, parameter updates may go wrong. Confirm that the mixed-precision strategy matches the reference implementation, and record whether key operators keep high-precision computation.
5. Parallel Strategy Configuration: Replica Boundaries for Data, Tensor, and Pipeline Parallelism
On a two-node, sixteen-card topology, the parallel strategy directly determines whether the pipeline runs and whether communication pressure is reasonable. Note carefully: under a parallel strategy combination, you can’t simply assume “each card holds a full model replica.”
A more accurate statement is: each data-parallel group holds one identical post-sharding model replica.
- Data parallelism: within the same data-parallel group, each card uses the same model shard replica, processes a different data slice, and stays consistent via gradient synchronization.
- Tensor parallelism: single-layer weights are split across the tensor-parallel group; each card in the group holds only part of the weights, not a full model replica.
- Pipeline parallelism: the model is split by layer into different stages; each stage holds the parameters for its layers, and stages pass activations and gradients to each other.
Common parallel strategies compared:
| Parallelism | Suitable when | Communication volume | Memory impact | Typical placement |
|---|---|---|---|---|
| Data parallelism | The model fits on a single card, or after an intra-node split it is still easy to sync | Grows with card count; gradient sync becomes significant | High, needs multiple replicas | Across nodes |
| Tensor parallelism | Single-layer parameters are large, needs high intra-node bandwidth aggregation | High frequency, intra-layer communication | Reduces single-layer memory | Intra-node high-bandwidth interconnect domain |
| Pipeline parallelism | Many layers, can be grouped by layer | Point-to-point communication between adjacent stages | Reduces layers resident per card | Grouped by layer, across or within node |
Example configuration:
# Topology assumption: 2 nodes x 8 cards = 16 cardsparallel_config = {"tensor_parallel_size": 4, # Split single-layer weights intra-node"pipeline_parallel_size": 2, # Group by layer"data_parallel_size": 2, # Gradient sync across nodes# Check: tensor x pipeline x data == total cards 16}
Actual values should be tuned based on model size, layer count, remaining memory, and measured communication overhead — don’t allocate purely by formula.
6. Collective Communication and Gradient Sync: The Invisible Bottleneck
The success of multi-node training depends heavily on collective communication. Common problems include: an inappropriate communication backend, a gradient reduction method that doesn’t match the parallel strategy, wrong communication/compute scheduling, and inconsistent gradient accumulation scaling factors.
Key things to check:
- Is an appropriate collective communication library enabled for the communication backend?
- Is it using the high-speed interconnect rather than falling back to a slow channel?
- Do AllReduce, or ReduceScatter + AllGather, match the parallel strategy?
- Does gradient accumulation change the synchronization cadence, and are the scaling factors correct?
- Do multi-card results match single-card results?
Long-tail troubleshooting checklist
AllReduce fallback detection
If multi-card training throughput is significantly below expectations, check whether AllReduce has fallen back to a slow channel. Confirm this via communication logs, bandwidth tests, device topology, and link status.
Slow-link identification
Common slow links include PCIe link downshift, abnormal NIC binding, inconsistent MTU, cross-node congestion, and thermal throttling. Combine dmesg, topology tools, and monitoring metrics to judge.
Gradient sync timeout
If training stalls for a long time in the communication phase, check for unwaited async handles, process deadlocks, unreasonable communication-library timeout settings, or a straggler card. If you implement asynchronous communication, make sure to wait and validate before the parameter update.
Two-card vs single-card comparison
With the same random seed, data order, global batch, and loss reduction, compare the single-step result of single card vs two cards. Example output:
single: step=0 loss=3.456789 grad_norm=1.2345two-card: step=0 loss=3.456801 grad_norm=1.2346diff_loss=1.2e-05
If the difference clearly exceeds the expected floating-point error range, first check gradient sync, data splitting, loss reduction, random seed, or communication reduction order.
7. Numerical Precision Alignment and a Common-Error Map
Numerical precision is the most critical and hardest-to-diagnose part of training on heterogeneous hardware. Stable training usually needs:
- A reasonable initialization range;
- A normalization strategy matched to the precision;
- Keeping high-precision computation for overflow-prone operators under mixed precision;
- Gradient clipping to prevent abnormal gradients from blowing up parameters;
- Monitoring NaN/Inf at key points.
Common symptoms and where to look first:
| Symptom | Where to look first |
|---|---|
| NaN at startup | Initialization, loss scaling, softmax, layer norm, epsilon, abnormal input data |
| Single card fine, multi-card diverges | Data splitting, gradient sync, global batch, loss reduction, dropout, communication reduction |
| OOM at some step during a long run | Activation caching, memory fragmentation, pipeline bubbles, checkpoint strategy, gradient accumulation |
| Sudden throughput drop | Communication fallback, slow card, PCIe downshift, network congestion, thermal throttling, memory paging |
| Loss oscillation late in a long run | Learning rate, gradient clipping, accumulated communication error, mixed-precision scaling anomaly |
The most direct evidence for whether the pipeline is trustworthy is still the loss curve. Under normal training, loss should decrease smoothly within a few steps and then level off. If it’s abnormal early on, it usually points to operator precision, initialization, or data problems; if it only worsens after scaling up, it’s more likely a parallel-splitting, communication-accumulation, or memory-strategy problem.
8. Verification Criteria and Observability
To make “it runs” measurable, build a single-card baseline and multi-card alignment conditions rather than relying on subjective judgment.
8.1 Single-card baseline alignment conditions
The single-card baseline must fix the following variables:
- Fixed random seed;
- Fixed data order;
- Fixed global batch;
- Fixed loss reduction method;
- Fixed dropout state and random strategy;
- Fixed gradient accumulation scaling factor;
- Fixed initialization and normalization parameters.
Just writing “same data, same seed” isn’t enough, because inconsistent global batch, loss reduction, or gradient accumulation scaling will also make multi-card and single-card results incomparable.
8.2 Multi-card consistency criteria
Under the same initialization and same input, compare key metrics at step 0 and step 1. The comparison targets include loss, grad_norm, and the before/after parameter-update difference of several key layers.
Reference thresholds (adjust for precision mode and model size):
- Under the same backend, precision, and schedule, element-wise differences of key parameters should be kept around 1e-5;
- Across backends or under mixed precision, the relative error of loss and grad_norm should be kept around 1e-3;
- If the difference keeps growing, localize it to a specific operator, communication reduction, or data split.
8.3 Log field template
Each training log should contain at least:
step, loss, grad_norm, throughput, mem, comm_time, nan_inf_flag
Optional fields:
dp_rank, tp_rank, pp_rank, micro_batch_id, version_tag, ret_code
Alert thresholds and rules:
- loss non-finite or NaN/Inf: alert immediately;
- grad_norm exceeds the clip threshold or spikes noticeably: alert and save a checkpoint;
- throughput drops more than 30% vs baseline: alert and investigate communication;
- memory usage exceeds 90%: alert and check fragmentation and activations;
- comm_time rises noticeably: alert and investigate slow links and congestion;
- communication timeout or device dropout: stop the job immediately and keep the logs.
8.4 Criteria
Only when all of the following are met can you say the training pipeline “truly works”:
- The single-card baseline loss trajectory is reproducible;
- Multi-card matches the baseline under the same alignment conditions;
- Several hundred continuous iterations without crashing;
- Loss, memory, throughput, and communication metrics remain observable.
9. A Sample Training Loop
The following is framework-agnostic pseudocode, focused on where forward, backward, clipping, gradient sync, update, and monitoring happen.
Training loop without communication overlap
for step, batch in enumerate(dataloader):# 1) Distribute data and copy to deviceinputs = to_device(batch, device)# 2) Forward (mixed precision; keep high precision for overflow-prone ops)with autocast():loss = model(inputs)# 3) Backward passscaler.scale(loss).backward()# 4) Gradient sync (not overlapped)scaler.unscale_(optimizer)clip_grad_norm(model.parameters(), max_norm=1.0)all_reduce_gradients(model)# 5) Parameter updatescaler.step(optimizer)scaler.update()optimizer.zero_grad()# 6) Stability and observability checksif not is_finite(loss):log_and_skip(step, loss)log_metrics(step=step,loss=loss.item(),grad_norm=grad_norm,throughput=tokens_per_second,mem=memory_used,comm_time=comm_time,nan_inf_flag=not is_finite(loss),)
Using an async handle / wait
If the framework supports asynchronous gradient sync and the scheduling is correct, it can be abstracted as:
# Enable only if async communication is implemented and scheduling is confirmed correcthandle = all_reduce_gradients_async(model)# Communication runs in the background and can overlap with subsequent compute# If there is still executable compute afterward, continue during this window# Must wait for communication to finish before the parameter updatehandle.wait()# Then perform the parameter updatescaler.step(optimizer)
Emphasize: if the current training script hasn’t implemented asynchronous communication, don’t describe it in docs or logs as “communication and computation are overlapped.” The non-overlapped version must explicitly perform the sync operation and ensure communication completes before updating parameters.
10. Risk Warnings and Rollback Plan
Switching the driver, kernel, runtime, operator library, or communication channel can cause training interruption, device enumeration failure, communication fallback, or non-reproducible results. So in production or long-running training environments, prepare a rollback plan in advance.
Recommended process:
- Before the change, back up the current checkpoints, training config, parallel config, version matrix, and logs.
- Record current baseline metrics, including single-card loss, multi-card comparison results, throughput, and communication time.
- Validate with a canary rollout on a single node or small-scale environment first; don’t switch everything at once.
- If devices can’t be enumerated after the change, roll back the driver, firmware, or kernel module, and recheck
dmesg. - If communication is abnormal, roll back the collective communication library or backend config, and re-run the AllReduce baseline test.
- If precision is abnormal, restore the old runtime or operator library and continue validating with the old checkpoint.
- After rollback, re-run device enumeration, topology check, single-card baseline, and multi-card comparison to confirm the pipeline is restored.
11. Summary and Best-Practices Checklist
Getting large-model distributed training working on domestic AI accelerators is a systematic adaptation effort, not a single-point patch. Reusable best practices:
- Small to large: validate with a minimum reproducible unit first, then scale up the model and card count.
- Build a single-card baseline: compare every multi-card result against a trustworthy baseline.
- Localize at the operator level: narrow “precision is wrong” down to a specific operator’s semantic difference.
- Suspect communication first: when multi-card differs from single-card, check gradient sync and data splitting first.
- Trust the curve: whether the loss curve converges smoothly is the most direct evidence of a trustworthy pipeline.
- Only long runs count: hundreds of stable continuous steps, together with logs and monitoring, confirm “it works.”
- Change with caution: before switching the driver, kernel, runtime, or communication channel, back up checkpoints and prepare rollback steps.
Turning these checks into automated scripts, a version matrix, and log templates can significantly lower the cost of migrating to domestic accelerators and take large-model training from “it starts” to “trustworthy and scalable.”
