Bringing Up LLM Training Pipelines on Domestic GPUs: Practical Experience
This article explains why completing an end-to-end training pipeline is a major engineering milestone when running large language model training on domestic GPUs. It covers the adaptation layer, operator migration, distributed parallelism, mixed precision and memory optimization, stability validation, observability, and acceptance criteria. It is intended for engineers and teams that need to validate, debug, and scale LLM training on new or less mature hardware.
1. Why Bringing Up a Training Pipeline Is a Major Engineering Milestone
Before discussing model quality, engineering teams need to answer a more fundamental question: can the model run one complete training iteration from start to finish on hardware that has not previously been validated, and do all numerical results match expectations at each step? This is what it means to bring up a training pipeline.
It depends on four types of continuity:
- Operator continuity: Every forward and backward operator used by the model has a corresponding implementation on the target hardware, and the implementation is numerically correct.
- Data-pipeline continuity: Data loading and preprocessing can feed samples into the model without stalls or mismatches.
- Parallelism continuity: Multiple nodes and GPUs can establish communication groups correctly, and gradient synchronization and parameter updates remain consistent.
- Numerical continuity: The loss curve decreases smoothly, without NaN, Inf, or abnormal jumps.
For domestic accelerators, the difficulty is often not peak compute. It is ecosystem maturity: whether the framework, operator libraries, communication libraries, and debugging tools are available and sufficiently validated. A milestone such as “completing hundreds of training steps on two nodes with 16 GPUs” validates an integrated software-hardware capability, not a single performance metric.
2. Hardware-Software Adaptation: The First Gate to Bringing Up the Pipeline
To run a model on unfamiliar hardware, the adaptation layer is the unavoidable starting point. It sits between the deep learning framework and the accelerator, translating high-level framework instructions into executable operator calls.
The adaptation layer should focus on three areas:
- Consistent device abstraction: The framework accesses the accelerator through a unified device interface. Semantics for memory allocation, memory copies, streams, and events must align with mainstream implementations; otherwise, training code cannot be migrated directly.
- Communication backend adaptation: Multi-node training relies on collective communication primitives such as broadcast, reduce, and all-to-all. These primitives must be correctly implemented over the target hardware’s interconnect topology, covering multi-node RDMA and intra-node high-speed interconnect scheduling.
- Precision and rounding behavior: Different hardware may handle intermediate precision in floating-point operations differently. This directly affects convergence stability, so strict numerical consistency testing is required in the adaptation layer.
At this stage, container platforms and image distribution can significantly reduce cost. Packaging the driver, framework, and operator libraries into standardized images ensures that every machine runs in an identical environment, avoiding environment drift where training works on one machine but fails on another.
3. Operator and Kernel Migration: From Running to Running Correctly
Most of the effort in bringing up a pipeline is hidden in operators. Large language models depend on many operators: matrix multiplication, attention, layer normalization, activation functions, and various fused operators under mixed precision.
There are usually three migration strategies, from lowest to highest priority:
- Fall back to generic implementations: Use the framework’s generic operators first. This sacrifices performance for correctness and quickly gets the pipeline running.
- Replace with high-performance libraries: Replace hot operators with the hardware vendor’s high-performance operator libraries to obtain most of the initial performance gains.
- Build custom fused kernels: Fuse operators around attention and normalization memory-access bottlenecks to reduce memory reads/writes and kernel launch overhead.
A practical approach is to move forward in phases:
Phase 1: Prioritize correctness- Use generic operators to get forward and backward passes running- Compare each operator numerically against the reference implementation (error within threshold)Phase 2: Performance substitution- Replace hot operators such as matrix multiplication and attention with operator-library implementations- Use a profiler to identify Top-N operators by time consumption and optimize them one by onePhase 3: Fusion optimization- Fuse adjacent operators such as RMSNorm + residual and Softmax- Verify numerical equivalence before and after fusion to avoid convergence drift
Any operator replacement must be accompanied by an automated numerical alignment test suite: with the same input and the same weights, compare the forward outputs and backward gradients produced by the target hardware against the reference implementation. The error must stay within the tolerance allowed by mixed precision. Skipping this step makes it extremely difficult to diagnose abnormal loss curves later.
4. Distributed Parallelism: Designing a Two-Node, 16-GPU Setup
A two-node, 16-GPU setup crosses the boundary of a single machine and requires distributed parallelism. The common approach combines three forms of parallelism:
- Data parallelism (DP): Each GPU holds a full copy of the model and processes a different data shard. Gradients are reduced to synchronize parameters. This is easy to implement but memory-intensive.
- Tensor parallelism (TP): A large matrix multiplication within a layer is split across multiple GPUs. It communicates frequently and is best placed inside a high-bandwidth intra-node interconnect domain.
- Pipeline parallelism (PP): The model is split by layers across devices, and activations are passed from one stage to the next like a pipeline. Communication volume is relatively small, making it suitable for inter-node deployment.
For two nodes with 16 GPUs, a common combination is to use tensor parallelism inside a node to exploit high-bandwidth interconnects, and to use data parallelism or pipeline parallelism between nodes to reduce cross-node communication pressure. A proper parallel partition minimizes communication overhead.
An example of an abstracted parallel-strategy configuration:
global_world_size = 16 # Two nodes x 8 GPUs per nodetensor_parallel_size = 4 # Intra-node tensor parallelismpipeline_parallel_size = 2 # Inter-node pipeline parallelismdata_parallel_size = 2 # Remaining dimension for data parallelism# Constraint: tp * pp * dp == global_world_size
The goal is to find a balance among “the model fits in memory,” “communication is feasible,” and “pipeline bubbles are acceptable.” Pipeline parallelism introduces bubbles, and its impact can be reduced by increasing batch size or optimizing scheduling.
5. Mixed Precision and Memory Optimization: Making Room Under Limited Compute
Large-parameter models can almost never be trained at full precision within limited memory, so mixed precision is usually a must. The core approach is:
- Use half precision (FP16/BF16) for forward and backward computation to improve speed and save memory.
- Keep a full-precision master copy of parameters, accumulate gradients in full precision, and store optimizer states in full precision to maintain numerical stability.
- Use loss scaling to prevent gradient underflow under half precision.
Among these, BF16 usually has a larger dynamic range than FP16 and often does not require loss scaling. This makes it easier to use when training large models, so it should be preferred.
Memory optimizations can be layered on top of mixed precision:
- Activation checkpointing: Store only part of the intermediate activations and recompute them during the backward pass, trading time for memory.
- Optimizer state sharding (for example, ZeRO-style sharding): Shard optimizer states, gradients, and parameters across the data-parallel group to significantly reduce per-GPU memory pressure.
- Memory fragmentation management: Set allocation strategies carefully to avoid OOM after long training runs.
Conceptually, the memory used by one forward and backward pass can be divided into five parts: model parameters, gradients, optimizer states, activations, and temporary buffers. The essence of memory optimization is to compress each of these five parts through precision, recomputation, and sharding until they fit within device capacity.
6. Training Stability and Convergence Validation
Running a pipeline does not mean running it correctly. Completing hundreds of steps is only an initial validation. The real criterion is whether the loss curve is healthy:
- Smooth decrease: Loss should continue to decrease within reasonable fluctuations, rather than oscillate or stagnate.
- No abnormal numerical values: NaN or Inf should never appear, and the gradient norm should remain in a reasonable range.
- Reproducibility: With fixed random seeds and data order, repeated runs should produce highly overlapping loss curves.
If training diverges, the recommended troubleshooting order is:
- Check whether the learning rate and warmup are too aggressive.
- Check whether mixed precision causes gradient underflow or overflow, and adjust loss scaling.
- Check whether operator numerical alignment has deviations, and return to operator-level comparison.
- Check whether the data pipeline contains dirty data or misaligned labels.
A training-stability monitoring loop is essentially a process of hypothesis, validation, and convergence. Change only one variable at a time and observe how the curve responds. Changing multiple variables at once makes attribution difficult.
7. Observability: Making Long Training Runs Visible and Debuggable
Once a long-running training job fails, a lack of observability makes diagnosis difficult. At minimum, engineering teams should establish three layers of monitoring:
- Performance metrics: Step time, per-GPU throughput (tokens/s), communication time share for each parallel dimension, and peak memory usage.
- Training metrics: Loss, learning rate, gradient norm, and parameter update magnitude.
- System metrics: Accelerator utilization, temperature, power consumption, and inter-node network bandwidth usage.
At the deployment level, log services can aggregate output from all nodes. Monitoring and alerting can notify engineers promptly when loss spikes, memory approaches its limit, or communication times out. Training checkpoints and experiment configurations should be stored in object storage so that any failed step can be resumed from the latest checkpoint instead of restarting from the beginning.
This combination—checkpointing, centralized monitoring, and alerting—is the foundation for maintaining control over long training jobs.
8. Acceptance Criteria: What Counts as a Truly Completed Training Pipeline?
Overall, the acceptance criteria for bringing up a training pipeline should include the following items, and none can be missing:
- Complete closed loop: Data loading → forward pass → backward pass → parameter update → checkpoint saving, with no errors in the full process.
- Multi-GPU consistency: Losses and gradients are consistent across all GPUs in the multi-node, multi-GPU setup, with no dropped GPUs and no deadlocks.
- Numerical correctness: Each operator aligns with the reference implementation, and errors remain within tolerance.
- Stable convergence: Loss decreases smoothly over hundreds of consecutive steps, with no NaN or Inf.
- Recoverability: Training can resume correctly from any checkpoint, with continuous results.
- Observability: Key metrics can be collected, visualized, and used for alerting.
Only when all six conditions are met can the training pipeline be considered truly brought up on domestic GPUs. This marks the critical transition from “able to run” to “able to train,” and eventually to “able to train at scale.”
9. Conclusion
The greatest value of training large models on domestic hardware is not the fact of a single successful run. It is the creation of a reusable methodology: prioritize correctness before performance, use numerical alignment to hold the baseline, use parallel strategies to balance memory and communication, use mixed precision to make room under limited compute, and use observability to manage long-duration risks.
By embedding this methodology into standardized container images, automated tests, and monitoring/alerting pipelines, the bring-up cycle can be shortened when onboarding new models and new hardware. This is the necessary path for the domestic training ecosystem to become more mature and more engineering-oriented.
