Practices for Running Large Model Training Pipelines on Domestic GPUs

    This article walks through the engineering practice of validating a complete large model training pipeline on domestic GPU accelerators before chasing peak throughput. It explains why completing several hundred stable iterations on a two-node, sixteen-card setup surfaces most environment-level issues, how to pin a reproducible version matrix, how to split tensor, data, pipeline, and sequence parallelism across nodes, and what minimal observability and checkpointing practices make failures diagnosable. It also lists common failure modes with a recommended triage order and a data-first, parallelism-second, operators-last tuning path for scaling up and migrating to domestic hardware.

    1. Why Getting the Pipeline Working Matters More Than Raw Speed

    In large-scale pretraining engineering, the first step when bringing up a new hardware platform is usually not chasing peak throughput but getting the full training pipeline to run end to end. “Running end to end” means completing several hundred consecutive iterations under limited resources with a smoothly decreasing loss curve, no gradient anomalies, no silent process exits, and no stalled collective communication. Take 400 iterations on two nodes with sixteen cards as an example: this scale is enough to expose most environment-level problems, such as driver and runtime version mismatches, fallback paths triggered by missing operators, incorrect cross-node network topology detection, numerical overflow under mixed precision, and incomplete checkpoint writes.

    The value of pipeline validation is turning “unreproducible intermittent failures” into engineering problems that can be located, reproduced, and fixed. Once 400 steps pass stably, scaling up card counts, increasing the global batch size, and extending training duration all have a reliable baseline.

    2. Environment Setup: Narrowing Uncertainty to a Version Matrix

    The software stack for domestic accelerators typically consists of a driver, runtime, communication library, operator library, and framework adaptation layer, and version drift in any layer can trigger errors that are hard to read. The recommended approach is to fix a version matrix first, then distribute it uniformly through a container platform, avoiding the differences caused by manual installation on each machine.

    1. # Example: record key versions to form a reproducible baseline
    2. accelerator-smi --version # driver and runtime versions
    3. python -c "import torch;print(torch.__version__, torch.cuda.is_available())"
    4. python -c "import torch;print(torch.cuda.device_count())" # expected output: 8

    Three things need close verification. First, device visibility: a single node should enumerate all accelerators. Second, the collective communication library should recognize both intra-node interconnects and inter-node NICs, avoiding a fallback to inefficient paths. Third, the framework’s operator coverage should be checked, with a clear fallback strategy and alerts for missing operators rather than silent degradation.

    3. Parallelism Strategy: How to Split Two Nodes and Sixteen Cards

    With a topology of two nodes of eight cards each, a common split is tensor parallelism inside a node and data parallelism across nodes, optionally combined with pipeline parallelism and sequence parallelism to support long contexts. Tensor parallelism involves heavy communication and must be confined to a high-bandwidth domain; data parallelism performs gradient synchronization across nodes and is sensitive to NICs and topology.

    1. # Example: parallel dimension configuration
    2. parallel = dict(
    3. tensor_parallel_size=8, # confined to the intra-node high-bandwidth domain
    4. pipeline_parallel_size=1, # leave off during small-scale validation
    5. data_parallel_size=2, # cross-node gradient synchronization
    6. sequence_parallel=True, # reduce activation memory for long sequences
    7. )
    8. global_batch = micro_batch * grad_accum_steps * data_parallel_size

    During the 400-step validation phase, it is best to disable pipeline parallelism and all forms of recomputation to keep the number of variables minimal. Once the loss curve and memory usage are stable, enable them one at a time and compare throughput and memory watermarks. The global batch size should not be too large, or numerical behavior and convergence trends become hard to judge.

    4. Stability and Observability: Make Failures Leave Evidence

    Long training runs fear “exits without logs” most. In engineering terms, logging services and monitoring alerts should be integrated into the training flow, collecting per-step loss, gradient norm, learning rate, peak memory, per-step time, and the share of communication wait time. When per-step time suddenly rises while the compute volume stays the same, the bottleneck is usually on the communication or storage side.

    1. # Example: minimal observability set in the training loop
    2. for step, batch in enumerate(loader):
    3. loss = model(batch)
    4. loss.backward()
    5. clip_grad_norm_(model.parameters(), 1.0)
    6. optimizer.step(); optimizer.zero_grad()
    7. if step % 10 == 0:
    8. log(step, loss=loss.item(), grad_norm=gn,
    9. mem=torch.cuda.max_memory_allocated(),
    10. tps=tokens / elapsed)
    11. if step % 50 == 0:
    12. save_checkpoint(step) # atomic write to avoid partial files

    Checkpoints should be written to object storage or a shared file system, using a “write in a temporary directory, then atomically rename” approach to prevent corrupted files from interruptions. Also keep the most recent few checkpoints plus one periodic archive for rollback and recomputation.

    5. Common Problems and Triage Order

    • Hang during initialization: check NIC selection, timeout thresholds, and port connectivity first, then verify topology detection.
    • Out-of-memory: lower the micro batch, enable recomputation or sequence parallelism, and observe the respective shares of activations and optimizer states.
    • NaN loss: verify the mixed-precision scaling strategy, learning rate, and whether data shards are duplicated or misaligned.
    • Throughput below expectations: distinguish compute bottlenecks from communication bottlenecks, and measure the communication wait share before deciding on an optimization direction.
    • Silent process exit: check whether logging is flushed to disk and whether the container platform reclaimed the process for exceeding memory limits.

    6. Tuning Directions and Migration Advice

    Once the pipeline is stable, optimization can proceed in the order of data first, then parallelism, then operators: improve data loading parallelism and preprocessing efficiency, adjust parallel splits and gradient accumulation to fit memory and bandwidth, and finally fuse hot operators and tune precision strategies. When migrating to domestic hardware, the safest path is to complete pipeline validation below the thousand-card scale first, then scale up gradually, keeping comparable baseline data at each step. If training and data are hosted on general-purpose capabilities such as the container platform, object storage, and monitoring alerts offered by Baidu AI Cloud, you can focus more on the parallelism strategy and convergence quality itself rather than infrastructure operations.