Running a Full Large Model Training Pipeline on a Domestic AI Accelerator Cluster: An Engineering Practice Guide

    This article details the engineering practice of successfully running a complete dense large model training pipeline on a domestic AI accelerator cluster consisting of two servers with 16 accelerators. It outlines key challenges that differentiate training from inference, including memory pressure, communication overhead, and fault tolerance. The guide covers cluster environment setup, parallel strategy design (data, tensor, and pipeline parallelism), memory optimization techniques like activation recomputation and optimizer state sharding, and critical stability measures for long-running tasks. The discussion concludes with practical recommendations for teams adopting a phased approach to achieve stable and scalable model training on domestic hardware.

    Introduction

    As the parameter scale of large language models continues to grow, the demands on the underlying computational infrastructure have intensified. With domestic AI accelerators gradually becoming viable, the ability to reliably execute a complete large model training pipeline across a multi-server, multi-accelerator cluster has become a primary focus for engineering teams. This article draws on a representative engineering practice: successfully completing a 400-step training run for a dense large model using a cluster of 16 domestic accelerators spread across two servers. We will examine the key technical challenges and the engineering lessons learned from this exercise.

    Why “Running a Training Pipeline” Is Harder Than “Running Inference”

    Inference typically involves single-step forward computation with manageable memory usage and relatively uniform hardware demands. Training, in contrast, presents far greater complexity:

    1. Significantly Higher Memory Pressure: Training requires concurrently storing model parameters, gradients, optimizer states, and activation values. For a model with billions of parameters, using mixed precision training, the combined memory footprint for parameters, gradients, and optimizer states alone can consume tens of gigabytes per accelerator. The addition of activation memory for micro-batches further increases this peak usage.
    2. Dependence on High-Bandwidth Communication: Strategies such as data parallelism, tensor parallelism, and pipeline parallelism necessitate frequent collective communication across accelerators and nodes. The bandwidth and stability of the interconnection network directly impact training throughput.
    3. Stringent Fault Tolerance Requirements: Training is a long-duration task. A single out-of-memory (OOM) event, a communication timeout, or an unsupported operator can interrupt the entire process.

    Therefore, successfully completing 400 consecutive steps on a 16-accelerator dual-server setup signifies that the entire software and hardware stack—from device drivers and operator libraries to the distributed framework and training script—has been effectively integrated and debugged. This is a critical engineering milestone.

    Cluster Setup and Preliminary Preparation

    Before initiating the training job, several preparatory steps are essential:

    1. Hardware and Topology Verification

    A standard configuration is two servers, each housing 8 accelerators. Intra-node communication typically uses a high-speed interconnect bus, while inter-node communication relies on a network link. Before proceeding, verify:

    • The basic compute capability and memory read/write performance of each individual accelerator.
    • The intra-node inter-accelerator communication bandwidth meets expected specifications.
    • The inter-node network is stable, and packet loss is within an acceptable range.

    2. Software Stack Alignment

    The training framework must be strictly compatible with the underlying operator and communication libraries. A common approach is to build a unified container image that bundles the driver compatibility layer, the acceleration operator library, the collective communication library, and the training framework to eliminate environment-specific inconsistencies. When using domestic hardware, it is particularly important to verify that all operators used by the model have compatible implementations. For any missing operators, prepare fused alternatives or fallback implementations in advance.

    3. Data and Model Preparation

    Training data must be cleaned, tokenized, and packaged, then stored in an object store or shared file system that the cluster can access efficiently. The model architecture or initialization configuration should be checked for format compatibility, with special attention to details like the attention implementation (e.g., GQA, MHA) and the position of normalization layers.

    Parallel Strategy Design

    For training a large model on 16 accelerators, the choice of parallel strategy directly determines both feasibility and efficiency:

    • Data Parallelism: The most basic form where each accelerator holds a complete copy of the model. Data is split across devices, and gradients are aggregated after each step. This works best when the model fits within a single accelerator’s memory.
    • Tensor Parallelism: The weight matrices of an operator are split across multiple accelerators to reduce per-device memory usage. This introduces high-frequency communication and is typically confined to within a single node.
    • Pipeline Parallelism: The model’s layers are split across different devices, with only inter-layer activations passed between stages. This has lower communication overhead and is suitable for scaling across nodes.

    A common configuration is to use tensor parallelism across the 8 accelerators within a node, pipeline parallelism between the two nodes, and optionally a layer of data parallelism on top. The optimal ratio depends on the model’s layer count, hidden dimension, and memory budget, requiring iterative calculation. A rough estimate of memory usage is:

    1. Memory Usage ≈ Parameters + Gradients + Optimizer States + Activation × Micro-batch Size

    With mixed precision and gradient accumulation, additional memory for master weight copies must be accounted for. A practical guideline is to reserve roughly 10-15% of memory as headroom to prevent failures caused by memory fragmentation.

    Memory and Performance Optimization

    1. Activation Recomputation

    By storing only a subset of activations during the forward pass and recalculating the rest during the backward pass, this technique trades an additional ~20-30% of computation for a significant reduction in memory usage. It is a standard practice in memory-constrained training scenarios.

    2. Optimizer State Sharding

    This approach partitions the optimizer states across the devices in a data parallel group. Each accelerator is responsible for updating only its shard of the states, substantially reducing the redundant memory footprint. This technique is widely adopted in the industry.

    3. Gradient Accumulation and Micro-batch Tuning

    To maintain a constant global batch size, reducing the micro-batch size per step while increasing the number of accumulation steps can flatten activation memory peaks. However, this must be balanced; if the micro-batch size is too small, compute utilization drops, reducing overall efficiency.

    4. Communication and Computation Overlap

    Overlapping gradient communication with backward computation hides a significant part of the communication latency. This is especially crucial when inter-node bandwidth is limited, ensuring that the accelerators remain busy while network transfers occur in the background.

    Stability Assurance: The Details Behind 400 Steps

    Completing 400 continuous steps without failure requires a robust resilience mechanism:

    • Health Checks:Run full-stack communication stress tests and small-scale trial runs before starting the full training job to ensure there are no “slow” accelerators or problematic nodes.
    • Checkpointing: Save checkpoints at regular step intervals. If a job is interrupted, training can resume from the latest saved state, thus avoiding the loss of all prior progress.
    • Monitoring and Alerts: Continuously monitor key metrics such as memory usage, loss curve, gradient norms, and communication time. An unexpectedly diverging loss or a sudden spike in gradient norm is often an early sign of numerical instability, requiring immediate intervention.
    • Structured Logging: Implement a unified logging service with structured output. This can reduce issue diagnosis time from hours to minutes.

    During the validation phase, it is advisable to first run a few dozen steps with a small subset of data to confirm that the loss is decreasing as expected and that throughput meets targets. After this initial validation, scale up to the full data set and run the complete validation loop.

    Key Takeaways and Outlook

    This practice of running a 400-step training job on a 16-accelerator, dual-server cluster demonstrates that the capability of domestic accelerators to support large model training hinges not on single-device performance, but on full-stack integration. The operator coverage determines whether you can run; the parallel strategy and memory optimization determine how efficiently you run; and communication tuning and stability infrastructure determine how reliably you can sustain the run.

    For teams planning similar initiatives, a phased approach is recommended: start with a single accelerator, then scale to multiple accelerators on one node, and finally to multiple nodes. Each stage should be gated by quantifiable acceptance criteria, such as throughput, memory usage, and loss consistency. Additionally, leveraging cloud-native capabilities like container platforms, object storage, and managed monitoring services can significantly reduce cluster management and operational overhead. As the ecosystem for domestic accelerators continues to mature, the path toward more autonomous and controllable large model training is steadily expanding.