Bringing Large Model Training Up on Domestic Accelerators: A Dual-Node, 16-Card Walkthrough

    A practical, engineering-focused guide to standing up a stable large language model training pipeline on domestic AI accelerator cards. It covers the most common blockers (operator gaps, collective communication behavior, memory pressure, numerical stability), a step-by-step strategy for layering parallelism from data parallel up to tensor, pipeline, and sequence parallelism, mixed-precision and memory-saving choices, the distributed environment variables that define the process world, cross-node communication optimizations, and the concrete checks that make a multi-hundred-step run meaningful as a stability signal. Readers will come away with a repeatable validation path, reference-parity testing advice, and an observability and recovery baseline for long-running jobs.

    1. Why “Getting the Training Loop Running” Is the First Gate for Domestic Compute

    When you train a large language model on a domestic AI accelerator platform, the hard part is usually not writing the model architecture. It is getting the full chain — data loading, forward pass, backward pass, gradient synchronization, optimizer step, checkpoint save — to run end to end and stay stable.

    The industry calls this stage “getting the training loop working.” It means that on the target hardware the model can start from a fresh initialization, the loss decreases normally, and you see no NaNs, no collective communication deadlock, no out-of-memory errors, and the ability to keep iterating up to the expected number of steps.

    Take a representative example: a continuous 400-step run across 16 cards on two nodes. This is not a throughput benchmark chasing peak performance. It is an engineering feasibility check. It demonstrates that the software stack, hardware drivers, communication library, parallelism strategy, and optimizer logic are internally consistent as a closed loop. Only when training stays numerically sound across hundreds of steps can you be confident about moving on to long-duration, large-scale pretraining.

    2. Core Challenges in the Training Loop

    Domestic hardware differs from a native data center environment, so bringing the loop up typically hits a few recurring classes of problems:

    • Operator coverage and precision differences: Some fused operators, attention operators, and normalization operators used by the model may be missing on domestic cards or behave differently. The forward result then deviates slightly from the reference implementation, and the error accumulates into non-convergence.
    • Collective communication behavior differences: Multi-node, multi-card training relies on primitives such as All-Reduce, All-Gather, and Reduce-Scatter. Domestic communication libraries can show performance jitter or occasional hangs under high-bandwidth topologies and cross-node RDMA.
    • Memory and host-memory management: Model weights, gradients, optimizer states, and activations all compete for device memory. Different usable memory sizes and defragmentation strategies on domestic cards make OOM easy to trigger.
    • Numerical stability: Mishandled loss scaling under mixed precision, accumulation precision in LayerNorm, or the numeric range of softmax can cause gradient explosion or a loss that suddenly becomes NaN.

    3. Parallelism Strategy: Start Simple, Add Complexity Incrementally

    Large model training usually combines several forms of parallelism. On a domestic platform, the recommended path is “get it running first, then make it fast”:

    1. Data parallelism (DP): Each card holds a full model replica and takes a slice of the batch, kept consistent through gradient synchronization. This is the simplest starting point for bringing up the loop.
    2. Tensor parallelism (TP): Splits the weight matrices of a single layer across cards. It suits high-bandwidth intra-node interconnect and reduces per-card memory pressure.
    3. Pipeline parallelism (PP): Splits the model across devices layer by layer, which requires careful micro-batch scheduling and attention to bubble overhead.
    4. Sequence / context parallelism: Partitions activations for long-sequence workloads, easing the memory growth in the attention part of the model.

    The practical recommendation is to first verify numerical correctness of the forward pass, backward pass, and optimizer on a single card or single node, then add parallelism dimensions one at a time. Every time you add a dimension, re-align the loss curve and confirm that the split itself has not introduced numerical drift.

    4. Mixed Precision and Memory Optimization

    Mixed-precision training (FP16/BF16 compute with FP32 master weights) is how you balance memory against throughput. On domestic cards, a few points deserve particular attention:

    • Prefer BF16: Compared with FP16, BF16 has a much wider dynamic range, needs no complex loss scaling, and is numerically more stable, which significantly reduces the risk of NaNs.
    • Optimizer state sharding: Sharding optimizer state across the data-parallel group can cut per-card memory use by a multiple. This is a common practice for long-context, large-batch training.
    • Activation recomputation: Trading compute for memory — dropping some activations in the forward pass and recomputing them in the backward pass — is an effective way to relieve OOM.

    A generic mixed-precision and parallelism configuration sketch (not tied to a specific product, shown only to illustrate the shape of the setup):

    1. # Parallelism sketch
    2. parallel:
    3. tensor_parallel_size: 2 # tensor parallel degree
    4. pipeline_parallel_size: 1 # pipeline parallel degree
    5. data_parallel_size: 8 # data parallel size = total cards / (TP * PP)
    6. precision:
    7. dtype: bfloat16 # prefer BF16, avoids complex loss scaling
    8. master_weights: float32 # keep FP32 master weights
    9. memory:
    10. optimizer_state_shard: true # shard optimizer state
    11. activation_recompute: true # recompute activations to relieve memory pressure
    12. checkpoint:
    13. save_interval_steps: 100 # save periodically for resume and recovery

    5. Key Variables in a Distributed Environment

    Launching multi-node, multi-card training depends on a standard set of environment variables that give processes a shared “world view.” Understanding them is the foundation of troubleshooting:

    1. # Core distributed training environment variables (common convention)
    2. export MASTER_ADDR=<master node address> # host running rank 0
    3. export MASTER_PORT=29500 # communication port
    4. export WORLD_SIZE=16 # total processes/cards in training
    5. export RANK=<global index of this process> # 0 ~ WORLD_SIZE-1
    6. export LOCAL_RANK=<index within the node> # 0 ~ (cards per node - 1) per node

    In a two-node, 16-card setup, each machine has 8 cards, so WORLD_SIZE=16, and the RANK values span 0–7 on one machine and 8–15 on the other. The launch script must ensure MASTER_ADDR and WORLD_SIZE are identical on every node; otherwise some processes will wait, time out on communication, or even deadlock. It is better to put node addresses, ports, and card counts into a single shared configuration file and have the scheduler distribute it, rather than filling values in by hand.

    6. Communication Optimization: Where Cross-Node Performance Is Decided

    In multi-node training the bottleneck is often communication rather than computation. Useful directions to optimize:

    • Overlap gradient communication with computation: Trigger gradient reduction asynchronously while the forward/backward compute is still running, hiding communication latency.
    • Hierarchical All-Reduce: Reduce within the node first, then across nodes, to cut pressure on cross-node bandwidth.
    • Gradient bucketing: Merge many small gradients into larger chunks for transfer, improving bandwidth utilization and lowering launch overhead.
    • Topology awareness: Keep tensor parallelism inside high-bandwidth intra-node links and let data parallelism span nodes, reducing dependence on slower links.

    When tuning, start by running a collective communication benchmark to establish the bandwidth and latency baseline of the target hardware, then set the parallel degrees and bucket sizes from that baseline instead of guessing.

    7. Training Stability: What the 400-Step Run Actually Proves

    Running continuously for hundreds of steps is an important stability signal. What to watch:

    1. Smooth loss decrease: The loss should converge overall. Small fluctuations are fine, but a sustained rise or a sudden jump to NaN is not.
    2. Controlled gradient norm: Monitor the global gradient norm. If it keeps climbing, enable gradient clipping; if it stays at 0, the backward path may be broken.
    3. Consistent loss across cards: Loss values within a data-parallel group should closely align. Divergence indicates a problem with gradient synchronization.
    4. No silent errors: Some operators on domestic cards can produce “silent” failures — no error raised, but wrong results. These need numerical parity checks against a reference implementation.

    Keep a small parity test suite: run the first few steps with the same random seed on a CPU or a known-good environment, compare loss and gradients layer by layer, and you can quickly localize where an operator-level deviation comes from.

    8. Monitoring, Troubleshooting, and Best Practices

    Once the loop is up, long-running training depends even more on good observability:

    • Metrics collection: Wire throughput, memory usage, communication time, loss, and learning rate into a logging service and an alerting system so anomalies trigger a notification promptly.
    • Checkpoints and resumable training: Periodically save the model, optimizer state, random number state, and the current step so that any node failure can be recovered from quickly instead of restarting from scratch.
    • Fault tolerance and elasticity: Combine with a containerized platform to automatically isolate failed nodes and reschedule the job, improving availability for large-scale training.
    • Version your data and environment: Keep complete records of dataset versions, code commits, dependency stacks, and driver versions so experiments stay reproducible.

    In a public cloud setting, object storage can hold datasets and checkpoints, the container platform handles orchestration and elastic scaling of training jobs, and the logging and monitoring stack handles metric observation — together forming an integrated “storage–compute–monitoring” training loop.

    9. Conclusion

    Getting large model training running on domestic accelerators is a systems engineering effort, not a single-point optimization. The right sequence is: first guarantee numerical correctness on a single card, then add parallelism dimensions; use BF16 mixed precision and memory sharding to buy stability and scale; unlock cross-node bandwidth through communication optimization; and finally close the engineering loop with several hundred stable iterations plus solid monitoring. A successful multi-hundred-step run on 16 cards across two nodes marks the point where domestic compute has the foundational capability to take on larger-scale training. For developers and enterprises, the real value lies in turning this methodology into a standardized process and an automated toolchain — that is what continuously lowers migration cost and accelerates large-scale adoption of domestic compute.