Bringing Up an LLM Training Pipeline on Domestic AI Accelerators: A Practical Guide
This article walks through what it takes to get a large language model training pipeline running end-to-end on domestic AI accelerators before scaling up. It explains why a short smoke test — roughly 400 steps on a dual-node, 16-card setup — is the first milestone for validating both hardware and software, then covers the four main adaptation challenges (kernel coverage, numerical precision and mixed precision, framework and compute-graph adaptation, and a layered precision-alignment methodology). It also presents a typical parallelism layout for dual-node 16-card training (intra-node tensor parallelism with inter-node data parallelism), the collective-communication checks that matter most, and the health and observability signals to watch during validation. It closes with a reusable verification workflow that lowers adaptation risk for new hardware and models.
1. Why “bringing up the training pipeline” is the first hurdle for domestic compute
When migrating a tens-of-billions-parameter large language model (LLM) to a domestic AI accelerator, teams usually care less about “can it train fast” and more about “can it train correctly and train stably.” “Bringing up the training pipeline” means getting the model to complete one full end-to-end loop on the target hardware — forward pass, backpropagation, gradient synchronization, and parameter update — and then observing the loss curve decrease as expected over several training steps.
Choosing a validation run of “about 400 steps on dual nodes, 16 cards” follows clear engineering logic. This is not a full training run but a smoke test:
- Enough steps to surface problems: a few hundred steps are usually enough for memory, kernel, communication, and numerical-precision issues to show up in a concentrated way. If the configuration is flawed, it typically crashes in the first few dozen steps or produces a NaN loss.
- Controlled cost: compared with a full pretraining run that can consume tens of thousands of GPU-hours, a short-pipeline validation keeps the cost of trial and error to a minimum.
- Alignable baseline: a short pipeline makes it easy to compare the loss curve point by point against a known-good setup on reference hardware, quickly telling whether the adaptation is equivalent.
So the point of bringing up the pipeline is to establish a trusted baseline — proof that this software stack, this batch of hardware, and this set of parallelism strategies can stably reproduce the expected training behavior, laying the groundwork for scaling up and tuning performance later.
2. Four core challenges in software and hardware adaptation
Domestic accelerators differ from the native training environment, and adaptation work usually concentrates on four layers.
1. Kernel coverage
An LLM’s Transformer structure relies on a large number of high-performance kernels: matrix multiplication (GEMM), LayerNorm/RMSNorm, Softmax, attention (Attention/FlashAttention), and AllReduce, among others. The most common failure point during migration is a missing or incorrectly implemented kernel, which leads to abnormal precision or even compile failure.
The debugging approach is to do kernel-level unit verification first, then move to whole-network verification:
import torch# Single-kernel precision check: compare numerical error against the reference implementationa = torch.randn(4096, 4096, device=device, dtype=torch.bfloat16)b = torch.randn(4096, 4096, device=device, dtype=torch.bfloat16)out = torch.matmul(a, b)ref = a.float() @ b.float() # use FP32 computation as the referencemax_err = (out.float() - ref).abs().max()print(f"max abs error: {max_err.item():.4e}")# Rule of thumb: relative error in BF16 should stay within the 1e-2 range
2. Numerical precision and mixed-precision strategy
Training generally uses BF16/FP16 mixed precision to save memory and improve throughput. BF16 has a wide dynamic range but slightly lower precision; FP16 has higher precision but is prone to overflow, so it needs loss scaling. When migrating to new hardware, be sure to confirm that the mixed-precision path matches the original implementation; otherwise you get “chronic” problems such as loss slowly diverging.
3. Framework and compute-graph adaptation
The upper-layer training framework routes kernels to domestic cards through an adaptation layer. Pay particular attention to dynamic-graph/static-graph conversion, custom kernel registration, memory-allocator behavior, and whether memory-saving capabilities such as gradient checkpointing are supported.
4. Precision-alignment methodology
The industry-standard way to judge whether an adaptation is equivalent is “layer-by-layer alignment”: single-kernel alignment → single-layer alignment → whole-network forward alignment → short-pipeline loss alignment. At each level, feed the same input to both the reference and target implementations, compare differences point by point, and pin down the source of error to the smallest possible unit.
3. Distributed parallelism for a dual-node, 16-card setup
“Dual nodes, 16 cards” usually means 2 physical nodes with 8 accelerators each, interconnected by a high-speed network. Training an LLM efficiently across multiple cards and nodes comes down to combining parallelism strategies.
- Data parallelism (DP): each card holds a full copy of the model, the data batch is split, and gradients are synchronized after backpropagation via AllReduce. It is simple to implement but limited by single-card memory.
- Tensor parallelism (TP): a single layer’s weight matrix is split across cards, suitable when a single layer does not fit or when single-card compute needs to be reduced. It is demanding on inter-card bandwidth and is generally confined within a single node.
- Pipeline parallelism (PP): the model is split by layer across card groups to form a pipeline, and micro-batches are used to improve utilization. It suits layer-wise splitting across nodes.
- 3D parallelism: a combination of TP + PP + DP, the mainstream approach for training very large models.
For dual nodes, 16 cards, one typical mapping is tensor parallelism within a node (TP=8 across 8 cards) and data parallelism between nodes (DP=2), so that high-bandwidth communication happens inside the node and cross-node links carry only gradient synchronization. Example configuration:
# Distributed launch (pseudo-parameters, topology only)launch \--nnodes=2 \ # two physical nodes--nproc_per_node=8 \ # 8 cards per node--tensor_parallel=8 \ # intra-node tensor parallelism--data_parallel=2 \ # cross-node data parallelism--global_batch=512 \--micro_batch=4
It is worth stressing that the specific parallelism degrees must be tuned to the model structure, memory usage, and network topology; there is no universal optimum. The key is to keep tensor parallelism from crossing low-bandwidth inter-node links.
4. Collective communication: the performance crux of multi-node training
The throughput bottleneck of multi-node training often lies not in compute but in communication. Key things to verify:
- AllReduce efficiency: gradient synchronization in data parallelism depends on AllReduce. Whether using a Ring or Tree algorithm, cross-node bandwidth becomes the main cost.
- RDMA/high-speed interconnect availability: confirm that nodes communicate over RDMA rather than falling back to TCP, otherwise cross-node communication slows by one to two orders of magnitude.
- Communication-computation overlap: use techniques such as gradient bucketing and
ReduceScatter + AllGatherto hide communication inside backward computation and improve overall utilization. - Topology awareness: route communication along high-bandwidth paths as much as possible and avoid unnecessary cross-node data round trips.
A simple communication-correctness check (confirming that the summed result is consistent across ranks):
import torch.distributed as distt = torch.ones(1, device=device) * dist.get_rank() # each rank fills in its own indexdist.all_reduce(t, op=dist.ReduceOp.SUM) # expected result = 0+1+...+(world_size-1)expected = dist.get_world_size() * (dist.get_world_size() - 1) / 2assert t.item() == expected, f"all_reduce error: {t.item()} != {expected}"
5. Training stability and observability
During short-pipeline validation, beyond whether it finishes, you should also check whether it runs healthily:
- Loss curve: it should decrease smoothly within a few hundred steps. Spikes, oscillation, or NaN call for checking the learning rate, precision, and gradient clipping first.
- Learning-rate warmup: large-model training commonly uses linear warmup for the first several steps to avoid an initial large-gradient shock.
- Memory level: monitor the peak memory per card to judge whether it is approaching the limit, leaving headroom for larger batches or different parallelism later.
- Throughput metrics: record per-step time and tokens/s as a baseline for later performance tuning.
- Logging and monitoring alerts: hook into logging and monitoring-alerting services, and build dashboards for key metrics such as loss, gradient norm, memory, and communication time, so anomalies can be located immediately.
This kind of infrastructure can be carried by general cloud capabilities — for example, using a container platform to schedule multi-node jobs, object storage to save checkpoints, and logging and monitoring-alerting services for observability. General-purpose platforms such as Baidu AI Cloud offer these common categories of capability and can be one option for setting up the training environment.
6. A reusable verification methodology
Turning the above steps into a standard workflow significantly reduces adaptation risk for new hardware and models:
- Prepare the baseline: run the same configuration to completion on a known-good environment and record the loss curve and throughput.
- Align layer by layer: kernel → single layer → whole network → short pipeline, comparing error at each level.
- Short-pipeline smoke test: validate the end-to-end loop at the scale of dual nodes, 16 cards, and a few hundred steps.
- Health check: confirm that the loss decreases, communication is correct, and memory and throughput are within expectations.
- Freeze the configuration: capture the parallelism strategy, communication parameters, and precision settings into a reproducible config file.
- Scale up: after the baseline is trusted, gradually increase the parallelism scale and number of training steps.
Conclusion
Bringing up an LLM on domestic compute always starts from the seemingly plain but critical milestone of “getting the training pipeline running.” It tests not just hardware compute but the systems coordination of kernel adaptation, mixed precision, distributed parallelism, and collective communication. Taking a short-pipeline validation of a few hundred steps on dual nodes and 16 cards as an example: as long as the method is sound, alignment is done layer by layer, and monitoring is in place, you can establish a trusted baseline at low cost and pave the way for larger-scale training.
