Getting Large Model Training Working on Domestic GPUs: A Practical Guide

    This article walks through the practical work of establishing a stable end-to-end training pipeline for large models on domestic GPU accelerators. It explains why pipeline closure matters more than raw speed, how to pin down a version matrix, how to allocate memory and communication budgets across parallelism strategies, and how to configure mixed precision for numerical stability. It also covers observability, common failure patterns, and a recommended order for performance tuning.

    1. Why Getting the Pipeline Working Matters More Than Speed

    When pretraining large models on domestic accelerator cards, the first obstacle engineering teams face is usually not a lack of compute, but whether the pipeline closes end to end. Pipeline closure means the entire path—data loading, operator computation, gradient synchronization, optimizer updates, and checkpoint saving and restoration—runs stably on the target hardware without precision anomalies, communication interruptions, or out-of-memory errors. Only when training can run continuously for four hundred or even a thousand steps, with a smoothly decreasing loss curve and consistent state after resuming, is there a solid basis for further performance optimization.

    The value of a working pipeline shows up in three areas: first, it validates software stack compatibility, including the mutual compatibility of drivers, runtime, communication libraries, and framework versions; second, it validates numerical correctness, confirming that mixed precision produces no overflow or silent errors; third, it establishes an observability baseline to compare against when scaling to more nodes later.

    2. Environment Setup: Reducing Uncertainty to a Version Matrix

    Version drift is the most common pitfall in adaptation projects. It is advisable to fix the OS kernel, driver, runtime, collective communication library, framework, and dependency libraries into a single version matrix and keep it consistent across all nodes. A version difference on any single node can surface as a subtle problem where short runs succeed but long runs hang.

    1. # Example: consistency check (pseudocode, conveys the idea only)
    2. for host in $(cat hosts.txt); do
    3. ssh $host "collect_versions" >> versions.log
    4. done
    5. sort versions.log | uniq -c # expect each entry count to equal the number of nodes

    An environment self-check step is also needed: inter-card interconnect bandwidth, point-to-point communication, all-reduce and broadcast in collective communication, and single-card compute benchmarks should all be validated at small scale first, so that hardware or link issues are not mistaken for model code issues.

    3. Parallelism Strategy: Allocating Memory and Communication Budgets

    At a scale of two nodes and sixteen cards, memory capacity and inter-card bandwidth are two hard constraints. A common approach is to use data parallelism for throughput scaling, tensor parallelism to split matrix computation within a single layer, pipeline parallelism to split inter-layer dependencies, and parameter sharding schemes when necessary to reduce optimizer state usage. One principle guides the choice: place the splits with the largest communication volume within the highest-bandwidth domain, and keep only dimensions with relatively controllable communication across nodes.

    A practical decision order is: first estimate total memory usage for weights, gradients, optimizer states, and activations; then decide whether recomputation is needed to trade compute for memory; finally, choose the parallelism combination based on measured bandwidth. Avoid copying parallelism configurations from other hardware directly—differences in inter-card interconnect topology can make the same configuration perform very differently.

    4. Mixed Precision and Numerical Stability

    Mixed precision is a standard configuration for long-pipeline training, but it needs accompanying loss scaling and numerical clipping strategies. In practice: keep higher precision for normalization layers and loss computation; apply global gradient norm clipping to suppress abnormal steps; enable anomaly detection that records the step number and parameter shard when overflow occurs, making it easier to locate issues quickly.

    1. # Example: training step skeleton
    2. for step, batch in enumerate(loader):
    3. with autocast():
    4. loss = model(batch) / grad_accum
    5. loss.backward()
    6. clip_grad_norm_(model.parameters(), max_norm=1.0)
    7. optimizer.step(); optimizer.zero_grad()
    8. if step % 50 == 0:
    9. log(step, loss, lr, mem, tps) # log throughput and memory
    10. if step % 200 == 0:
    11. save_checkpoint(step) # support resuming from checkpoint

    5. Stability and Observability

    Long-pipeline training must treat monitoring as a first-class concern. It is advisable to collect four categories of metrics: throughput (samples per second), peak memory, communication time share, and per-node temperature and throttling. A combination of logging services and monitoring alerts can carry these metrics, allowing a slowdown on a single card to be detected within minutes. Checkpoints should be saved asynchronously with multiple historical versions retained; when resuming, verify that optimizer state and random number state are complete to avoid hard-to-trace problems such as loss jumps.

    6. Common Failures and Diagnosis Paths

    • Hanging on a collective communication call: usually a process on some node exited abnormally or there is network jitter; check process liveness and link quality first.
    • Out of memory: first adjust the recomputation scope and batch size, then consider increasing parallelism.
    • Continuously declining throughput: investigate throttling, cooling, and background processes competing for resources.
    • Abnormal curve after resuming: check checkpoint integrity and data loading order.

    Performance optimization should happen only after the pipeline is stable, in this order: establish baseline throughput, optimize data loading and preprocessing, adjust parallelism and recomputation, and finally fine-tune communication and computation overlap. Change only one variable per round and keep comparison records, avoiding simultaneous multi-variable changes that make attribution impossible. If scaling to a larger scale is needed later, container platforms and object storage can be combined to handle image distribution and dataset version management, making experiments reproducible.