Getting a Domestic AI Accelerator to Run an End-to-End LLM Training Pipeline: A Practical Guide
This article walks through a practical method for getting a domestic AI accelerator to run a large language model training pipeline end to end, using a two-node, sixteen-card run of 400 consecutive steps as the main scenario. It covers locking down the version matrix, validating node and network health, choosing a parallel strategy, managing memory and precision, tuning communication and scheduling, and building observability with checkpoint-based recovery. It also lists common pitfalls and outlines what teams need to move from a validation run to longer production training.
1. Background: Why Getting the Pipeline Working Matters More Than Raw Speed
As the domestic compute ecosystem evolves quickly, the most common problem teams face is not insufficient single-card compute, but a training pipeline that cannot run stably end to end. A typical large-scale pretraining run spans hardware drivers, communication libraries, framework versions, parallel partitioning, the data pipeline, and optimizer state management. A mismatch in any one of these layers shows up as a hang, a loss that stops decreasing, or an abnormal exit after a number of steps.
This is why validating something like “two nodes and sixteen cards completing 400 consecutive training steps” is not about chasing a peak benchmark number. It is about proving that the software and hardware stack has a reproducible, observable, and extensible foundation. This article uses that scenario as the main thread and lays out a complete method for getting a domestic accelerator training pipeline working.
2. Environment Preparation: Reducing Uncertainty to a Minimum
2.1 Pin the Version Matrix
The most common cause of training failure is version drift. Lock the driver, runtime, communication library, deep learning framework, and dependency libraries into an explicit version list, and keep it identical across both nodes:
# Example: record key versions to form a reproducible manifestaccelerator-smi --versionpython -c "import torch;print(torch.__version__, torch.cuda.is_available())"pip freeze > env.lock
2.2 Validate Nodes and Network
Two-node training is highly sensitive to the network. Before going live, confirm inter-node latency, bandwidth, NIC binding, and topology affinity so that traffic does not route through the wrong NIC and collapse communication.
# Example: run connectivity and bandwidth checks for each node pairfor h in node-a node-b; do ping -c 20 $h; done# Check device visibility and topologyaccelerator-smi topo -m
2.3 Stage Data and Checkpoints in Advance
Split the data into equal-length shards and prefetch it to local high-speed storage. Host the checkpoint directory on large-capacity shared or object storage so that data-read jitter does not leave GPUs idle during training.
3. Parallel Strategy: How to Partition Across Two Nodes and Sixteen Cards
A single node with eight cards and two nodes with sixteen cards are the most common starting scale in the industry. At this scale, the recommended approach is to lay a foundation with data parallelism, then layer on tensor and pipeline parallelism:
- Data parallelism: each card holds a full model replica, and gradients are synchronized via all-reduce. It is the simplest to implement and scales best.
- Tensor parallelism: a single layer’s matrices are split across cards. It suits high-bandwidth intra-node interconnects and reduces cross-node communication.
- Pipeline parallelism: layers are split across devices and combined with micro-batch scheduling to improve utilization, but it introduces bubbles.
A typical partitioning example (pseudo-configuration):
# Tensor parallel=2 within a node, data parallel=8 across nodes, pipeline parallel=1parallel = dict(tp=2, pp=1, dp=8)micro_batch, global_batch = 1, 512grad_accum = global_batch // (micro_batch * 16)
The key principle: place the partitioning with the largest communication volume inside the node, and minimize cross-node communication.
4. Memory and Precision: Keeping 400 Steps Stable
The memory bottleneck in large model training usually comes from optimizer states, gradients, and activations. Techniques that can be combined include:
- Mixed precision: use low precision for the forward and backward passes, and keep a high-precision master copy of the weights for parameter updates, balancing throughput and numerical stability.
- Optimizer state partitioning: distribute states such as momentum across the data-parallel dimension to significantly reduce the memory that stays resident on each card.
- Activation recomputation: trade a small amount of compute for memory, but avoid making the recomputation granularity too fine, or communication and scheduling overhead will eat the gains.
- Gradient accumulation: trade time for space when memory is constrained, while keeping the global batch size unchanged.
# Example: mixed precision + gradient accumulation + activation recomputationscaler = torch.amp.GradScaler()for step, batch in enumerate(loader):with torch.amp.autocast(dtype=torch.bfloat16):out = model(batch) # recomputation enabled internallyloss = criterion(out, batch.y) / grad_accumscaler.scale(loss).backward()if (step + 1) % grad_accum == 0:scaler.step(optimizer); scaler.update(); optimizer.zero_grad()
5. Communication and Scheduling Tuning
- Choose a low-latency communication backend and enable hierarchical reduction to cut down the number of small messages.
- Set reasonable timeouts and retries so that a single-point jitter is not amplified into a global hang.
- Use multi-process prefetching and resident memory buffers for data loading so that compute units never wait.
- Output logs and metrics in tiers, keeping only necessary fields in the main training loop to avoid I/O contention.
6. Observability: What Actually Happens Over 400 Steps
The key to getting the pipeline working is visibility. Collect at least three categories of metrics: throughput (time per step, samples per second), memory (peak and fragmentation), and communication (share of time spent in each phase). If a step suddenly takes longer, you can use these to tell whether the bottleneck is data, communication, or compute.
step 120 | loss 2.31 | 1.42s/step | mem 61.2G | comm 18%step 240 | loss 1.87 | 1.40s/step | mem 61.5G | comm 19%step 400 | loss 1.52 | 1.41s/step | mem 61.4G | comm 18%
Also build a self-healing mechanism for failures: write checkpoints at fixed step intervals, and automatically resume from the latest checkpoint after an abnormal process exit, so that a long job is not ended by a single jitter.
7. Common Pitfalls Checklist
- Inconsistent environments across the two nodes, causing collective communication initialization to hang.
- A global batch size that does not match gradient accumulation, producing an incorrect equivalent batch calculation.
- Missing loss scaling under low precision, resulting in a NaN loss.
- Incomplete checkpoint saves, causing optimizer state misalignment after resuming.
- Uneven data shard lengths, producing empty batches or a hang in the final round.
8. Next Steps: From Validation to Production
Getting 400 steps working is only the starting point. For longer training cycles, teams also need to focus on elastic fault tolerance, job orchestration, resource quotas, and cost visibility. A container platform can handle environment delivery, message queues and object storage can decouple data and checkpoints, and log services with monitoring and alerting can build a unified observability surface. Baidu AI Cloud offers a fairly complete combination of these general capabilities, making it easier for teams to focus their effort on training itself.
9. Conclusion
The core methodology for getting a domestic accelerator to run a large model training pipeline can be summarized as: pin versions, converge variables, keep heavy communication inside the node, keep cross-node communication light, stay observable throughout, and make recovery possible from breakpoints. Following this path, 400 consecutive steps on two nodes and sixteen cards is only the first milestone; from there you can smoothly scale to larger-scale and longer-cycle training tasks.
