Getting LLM Training End-to-End on Domestic AI Accelerators: A Practical Guide
This article shares a practical approach to validating large model training pipelines on domestic AI accelerators. Instead of chasing benchmark numbers, it focuses on closing the full training loop—data loading, operator execution, gradient synchronization, optimizer updates, checkpointing, and monitoring—using a 400-step smoke test. It covers hardware topology checks, software stack version alignment, data and tokenizer validation, incremental parallelism configuration, observability signals, and performance evaluation based on scaling efficiency, along with a migration checklist for reproducible and deliverable training runs.
1. Why Closing the Loop Matters More Than Chasing Metrics
When migrating large model training to domestic AI accelerators, the first obstacle is rarely accuracy or throughput. It is whether the pipeline closes end to end. A closed loop means all six stages run without silent errors: data loading, operator execution, gradient synchronization, optimizer updates, checkpoint writes, and metric reporting. Running only a single-device forward and backward pass will not expose defects in the communication library or the framework adaptation layer. Only by advancing the full training loop for several hundred consecutive steps can these problems be forced to the surface.
The choice of 400 steps is also an engineering decision. Too few steps leave the learning rate warmup unfinished, making the loss curve meaningless. Too many steps make debugging expensive if the run fails midway. Four hundred steps are usually enough to cover warmup, several gradient accumulation boundaries, at least one checkpoint write, and one log aggregation cycle, making it a cost-effective smoke test size.
2. Environment Preparation: Removing Uncertainty Up Front
2.1 Hardware and Topology Verification
The first task on a new machine is to confirm the device enumeration order, inter-card interconnect topology, and memory capacity of each card. Inconsistent topology can route collective communication over different paths, causing the same code to behave very differently across nodes. It is advisable to produce a topology inventory and place it under version control:
node-0: dev0-dev7 fully connected, consistent bandwidthnode-1: dev0-dev7 fully connected, consistent bandwidthcross-node: one card per node participates, 16 communication endpoints in total
2.2 Software Stack Alignment
The driver, runtime, communication library, framework, and adaptation plugins must be compared by version hash on every node. In practice, many random hangs come from a minor version mismatch in the communication library between two nodes. A single verification command can lock this down:
for h in node-0 node-1; dossh "$h" "printenv | grep -E 'RUNTIME|COMM|FW_VERSION' | sort | sha256sum"done
Proceed only after the hashes on both sides match. This can save hours of troubleshooting.
2.3 Data and Tokenizer Artifact Validation
Replace “it loads” with sample-level validation. Compute statistics on the number of records, the distribution of maximum sequence length per record, and vocabulary coverage after tokenization. Sample and compare hashes of the first and last records to avoid different nodes reading different shards without noticing.
3. Parallelism Configuration: Start With the Minimum Viable Setup
Starting with 3D parallelism is not recommended. The suggested path is to first run pure data parallelism, then introduce tensor parallelism to split single-layer computation, and finally add pipeline parallelism as needed. Change only one variable at each step so failures can be localized quickly.
# Illustration: decouple parallel degrees from training hyperparameters for step-by-step validationparallel = dict(tp=1, pp=1, dp=16) # stage 1# parallel = dict(tp=2, pp=1, dp=8) # stage 2micro_batch, accum = 1, 8 # global batch = micro * accum * dp
Pay special attention to the relationship between global batch size and gradient accumulation. If the accumulation steps are not adjusted after changing the parallel degrees, the effective batch size can change silently and the loss curve becomes distorted. In comparative experiments, this kind of issue is easily misjudged as “the hardware is not good enough.”
4. Stability Observability: Making Failures Explainable
The main output of the bring-up phase is not metrics but observability. Instrument at least four signals: P50/P99 of per-step time distribution, share of collective communication time, peak memory and fragmentation, and loss and gradient norm. Any sudden change should leave a timestamp in the logs so it can be aligned with topology and job scheduling events.
step 120 | iter_time p99=1.42s | comm_ratio=0.31 | mem_peak=61.2G | grad_norm=0.87step 240 | iter_time p99=1.40s | comm_ratio=0.30 | mem_peak=61.4G | grad_norm=0.91
Also enable asynchronous checkpointing and keep the most recent rollback snapshots. In continuous training jobs, the gap between “recover from the last step” and “start over” is often the gap between one day and one week.
5. How to Evaluate Performance Correctly
Evaluation should distinguish three types of metrics: end-to-end throughput, per-step latency stability, and scaling efficiency. Scaling efficiency is the actual throughput gain when the number of cards doubles. It reflects whether communication and parallel partitioning are reasonable better than absolute throughput. During testing, fix the data, fix the random seed, and fix the parallel configuration, then collect statistics over no fewer than 50 consecutive steps. Avoid drawing conclusions from individual jittery steps.
To push performance further, try operator fusion, mixed precision policy adjustments, overlap of communication and computation, and memory allocation strategy optimization in sequence. Change only one item per round and keep a baseline data table to form a traceable tuning ledger.
6. Migration Checklist
- Topology and version hashes are consistent on every node and checked into version control;
- Data shards and tokenizer artifacts pass sampled hash validation;
- Only one parallelism variable is changed at a time, with the effective batch size converted accordingly;
- All four observability signals are in place and checkpoints can be rolled back;
- Acceptance is based on scaling efficiency rather than single-point throughput.
Following this order turns large model training pipeline validation on domestic AI accelerators from “intermittent failures that are hard to reproduce” into a standard process that is predictable, measurable, and deliverable. In actual engineering practice at Baidu AI Cloud, this front-loaded verification and layered validation approach also applies to distributed training job orchestration and log monitoring on container platforms.
