Validating Large-Model Training Pipelines on Domestic AI Accelerators: A Two-Node, 16-Accelerator, 400-Step Practice
This article presents a practical method for validating large-model training pipelines on domestic AI accelerators before long-running production training. It covers software stack alignment, operator coverage checks, data and hyperparameter alignment, parallelism design for two nodes and 16 accelerators, staged validation, key training signals during a 400-step run, metric interpretation, and common troubleshooting. The approach is designed to detect functional, numerical, performance, and stability risks early.
1. Why a dedicated training-pipeline validation is needed
Large-model training is a full pipeline made of data, model, parallelism, framework, and hardware. If any part does not match, it can show up as errors, abnormal loss, or low throughput.
When moving training from an existing platform to domestic AI accelerators, lower-level components such as drivers, runtimes, communication libraries, and framework adaptation layers differ. This commonly leads to three types of problems:
- Functional issues: some operators lack efficient implementations or fall back to generic paths, causing very slow training or errors.
- Numerical issues: rounding and accumulation-order differences under mixed precision can cause the loss curve to drift slowly or even diverge.
- Stability issues: long training runs may show growing memory usage, device dropouts, or communication interruptions.
Formal training can last weeks and consume huge compute on thousands of accelerators. Therefore, teams usually run a few hundred steps on a small cluster, such as two nodes with 16 accelerators, to expose risks early. This is similar to the feedback step in continuous integration before code is merged, except that the object being validated is the entire training pipeline.
2. Validation goals: four levels and pass criteria
Before designing the test, break “it runs” into measurable goals:
- Functional level: use a small model or reduced-layer configuration and run from initialization to checkpoint saving without blocking errors.
- Numerical level: fix random seeds, confirm that loss decreases smoothly, keep training metrics such as gradient norm and loss scale in normal ranges, and compare against a reference curve with the same configuration on a mature platform while keeping deviations controlled.
- Performance level: per-accelerator throughput, multi-accelerator scaling, and compute utilization should meet expectations, and training speed should be acceptable.
- Stability level: continuous training should not show growing memory usage; after active termination, training should resume from the latest checkpoint without loss.
Each level’s goal, method, pass criterion, and priority are shown below:
| Level | Core question | Validation method | Pass criterion | Priority |
|---|---|---|---|---|
| Functional | Can one complete forward, backward, and parameter update run without blocking issues? | Short run with a small model | No blocking errors; checkpoints can be saved and loaded | High |
| Numerical | Does training converge correctly? | Fix random seed and align reference curve | Loss decreases smoothly; deviation is within expected range | High |
| Performance | Is training efficient enough? | Measure throughput and compute utilization step by step | Meet predefined performance baseline | Medium |
| Stability | Can it support long-running training? | Extend step count and simulate fault injection | No memory leak; resume from checkpoint works | Medium |
It is important to emphasize that the numerical level has the highest priority. Insufficient performance can be optimized later, but if correctness is missing, later conclusions do not hold.
3. Preparation: software stack alignment and operator coverage
3.1 Build a software stack baseline
Before starting, fix and record the versions of the following components:
- Operating system and kernel
- Device driver
- Runtime and collective communication library
- Framework version and the corresponding hardware adaptation plugin
- Libraries required by the training scripts
It is recommended to write these versions into a configuration file and record them into the runtime environment when training starts. This makes it easier to determine whether a later issue comes from code or from an environment mismatch.
3.2 Operator coverage and fusion support check
Mainstream training frameworks often connect to new hardware through a “unified device abstraction + hardware adaptation plugin” model. Operators used by a model generally fall into three categories:
- Natively supported: the adaptation layer provides a dedicated implementation.
- Generic fallback: the framework’s built-in generic implementation is reused; it is functionally correct but may be significantly slower.
- Not implemented: the framework raises an error directly.
Before validation, you can use a static analysis script to scan the model’s operator list and compare it with the adaptation layer’s supported list. You can also use framework-provided profiling tools to count the actual operator distribution at runtime and identify operators that are frequently falling back.
# Example: operator coverage check (API names depend on the framework used)import torchfrom torch.fx import symbolic_tracedef collect_ops(model, example_inputs):"""Walk the model graph and count operator types."""graph = symbolic_trace(model).graphcounter = {}for node in graph.nodes:if node.op == "call_function":name = getattr(node.target, "__name__", str(node.target))counter[name] = counter.get(name, 0) + 1return counter# The supported-operator set can be obtained from the hardware adaptation layer or runtime traces.supported_ops = {"aten::linear", "aten::mm", "aten::add"}used_ops = collect_ops(model, dummy_inputs)unsupported = {op: cnt for op, cnt in used_ops.items() if op not in supported_ops}print("Unsupported operators:", unsupported)
3.3 Align data, model, and hyperparameters
- Data: prepare a small and fixed training subset, such as a few thousand samples, and ensure that the data order is consistent across experiments. Data sharding, sampling strategy, and preprocessing should match the reference platform, and random seeds should be fixed.
- Model: prefer a small configuration with the same structure as the target model, rather than a substitute model with a very different architecture.
- Hyperparameters: learning rate, batch size, gradient accumulation steps, optimizer parameters, and gradient clipping threshold must be aligned item by item. Any difference can distort comparison results.
4. Parallel strategy design: using resources on two nodes with 16 accelerators
Parallel strategy determines how computation and communication are distributed. The core design principle is: place parallelism with heavy communication inside high-bandwidth links, and place parallelism with light communication across nodes.
Common parallelism methods have the following characteristics:
- Data parallelism: each device holds a full model replica. Gradient reduction scales with model size and is typically “large-message communication”.
- Tensor parallelism: operators within a layer, such as linear layers, are split across devices. Forward and backward passes require frequent communication, so it is usually placed inside one node.
- Pipeline parallelism: the model is split by layers, and activations and gradients are passed through smaller point-to-point communication. It is relatively friendly to cross-node bandwidth, but it introduces pipeline bubbles.
- Parameter and optimizer state sharding: gradients and optimizer states produced by data parallelism are sharded, which significantly reduces per-device memory usage at the cost of additional communication.
A common combination is “tensor parallelism + data parallelism”. Some designs also add parameter sharding across nodes. For two nodes with 16 accelerators, the following steps can be used:
- Estimate memory requirements:
- Under mixed-precision training, model states, including parameters, gradients, and optimizer states, usually require about “parameter count × 16 to 20 bytes”. Optimizer states take up the largest share.
- Add activation memory, temporary buffers, and communication buffers, and measure peak memory usage with multiple batch sizes and sequence lengths.
- Determine split dimensions: set tensor parallelism to 8 so that it stays within one node; set data parallelism to 2 so that cross-node communication only handles gradient reduction, with communication volume approximately “parameter count × 4 bytes in FP32”.
- Check constraints: the product of all parallelism dimensions must equal the total number of accelerators, that is, 8 × 2 × 1 = 16.
- Leave headroom: memory utilization should leave about 10% to 20% headroom to avoid occasional OOM caused by fragmentation or communication buffers.
# Example: rough memory estimate and parallel configuration (coefficients should be calibrated by measurement)def estimate_memory_gb(num_params, batch_size, seq_len, hidden_size, layers, bytes_per_param=18):"""Roughly estimate per-device model state memory (GB)."""model_states = num_params * bytes_per_param / 1e9# Activation memory roughly scales with batch size, sequence length, hidden size, and layer count.activations = batch_size * seq_len * hidden_size * layers * 2 / 1e9return model_states, activationstp, pp = 8, 1 # Tensor parallelism stays within one node; no pipeline parallelism for now.dp = 16 // (tp * pp) # Data parallelism is derived from the total number of accelerators.print(f"Tensor parallel={tp}, pipeline parallel={pp}, data parallel={dp}")model_states, acts = estimate_memory_gb(num_params=1e9, batch_size=4,seq_len=2048, hidden_size=2048, layers=24)print(f"Model states ~ {model_states:.1f} GB; activations ~ {acts:.1f} GB (example configuration only)")
5. Staged execution: from single-accelerator validation to a 400-step run on two nodes
Starting hundreds of training steps on two nodes with 16 accelerators at once often makes it hard to locate the root cause. It is better to progress through stages: smallest unit → multi-accelerator on one node → multi-node multi-accelerator → scale and stability testing.
- Stage 1: single-accelerator short run, about 50 steps
- Goal: confirm that data loading, forward pass, backward pass, and parameter updates work normally, and that loss is finite and generally decreasing.
- Record single-accelerator throughput as a baseline for later scaling tests.
- Stage 2: multi-accelerator on one node, about 200 steps
- Goal: validate collective communication, data sampling, and gradient synchronization; the aggregated loss should match the result from a single accelerator with the same configuration.
- Check whether inter-device bandwidth inside the node is fully utilized.
- Stage 3: full two-node, 16-accelerator pipeline, 400 steps
- Validate cross-node communication, parallel strategy splitting, checkpoint saving, and checkpoint loading, and collect complete performance and stability metrics.
- If possible, compare with a reference result using the same configuration on a mature platform.
- Stage 4: extended steps and stability testing, depending on the situation
- Extend the run to thousands of steps and observe whether loss remains smooth and whether memory usage keeps growing.
- During the run, deliberately inject a device error or network jitter to verify that the job can automatically recover from the latest checkpoint.
For example, memory usage can be used as a signal. A single accelerator must hold the full model. After sharding across accelerators, each device only needs to hold about 1/N of the states and gradients. Therefore, memory usage should drop noticeably as parallelism increases. If it does not drop, the split is likely not effective.
6. Core validation loop: what signals should be collected during the 400-step run
The training loop itself is not complex. The key is to collect the validation signals completely.
# Example: training validation loop (pseudocode; API names depend on the framework used)for step in range(1, max_steps + 1):batch = next(data_iter)with autocast(dtype=bfloat16): # Mixed-precision forward passloss = model(batch) / grad_accum_stepsloss.backward()if step % grad_accum_steps == 0:grad_norm = clip_grad_norm_(model, max_grad_norm) # Gradient clippingoptimizer.step() # Includes mixed-precision loss-scaling handlingoptimizer.zero_grad(set_to_none=True)if step % log_interval == 0:record(step=step, loss=loss.detach().item(),grad_norm=grad_norm,tokens_per_sec=count_tokens(batch) * world_size / elapsed,peak_mem=max_memory_allocated(),loss_scale=get_loss_scale(optimizer))if step % ckpt_interval == 0:save_checkpoint(step) # Periodic checkpointing for rollback and resume
At minimum, each training step should collect the following signals:
| Metric | Meaning | Abnormal signal and troubleshooting direction |
|---|---|---|
| Loss | Model convergence trend | Continuously rising or becoming NaN/Inf; check learning rate, numerical overflow, and data anomalies |
| Gradient norm | Whether backward propagation is stable | Continuously spiking or staying at zero; check gradient clipping, communication synchronization, and data labels |
| Loss scale factor | Whether the dynamic range under mixed precision is appropriate | Frequently lowered or too many skipped steps; consider switching to a precision format with a larger numeric range |
| Throughput | Number of tokens processed per unit time | Clearly below the single-accelerator baseline; check communication bottlenecks and operator fallback |
| Peak memory | Per-device memory usage | Steadily rising; usually indicates memory leaks or cache fragmentation |
| Per-step time distribution | Time spent in each stage | Some steps are noticeably slower; often related to periodic checkpoint saving |
The 400-step run includes several periodic checkpoint saves, which introduce extra storage write overhead. When analyzing throughput, distinguish “pure compute steps” from “checkpoint-saving steps” to avoid drawing an overly low performance conclusion.
Metric interpretation: throughput, scaling, and compute utilization
- Throughput: measured as the number of tokens processed per unit time. The measurement must use the same definition as the reference result.
- Scaling: ideally, throughput grows linearly with the number of accelerators. If the scaling efficiency of 16 accelerators relative to the single-accelerator baseline is clearly low, communication overhead is likely too high.
- Model FLOPs utilization, MFU: the ratio of achieved floating-point performance to the hardware’s theoretical peak performance. Because hardware specifications differ, MFU is often better than absolute throughput for cross-hardware comparison.
# Example: MFU calculation (constants depend on the actual model architecture)# Training one token requires roughly 2N forward FLOPs and 4N backward FLOPs, about 6N in total.FLOPS_PER_TOKEN = 6 * num_paramsachieved_flops = tokens_per_sec * FLOPS_PER_TOKEN # Measured FLOPSmfu = achieved_flops / peak_flops # peak_flops is the hardware theoretical peak
7. Result interpretation and conclusions
7.1 Numerical comparison
When comparing loss with a reference platform, first exclude differences in hyperparameters and data order, and focus on three points:
- Whether the starting point is consistent.
- Whether the overall trend matches.
- Whether there is a persistent offset.
In parallel training, floating-point addition is not associative, and different reduction orders can introduce small numerical differences. Therefore, small deviations are allowed, but the deviation should not accumulate and grow with the number of steps.
7.2 Performance comparison
Compare throughput under different parallel configurations to locate bottlenecks:
- If increasing data parallelism does not improve throughput, gradient reduction communication has become the bottleneck.
- If single-node throughput is high but cross-node throughput drops clearly, cross-node link utilization is insufficient.
- If some operators take an abnormally high share of time, operator fallback is likely.
7.3 Final report
The final validation report should include at least:
- Environment and version information
- Model and data configuration
- Parallel strategy and resource usage
- 400-step loss curve and key metrics
- Issues found and improvement suggestions
8. Common failures and troubleshooting
| Symptom | Common causes | Investigation methods |
|---|---|---|
| Operator not supported or output is abnormal | The adaptation layer lacks the corresponding implementation | Check the operator list and fallback logs; use an equivalent implementation or report the issue to the adaptation team |
| Loss becomes NaN/Inf | Numerical overflow, learning rate too high, or bad data | Locate the first abnormal step, bisect data batches, and check loss-scaling settings |
| Multi-node training hangs at a certain step | Execution paths differ across ranks, or collective communication is not aligned | Check whether conditional branches depend on device ID, and enable communication timeout detection |
| Throughput is far below the single-accelerator baseline | Communication bottleneck or data-loading bottleneck | Use a performance analysis tool to locate time spent in each stage, and check whether preprocessing consumes too many resources |
| Memory usage keeps growing | Cache not released, computation graph not detached, or memory fragmentation | Observe memory usage curves at each stage and adjust memory allocation strategy |
| Loss jumps after resuming training | Random states not restored, or optimizer states not saved | Verify checkpoint contents, and save and restore random number generator states |
When troubleshooting, follow two principles:
- Reduce the reproduction scope: start from the smallest model, fewest accelerators, and shortest steps.
- Change only one variable at a time: otherwise, it is impossible to tell which change caused the improvement.
9. Extended practice: cloud validation and engineering deployment
For teams without their own clusters, heterogeneous accelerator capacity can be obtained on cloud platforms, and common cloud products can be used to build an engineering validation system:
- Container platform: package a unified runtime environment and ensure consistency across nodes.
- Object storage: store training data and checkpoints, and support shared reading across nodes.
- Message queue: pass job status in the scheduling workflow.
- Logging, monitoring, and alerting: collect training logs centrally, monitor device status, and notify users promptly when anomalies occur.
Cloud platforms such as Baidu AI Cloud can cover these categories, subject to official documentation. For example, in the Baidu AI Cloud/PaddlePaddle ecosystem, PaddlePaddle provides a multi-hardware adaptation mechanism based on a unified device abstraction and hardware adaptation plugins. When migrating training, developers can confine hardware differences to the adaptation layer and reuse the same training code where such mechanisms are available. Of course, the adaptation quality still needs to be confirmed item by item through the staged validation described above.
After validation passes, it is recommended to freeze the environment and parameters into a configuration file, and add the validation scripts to the continuous integration workflow. After every driver, framework, or adaptation-layer upgrade, rerun the short validation automatically to prevent regressions such as “fixed once, then broken again”.
10. Conclusion
Two nodes, 16 accelerators, and 400 steps are not a large scale, but they are enough to cover the main risk points of a large-model training pipeline. The value of this method is not the numbers themselves, but the reusable judgment framework it provides:
- First break “it runs” into four levels: functional, numerical, performance, and stability.
- Align the environment and data to eliminate confounding variables.
- Design the split strategy according to parallelism principles.
- Validate in stages and scale up gradually.
- Let complete metrics speak, and use standard reports to preserve conclusions.
As the domestic hardware ecosystem continues to improve, more teams will face training migration problems. Mastering a scientific validation method helps make reliable judgments with limited compute and limited time, and lays a solid foundation for large-scale training.
