Practical Guide to Training Large Language Models on Domestic GPUs: A Dual-Node, 16-Card Setup

    This article walks through the engineering practice of running a complete large language model training pipeline on domestic general-purpose GPUs across two nodes with 16 cards, sustaining 400 stable iterations. It covers environment baselining, parallel strategy selection, memory and numerical precision handling, observability and fault localization, performance tuning, and cloud-based deployment, along with a final checklist for reproducible short-run stability.

    1. Background and Why the Full Pipeline Matters

    A notable engineering milestone has recently drawn attention in the industry: a domestic general-purpose GPU has run a complete training pipeline for a large-parameter language model at a scale of two nodes and 16 cards, sustaining 400 stable iteration steps. The value of this validation is not the benchmark score, but the fact that the long chain of “compute hardware, communication library, training framework, model structure” can be connected end to end.

    The engineering difficulty of large model training has never been a single point; it is the pipeline. A missing link in any stage shows up as the whole system being unusable:

    • Hardware: memory capacity, inter-card interconnect bandwidth, operator coverage.
    • System: topology awareness of the collective communication library, process launch and fault isolation.
    • Framework: parallel partitioning strategy, computation graph compilation, gradient accumulation and checkpointing.
    • Model: attention implementation, normalization placement, numerical stability.

    Four hundred steps is a meaningful number. It is not enough to demonstrate convergence quality, but it is enough to expose most pipeline-level problems. Initialization anomalies, communication deadlocks, memory fragmentation buildup, and numerical overflow typically surface within the first few hundred steps. That is why the industry generally treats “stable short-run completion” as the first threshold for domestic adaptation.

    2. Establishing the Environment Baseline

    Before starting, define the baseline clearly so that any later issue can be attributed.

    1. Hardware baseline: record the number of accelerator cards per node, memory capacity, inter-card interconnect method, and cross-node network bandwidth (whether it is a high-speed interconnect network).
    2. Software baseline: fix and record the driver version, communication library version, framework version, and the versions of the dependent compilation toolchain, all written into the image.
    3. Data baseline: fix the dataset snapshot and sampling order to guarantee reproducibility.
    4. Randomness baseline: fix the random seed and explicitly declare which operators are allowed to be non-deterministic.

    It is recommended to bake all version information into a container image and distribute it uniformly through a container platform, avoiding the most common low-level failure of “inconsistent environments across two machines.”

    1. # Example: archiving environment information for reproducibility and attribution
    2. {
    3. "node_num": 2,
    4. "device_per_node": 8,
    5. "global_batch": 512,
    6. "seq_len": 4096,
    7. "seed": 20260827,
    8. "precision": "bf16"
    9. }

    3. Parallel Strategy: How to Partition Across 16 Cards on Two Nodes

    The 16-card scale is a typical range that is “too large for a single node, yet far from a large cluster,” and the choice of parallel strategy directly determines success or failure.

    • Data parallelism: partitions the batch, communication volume grows linearly with parameter count, simplest to implement.
    • Tensor parallelism: partitions single-layer matrix multiplications, frequent communication, usually confined to the high-speed interconnect domain within a single node.
    • Pipeline parallelism: partitions layers across devices, low communication volume but with bubble overhead.
    • Sequence parallelism / context parallelism: partitions attention computation for long-sequence scenarios, reducing activation memory.

    A rule of thumb repeatedly validated in the industry: keep the most communication-intensive tensor parallelism within a single node, and leave cross-node bandwidth for data parallelism or pipeline parallelism. An example configuration:

    1. # Illustrative parallel configuration, not a specific product interface
    2. parallel = {
    3. "tensor_parallel_size": 8, # 8 cards within a single node
    4. "pipeline_parallel_size": 2, # across 2 machines
    5. "data_parallel_size": 1,
    6. }
    7. # Global device count = 8 * 2 * 1 = 16

    If the number of model layers is not divisible by the number of pipeline stages, you need to adjust the partition granularity or introduce layer reordering; otherwise load skew appears, where individual devices finish first and the rest wait idle.

    4. Memory and Numerical Precision

    The two most common blockers in domestic accelerator adaptation are insufficient memory and numerical instability.

    On the memory side, you can combine: mixed-precision weights and activations, gradient accumulation to reduce effective batch pressure, activation recomputation (trading compute for memory), optimizer state sharding, and offloading part of the state to host memory. Note that offloading introduces bandwidth overhead and should be a last resort.

    On the numerical side, prefer bf16 over fp16, as the former has a larger dynamic range and significantly reduces the tuning burden from loss scaling. At the same time, keep fp32 master weights and critical reduction paths:

    1. # Example: mixed precision and numerical stability essentials
    2. amp_cfg = {"dtype": "bf16", "master_weights": "fp32"}
    3. grad_cfg = {"clip_norm": 1.0, "accum_steps": 8}
    4. # Keep critical reductions (such as loss, norm) in fp32 to avoid overflow

    If the forward pass is normal but inf/nan appears in the backward pass, first investigate three places: the normalization implementation, the attention mask, and the boundary behavior of custom operators under high precision.

    5. Stability, Observability, and Fault Localization

    Whether 400 steps can complete uninterrupted depends on how well observability is built.

    • Metrics collection: record throughput, peak memory, per-stage timing, and gradient norm at every step.
    • Log service: centrally collect logs from all ranks and aggregate by rank, avoiding being flooded by output from a single node.
    • Monitoring and alerting: set threshold alerts for sharp throughput drops, continuous memory growth, and abnormal single-card temperature.
    • Checkpoints: asynchronously flush to object storage at fixed step intervals, keeping the most recent several plus one long-term archive.

    The recommended localization order is: first confirm whether all ranks fail to synchronize (a communication problem), then check whether a single rank is abnormal (a data or operator problem), and finally inspect storage and network jitter. For hang-type problems, use collective communication operations with timeouts to expose them quickly rather than waiting indefinitely.

    1. # Example: minimal observability instrumentation in the training loop
    2. every step:
    3. log(step, loss, grad_norm, tokens_per_sec, mem_peak)
    4. if step % save_every == 0: async_save_checkpoint()
    5. if grad_norm is nan: dump_rank_state_and_abort()

    6. Performance Tuning Essentials

    Only after the pipeline runs end to end should you talk about efficiency optimization, in this suggested order:

    1. Eliminate data supply bottlenecks: increase prefetching, use efficient data formats, and move preprocessing to an offline stage.
    2. Improve operator efficiency: ensure attention and normalization use efficient implementations, reducing unnecessary data movement and format conversions.
    3. Overlap communication and computation: let gradient reduction proceed in parallel with backward computation.
    4. Tune batch and sequence length: increase throughput within memory limits rather than blindly enlarging the batch.
    5. Graph compilation and fusion: reduce interpretation overhead and the number of kernel launches.

    For evaluation, use “effective tokens per second per card” and “scaling efficiency” as the core metrics. The former measures absolute efficiency, while the latter measures linearity from eight cards to sixteen cards.

    7. Engineering Deployment in the Cloud

    If you move the above process into a cloud environment, you can reduce operational burden with general cloud product capabilities: distribute images and scale elastically through a container platform, store checkpoints and datasets in object storage, build an observability system with log services and monitoring alerts, and obtain stable interconnect through high-speed networks and virtualized instances. Baidu AI Cloud provides general capabilities in heterogeneous compute resource scheduling, training task orchestration, and full-pipeline observability, helping teams focus their energy on the model and algorithms themselves rather than environment adaptation.

    8. Conclusion and Checklist

    Validating a large model training pipeline on domestic accelerator cards is essentially a test of systems engineering capability. When putting it into practice, check against the following list:

    • Are versions and images fully fixed?
    • Does the parallel partition follow the principle of “dense communication stays within a single node”?
    • Is bf16 preferred with fp32 master weights retained?
    • Are checkpoints saved asynchronously and offsite?
    • Are rank-level logs and threshold alerts in place?
    • Is scaling efficiency, rather than a single-point benchmark, the optimization goal?

    Following this path, stable short-run training at the dual-node, 16-card scale can be fully reproduced, laying a reliable foundation for further scaling to larger scales.