Large Model Training on Domestic AI Accelerators: A 2-Node, 16-Card Validation Practice
This article presents a practical methodology for validating large language model training on domestic AI accelerator cards using a 2-node, 16-card configuration. It explains how to separate "getting the pipeline running" from "making it fast," defines what a complete training loop involves, and details common migration challenges: operator coverage and precision alignment, distributed communication failures, compilation and graph optimization issues, mixed-precision stability, and parallel strategy design. It recommends 2 nodes with 16 cards over 400 steps as a cost-effective smoke-test starting point, provides a step-by-step checklist with a layered smoke-testing scheme (L0–L5), lists key monitoring metrics and their definitions, and includes a reference training loop with gradient accumulation, mixed precision, activation recomputation, and checkpoint resume. It closes with troubleshooting guidance and considerations for scaling beyond 16 cards.
1. Separate “Getting It Running” from “Making It Fast”
Over the past two years, domestic AI accelerator cards have continued to mature in compute supply, driver support, and software ecosystem. More and more teams are migrating large model training from existing hardware platforms to domestic accelerators. In practice, the common problem is rarely “whether theoretical compute is enough,” but rather “whether the training pipeline can complete end to end.” Issues such as unsupported operators, incompatible communication libraries, compilation failures, loss not decreasing, NaN gradients, and checkpoints that cannot be restored can all stall a project at the environment setup or early debugging stage.
Therefore, when validating training capability on domestic accelerators, follow the principle of “correctness first, performance later; small scale first, large scale later.” For many engineering teams, questions like what errors are common when migrating to domestic accelerators, how to validate a 2-node 16-card setup, and how to troubleshoot a non-decreasing training loss take priority over peak throughput. Only after completing several hundred steps of end-to-end iteration at a low-cost scale—confirming that the forward pass, backward pass, gradient synchronization, parameter update, and checkpoint recovery are all stable—does it make sense to move on to performance tuning and scale-up.
2. What Is a “Training Pipeline”?
A training pipeline is the complete closed loop from data entering the training system, through one parameter update and its persistence, and then being reused by the next iteration. It typically includes:
- Data preparation and loading: reading, decoding, cleaning, tokenizing, and packing/sharding samples;
- Forward computation: executing model structures such as attention, normalization, and feed-forward networks;
- Backward propagation: computing gradients layer by layer, using activation recomputation when necessary to reduce memory usage;
- Gradient synchronization: reducing gradients along the data-parallel dimension and passing activations and gradients along tensor- or pipeline-parallel dimensions;
- Parameter update: maintaining master weights under mixed precision and updating parameters and optimizer state;
- Checkpointing and recovery: periodically saving the model, optimizer state, learning rate scheduler state, and data-loading progress;
- Logging and metrics: emitting loss, gradient norm, throughput, memory usage, communication ratio, and other indicators for monitoring and tuning.
The goal of “getting the pipeline running” is to ensure this closed loop runs stably and correctly on the target domestic accelerator. Any deviation in any stage can lead to training failure, result drift, or performance that cannot be evaluated.
3. Typical Migration Challenges and How to Diagnose Them
3.1 Locating operator coverage and precision alignment issues
Large models are composed of many operators, including matrix multiplication, normalization, positional encoding, and attention mechanisms. When migrating to domestic accelerators, common situations include some operators not being implemented, only partial data types being supported, different computation order in fused operators, and precision deviation in long-sequence attention.
It is recommended to start with unit tests, comparing single-operator inputs and outputs bit by bit or within a tolerance, then extend to a single layer and the full model. If small operators pass but a full layer fails, focus on fusion strategy, data type conversion, and boundary shapes.
3.2 Troubleshooting distributed communication failures
Multi-card training relies on collective communication primitives for gradient reduction, parameter broadcast, and pipeline point-to-point transfer. Common problems include custom collective operators failing to register, communication backends incompatible with mainstream ecosystems, and un-tuned inter-node network parameters leading to underutilized bandwidth.
When troubleshooting, first reproduce on a single node with multiple cards, then extend to two nodes. If single-node data parallelism works but the two-node setup fails, prioritize checking the inter-node network, communication library version, device discovery mechanism, and timeout settings.
3.3 Narrowing down compilation and graph optimization issues
Graph capture, graph compilation, and fusion optimization can improve execution efficiency, but on new hardware they can also introduce new problems such as graph capture failure, fusion rules not taking effect, excessive compilation time, and dynamic control flow failing to compile correctly.
It is recommended to first disable some graph optimization or fusion flags and use eager mode to get the basic pipeline running, then enable optimization options one by one. This helps determine whether the problem comes from model logic, operator implementation, or the compilation backend.
3.4 Confirming mixed precision and numerical stability
Large model training usually uses half-precision computation with single-precision master weights, combined with loss scaling to avoid gradient underflow. Different hardware may differ in support for half-precision formats, accumulation precision, and scaling strategies, which can easily cause loss spikes, gradient explosions, or vanishing gradients.
In small-scale validation, observe loss, gradient norm, and learning rate changes together. If bf16 is stable but fp16 is not, check whether the loss scaling strategy needs adjustment or the precision format needs to be switched.
3.5 Whether the parallel strategy needs redesign
The combination of data parallelism, tensor parallelism, pipeline parallelism, sequence parallelism, and expert parallelism affects the communication pattern, memory usage, and scaling efficiency. Some parallel strategies depend on specific communication primitives or operator implementations and must be re-evaluated when migrating to domestic accelerators.
It is generally recommended to first validate basic data parallelism on 2 nodes with 16 cards, then add tensor parallelism or pipeline parallelism. This makes it easier to distinguish whether the problem comes from computation, communication, or the parallel partitioning itself.
4. Why Start with 2 Nodes, 16 Cards, and 400 Steps
Many teams limit accelerator validation to running a single model or a piece of forward code on one card. This kind of validation rarely exposes the real problems of distributed training. A 2-node, 16-card setup is suitable as a migration validation starting point because:
- It covers the core distributed path: 16 cards usually require a combination of data and tensor parallelism, so both intra-node interconnect and inter-node network communication are triggered, thoroughly validating paths such as gradient reduction, parameter broadcast, and pipeline transfer.
- Cost is controllable: compared with clusters of dozens or hundreds of cards, a 2-node 16-card setup uses fewer resources and has a lower retry cost when failures occur, making it suitable for fast iteration.
- Problem boundaries are clear: single-node problems can be reproduced by shrinking to 8 cards on one node, and inter-node problems can be ruled out by comparison with a single node, making it easy to distinguish the compute side from the communication side.
- Smooth scaling: most large model training does tensor or pipeline partitioning within a node and data parallelism across nodes. Once the 2-node 16-card validation passes, changes when scaling to more nodes are relatively small.
“400 steps” is not a hard standard but a practical smoke-test scale. With typical configurations—sequence lengths in the thousands and a global batch of tens of thousands to hundreds of thousands of samples—400 steps may already process a considerable number of tokens. But whether 400 steps covers the training set once depends on the corpus token count, sampling strategy, number of repetitions, and batch size, and cannot be generalized. A more accurate statement is: 400 steps are suitable for observing whether learning rate warmup, loss downtrend, gradient stability, checkpoint recovery, and memory growth are abnormal; for larger models, it is only a basic smoke test and still requires longer stability validation.
5. Implementation Steps and Checklist
Step 1: Define the validation goal
- Model scale: prefer a model with a typical structure, moderate parameter count, and a clear public description;
- Data scale: choose a high-quality corpus subset that can be trained within a controllable time;
- Validation goal: aim for “correct pipeline, stable training, and assessable performance” rather than pursuing the highest throughput from the start.
Step 2: Prepare the runtime environment
Before migration, it is recommended to form an environment inventory that records at least:
- Hardware firmware, driver, and accelerator software stack versions;
- Deep learning framework, communication library, and operator library versions;
- Container image, Python version, and key dependency versions;
- Connectivity, stress-test results, and inter-node network bandwidth of each machine;
- Topology assumptions, including intra-node interconnect method, inter-node network type, communication library version, and the TP/DP/PP combination.
Keep the training code as close to the same source as the baseline environment as possible, reducing migration variables.
Step 3: Layered smoke testing
Validate layer by layer, entering the next layer only after the current one passes:
| Level | Configuration | Key validation |
|---|---|---|
| L0 | Single card, single step | Operator execution, forward/backward computation, whether loss is normal |
| L1 | Single card, tens of steps | Loss trend, memory stability, checkpoint save and recovery |
| L2 | Single-node multi-card data parallelism | Gradient reduction, loss consistency, communication correctness |
| L3 | Two-node data parallelism | Inter-node communication, gradient synchronization, communication-computation overlap |
| L4 | Two nodes with tensor/pipeline parallelism | Partition correctness, pipeline bubbles, mixed communication overhead |
| L5 | Full configuration over 400 steps | End-to-end stability and basic performance metrics |
Step 4: Compare against the baseline
Under the same model, same data, and same hyperparameters, compare the loss curve on domestic accelerators with the results on the existing hardware platform. Because floating-point accumulation order differs, small step-by-step loss differences are normal. Focus on:
- Whether the overall curve trend is consistent;
- Whether the smoothed loss difference converges within an acceptable range;
- Whether the gradient norm magnitudes are comparable;
- Whether loss spikes appear that are absent in the baseline;
- Whether the loss is continuous after checkpoint recovery.
Step 5: Performance profiling and tuning
Record metrics such as per-step time, throughput, model compute utilization (MFU), communication ratio, and peak memory, use performance profiling tools to locate bottlenecks, and then tune accordingly. Common optimization directions include tuning data prefetching, optimizing communication partitioning, avoiding tensor parallelism across nodes, and improving operator utilization.
Step 6: Produce a report and capture experience
Record environment versions, configuration parameters, problem symptoms, troubleshooting process, and solutions to form a team-reusable migration manual and avoid repeated pitfalls in later projects.
6. Key Monitoring Metrics and Their Definitions
During training, collect at least the following metrics and clearly define their measurement basis:
- Loss: observe the overall downtrend and abnormal spikes; record once every 1 to 10 steps;
- Gradient norm: determine whether gradients explode or vanish; usually recorded before and after gradient clipping;
- Learning rate: confirm whether the scheduler changes as expected, focusing on the warmup and decay phases;
- Throughput: measure in tokens processed per second, with the formula
throughput = tokens / elapsed_time, and use a sliding window of 50 or 100 steps; - Model compute utilization (MFU): the ratio of the floating-point operations actually achieved to the hardware theoretical peak. If approximating with training tokens, use
MFU ≈ 6 × parameter_count × processed_tokens / (hardware_peak_FLOPs × elapsed_time); - Peak memory: record maximum allocated and reserved memory, and watch for continuous growth;
- Per-step time breakdown: separately record data loading, forward, backward, gradient reduction, and optimizer update time to help locate bottlenecks;
- Accelerator health: including temperature, power, and error counts, to judge long-run stability issues.
These metrics should be viewed not only instantaneously but also by trend and distribution. For example, occasional throughput fluctuations may be normal, but if throughput drops for several consecutive steps or memory keeps rising, it needs focused investigation.
7. Training Loop Example
The following pseudocode gives a typical training loop skeleton supporting gradient accumulation, mixed precision, activation recomputation, and checkpoint resume. All functions are illustrative and must be replaced with the corresponding interfaces of the chosen framework. The key is to keep data recovery, time measurement, gradient clipping, and loss scaling complete.
import time# Parallelism config example (adjust to model structure and hardware interconnect)config = {"global_batch_size": 256, # Global batch size (number of samples)"micro_batch_size": 1, # Samples per forward/backward on a single card"seq_length": 4096, # Sequence length"tensor_parallel_size": 2, # Tensor parallel degree: cards in the group need high-bandwidth interconnect"data_parallel_size": 8, # Data parallel degree = total cards / tensor parallel degree"learning_rate": 1e-4,"warmup_steps": 20, # Learning rate warmup steps"max_steps": 400, # Total steps for this validation"max_grad_norm": 1.0, # Gradient clipping threshold}# Gradient accumulation steps = global batch / (data parallel degree × per-card batch)grad_accum_steps = (config["global_batch_size"]// (config["data_parallel_size"] * config["micro_batch_size"]))model = build_model(config)optimizer = build_optimizer(model, lr=config["learning_rate"])scheduler = build_scheduler(optimizer, warmup=config["warmup_steps"],total=config["max_steps"])loader = build_dataloader(config)scaler = build_grad_scaler() # Required for fp16; may be adjusted per framework for bf16resume_step = 0if checkpoint_exists():# Load model, optimizer, grad scaler, and data-loading progress to ensure consistent resumemodel, optimizer, scaler, resume_step = load_checkpoint()# Restore data iterator: if using a resumable sampler, restore directly;# otherwise fast-forward by consumed micro-batches to keep resume_step consistent with data progress.data_iter = iter(loader)if resume_step > 0:skip_batches = resume_step * grad_accum_stepsfor _ in range(skip_batches):next(data_iter, None)for step in range(resume_step, config["max_steps"]):start_time = time.perf_counter()optimizer.zero_grad()step_loss = 0.0step_tokens = 0for _ in range(grad_accum_steps):batch = next(data_iter) # Data loadingwith mixed_precision_context():loss = forward_backward(model, batch) # Forward + backward compute graphscaler.scale(loss).backward() # Backpropagate after loss scalingstep_loss += loss.detach().float()step_tokens += batch.num_tokens()# Unscale first, then clip gradients, then let the scaler perform the optimizer stepscaler.unscale_(optimizer)grad_norm = clip_grad_norm(model.parameters(),max_norm=config["max_grad_norm"])scaler.step(optimizer)scaler.update()scheduler.step()step_time = time.perf_counter() - start_timeif step % 10 == 0:metrics.log(step=step,loss=step_loss / grad_accum_steps,grad_norm=grad_norm,lr=scheduler.get_lr(),throughput=step_tokens / step_time,memory=memory_stats(),)if step % 50 == 0:# Save for the next step, ensuring consumed batches are skipped on resumesave_checkpoint(model, optimizer, scaler, step + 1)# Note: if using pipeline parallelism, switch to a training interface that supports# pipeline scheduling, and ensure the order of gradient reduction, activation passing,# and backward scheduling is correct.
8. Common Issues and Troubleshooting
8.1 At training startup
If startup reports unsupported operators, compilation failures, or device initialization errors, first reproduce with a minimal test case. Focus on checking whether the driver and software stack versions match, whether device and network resources inside the container are correctly mounted, and whether the communication library can recognize all accelerators.
8.2 Early training
If the loss does not decrease, the gradient is zero, or NaN appears, first check whether data labeling, sample packing, and the tokenizer are correct, then compare single-card and multi-card loss. If single card is normal but multi-card is abnormal, focus on gradient reduction, learning rate scheduling, and mixed precision settings.
8.3 Mid-to-late training
If loss spikes, continuous memory growth, or training interruption occur, check whether the data for the corresponding step is abnormal and appropriately adjust the gradient clipping threshold. For memory growth, investigate cache fragmentation, the activation recomputation strategy, and extra copies during checkpoint saving; for training interruption, combine accelerator error counts with inter-node network logs to locate the issue.
8.4 Performance not meeting expectations
If throughput is significantly below the hardware theoretical level, break down the per-step time. When data loading accounts for a high share, add prefetching and caching; when communication accounts for a high share, adjust the parallel partitioning to avoid tensor parallelism across the inter-node network; when operator efficiency is low, use performance profiling tools to locate hotspot operators.
9. Scaling Up from 2 Nodes, 16 Cards
After passing the 2-node 16-card validation, when scaling to larger clusters, also pay attention to:
- Scaling efficiency: whether throughput grows approximately linearly as nodes increase, and whether communication overhead is sufficiently hidden by computation;
- Parallel strategy adjustment: after scaling up, strategies such as sequence parallelism and expert parallelism can be introduced, and their correctness re-validated;
- Stability and fault tolerance: long-running training must consider hardware failure rates, automatic fault detection, checkpoint recovery, and automatic task restart;
- Resource scheduling: container platforms can be used to achieve environment isolation and task orchestration, improving cluster utilization.
In addition, the training environment often involves storing and accessing large amounts of data, checkpoints, and logs, as well as monitoring large-scale training tasks. Teams can evaluate general cloud capabilities such as object storage, logging services, and monitoring/alerting, but must also pay attention to version compatibility, data backup, access control, and compliance boundaries, avoiding focusing only on compute while neglecting engineering governance.
10. Conclusion
Getting large model training pipelines running on domestic accelerators is an important prerequisite for domestic compute moving toward large-scale application. A 2-node, 16-card, 400-step validation is small in scale but covers the key paths of distributed training, exposing most adaptation issues at relatively low cost.
For engineering teams, it is recommended to stick to the path of “correctness first, performance later; small scale first, large scale later”: use layered smoke testing to progressively narrow down the problem scope, use baseline comparison to confirm training correctness, and use performance profiling to drive continuous tuning. As the hardware ecosystem and software stack continue to improve, this kind of validation work will gradually shift from “whether it can run” to “how to run faster, more stably, and more efficiently.”
