Adapting China-Made GPUs for LLM Training: From Running to Stable Training

    This article explains why training adaptation on China-made GPUs is harder than inference adaptation, and what it takes to move from a job that runs to one that trains stably. It covers the FSDP2 training workflow and its hardware constraints, a checklist for long-run stability testing, common failure patterns and how to troubleshoot them, the layers of an engineering stack, and cloud configuration guidance.

    Model parameter counts have reached the trillion scale, and training adaptation is becoming a key test of how mature domestic computing hardware is. Getting a model to run on a chip is very different from getting it to train stably over long periods. The two place very different demands on software and hardware. This article covers four areas: the technical meaning of adaptation, the training pipeline, verification methods, and engineering systems. It helps developers judge how much a given adaptation result is worth.

    1. How Training Adaptation Differs from Inference Adaptation

    Many people treat “adapting a model to a chip” as a single task, but inference adaptation and training adaptation operate at very different scales. During inference, the model weights are fixed, so the chip only needs to execute the forward pass correctly and match the reference implementation’s outputs. During training, the chip must complete the forward pass, backpropagation, and optimizer updates, and keep numerical results reliable across many iterations.

    Comparison dimension Inference adaptation Training adaptation
    Core goal Correct forward computation, with outputs matching the reference implementation A complete loop of forward pass, backward pass, and optimizer update
    Operator requirements Forward operators needed for inference Also requires backward operators, collective communication operators, and optimizer operators
    Weights and sharding Weights are fixed and can be deployed as a whole Parameters, gradients, and optimizer states all need sharding and synchronization
    Memory pressure Mainly weights and inference cache Parameters, gradients, and Adam’s momentum and variance together often amount to several times the size of the parameters themselves
    Numerical stability Accuracy alignment Mixed precision, loss scaling, and gradient clipping must be implemented correctly
    Verification Output consistency and accuracy metrics Long-run loss, gradient norm, throughput, and fault recovery behavior

    Training adaptation therefore tests chip compute, memory capacity, interconnect bandwidth, and software stack maturity at the same time. A weakness in any one of these will surface during long training runs.

    2. How the FSDP2 Training Pipeline Works

    Fully Sharded Data Parallel (FSDP) splits parameters, gradients, and optimizer states across devices to reduce per-device memory usage. FSDP2 wraps modules layer by layer through the fully_shard interface, and parameters are stored as per-device shards. The data flow for one training iteration is roughly as follows.

    1. Forward pass: Before entering a module, the framework runs an all-gather on that module’s parameters to reconstruct the full parameters for computation. After the computation finishes, if reshard_after_forward is enabled, the non-local parameter shards are released immediately to control memory use.
    2. Backward pass: After each module computes its full gradients, a reduce-scatter sums gradients across devices and returns each device’s portion. Each device keeps only the gradient segment it is responsible for.
    3. Optimizer update: AdamW updates parameters on the local shards. Momentum and variance have the same shape as the parameter shards, so optimizer states are sharded too, and no device needs a full copy.

    The example code below omits data loading, mixed-precision policy, and checkpointing logic:

    1. # Illustrative: FSDP2-style layer-wise wrapping
    2. for block in model.transformer_blocks:
    3. fully_shard(block, mesh=device_mesh)
    4. fully_shard(model, mesh=device_mesh)
    5. # Create the optimizer after sharding so its states
    6. # automatically match the local parameter shards
    7. optimizer = torch.optim.AdamW(
    8. model.parameters(), lr=3e-4, weight_decay=0.1
    9. )

    When running on domestic GPUs, three boundary conditions need separate measurement.

    • Peak memory is determined by the largest unit gathered in a single operation. Coarse wrapping granularity means a single all-gather covers more parameters, which raises peak memory. Fine granularity increases the number of communication calls and lowers efficiency.
    • CPU offload can further reduce device memory usage, but moving data between host and device slows throughput. It suits scenarios where memory is tight and throughput requirements are lower.
    • Overlapping communication with computation depends on the prefetching strategy. If the all-gather and reduce-scatter implementations in a custom communication library are not efficient enough, the overlap gains shrink, which directly increases the time per step.

    Multimodal models also include a vision encoder, a projection layer, and a language backbone. These modules differ widely in parameter count and compute density. A reasonable approach is to use fine-grained sharding for the backbone layers and coarser sharding or replicated parallelism for the smaller encoder. The specific strategy should be based on the memory usage and communication time measured for each module, not applied uniformly.

    Cross-node training must also account for bandwidth differences. Interconnects within a node are typically faster than the network between nodes. A common practice is to limit tensor parallelism to within a node, run data or pipeline parallelism across nodes, and reduce cross-node waiting through gradient bucketing and overlapping communication with computation.

    3. How to Verify Stable Training

    Whether a training adaptation has succeeded cannot be judged only by whether the model starts. Some published results, such as “a continuous 400-step optimizer update run on two nodes with 16 accelerators in total,” are only comparable if the following conditions are also disclosed.

    • Accelerator model and memory capacity per device
    • Number of nodes and accelerators per node
    • Parallelism strategy (data, tensor, pipeline, and expert parallelism, and their combinations)
    • Global batch size and sequence length
    • Whether full-parameter training is used, and whether CPU offload is enabled
    • Software stack and operator library versions

    Without this information, a result only shows that the pipeline completed a short run. It does not show whether the system can train stably over the long term. In this context, 400 steps should be treated as one example of a verification procedure, not as a final conclusion.

    The table below provides a checklist for long-run stability testing. The thresholds are examples only and should be set based on the specific model and project.

    Verification item How to collect Pass criteria (example)
    Continuous run duration and step count Global step count from training logs Planned steps reached with no interruptions
    Loss Recorded at every step, checked for NaN and Inf All values stay finite, and the trend stays close to a reference run of the same scale
    Gradient norm Gradient norm before clipping No sustained spikes; raise an alert when the value exceeds the historical median by a set multiple
    Throughput Tokens processed per second, tracked per step Fluctuation stays within the expected range; a sustained decline requires investigation
    Peak memory Peak memory and fragmentation on each device No monotonic growth over time
    Communication stability Collective communication timeout count and latency distribution No timeout errors, and stable P99 latency
    Checkpoint recovery Terminate the process midway, then resume from the most recent checkpoint Loss curve continues after recovery, with no numerical jumps
    Fault injection Simulate a single device dropout or a node network interruption The job restarts according to policy or exits with an error, and does not hang

    Problems that appear during long-run training fall mostly into the categories below.

    Symptom Common causes Troubleshooting steps
    NaN or Inf values Learning rate too high, improper loss scale settings, operator overflow Lower the learning rate, check the dynamic loss scale logs, and compare forward outputs layer by layer
    Gradient spikes Anomalous samples, very long sequences, missing gradient clipping Locate the data batch that triggers the spike, enable gradient clipping, and record the samples
    Memory keeps growing Tensors not released, computation graph retained unintentionally, cache not cleared Check logs for retained computation graph references, and use memory snapshots to locate where growth occurs
    Communication timeouts or deadlocks An abnormal process on a node, topology configuration errors, mismatched communication library versions Verify environment variables and library versions on each node, and inspect the call stack on each rank
    Checkpoint recovery failure Incomplete checkpoint files, parallelism configuration at restore differs from save time Verify checkpoint file integrity, and confirm the parallelism configuration matches the one used at save time

    4. The Four Layers of an Engineering System

    A successful adaptation of a single model is only the starting point. Platform capability comes from a reusable engineering system. A complete training support system usually includes four layers.

    1. Operator layer: Covers the core operators needed by mainstream model architectures, with dedicated optimization for frequently used operators.
    2. Parallel framework layer: Supports data, tensor, pipeline, and expert parallelism, as well as combinations of them.
    3. Toolchain layer: Provides model conversion, accuracy alignment, performance profiling, and checkpoint-based resumption tools to reduce migration cost.
    4. Cluster scheduling layer: Combines a container platform with monitoring and alerting to handle job orchestration, fault tolerance, and elastic recovery.

    Each layer should produce verifiable outputs. For example, the operator layer should provide an operator coverage list, the toolchain layer should provide an accuracy alignment report, and the scheduling layer should provide fault recovery test records.

    5. Executable Configurations for Cloud Combinations

    On cloud platforms, training support capabilities can be assembled from general-purpose cloud services. The configuration directions below can be applied directly, along with their limits.

    • Object storage: Save checkpoints in directories organized by training step, keep the most recent several, verify checksums after each write, and set lifecycle rules to delete old files automatically. The limitation is that write throughput may become a bottleneck for large model checkpoints.