Validating an End-to-End LLM Training Pipeline on a Chinese-Made GPU Cluster: 400 Steps on Two Nodes with 16 GPUs

    This article describes a validation of a full large language model training pipeline on two servers with 16 Chinese-made GPUs. It covers data preprocessing, distributed initialization, hybrid data and sequence parallelism, checkpoint saving and recovery, and performance observation and tuning. It also describes operator adaptation, cross-node communication issues, and how these were handled.

    1. Background: Why Validate LLM Training on Non-Traditional Hardware

    As large language models grow, training places heavy demands on cluster stability, communication efficiency, and memory capacity. Mainstream training pipelines have long depended on specific GPU vendors and their software stacks. Outside that ecosystem, developers often face missing operators, incompatible communication libraries, and difficulty adapting distributed training frameworks. Running a complete end-to-end training pipeline on a non-traditional GPU platform therefore tests both hardware capability and software stack maturity.

    The core goal was to run a full training pipeline for an open-source bilingual LLM with long-context capability (for example, at the 128K level). The setup had only two servers with 16 Chinese-made full-featured GPUs in total. “Running the pipeline” meant more than executing forward and backward passes. It covered the full loop: data preprocessing, distributed initialization, multi-GPU parallelism, gradient synchronization, logging and monitoring, and checkpoint saving and recovery. A 400-step run cannot show the final quality of a converged model. It is long enough, however, to expose most of the engineering risks in the pipeline.

    2. Cluster Topology and Base Environment

    2.1 Hardware Topology: Two Nodes with Eight GPUs Each

    The test environment used two servers. Each server has eight full-featured GPUs connected through a high-speed NVLink-style bus. The two servers connect over InfiniBand or RoCE (RDMA over Converged Ethernet), forming a typical two-node, 16-GPU topology.

    This topology is common in small and mid-sized R&D teams. It avoids the multi-tier network planning that very large clusters require, and it doubles the compute of a single eight-GPU server. It works well as a testbed for distributed training. Cross-node bandwidth and latency are much higher than intra-node links, so the choice of gradient synchronization strategy directly affects overall training efficiency.

    2.2 Software Stack: Framework Selection and Operator Adaptation

    The project used a widely adopted open-source deep learning framework as its base and extended the framework’s distributed training interfaces. The main adaptation work covered the following areas:

    • Operator layer: An operator adaptation layer maps operations commonly used in the model, such as attention, normalization, and activation functions, onto the GPU’s low-level instruction set. For the few operators that are not supported, the team used custom operators or equivalent substitutes as a fallback.
    • Communication layer: Distributed training relies on collective communication primitives such as All-Reduce and All-Gather. The test environment used the communication library provided by the hardware vendor. This library automatically detects intra-node and inter-node topology and selects the best communication path.
    • Distributed framework: The team used a hybrid of data parallelism and model parallelism. At 16 GPUs, data parallelism is the main choice. For very long sequences (such as a 128K context), sequence parallelism is needed to split the attention computation.

    3. Training Pipeline Breakdown

    3.1 Data Preparation and Preprocessing

    The data pipeline is usually the first place where training gets blocked. In this test, the training corpus went through tokenization, concatenation and truncation, and mask generation before it became binary samples the model could read.

    To keep data reads from slowing GPU utilization, the pipeline used asynchronous data loading. CPU-side prefetching and tokenization ran in parallel with GPU computation. A multi-process pipeline fed preprocessed data into GPU memory buffers. Because the corpus contains both Chinese and English text, the tokenizer vocabulary extension and special token handling also had to match the model configuration exactly.

    The data pipeline could be structured as follows:

    1. # Data pipeline pseudocode sketch
    2. dataset = load_dataset("bilingual_corpus", cache_dir="./data_cache")
    3. tokenizer = AutoTokenizer.from_pretrained("tokenizer_config")
    4. def tokenize_function(examples):
    5. return tokenizer(
    6. examples["text"],
    7. max_length=8192,
    8. truncation=True,
    9. padding="max_length",
    10. return_tensors="pt"
    11. )
    12. # Use asynchronous prefetching and parallel shuffling
    13. train_loader = DataLoader(
    14. dataset.map(tokenize_function, batched=True, num_proc=32),
    15. batch_size=1,
    16. shuffle=True,
    17. num_workers=8,
    18. prefetch_factor=16,
    19. pin_memory=True
    20. )

    The key parameters are prefetch_factor and num_workers, which must work together. If CPU preprocessing cannot keep up with GPU consumption, training waits for data at intervals and the GPUs sit idle. As a rule of thumb, data loading time should not exceed 10% of a single training step.

    3.2 Parallelism Strategy: From Pure Data Parallelism to Hybrid Parallelism

    At 16 GPUs, pure data parallelism is the simplest approach. Each GPU holds a full copy of the model and processes its own micro-batches. After each step, All-Reduce synchronizes the gradients.

    However, when the model is large or the sequences are very long, a single GPU may not have enough memory for the full model and its activations. This test used a model with 128K long-context capability. With pure data parallelism, the activations would fill a single GPU’s memory quickly. The team therefore used a hybrid of data parallelism and sequence parallelism:

    • Data parallel dimension: The 16 GPUs form four data-parallel groups of four GPUs each.
    • Sequence parallel dimension: Within each group of four GPUs, the attention computation is split along the sequence length. This reduces activation memory pressure on each GPU.

    In code, this strategy requires splitting the QKV linear projections, the Softmax computation, and the output projection of the attention module, then reorganizing communication across GPUs. The simplified sequence parallelism sketch is below:

    1. # Core logic of sequence parallelism (pseudocode)
    2. def attention_with_sequence_parallel(q, k, v, seq_world_size, seq_rank):
    3. # Split Q/K/V along the sequence dimension
    4. local_seq_len = q.shape[1] // seq_world_size
    5. q_local = q[:, seq_rank * local_seq_len: (seq_rank + 1) * local_seq_len, :]
    6. # Compute local attention scores (requires gathering K/V across devices)
    7. k_full = all_gather(k, dim=1) # Gather full K across devices
    8. v_full = all_gather(v, dim=1) # Gather full V across devices
    9. attn_scores = torch.matmul(q_local, k_full.transpose(-1, -2))
    10. ...
    11. return output # Output is the result for the local sequence

    The results show that, at 16 GPUs, hybrid parallelism significantly reduces peak memory compared with pure data parallelism, but it increases communication volume. The next optimization step is to introduce grouped normalization for local computation, which would reduce the number of cross-GPU communication calls.

    3.3 Stability: Checkpoint Resumption and Fault Recovery

    Any long training job must account for occasional device failures. A 400-step run is short, but it is still a good window for testing checkpoint resumption.

    The checkpoint mechanism has two layers:

    1. Periodic checkpoint saving: Every 50 steps, the pipeline saves the model weights, optimizer state (including the first and second moment estimates for Adam), the learning rate scheduler state, and the RNG (random number generator) state.
    2. Asynchronous saving: Checkpoint saving runs on a separate CPU thread so it does not block the GPU training stream. The tensors are first copied from GPU memory to host memory, and a background thread then writes them to disk.

    To test resumption, the training process was killed manually at step 200. After restarting, the pipeline loaded the checkpoint from step 199 or 200. The loss curve after recovery matched the baseline of an uninterrupted run, which confirmed that the save and load process was complete.

    Saving model weights alone is not enough. Without the data iterator position and the random seed for data shuffling, the data order changes after a restart, and training no longer matches the original run. Saving every state variable tied to randomness is therefore required for reproducible recovery.

    4. Performance Observation and Tuning

    4.1 Key Performance Metrics

    During the 400-step run, the team tracked the following metrics:

    • Throughput (tokens per second): Measures GPU compute efficiency and communication efficiency together.
    • Peak memory usage: Monitors the risk of out-of-memory (OOM) errors.
    • Communication ratio: The share of each step’s time spent on communication. This metric shows whether the parallelism strategy is reasonable.

    Under the hybrid parallelism configuration, the measured throughput did not reach the theoretical peak utilization. It was, however, sufficient for routine R&D iteration. The main bottleneck was cross-node communication. Network bandwidth between the two servers was used at about 60%, which leaves room for optimization.

    4.2 Three Key Tuning Techniques

    During training, the team identified three tuning methods that had the most impact:

    First, gradient accumulation with micro-batches. When a single GPU can hold a maximum batch size of only 1 (common in long-sequence scenarios), set the gradient accumulation steps to 8 or 16 to simulate a larger effective batch size. This improves training stability without adding memory pressure.

    Second, overlapping communication with computation. In the default implementation, gradient All-Reduce starts only after backpropagation finishes. Using a communication hook or delayed gradient synchronization, communication for a layer can start as soon as that layer’s gradients are ready. This overlaps communication with the computation of subsequent layers.

    Third, adjusting the loss scaling factor for mixed-precision training. Chinese-made GPUs differ slightly from common platforms in FP16 and BF16 support. The loss scaling factor needs dynamic adjustment based on observed gradient magnitudes to prevent underflow, which can cause loss oscillation.

    5. Problems Encountered and Solutions

    5.1 Missing Operators and Adaptation Priorities

    In the early adaptation phase, some custom operators, such as the fused implementation of rotary position embedding, had no efficient kernel on the GPU. The fix was to prioritize functional correctness. The team used a composite implementation built from basic operators and planned to replace it with a fused kernel later. This confirmed the engineering principle of getting it working first and optimizing second.

    5.2 Cross-Node Communication Jitter

    During training, occasional jitter in cross-node communication latency could double the time of a single step and trigger All-Reduce timeouts. The mitigations included adjusting the communication library’s timeout parameters, enabling port coloring and multi-path transmission, and adding random jitter on the data loading side so that many messages do not fire at the same step.

    6. Summary and Outlook

    This validation of two-node, 16-GPU training on a Chinese-made GPU cluster showed three main results:

    1. The pipeline is complete. Data loading, distributed parallelism, and checkpoint resumption all ran successfully on the hardware.
    2. Hybrid parallelism is feasible. Without relying on very large memory per device, combining sequence parallelism with data parallelism unlocked the training capacity.
    3. The software stack is ready for engineering use, with some friction. Operator adaptation, communication library compatibility, and framework integration still add cost, but the stack has reached a state suitable for engineering use.

    As drivers and ecosystem tools for Chinese-made GPUs continue to mature, training pipelines on small clusters are expected to become common R&D infrastructure. Teams planning to validate LLM training on non-traditional GPU platforms should start small, with short runs, and focus first on pipeline completeness. Batch size and model size can then be scaled up step by step. Each validation should test three things: whether results are reproducible, whether training can resume after interruption, and whether performance keeps improving. These checks are the core of engineering distributed training.