End-to-End LLM Training on Domestic GPU Clusters: Practices and Lessons Learned

    This article breaks down the engineering path to running a large language model pretraining pipeline on a domestic GPU cluster. Using a real validation case—400 training steps completed on a two-node, 16-GPU setup—it covers software stack alignment, operator equivalence testing, parallel strategy design, communication optimization, and acceptance criteria for numerical stability and correctness, offering a practical reference for teams adopting new accelerator hardware.

    End-to-End LLM Training on Domestic GPU Clusters: Practices and Lessons Learned

    1. Background and Problem Definition

    As demand for large model training continues to grow, diversifying compute supply has become an industry consensus. Beyond the mainstream GPU ecosystem, more and more teams are exploring how to build training capabilities on new accelerator hardware such as domestic GPUs. Recently, a domestic GPU platform completed a notable validation: on a two-node cluster with 16 GPUs in total, a mainstream large language model completed 400 pretraining steps end to end, verifying the full pipeline from data loading, forward and backward computation, and gradient synchronization to parameter updates.

    “400 steps” may sound small in scale, but its engineering significance goes far beyond the number itself. This article breaks down the complete technical path for bringing LLM training to new accelerator hardware, providing a reference for teams facing similar tasks.

    2. Why “400 Steps” Is a Meaningful Milestone

    It’s easy to underestimate the value of small-scale validation. In practice, completing 400 training steps usually means the following key problems have been solved:

    1. Operator completeness: the hundreds of operators involved in the model (matrix multiplication, attention, normalization, activation functions, etc.) all have working implementations on the new hardware, with correct numerical behavior.
    2. Distributed communication works: gradient synchronization across nodes and GPUs (collective communication primitives such as AllReduce) runs stably, with bandwidth and latency within acceptable ranges.
    3. Memory management is feasible: model parameters, gradients, optimizer states, and activations can all be placed reasonably, without unrecoverable out-of-memory failures.
    4. Numerical stability is preliminarily confirmed: the loss curve decreases normally within the first few hundred steps, with no gradient explosions or NaN anomalies—indicating that the mixed-precision strategy basically matches the hardware’s numerical behavior.

    In other words, completing the first 400 steps means the question “can it train at all?” has a definitive yes. Only then does the work shift to the optimization stage: “how fast and how stable can it train?”

    3. Environment Adaptation: Three Layers of Alignment from Driver to Framework

    The first step in training on new accelerator hardware is aligning the software stack across three layers:

    Layer 1: Driver and runtime. Confirm that the hardware driver version and the underlying compute and communication libraries form a validated version combination. In practice, it’s recommended to pin a version baseline to avoid version drift between “it runs” and “it runs correctly.”

    Layer 2: Training framework adaptation. Mainstream training frameworks typically support multiple hardware backends through plugins or backend extension mechanisms. Key items to verify:

    • Whether tensor allocation, copying, and release on the device work properly;
    • Whether the automatic mixed precision (AMP) path is fully supported;
    • Whether checkpoint saving and loading are compatible.

    Layer 3: Model code. Custom operators common in LLM code (such as fused attention or specific rotary position embedding implementations) are often the hardest part of adaptation. The general approach is: first replace them with equivalent implementations built from native framework operators, verify accuracy, and only then consider switching to hardware-optimized versions. A simple equivalence check looks like this:

    1. import torch
    2. def check_equivalence(ref_impl, new_impl, shape=(4, 1024, 4096), atol=1e-3):
    3. x = torch.randn(*shape, device="cuda", dtype=torch.float16)
    4. ref_out = ref_impl(x)
    5. new_out = new_impl(x)
    6. diff = (ref_out - new_out).abs().max().item()
    7. assert diff < atol, f"max diff {diff} exceeds tolerance"
    8. print(f"equivalence check passed, max diff = {diff:.2e}")

    This kind of operator-by-operator alignment testing is the foundation for everything that follows.

    4. Parallel Strategy: Sensible Partitioning for Two Nodes and 16 GPUs

    A two-node, 16-GPU setup is a small-to-medium cluster, so the parallel strategy must balance memory constraints against communication overhead. The common parallelism dimensions in the industry include:

    • Data parallelism (DP): each GPU holds a full model replica and processes a shard of the data. Simple to implement, but memory-hungry.
    • Tensor parallelism (TP): splits the weights of each layer across multiple GPUs. Suitable when a single layer is too large to fit on one device, but communication-intensive, so it’s usually confined within a single node.
    • Pipeline parallelism (PP): partitions layers across different devices. Commonly used across nodes, but requires handling pipeline bubbles.
    • Optimizer state sharding: shards optimizer states across devices, significantly reducing per-GPU memory pressure.

    For a two-node, 16-GPU configuration, a common and robust combination is: tensor parallelism within each node, pipeline or data parallelism across nodes, plus optimizer state sharding. For example, use TP=8 within each node so that intra-node high-bandwidth interconnects carry the tensor-parallel communication, and PP=2 across the two nodes by partitioning layers—this way, cross-node traffic is limited to inter-layer activation transfers, which are small and can overlap with large computations.

    5. Communication Optimization and Performance Profiling

    Cross-node communication is one of the main bottlenecks in multi-node training. In practice, pay attention to:

    1. Network topology verification: confirm the interconnect bandwidth between the two nodes (e.g., whether RDMA networking is enabled and whether NIC binding is configured correctly). Use bandwidth testing tools to establish a baseline first.
    2. Gradient bucketing and communication overlap: aggregating gradients into buckets so that backward computation and gradient communication are pipelined is a key technique for improving MFU (model FLOPs utilization).
    3. Performance profiling: break down the time spent in each phase (forward, backward, communication, optimizer update) over the first few dozen steps. Locate the bottleneck before optimizing—avoid blind parameter tuning.

    6. Stability and Correctness Acceptance

    During the 400-step validation, establish clear acceptance criteria:

    • Loss curve alignment: compare against a baseline run on reference hardware. The loss trend and numerical deviation over the first 400 steps should fall within a reasonable range (typically a relative deviation of no more than a few percentage points).
    • Gradient norm monitoring: record grad norm throughout the run and confirm there are no abnormal spikes.
    • Failure drills: proactively simulate single-GPU failures and checkpoint recovery to verify the ability to resume training from checkpoints—a prerequisite for long-duration training later on.

    7. Conclusion and Outlook

    Completing 400 steps on a two-node, 16-GPU cluster validates the end-to-end feasibility of running LLM training pipelines on domestic GPUs. The methodology can be summarized as follows: first align the software stack and operators layer by layer; then choose a parallel strategy appropriate for the cluster size; next, improve throughput through communication optimization; and finally, confirm correctness and stability against quantitative acceptance criteria. For teams looking to build training capabilities on diversified compute, leveraging general cloud infrastructure—container platforms, object storage, monitoring and alerting—to manage training jobs and data assets can significantly reduce engineering costs. The next challenges lie in scaling up, improving compute utilization, and continuously validating stability over longer training runs.