Practical Guide to Training Large Models on Domestic GPUs: From First Steps to a 400-Step Milestone

    This article explains how to bring up a stable large-model training pipeline on domestic GPU accelerators, using the completion of 400 consecutive iterations as the practical milestone. It covers why that threshold matters, how to inspect hardware and interconnect topology before tuning, how to balance data, tensor, and pipeline parallelism, and how to move from compilable operators to numerically correct results. It also outlines a troubleshooting order for loss spikes and gradient explosions, the observability and fault-tolerance baseline needed for long runs, and three metrics for evaluating performance. The goal is a reproducible, operable engineering workflow rather than anecdotal speedups.

    1. Why “400 Steps Completed” Is a Meaningful Milestone

    In large-scale pretraining engineering, the hard part is rarely writing the training script. It is keeping the entire pipeline running stably on real hardware. The industry generally treats “several hundred consecutive iterations with normal metrics” as the sign that a pipeline is working, for three reasons:

    1. The first few dozen steps only prove the program does not crash. They do not expose chronic problems such as memory fragmentation, communication jitter, or abnormal gradients.
    2. The learning rate schedule usually finishes warmup within the first few hundred steps. Only after passing the warmup window can you tell whether the loss is decreasing as expected.
    3. Peripheral systems such as checkpoint saving and restoration, log sampling, and metrics collection need a long enough running window to be genuinely stress-tested.

    So 400 is not an arbitrary number. It is the smallest credible sample that covers the full cycle of startup, warmup, stabilization, and writing to storage.

    2. Hardware and Interconnect: Confirm the Bandwidth Topology Before Discussing Parallelism

    Two nodes with sixteen cards means eight cards per node plus one cross-node aggregation. The first practical step is not tuning hyperparameters but mapping the topology:

    • Whether intra-node card-to-card links are high bandwidth, and whether traffic detours across chip groups.
    • Whether the inter-node network is a dedicated high-speed network, isolated from business traffic.
    • Differences in memory capacity and usable bandwidth per card, which set the upper limit on sharding granularity.

    A common mistake is launching with the default parallel configuration, which leaves cross-node communication dominant and GPUs waiting most of the time. The test is simple: if communication wait is clearly visible in per-step time, adjust the parallel sharding first to reduce the number of cross-node exchanges, rather than changing the batch size.

    3. Parallel Strategy: Balancing Data, Tensor, and Pipeline Parallelism

    Combining parallelism for large-model training is essentially trading communication for memory. General guidance:

    • Data parallelism: shards the batch; communication grows linearly with parameter count, so it suits high intra-node bandwidth.
    • Tensor parallelism: shards individual layer matrices; communication is frequent and latency-sensitive, so keep it within a node where possible.
    • Pipeline parallelism: shards layers; little cross-node communication but pipeline bubbles, so the number of micro-batches must be set sensibly.
    • Sequence parallelism and recomputation: trade compute for memory to relieve activation pressure.

    The recommended layering principle is heavy sharding inside a node and light sharding across nodes. Illustrative configuration sketch (not product-specific values):

    1. # Pseudocode: hierarchical mapping of parallel dimensions
    2. parallel_plan = {
    3. "tensor_parallel_size": 8, # confined within a single node
    4. "pipeline_parallel_size": 2, # across nodes, reduces communication frequency
    5. "data_parallel_size": 1, # remaining cards derived automatically
    6. "micro_batch_num": 8, # more micro-batches to shrink pipeline bubbles
    7. "recompute_layers": "half", # enable partial recomputation when memory is tight
    8. }

    4. Operator and Framework Adaptation: From “It Compiles” to “The Numbers Are Correct”

    Bringing up the pipeline on domestic accelerators concentrates the work at the operator layer. A four-step approach:

    1. Precision alignment: on a small-scale configuration, compare the loss curve against a widely used reference implementation of the same model. Minor last-digit differences are acceptable, but the trend must match.
    2. Operator coverage: replace custom operators with equivalent combinations of standard operators. Get it running first, then optimize.
    3. Mixed-precision strategy: confirm that loss scaling, normalization layers, and softmax are computed in higher precision.
    4. Determinism switches: fix random seeds and data order so problems are reproducible.

    One point deserves emphasis: any claim about a card-exclusive acceleration feature should be verified before it is trusted. Engineering accepts only reproducible measurements.

    5. Numerical Stability: A Troubleshooting Order for Loss Spikes and Gradient Explosions

    Loss spikes within 400 steps are normal. Recommended order, from the outside in:

    • Data first: are there over-long samples, empty samples, or out-of-range labels?
    • Learning rate next: are the warmup length and peak value too aggressive?
    • Gradients after that: is the global gradient norm clipped, and is the threshold reasonable?
    • Numerics last: do normalization and attention overflow in low precision?

    Pair this with monitoring alerts and a log service. Turn gradient norm, parameter update magnitude, and memory usage into time-series curves, and the time to locate a spike typically drops by an order of magnitude.

    6. Observability and Fault Tolerance: Making Long Runs Operable

    Bringing up the pipeline is only the start. Whether it can run for a long time depends on the engineering baseline. The minimum viable set includes structured logs, metrics collection with dashboards, automatic state dumps on exceptions, and periodic checkpoint saving with verified resume-from-checkpoint. Resume must be tested for real: after saving, deliberately kill the process, then restore from the checkpoint and confirm that data progress and optimizer state match. Otherwise a single failure can waste dozens of hours of compute. If a container platform handles scheduling, also confirm that node affinity and storage mounts stay consistent after a restart.

    7. Performance Evaluation: Three Metrics Instead of “It Feels Faster”

    • Per-step time (median, after excluding first-step compilation and warmup overhead).
    • Compute utilization (actual throughput as a ratio of theoretical peak).
    • Scaling efficiency (throughput gain when the card count doubles).

    Conclusions hold only under a fixed model, fixed data, and fixed parallel configuration for side-by-side comparison. Any speedup quoted without its configuration has little reference value.

    8. Implementation Checklist

    1. Verify numerical correctness at small scale before scaling up.
    2. Follow heavy intra-node and light inter-node sharding.
    3. Treat observability as a deliverable, not an add-on.
    4. Attach the configuration and reproduction steps to every performance claim.
    5. When validating on platforms such as Baidu AI Cloud, object storage can hold the dataset, a container platform can handle scheduling, and monitoring, alerting, and log services can carry observability, forming a complete engineering loop.