Domestic GPU Training Adaptation: How to Validate Training Stability

    Running inference on a GPU is very different from training on it. This article explains why training adaptation is far more demanding, breaks down the four key links in a training pipeline, shows how to organize sharded training with FSDP2, and presents a three-layer validation approach with a practical stability checklist for long-running distributed training.

    Inference Working Doesn’t Mean Training Works

    When discussing domestic (China-produced) compute hardware, “whether it can run inference” and “whether it can complete training” are often conflated. The engineering difficulty of the two differs enormously.

    The core of inference adaptation is operator coverage and precision alignment. Once a model is released, the hardware vendor fills in operators such as attention computation, expert routing, normalization, and activation functions, ensuring the forward pass produces correct outputs. This kind of validation only covers the forward path and says nothing about whether backpropagation and parameter updates actually work.

    Training adaptation must build on inference by getting several additional paths working: gradient computation in backpropagation, optimizer state updates, cross-device gradient synchronization, numerical management under mixed precision, and parameter sharding with communication scheduling in distributed environments. A failure in any single link can lead to out-of-memory errors, loss divergence, or hung processes.

    Therefore, to judge whether a software stack supports training, check whether it can complete several full optimizer update cycles in a row while keeping all metrics normal. Correct forward outputs are only one step in that process.

    1. Model loading and initialization: Weights of very large models require sharded loading or deferred initialization; otherwise a single device cannot hold all parameters.
    2. Distributed parallelism strategy: Data parallelism, tensor parallelism, pipeline parallelism, and expert parallelism can be combined. For MoE models, unbalanced routing loads and inter-expert communication make configuration noticeably harder.
    3. Gradient synchronization and communication: Cross-node ReduceScatter and AllGather place high demands on interconnect bandwidth and the maturity of the communication library. Communication efficiency directly affects training throughput.
    4. Numerical stability management: Loss scaling in mixed precision, gradient norm monitoring, and NaN/Inf handling determine whether training can continue.

    Each link needs to be validated independently. Looking only at the final loss curve makes it hard to tell which link is failing.

    Organizing Sharded Training with FSDP2

    FSDP2 shards parameters, gradients, and optimizer states across devices at the module level. When the forward or backward pass needs a layer’s parameters, they are temporarily gathered and released after use. As a result, per-device memory usage drops as device count increases, so even a small cluster can host larger models.

    The following code illustrates only how sharding and mixed precision are organized. Interface names may differ across PyTorch versions, and device type names vary by vendor—always follow the documentation of the framework you use.

    1. import torch
    2. from torch.distributed.device_mesh import init_device_mesh
    3. from torch.distributed.fsdp import fully_shard, MixedPrecisionPolicy
    4. mesh = init_device_mesh("cuda", (world_size,)) # set the device type per your vendor
    5. mp_policy = MixedPrecisionPolicy(
    6. param_dtype=torch.bfloat16,
    7. reduce_dtype=torch.float32,
    8. )
    9. for block in model.blocks: # shard layer by layer; finer granularity usually means lower peak memory
    10. fully_shard(block, mesh=mesh, mp_policy=mp_policy)
    11. fully_shard(model, mesh=mesh, mp_policy=mp_policy)

    A few points to note:

    • The granularity of per-layer sharding should match the model architecture. Sharding one large module as a whole brings peak memory close to the unsharded level.
    • Using float32 for gradient reduction reduces errors from low-precision accumulation.
    • Save and restore checkpoints using the framework’s distributed checkpointing APIs rather than manually concatenating local shards from each device.

    Validate in Three Layers

    Stability validation should proceed from small to large. Do not move to the next layer until the previous one passes.

    Layer 1: Single-device correctness. Compare layer-wise outputs and gradients against a reference implementation for the same inputs, confirming that operator precision falls within an acceptable error range. This layer catches operator implementation and numerical precision issues.

    Layer 2: Single-node multi-device functionality. Verify that sharding, communication, gradient synchronization, and checkpoint save/restore all work end to end. Start with a smaller model and focus on confirming the functional loop is closed.

    Layer 3: Multi-node long-run stability. Run continuous optimizer updates across nodes while recording loss, gradient norms, peak memory, communication time, and process status throughout. The number of steps should be set based on model scale and business requirements. Pass or fail depends on whether the metrics stay stable—step count is only one condition.

    As for some vendors’ disclosed ultra-large-scale training cases: public information often omits key conditions such as total vs. activated parameter counts, sequence length, batch size, and precision/parallelism configuration, and no independent reproduction exists. When these conditions are missing, the reported step counts or device counts should not be taken directly as validation standards. When you encounter such cases, ask about these conditions first before judging whether they support the conclusion.

    Stability Checklist

    The table below lists the metrics to record during long-run validation. Thresholds must be calibrated for your model, batch size, and precision; it is recommended to build a baseline from a period of normal operation first.

    Metric What to observe Warning signs
    Loss Curve trend and fluctuation magnitude NaN or Inf appears, or sudden jumps followed by sustained divergence
    Gradient norm Changes in the global gradient norm Continuous climbing, or sudden spikes in individual steps
    NaN/Inf count Number of abnormal values in gradients per step Nonzero count occurring repeatedly
    Peak memory Peak memory usage per device Steady growth, or clear imbalance between devices
    Communication time Time spent on AllGather and ReduceScatter per step Large fluctuations, or one node clearly slower
    Process liveness Running status of all ranks One process unresponsive while others wait without progress

    Common Failures and Troubleshooting

    • Out-of-memory early in training: First check the sharding granularity and activation recomputation settings, then confirm the batch size is within expectations.
    • Loss becomes NaN: Check the mixed-precision loss scaling settings, confirm gradient clipping and skipped abnormal steps are enabled, and locate the first layer where the anomaly appears.
    • Sudden gradient norm spikes: Check the data type used for gradient reduction and compare against single-device results to confirm communication results are consistent.
    • Process deadlock: Check that collective communication calls are in the same order across all ranks, and pay special attention to conditional branches where communication operations may execute on only some ranks.
    • Loss discontinuity after checkpoint restore: Confirm that optimizer states, random seeds, and data sampling positions are all restored together.

    When troubleshooting, change only one variable at a time and keep a configuration record of every experiment—otherwise it is very hard to tell which change made the difference.

    From “Capable of Training” to “Training Out of the Box”

    The goal of an engineering system is to let users worry less about low-level communication details. Prebuilt training images, standardized launch scripts, and built-in monitoring and log collection all shorten the path from environment setup to job launch.

    But “training out of the box” depends on the model architecture, cluster scale, software stack version, and operations configuration. The same image can behave very differently on clusters with different topologies. When promoting such capabilities, vendors should also state the applicable model types, scale range, and validated configurations.

    Long-duration training also requires risk planning. Hardware failures are not uncommon in large clusters, so checkpoints should be saved regularly and stored—along with training data—in independent storage to avoid data loss from a single point of failure. Object storage can hold data and checkpoints, container platforms handle job orchestration, and logging services plus monitoring and alerting provide observability. Working together, these common components allow training jobs to recover from interruptions and reduce the cost of full reruns.

    Conclusion

    Training adaptation ultimately answers one question: can the software stack, in a real distributed environment, continuously and stably complete full optimizer updates? Answering it requires layered validation, recorded metrics, and a traceable root cause for every anomaly.

    For readers, a practical approach is to establish your own baseline first, then use the same checklist to evaluate different solutions. Only when metrics and configurations are clearly stated does the claim “ready for training” actually hold up.