Engineering Practices for End-to-End LLM Training on Domestic Compute Clusters

    As LLMs grow in scale, more teams are exploring training on emerging domestic compute platforms outside the traditional GPU ecosystem. This article breaks down a representative case—stably running 400 training steps of a mainstream open-source LLM on a two-node, 16-card cluster—covering parallel strategy selection, collective communication optimization, memory management, data pipelines, and observability, plus the path from "making it work" to "making it work well."

    Engineering Practices for End-to-End LLM Training on Domestic Compute Clusters

    As large language models continue to grow in parameter count, training places unprecedented demands on compute, memory, and cluster interconnects. At the same time, more organizations are exploring LLM training on domestic compute platforms outside the traditional GPU ecosystem. A recent representative case in the industry stands out: a domestic GPU vendor successfully ran the complete training pipeline of a mainstream open-source LLM on a two-node, sixteen-card cluster, stably executing 400 training steps. While modest in scale, this case covers the full lifecycle—from environment setup and parallel strategy selection to stability validation—making it a valuable reference. This article uses such practices as a backdrop to dissect the core technical points.

    1. Why “Getting the Training Pipeline Running” Is Itself a Milestone

    Many developers underestimate what “getting it running” means. In a mature GPU ecosystem, launching a multi-node, multi-GPU training job may take just a few commands. On an emerging compute platform, however, the training pipeline spans a complete software stack—from low-level drivers, operator libraries, and communication libraries up to the training framework. Any missing or incompatible layer will prevent the job from starting or cause it to crash mid-run.

    A complete training pipeline includes at least the following layers:

    • Hardware and driver layer: GPU detection, topology discovery, and verification of inter-device connectivity.
    • Operator and compute library layer: Whether core operators like matrix multiplication and attention are correctly implemented at usable precision.
    • Collective communication layer: Whether cross-node and cross-card primitives such as AllReduce, AllGather, and Broadcast are efficient and reliable.
    • Framework adaptation layer: Whether mainstream distributed training frameworks can compile and schedule correctly on the platform.
    • Model and data layer: Whether the model can be properly partitioned and whether data loading keeps pace with computation.

    Four hundred stable steps mean every layer has withstood sustained stress: gradients synchronized repeatedly without errors, no slow memory leaks, no communication deadlocks or timeouts, and no numerical divergence. This is far more demanding than a single successful forward pass and is a strong signal of platform maturity.

    2. Choosing a Distributed Parallelism Strategy

    Training an LLM on two nodes with sixteen cards starts with parallelism design. The industry’s standard 3D parallelism framework—data parallelism, tensor parallelism, and pipeline parallelism—must be combined based on model size and cluster topology.

    2.1 Data Parallelism

    Data parallelism is the most basic approach: each compute node holds a full model replica, processes a different data shard, and keeps parameters consistent through gradient synchronization. In a 16-card setup, if a single card can hold the model weights, optimizer states, and activations, data parallelism combined with gradient sharding (partitioning optimizer states and gradients across cards) is often the most cost-effective option. Its communication pattern centers on AllReduce or ReduceScatter plus AllGather, placing relatively modest demands on the communication library.

    2.2 Tensor Parallelism

    When a single layer’s parameters exceed one card’s memory, weight matrices must be split by row or column across multiple cards—this is tensor parallelism. It is communication-intensive: every forward and backward pass requires cross-card exchange of intermediate results, making it highly sensitive to intra-node interconnect bandwidth. The general engineering rule is to keep tensor parallelism groups within a single node, avoiding cross-node communication that would drag down throughput.

    2.3 Pipeline Parallelism

    Pipeline parallelism partitions the model by layers across devices and executes micro-batches in a pipelined fashion. It has low communication volume and suits cross-node partitioning, but requires careful scheduling to minimize “bubbles” (idle device time). In a two-node setup, a common approach places the earlier layers on the first machine and later layers on the second, passing only activations and gradients across nodes—a manageable communication cost.

    In summary, a typical combination for two nodes and sixteen cards is tensor parallelism or data parallelism with gradient sharding within a node, plus pipeline or data parallelism across nodes. The exact ratio requires repeated trade-offs among memory footprint, communication overhead, and compute efficiency, validated through small-scale experiments.

    3. Communication Optimization: The Lifeline of Multi-Node Training

    The performance bottleneck in cross-node training is usually communication, not computation. Running 400 stable steps on a domestic compute platform requires deliberate communication optimization.

    First, adapt and tune the collective communication library. The library must be tailored to the underlying interconnect (such as RDMA networking or high-speed buses) so that operations like AllReduce fully utilize link bandwidth. Tuning techniques include choosing the right communication algorithm (ring, tree, etc.), adjusting chunk sizes, and enabling communication-computation overlap.

    Second, gradient compression and mixed precision. Transmitting gradients in lower-precision formats (such as FP16 or BF16) during backpropagation directly halves communication volume, while error compensation mechanisms preserve convergence accuracy.

    Third, overlap communication with computation. The training framework should asynchronously launch gradient synchronization for completed layers while backpropagation continues through remaining layers, hiding communication time behind computation. Illustrative configuration logic:

    1. # Illustrative pseudocode: overlapping gradient communication with backward computation
    2. for layer in reversed(model.layers):
    3. grads = backward(layer)
    4. # Launch gradient aggregation asynchronously without blocking subsequent layers
    5. all_reduce_async(grads, group=data_parallel_group)
    6. optimizer.register_hook(layer, sync_and_apply)

    Such overlap mechanisms have mature implementations at the framework level, but their correctness must be re-validated on new platforms—the interaction between asynchronous communication and custom operators is a common source of bugs.

    4. Memory Management and Training Stability

    Memory consumption in LLM training has four components: model weights, gradients, optimizer states, and activations. With mixed-precision training, a model with N parameters may require memory exceeding ten times N bytes for weights, gradients, and optimizer states alone. Practical optimization techniques include:

    • Activation recomputation (re-checkpointing): Save only partial intermediate results during the forward pass and recompute them on demand during backpropagation, trading compute time for memory.
    • Optimizer state sharding: Distribute optimizer states evenly across all data-parallel ranks, significantly reducing per-card pressure.
    • Memory pooling and defragmentation: Use a unified memory allocator to avoid fragmentation from frequent allocation and deallocation—critical for long-running training.

    Four hundred continuous steps directly validate memory management: any slow leak or fragment accumulation typically kills the job within tens of steps due to out-of-memory errors.

    5. Data Pipeline and Throughput Assurance

    In multi-GPU training, data loading must keep pace with computation, or GPUs sit idle. Key engineering practices include:

    1. Pipelined data preprocessing: Run tokenization, truncation, and packing asynchronously on dedicated CPU thread pools or preprocessing nodes, decoupled from the training loop via prefetch queues.
    2. Global batch consistency: Ensure all data-parallel replicas receive non-overlapping, deterministic sample shards at each step—essential for reproducibility.
    3. Sequence packing and padding optimization: Pack variable-length text sensibly to reduce wasted compute from excessive padding.

    6. Observability and Troubleshooting

    Long-running training demands a comprehensive monitoring system. At minimum, it should cover: per-card compute utilization and memory usage, cross-node communication bandwidth and latency, gradient norms and loss curves, and the share of time spent on data loading. When anomalies occur—such as sudden loss divergence or a step taking unexpectedly long—these metrics help quickly isolate whether the problem lies in computation, communication, or data. General-purpose monitoring, alerting, and logging services offered by cloud platforms can build this observability system at relatively low cost, continuously guarding the training job.

    7. From “Working” to “Working Well”

    The 400-step validation answers “can it run,” but production readiness requires answering “how well does it run”:

    • Scalability validation: When scaling from sixteen cards to tens or hundreds, does throughput grow near-linearly, and does the communication share stay under control?
    • Convergence consistency: Compare training curves against a reference platform to confirm the loss trajectory and final results match, ruling out hidden deviations from operator precision differences.
    • Long-term stability testing: Run continuously for thousands or tens of thousands of steps to validate fault tolerance, including checkpoint-based resume, automatic exclusion of failed nodes, and job recovery.

    Conclusion

    Running 400 training steps on two nodes and sixteen cards may look like just a starting point, but it fully validates end-to-end usability from the low-level software stack to the upper-layer framework. For developers training LLMs in diversified compute environments, the methods outlined here—parallelism strategy selection, communication optimization, memory management, and observability—are broadly applicable. As domestic compute ecosystems continue to mature, the experience distilled from such engineering practices will open more viable paths to lower-cost, higher-efficiency LLM training.