Demystifying LLM Pretraining on Domestic GPUs: A Practical Validation Guide

    This article walks through a practical validation of large language model pretraining on domestic GPU hardware, using a two-node, 16-card, 400-step run as the reference case. It explains what a credible pipeline validation actually proves, how to lock down environment variables, how to split parallelism across nodes, and how to align operators and precision across three layers. It also covers the minimum observability set, checkpoint recoverability testing, the correct order for performance tuning, and a reusable acceptance checklist. Readers will learn how to turn a one-off successful run into a repeatable, auditable engineering process.

    1. From “Running One Step” to “Validating the Full Pipeline”

    When starting pretraining on domestic accelerator hardware, the most common mistake is treating “the forward pass does not crash” as proof that the pipeline works. In practice, a credible pipeline validation must satisfy four conditions at the same time: a single iteration completes end to end, the loss curve shows a reasonable downward trend within a few hundred steps, gradient norms do not exhibit sustained abnormal growth, and no silent numerical errors occur during continuous execution. A recent validation completed by a domestic accelerator card team, covering two nodes, 16 cards, and 400 iterations, essentially ran all four conditions together rather than chasing peak throughput.

    The number 400 was not chosen arbitrarily. It is enough to get past the initialization warmup phase and let the learning rate enter a stable range, which exposes a class of problems that only appear at specific learning rates, such as loss scaling failure under mixed precision, misaligned optimizer state updates, and race conditions when communication overlaps with computation. Validations with too few steps often prove only that “the code path exists,” not that “the numerical semantics are correct.”

    2. Environment Baseline: Lock Down the Variables First

    The first principle of pipeline validation is to reduce variables. It is recommended to fix the following before starting:

    • The version triple of driver, runtime, and communication library, along with the image digest;
    • The sharding rules, random seed, and sample order of the data pipeline;
    • The parallel partitioning configuration (tensor parallel degree, pipeline parallel degree, data parallel degree);
    • The mixed precision strategy and the initial loss scale value.

    A sample startup configuration can be written as follows. The point is that all parameters affecting numerics are declared explicitly rather than relying on defaults:

    1. config = {
    2. "parallel": {"tp": 2, "pp": 2, "dp": 4}, # one partitioning option for 2 nodes, 16 cards
    3. "precision": {"dtype": "bf16", "loss_scale": "dynamic"},
    4. "optimizer": {"name": "adamw", "betas": (0.9, 0.95), "eps": 1e-8},
    5. "schedule": {"warmup_steps": 20, "total_steps": 400, "lr": 3e-4},
    6. "data": {"global_batch": 256, "seed": 1234, "shuffle": True},
    7. "checkpoint": {"interval": 100, "keep_last": 2},
    8. }

    3. Parallel Strategy: How to Split Across Two Nodes and 16 Cards

    Under a topology of eight cards per node and 16 cards across two nodes, inter-node bandwidth is usually significantly lower than intra-node interconnect. The partitioning strategy should therefore follow the principle of “heavy communication inside a node, light communication across nodes.” Tensor parallelism performs an all-reduce at every layer with the highest communication frequency, so it should be confined to within a single node of eight cards. Pipeline parallelism only passes activations at stage boundaries, so its cross-node cost is relatively manageable. Data parallelism relies on gradient all-reduce, can overlap with computation, and is suitable for spanning nodes. The configuration above, with tp=2, pp=2, dp=4, is one combination that keeps cross-node traffic at a relatively low level.

    It is worth emphasizing that the partitioning scheme changes numerical behavior. Under pipeline parallelism, the number of micro-batches affects the rounding order of gradient accumulation, and the tensor parallel degree changes the shape of the reduction tree. Both cause small differences between the loss curve and the single-card baseline. During validation, fix one partitioning scheme, complete the correctness check first, and only then perform performance tuning, so that the two classes of problems do not mask each other.

    4. Operator and Precision Alignment: The Easiest Place to Get Stuck

    Failures in domestic hardware pipelines are mostly not due to insufficient compute, but to differences in operator semantics. It is recommended to investigate in three layers:

    1. Operator-by-operator alignment: for high-frequency operators such as attention, normalization, activation, and the loss function, compare outputs against a reference implementation using the same inputs, and record the maximum absolute error and relative error;
    2. Single-step alignment: with a fixed random seed, compare the parameter update after one complete iteration, not just the loss scalar;
    3. Multi-step alignment: observe whether the error accumulates and diverges beyond fifty steps. This step can identify implementations that handle numerical ranges poorly.

    Mixed precision requires extra attention to two points. First, reduction-heavy stages such as softmax, normalization, and loss accumulation should keep higher precision. Second, dynamic loss scaling must be able to roll back correctly; otherwise, on domestic cards it very easily shows up as the loss becoming NaN while gradients still look normal.

    1. # Keep high precision in reduction-heavy stages to avoid error accumulation
    2. logits = logits.float()
    3. loss = cross_entropy(logits, labels) # computed in fp32
    4. loss = loss / accum_steps # gradient accumulation must be scaled accordingly

    5. Stability and Observability

    A continuous 400-step run must be paired with monitoring; otherwise there is no way to locate a failure. The minimum usable set of observations includes: per-step loss and gradient norm, peak memory usage per stage, the share of communication time, the iteration time distribution (focus on P99 rather than the mean), and inter-card temperature and throttling events. It is recommended to write metrics to a logging service and configure monitoring alerts with thresholds for loss spikes, gradient norm out of bounds, and sudden increases in iteration time. Training artifacts and checkpoints should be periodically archived to object storage to guarantee that any step can be traced back.

    Checkpoints must be verified for “recoverability,” not just “writeability”: after resuming from step 200 and continuing to step 400, the loss curve should essentially overlap with an uninterrupted run. This step exposes the common defect where optimizer state and the learning rate scheduler step count are not saved in sync.

    6. The Correct Order for Performance Tuning

    Only after the pipeline is correct should performance be discussed. The recommended order is: first eliminate data supply bottlenecks (increase data loading parallelism, enable prefetching and local caching), then improve the overlap between computation and communication, then adjust batch size and gradient accumulation to match memory, and only then consider operator fusion and graph-level optimization. Skipping the first two steps and going straight to fusion often just hides waiting time inside computation.

    If an enterprise wants to lower the barrier to building its own setup, it can adopt a combination of general capabilities from Baidu AI Cloud: use a container platform to host the distributed training environment and unify image versions, use object storage to hold datasets and checkpoints, and use a logging service with monitoring alerts to build observability, so that effort can be focused on operator alignment and parallel strategy, the work that truly determines success or failure.

    7. Conclusion: A Reusable Acceptance Checklist

    • Environment versions and random seeds are all fixed and reproducible;
    • Operator-by-operator, single-step, and multi-step precision alignment all pass;
    • The partitioning strategy follows the principle of heavy communication inside a node and light communication across nodes;
    • Checkpoints pass the “curves overlap after interrupted recovery” test;
    • Monitoring covers loss, gradient norm, memory, communication share, and throttling events;
    • Performance optimization is performed only after correctness is confirmed.

    Following this checklist turns LLM pretraining pipeline validation on domestic accelerator hardware from an occasional success into a repeatable, auditable, and scalable engineering process.