Building an LLM Training Pipeline on a Domestic Accelerator Platform: A Practical Guide

    This article walks through a complete methodology for validating an end-to-end LLM training pipeline on a domestic accelerator cluster. Using a 400-step training run on a dual-node, 16-card setup as a case study, it covers environment setup, framework adaptation, distributed parallelism strategies, memory optimization, and stability monitoring—offering a low-cost "validate small, scale gradually" approach for teams evaluating new compute platforms.

    Building an LLM Training Pipeline on a Domestic Accelerator Platform: A Practical Guide

    1. Why Validate the Full Training Pipeline?

    As model parameter counts keep growing, training workloads demand ever more compute, memory, and interconnect bandwidth. At the same time, more teams are evaluating whether training is feasible on domestic accelerator platforms. But “inference works” and “training works” are fundamentally different bars: training involves not only forward computation, but also gradient computation during backpropagation, optimizer state updates, and cross-node gradient synchronization. This places much higher demands on hardware stability, operator coverage, and software stack maturity.

    Before committing to large-scale training, it is therefore a low-cost, high-value strategy to run several hundred training steps on a modest configuration—for example, a two-node cluster with 8 cards per node (16 cards total)—to verify the integrity and stability of the entire pipeline. This article uses a real 400-step training run on a domestic accelerator cluster as an example and lays out the complete methodology from environment setup to result validation.

    2. What “Passing the Pipeline” Actually Means

    Validating a training pipeline means verifying five key aspects:

    1. Environment usability: Can the drivers, runtime, and deep learning framework be installed and initialized correctly on the platform?
    2. Operator compatibility: Are the operators the model relies on—attention, normalization, mixed-precision arithmetic—fully implemented, with numerics that meet expectations?
    3. Distributed communication: Do gradient synchronization and parameter sharding communication work correctly across multiple GPUs and nodes?
    4. Training correctness: Does the loss decrease normally, without numerical overflow or erratic spikes?
    5. Stability: Can the job run continuously for hundreds of steps without crashing or hanging, and does memory usage stay flat (i.e., no leaks)?

    Choosing 400 steps is a deliberate trade-off: too few steps won’t expose stability issues, while too many make validation expensive. A few hundred steps are generally enough to observe the loss trend, verify mixed-precision stability, and estimate overall training throughput.

    3. Environment Setup and Basic Configuration

    Setting up a training environment on a domestic accelerator platform typically involves the following steps:

    1. Driver and runtime installation

    First, confirm that the accelerator driver version matches the compute runtime version. This sounds trivial, but it is the most failure-prone step on a new platform. Recommendations:

    • Use the platform’s official images or installation scripts rather than assembling versions manually;
    • After installation, run basic health-check scripts to confirm all 16 cards are detected;
    • Verify that intra-node interconnect bandwidth meets hardware specifications.

    2. Deep learning framework adaptation

    Choose a framework version that supports the platform. Common industry practice is for framework and hardware vendors to co-maintain an adapted build, or to plug heterogeneous backends in through an extension mechanism. Key items to confirm:

    • Mixed-precision training support (FP16/BF16); BF16 is generally friendlier for numerical stability;
    • Coverage of custom or fused operators—missing operators may silently fall back to slow implementations or fail outright;
    • Distributed communication library support for the underlying network fabric (e.g., RDMA or high-speed interconnects).

    3. Model code migration

    If the model code was originally developed on another platform, common migration work includes abstracting device types (avoid hardcoded device names), keeping RNG and initialization logic consistent, and adapting the data loading pipeline. It is advisable to introduce a device-agnostic abstraction layer, for example:

    1. # Example of device-agnostic device selection
    2. import os
    3. def get_device():
    4. backend = os.environ.get("TRAIN_BACKEND", "cuda")
    5. if backend == "cuda":
    6. import torch
    7. return torch.device("cuda")
    8. elif backend == "custom":
    9. # Obtain the heterogeneous device through the framework's unified interface
    10. import torch
    11. return torch.device("custom_accelerator")
    12. raise ValueError(f"unsupported backend: {backend}")

    4. Designing the Distributed Parallelism Strategy

    With two nodes and 16 cards, a sensible parallelism strategy is critical to whether training runs at all. The three standard approaches each have their place:

    1. Data Parallelism (DP)

    Each card holds a full model replica and processes a different data batch; gradients are aggregated via AllReduce after backpropagation to synchronize parameters. It is the simplest to implement, with communication volume proportional to parameter count. For models that fit in a single card’s memory, DP is the default choice.

    2. Tensor Parallelism (TP)

    A single layer’s weight matrices are sharded across multiple cards; each card computes a partial result, followed by intra-layer communication. TP suits layers too large for one device, but it is communication-intensive and is usually confined within a node (to exploit high-speed intra-node interconnects); running TP across nodes significantly slows training.

    3. Pipeline Parallelism (PP)

    The model is split by layers into stages, with different devices responsible for different layers, passing intermediate activations in a pipeline. Communication volume is small, but pipeline bubbles exist and must be filled with micro-batching.

    In this 16-card setup, a typical combination is tensor or data parallelism across the 8 cards within a node, and data or pipeline parallelism across nodes. For larger models, parameter sharding techniques (sharding optimizer states, gradients, and parameters across cards, gathering them on demand) can dramatically reduce per-card memory pressure. A sample configuration:

    1. parallel:
    2. tensor_parallel_size: 4 # Intra-node tensor parallelism
    3. pipeline_parallel_size: 1 # Pipeline parallelism not used for now
    4. data_parallel_size: 4 # Remaining dimension used for data parallelism
    5. sharding: true # Enable optimizer state sharding
    6. mixed_precision:
    7. dtype: bf16
    8. loss_scale: dynamic

    5. Memory Optimization: The Make-or-Break of LLM Training

    When training large models on a 16-card cluster, memory usually becomes the bottleneck before compute does. Mainstream optimization techniques include:

    1. Activation recomputation (gradient checkpointing)

    Instead of storing all intermediate activations during the forward pass, recompute them as needed during backpropagation—trading compute for memory. This typically reduces activation memory severalfold, at the cost of roughly 20%–30% additional computation.

    2. Mixed precision and optimizer state management

    Run forward and backward passes in BF16 while keeping FP32 master weights in the optimizer, balancing memory savings against numerical stability. Combined with parameter sharding, optimizer states (usually several times the parameter size) can be spread across all cards.

    3. Gradient accumulation

    When per-step batch size is memory-limited, accumulate gradients over multiple micro-batches before applying a single update, effectively achieving a larger global batch. Note the interaction with distributed gradient synchronization: communicate only at accumulation boundaries to reduce sync overhead.

    4. Memory fragmentation control

    Long-sequence training tends to fragment device memory. Enable the framework’s pooled memory management and monitor peak memory usage and fragmentation rates during training.

    6. Ensuring Stability and Running the 400-Step Validation

    With environment, parallelism, and memory configured, formal validation begins. During the 400-step run, monitor these metrics closely:

    • Loss curve: Should decrease smoothly, with no spikes or NaNs. If loss spikes occur under mixed precision, first check the gradient clipping threshold and loss scaling strategy;
    • Gradient norm: Reflects whether training dynamics are healthy; abnormal growth usually signals instability;
    • Throughput: Tokens or samples processed per second. Combined with theoretical compute, estimate MFU (model FLOPs utilization) to determine whether there is a communication bottleneck or operator fallback;
    • Memory usage curve: Should flatten out; continuous growth indicates a leak;
    • Cross-node communication time share: If the share is too high, adjust the parallelism layout or increase gradient accumulation steps.

    A proven troubleshooting path in practice is incremental scale-up: first run the smallest model on a single card of one node, then multiple cards on one node, then multiple nodes—locating problems as scale grows. If the loss fails to decrease, first reproduce in FP32 on a single card to rule out precision issues; if communication misbehaves, test the communication library’s collective primitives in isolation to separate framework factors from transport issues.

    7. What the Validation Results Mean and Next Steps

    Completing a stable 400-step training run on 16 domestic accelerator cards across two nodes, with the loss converging normally, demonstrates that the platform has the fundamental capability to host LLM training workloads: a complete operator stack, functional distributed communication, and stable long-duration execution. This result provides a confidence baseline for larger-scale, longer-running training tasks.

    Follow-up work can build on this foundation: scaling the cluster to verify linear scaling efficiency, introducing longer-sequence training to validate memory strategies, running downstream fine-tuning to confirm the trained models are usable, and integrating the training pipeline with general-purpose infrastructure on the cloud platform—object storage, container orchestration, monitoring and alerting—to form a sustainable training engineering system.

    8. Conclusion

    Getting an LLM training pipeline running on a domestic accelerator platform is fundamentally a systems engineering effort: hardware environment, framework adaptation, parallelism strategy, memory optimization, and stability monitoring are all interlocked. Centered on a dual-node, 16-card, 400-step validation, this article has presented a complete methodology from environment preparation to result verification. For teams planning to migrate to domestic compute, the recommended path is “validate at small scale, then scale up gradually”: surface problems as early as possible at minimal cost, then proceed steadily toward production-grade training.