Getting Large Model Distributed Training Pipelines Running on Domestic AI Accelerators: A Practical Guide
An end-to-end guide to validating and stabilizing distributed training pipelines for large language models on domestic AI accelerators. It covers the overall architecture and applicability boundaries of a dual-node multi-GPU setup, the core challenges (operator coverage, collective communication, framework adaptation, and numerical stability), a standardized six-step workflow with runnable commands, key optimization practices, and a troubleshooting reference. Aimed at engineers bringing up large-model training on self-developed compute, it emphasizes reproducible checks, minimal configuration examples, and clear metric criteria over raw hardware specifications.
Introduction: Why “Getting the Pipeline Running” Is the First Hurdle in LLM Engineering
When a large model moves from experimental validation to production, the thing most easily underestimated is not single-point performance but whether the training pipeline can run end-to-end and stably. “Running through” does not just mean the model starts up; it means data, compute, communication, and optimizer state updates run continuously end-to-end on domestic accelerators, and that across hundreds of training steps you never hit compilation failures, communication hangs, out-of-memory errors, gradient desynchronization, or loss anomalies.
For domestic AI chips, the complexity of these problems is even higher. Large-model training depends on multiple layers — operator libraries, collective communication libraries, mixed-precision strategies, parallelism partitioning, memory management, and the distributed framework itself — and a gap in any one layer shows up as “training won’t run.” So getting a dual-node multi-GPU pipeline working is, at its core, a verification that the entire hardware-software stack coordinates correctly.
The Overall Architecture and Applicability Boundaries of a Dual-Node Multi-GPU Pipeline
A typical multi-node multi-GPU training environment usually includes these layers:
- Compute layer: multiple physical machines, each with several domestic accelerator cards. Within a card or within a machine, high-bandwidth interconnects handle communication; between machines, the network does.
- Framework layer: the distributed training framework handles model partitioning, data loading, the forward pass, backpropagation, and optimizer updates.
- Communication layer: the collective communication library provides primitives such as AllReduce, AllGather, ReduceScatter, and Broadcast — the core of synchronous training.
- Data layer: training data is usually stored on shared storage, a parallel file system, or object storage, and is read in parallel by multiple nodes.
- Scheduling and monitoring layer: responsible for job orchestration, log collection, metrics monitoring, and alerting.
Taking “two nodes, 16 cards” as an example, the common form is 8 cards per machine. Intra-machine communication typically relies on high-bandwidth interconnects, while inter-machine communication relies on high-speed networks. As the card count grows, communication overhead is amplified, so parallelism strategy and communication optimization directly affect training efficiency and stability.
Applicability Boundaries
Before diving in, I recommend first making clear the environment boundaries to which this article’s methods apply. Domestic accelerators vary widely across regions, vendors, and generations, so in practice you must defer to the vendor’s compatibility matrix. Here is an example of the boundaries:
| Item | Minimum recommendation | Example | Not applicable |
|---|---|---|---|
| Domestic accelerator model | An 8-card node listed on the vendor’s compatibility matrix | An 8-card model from Vendor A and one from Vendor B must each be validated separately | Uncertified models; mixing cards from different vendors |
| Software stack versions | Pin driver, runtime, communication library, and framework versions | Fixed image or fixed environment variables | Arbitrary mixing of multiple versions |
| Network type | High bandwidth within a node; prioritize a high-speed network between nodes | RDMA, RoCE, IB, or high-bandwidth Ethernet | Cross-node training over ordinary low-bandwidth networks |
| Storage requirements | Support for concurrent reads from multiple nodes | Shared storage, parallel file system, or object storage | A single node’s local disk that cannot be shared |
| Debugging capability | Ability to inspect device topology, communication logs, and process stacks | Vendor tools, log services, monitoring and alerting | No logs, no monitoring, no permission to troubleshoot |
I recommend running a basic check once when initializing the environment, for example:
#!/bin/bashset -euo pipefail# The commands below are generic examples; replace them with the tools# provided by your domestic chip vendor.DEVICE_TOOL=${DEVICE_TOOL:-device-tool}COMM_TOOL=${COMM_TOOL:-comm-tool}$DEVICE_TOOL version$COMM_TOOL version$DEVICE_TOOL topology --matrixpython -c "import torch; print('torch:', torch.__version__)"
The goal of this step is to confirm that the driver, runtime, communication library, and framework versions, along with the device topology, are all correctly recognized. If versions are inconsistent or the topology is not visible, every subsequent training step may produce misleading results.
Core Challenges in Getting the Pipeline Working
Hardware and Operator Adaptation
The first hurdle for domestic compute is operator coverage. Operations such as matrix multiplication, LayerNorm, Softmax, Attention, activation functions, and reductions in large-model architectures all need corresponding implementations on the target hardware. Adaptation work usually follows one of three paths:
- Use an existing implementation from the vendor’s operator library.
- Port or hand-optimize missing operators.
- Lower high-level operator graphs to hardware instructions through a compiler.
To turn the problem from “unknown” into “manageable,” I recommend building an operator checklist first. You can organize it with the following template:
| Operator | Model layer | Supported? | Adaptation approach | Validation result | Risk notes |
|---|---|---|---|---|---|
| MatMul | Transformer/FFN | Yes | Vendor library | Passed on single card | Watch precision mode |
| LayerNorm | Transformer | Partial | Custom implementation | Multi-card pending | May affect gradient numerics |
| Softmax | Attention | Missing | Hand-written adaptation | Pending | Watch overflow and stability |
| AllReduce | Data parallel | Yes | Communication library | Passed across two nodes | Check network topology |
To make the operator-check script runnable, prepare three input files:
model_ops.json: the model’s operator list, which can be generated by a model-export script.op_registry.json: the vendor’s operator registry or a manually compiled operator-support table.target_backend_ops: the set of operators actually supported by the target backend. If the runtime provides an interface, it can be exported automatically; otherwise, generate it from the vendor operator table.
For example:
python export_ops.py --model configs/model.yaml --output model_ops.jsonpython - <<'PY' > target_backend_ops.jsonimport jsonimport runtime_ops # Replace with the operator-query module provided by your actual runtimeprint(json.dumps(runtime_ops.list_supported_ops()))PY
Then run the check script:
#!/usr/bin/env python3import jsonimport sysimport osdef load_json(path: str):if not os.path.exists(path):raise SystemExit(f"missing file: {path}")with open(path, "r", encoding="utf-8") as f:return json.load(f)def main():model_ops_path = sys.argv[1] if len(sys.argv) > 1 else "model_ops.json"registry_path = sys.argv[2] if len(sys.argv) > 2 else "op_registry.json"model_ops = load_json(model_ops_path)registry = load_json(registry_path)target_backend = set(registry.get("target_backend_ops", []))required_ops = {op["name"] for op in model_ops}missing_ops = sorted(required_ops - target_backend)if missing_ops:print("unsupported_ops:", missing_ops)# Exit with code 2 on failure so it can plug into CI or automated checkssys.exit(2)print("all_required_ops_supported")if __name__ == "__main__":main()
For the runtime, I recommend using the same container or virtual environment as training, keeping the Python version, dependency packages, and device driver version consistent. If the script returns exit code 2, it means some operators are not yet adapted; handle the operator issues first before moving on to launching training.
Collective Communication and Interconnect Optimization
Correctness in multi-card training depends on collective communication. In domestic compute environments, common problems include incomplete support for communication primitives, inconsistent ordering when creating communication groups, sensitivity to the cross-machine network topology, and hangs caused by different ranks taking different code branches.
I recommend starting with a minimal communication check rather than running the full model directly. First validate with a communication smoke-test script or a tool built into the framework:
python comm_smoke.py --backend collective --world-size 16 --allreduce --dtype bfloat16
If you use a torchrun-style launcher, you can also validate with a minimal number of processes:
torchrun --nnodes=2 --node_rank=0 --nproc_per_node=8 \--master_addr=10.0.0.10 --master_port=29500 \comm_smoke.py --allreduce
When troubleshooting hangs, look at three kinds of evidence:
- Whether logs are aligned: Did every rank finish creating the communication group, and did every rank enter the same collective call?
- Whether the process stack is blocked: Use
py-spy,gdb, or a vendor debugging tool to see whether the process is stuck in a communication wait. - Whether communication-group parameters are consistent: Are world size, rank order, and group IDs the same across ranks?
Example commands:
py-spy dump --pid 12345paste logs/rank_*.log > logs/merged.loggrep -E "collective|group|allreduce|timeout|error" logs/merged.log
Common log signatures include collective group created ranks=[...], allreduce size=..., shape mismatch, dtype mismatch, and communication timeout. If only some ranks have entered AllReduce while others are still in the forward pass, this usually indicates inconsistent code branches.
Training Framework Adaptation
When migrating mainstream distributed training frameworks to a domestic backend, you need to complete adaptation of the device abstraction, mixed precision, distributed parallelism wrappers, and the collective communication interface. The key goal is to upgrade “runs on a single card” to “consistent across multiple cards.”
I recommend first validating numerical correctness on a single card with a tiny model, such as a single-layer Transformer or a two-layer FFN. After confirming that the loss is finite, gradients can backpropagate, and optimizer state can update, switch to multi-card. After switching, focus on observing:
- Whether the loss is consistent or close across ranks.
- Whether gradients complete synchronization.
- Whether parameter updates happen only once.
- Whether some rank exits early or blocks abnormally.
Numerical Stability and Convergence Validation
Domestic chips may differ subtly from the original environment in precision handling, accumulation order, and mixed-precision scaling. In a single training step these differences may be unnoticeable, but they accumulate and amplify over long runs, showing up as loss jitter, gradient explosions, precision that misses targets, or training interruptions.
Therefore, convergence validation should not only check “whether it crashed” but also whether the metrics are stable. I recommend establishing criteria like the following:
| Metric | How to judge | Example criterion |
|---|---|---|
| Loss curve | Compare against a reference baseline | Finite for 200 consecutive steps, with deviation from baseline within an acceptable range |
| Gradient norm | Monitor grad norm | No sustained explosion; no more than a few times the baseline |
| Learning rate | Compare against the actual configuration | Scheduler behaves consistently, with no abnormal jumps |
| Peak device memory | Monitor peak memory | Below the single-card safe watermark, leaving room for fragmentation |
| Throughput | Compare against baseline | No lower than the baseline target; avoid severe regression |
| Training stability | Continuous run | No crash, no hang, no duplicate checkpoints within 400 steps |
A note on targets like “running 400 steps”: 400 steps is better suited to validating pipeline stability than to proving that the model has converged. If the model is large, the data long, or the learning-rate schedule long, 400 steps may not be enough to observe a full convergence trend. So the usual conditions for a 400-step run are: a small model, a small data subset, a fixed random seed, and use for functional validation or baseline comparison. For formal training, judge based on longer step counts, more validation-set metrics, and convergence curves.
A Standardized Workflow for Getting the Pipeline Working
I recommend advancing through the following steps in order, with each step anchored to a verifiable result and, where possible, an executable command or minimal configuration example.
1. Environment Self-Check
Goal: confirm that the driver, runtime, communication library, framework versions, and device topology are consistent.
#!/bin/bashset -euo pipefailDEVICE_TOOL=${DEVICE_TOOL:-device-tool}COMM_TOOL=${COMM_TOOL:-comm-tool}$DEVICE_TOOL version$COMM_TOOL version$DEVICE_TOOL topology --matrixpython -m pip show torch | grep -E "Name|Version"
Pass criteria: no version conflicts, devices visible, a complete topology matrix, and the framework able to recognize the accelerators.
2. Single-Card Smoke Test
Goal: confirm that basic operators, the forward pass, backpropagation, and optimizer updates are available.
python train.py --steps 1 --batch-size 2 --amp --log-dir logs/smoke
Pass criteria: the process exits normally, the loss is finite, no operators are missing, and no memory anomalies occur.
3. Data Pipeline Validation
Goal: confirm that distributed reading has no duplication, no omissions, and no scrambling.
python data_check.py --shards 2 --epochs 1 --report data_report.json
Pass criteria: each sample index appears exactly once, batches are concatenated correctly, and preprocessing is free of anomalies.
4. Scaling Up Gradually
Goal: move from single card to intra-machine multi-card, then to cross-machine multi-card, validating communication and synchronization.
# Primary nodetorchrun --nnodes=2 --node_rank=0 --nproc_per_node=8 \--master_addr=10.0.0.10 --master_port=29500 \train.py --config configs/base.yaml# Secondary nodetorchrun --nnodes=2 --node_rank=1 --nproc_per_node=8 \--master_addr=10.0.0.10 --master_port=29500 \train.py --config configs/base.yaml
If your domestic framework uses its own launcher, replace torchrun with the corresponding launch command, but keep the meaning of the parameters the same. Pass criteria: all ranks join the communication group normally, loss synchronization works correctly, and there is no hang.
5. Long-Run Stability Validation
Goal: run continuously for several hundred steps and observe loss, throughput, memory, and communication stability.
torchrun --nnodes=2 --node_rank=0 --nproc_per_node=8 \--master_addr=10.0.0.10 --master_port=29500 \train.py --steps 400 --checkpoint-every 50 --metrics metrics_400.jsonl
Risk note: a long run may be interrupted by memory fragmentation, communication timeouts, excessive log volume, or numerical anomalies. I recommend saving checkpoints in advance, limiting the log level, and enabling timeout alerts.
6. Convergence Alignment
Goal: compare training metrics against a reference baseline to confirm that the numerical behavior meets expectations.
python compare_metrics.py \--candidate metrics_400.jsonl \--baseline baseline.jsonl \--tol-loss=1e-3 \--tol-grad=1e-2
Pass criteria: key metrics such as loss, gradient norm, throughput, and peak memory stay within the allowed deviation.
Key Optimization Practices
Once the pipeline is stable, you can improve efficiency from the following directions. Note that each optimization has applicability conditions and side effects, so do not enable them blindly.
- Communication-computation overlap: Overlap gradient communication with backpropagation to reduce bubble time. Suited to scenarios with ample bandwidth and a sensible model partition; if scheduled poorly, it can increase memory pressure.
- Mixed-precision tuning: Choose precision modes such as BF16 and FP16 appropriately. FP16 usually requires loss scaling, otherwise it tends to overflow; BF16 is more stable, but its throughput gains depend on hardware support.
- Memory optimization: Reduce memory pressure via activation recomputation, optimizer state sharding, gradient accumulation, and similar techniques. Activation recomputation reduces memory but increases compute time.
- Combining parallelism strategies: Combine data parallelism, tensor parallelism, and pipeline parallelism based on model size and interconnect bandwidth. Tensor parallelism suits high-bandwidth intra-machine interconnects; pipeline parallelism suits cross-machine scenarios, but you need to watch bubble overhead and scheduling complexity.
- Building observability: Wire up logging, metrics, monitoring, and alerting. Continuously collecting loss, throughput, memory, communication time, device temperature, and per-step time helps quickly locate anomalies in long runs.
In engineering environments, container platforms, object storage, monitoring and alerting, and log services are optional but recommended capability components. They are not requirements unique to domestic compute, but they can substantially lower the cost of environment reproducibility, data management, and long-run troubleshooting.
Troubleshooting Common Issues
| Symptom | Possible cause | Troubleshooting direction |
|---|---|---|
| Compilation or startup failure | Missing operators, version mismatch | Check the operator list, runtime version, and dependency versions |
| Training hangs with no progress | Inconsistent communication groups, divergent code branches | Align logs across ranks; check process stacks and the order of group creation |
| Loss does not decrease | Corrupted data, gradients not synced, abnormal learning rate | Validate the data pipeline, AllReduce, and optimizer updates |
| Out of memory | Batch too large, memory fragmentation, no activation recomputation | Adjust batch size, enable recomputation, monitor peak memory |
| Numerical anomaly after long runs | Accumulated precision error, improper mixed-precision scaling | Switch precision mode, check loss scaling, compare against baseline |
| One node has notably lower throughput | Network congestion, slow storage, process contention | Check the network, storage, log timestamps, and process state |
Long-Tail Quick Reference
Where do domestic accelerators mainly differ from the mainstream ecosystem?
The differences usually cluster around operator coverage, communication-library behavior, mixed-precision details, performance-profiling tools, and debugging interfaces. The mainstream ecosystem has more mature tooling, so domestic environments tend to rely more on vendor tools and self-built check scripts.
How should you choose a parallelism strategy for a dual-node multi-GPU setup?
If the model fits on a single card and communication bandwidth is sufficient, prefer data parallelism; only when the model is too large to fit on one card should you consider tensor or pipeline parallelism. When inter-node bandwidth is limited, minimize the frequency of cross-node gradient synchronization, or use coarser-grained partitioning.
How should you diagnose a startup failure?
First look at the process exit code, then at the first error in the logs. If it reports a missing operator, go back to the operator list; if it reports a communication-init failure, check the master address, port, rank IDs, and network connectivity; if it reports the device is not visible, check the driver, permissions, and container device mounts.
How should you investigate a loss that does not decrease?
First confirm that the data and labels are correct, then confirm that gradients are synchronized, and finally check the learning rate, optimizer, and precision mode. You can compare single-card short-step training against multi-card training to determine whether the problem was introduced by distribution.
Conclusion
Getting a large-model distributed training pipeline running on domestic compute is a typical hardware-software co-engineering effort. Its core is not a single-point performance sprint, but keeping the four main threads — data, compute, communication, and optimization — consistent and stable in a multi-node, multi-GPU environment. With “running continuously for several hundred steps” as the validation goal, teams can systematically surface problems in operator adaptation, collective communication, framework migration, and numerical stability.
For developers advancing self-developed compute, mastering a reproducible check workflow, minimal configuration examples, clear metric criteria, and troubleshooting methods delivers more long-term value than chasing hardware specs alone. Once the pipeline is stable, later scale-up, efficiency optimization, and model iteration all have a reliable foundation.
