Unlocking Large Model Training on Domestic GPUs: A 400-Step Stability Practice

    This article walks through the practical process of validating a large model pretraining pipeline on domestic accelerator cards, using a 400-step continuous run across two nodes and 16 cards as the key milestone. It covers building a reproducible software stack baseline, node-level connectivity checks, choosing a two-dimensional parallel strategy that balances memory and communication, overlapping communication with computation, maintaining numerical stability over long runs, and setting up observability and fault tolerance. A final acceptance checklist is included to help teams turn a one-off successful run into a reusable migration methodology.

    1. Why 400 Steps Is the Key Milestone for Domestic Compute Migration

    When migrating large model pretraining to domestic accelerator cards, the hardest problem is usually not whether the hardware can compute, but whether it can keep computing continuously and reliably. A full pipeline validation is typically broken into three progressive goals: getting the forward and backward passes working on a single card; completing gradient synchronization across multiple cards on one node via collective communication; and running hundreds of iterations without interruption at a real data-parallel scale across multiple nodes. Completing 400 consecutive iterations on two nodes with 16 cards covers the third goal, which means device initialization, memory allocation, communication topology, the data pipeline, optimizer state updates, and checkpoint saving and restoration are all closed-loop.

    The emphasis on step count rather than elapsed time is deliberate, because step count is a comparable metric that is independent of hardware. Four hundred steps are enough to expose most engineering issues: memory fragmentation starts accumulating around step 100; the interaction between learning rate warmup and gradient clipping shows up after tens of steps; the data loader’s prefetch queue may start jittering during long runs; and collective communication over the inter-node link will reveal bandwidth and latency bottlenecks. “It runs” for a few dozen steps and “it is stable” over hundreds of steps are two entirely different levels of engineering maturity.

    2. Environment Setup: Reducing Uncertainty to the Minimum

    The first step of any migration is to establish a reproducible software stack baseline. It is recommended to freeze the driver, runtime, communication library, math library, and framework versions into an image, and to avoid binary combinations from unknown sources. All dependency versions must be pinned, with no floating ranges allowed; otherwise the same code may hit different operator implementations on different nodes.

    1. # Example: build a reproducible environment image with fixed versions
    2. FROM base-runtime:fixed
    3. RUN pip install --no-cache-dir \
    4. framework==x.y.z \
    5. collective-comm==a.b.c \
    6. math-kernel==m.n.o
    7. COPY train.py /workspace/
    8. CMD ["python", "/workspace/train.py", "--steps", "400"]

    At the node level, three things need to be confirmed: the device visibility topology, hostname resolution, and clock synchronization between nodes. The device topology determines how the parallel strategy is split later; hostname resolution errors can cause the initialization phase to hang for a long time; and clock drift makes log timing inconsistent and fault localization difficult. Before the formal training run, it is recommended to perform a small-scale connectivity self-check, using a minimal collective communication operation to verify that full interconnectivity holds.

    3. Parallel Strategy: A Two-Dimensional Trade-off Between Memory and Communication

    A two-node, 16-card parallel configuration is usually not a single dimension, but a combination of data parallelism and model parallelism (tensor splitting and pipeline splitting). There are only two constraints for the choice: whether the model state fits in a single card’s memory, and whether the inter-node link can handle the corresponding communication volume.

    The communication volume of data parallelism is proportional to the model parameter count, and it suits scenarios where the model state fits in a single card. Tensor splitting cuts the weights of a single layer across multiple cards; communication is frequent and sensitive to bandwidth, so it is usually confined to the high-bandwidth interconnect inside a single node. Pipeline splitting cuts by layer; communication volume is small, but it introduces bubbles, so the number of stages needs to be divided reasonably.

    1. # Example: pseudocode for a two-dimensional parallel configuration
    2. parallel_config = {
    3. "data_parallel_size": 8, # inter-node dimension, carries the global batch
    4. "tensor_parallel_size": 2, # intra-node dimension, carries single-layer splitting
    5. "pipeline_stage": 1, # more stages make bubbles more obvious
    6. "micro_batch": 2,
    7. "grad_accum_steps": 4,
    8. }
    9. # global batch = micro_batch * grad_accum_steps * data_parallel_size

    It is worth stressing that the global batch is determined by all three factors together, and adjusting any dimension requires recalculating the effective batch size and its match with the learning rate. A common mistake in practice is changing only the parallel degree without changing the learning rate, which causes abnormal jitter in the loss curve.

    4. Overlapping Communication and Computation: Hiding the Waiting Time

    The performance ceiling of cross-node training is often determined by communication. The core idea of optimization is to overlap communication with computation on the timeline instead of waiting serially. Practical measures include: bucketing gradients and launching reductions bucket by bucket, where the bucket size must match the link bandwidth (too small means startup overhead dominates, too large means the overlap window is insufficient); triggering communication in the order layers become ready during backpropagation, rather than waiting for all gradients to be computed; and fusing element-wise operators where possible to reduce kernel launch counts and intermediate memory usage.

    When diagnosing communication bottlenecks, it is recommended to collect three types of metrics at the same time: per-step time, the share of communication time, and effective link bandwidth. If the communication share stays above 30% over time, prioritize adjusting the parallel split rather than continuing to fine-tune hyperparameters.

    5. Numerical Stability: The Key to Surviving Long Runs

    The most common failure mode over 400 consecutive iterations is the loss becoming non-numeric. The recommended troubleshooting order is: confirm whether the mixed-precision scaling strategy covers the entire backward path; check the numerical range at normalization layers and residual connections; verify whether the optimizer state needs a high-precision copy under low precision; and only then suspect abnormal samples on the data side.

    1. # Example: stability guards in the training loop
    2. for step in range(total_steps):
    3. with autocast(dtype=bfloat16):
    4. loss = model(batch) / grad_accum_steps
    5. loss.backward()
    6. if (step + 1) % grad_accum_steps == 0:
    7. clip_grad_norm_(model.parameters(), max_norm=1.0)
    8. optimizer.step()
    9. optimizer.zero_grad(set_to_none=True)
    10. if not isfinite(loss):
    11. skip_step_and_log(step) # skip the abnormal step and log it instead of aborting

    In engineering practice, “skip and log” is preferred over “exit immediately”, because it collects enough abnormal samples in a single long run for later localization.

    6. Observability and Fault Tolerance: Keeping Long Runs Under Control

    Long training runs must be paired with a complete observability system. On the metrics side, at least throughput, memory usage, per-stage time, and communication volume should be covered; on the logging side, output needs to be structured so it can be aggregated and analyzed by step number; on the alerting side, thresholds should be set for abnormal loss, memory approaching its limit, and sudden spikes in per-step time. The checkpoint strategy should save at fixed step intervals and retain the optimizer state and data loader progress, so that any interruption can be resumed.

    The way to verify fault tolerance is to deliberately terminate one process midway through training and observe whether the job can recover from the latest checkpoint with a continuous loss curve. This step is often skipped, but it is the dividing line for whether a long run can be delivered.

    7. Acceptance Checklist

    • Environment image versions are pinned, and the node connectivity self-check passes;
    • The parallel configuration is consistent with the global batch and learning rate;
    • Communication and computation overlap is in effect, and the communication share is within a reasonable range;
    • 400 consecutive steps run without interruption, the loss decreases monotonically, and there are no abnormal spikes;
    • Checkpoints are recoverable, and the curve is continuous after recovery;
    • Metrics, logs, and alerts are all in place.

    After completing the above validation, what the team gains is not a one-off run result, but a reusable migration methodology: when switching model structures, parallel scales, or cluster topologies, only the configuration and baseline need to be replaced, while the validation process itself stays unchanged. This is the practical path for domestic compute to move from “it runs” to “it is deliverable”.