Domestic GPU Large Model Training Adaptation and Stability Troubleshooting Guide

    This guide explains why adapting large models for training on domestic GPUs is more difficult than inference, and how to validate training correctness and stability step by step. It covers memory pressure, distributed parallelism, operator compatibility, phased validation from a minimal trainable prototype to multi-node stress testing, key stability indicators, troubleshooting tables, monitoring, logging, checkpointing, and a sample training loop. It also explains how to describe hundreds of continuous training steps accurately by specifying hardware scale, model size, parallel strategy, and observation conditions.

    1. Why training adaptation is harder than inference

    As large model parameter sizes continue to grow, training adaptation on domestic GPU platforms has become a necessary step for AI infrastructure deployment. Unlike inference deployment, training must not only produce a forward output, but also ensure that backward propagation, optimizer updates, gradient synchronization, mixed precision, and checkpoint recovery remain correct during long-running execution.

    For GPU training troubleshooting, many issues do not fail immediately. Instead, they may appear only after multiple iterations as abnormal loss, gradient norm drift, communication timeouts, memory fragmentation, or process hangs.

    Therefore, multi-node multi-GPU stability should not be judged only by whether the training job can start. It should be judged by whether training can continue in a sustained, reproducible, and recoverable way. The core of training adaptation is to establish a complete closed loop covering data loading, model construction, distributed sharding, forward computation, backward propagation, and parameter updates. Around this loop, teams should also build a verifiable engineering system for memory optimization, parallel strategies, operator compatibility, monitoring, and logging.

    From a practical perspective, training adaptation must satisfy three types of goals:

    1. Computational correctness: loss, gradients, and parameter updates should behave as expected, without NaN, Inf, or abnormal drift.
    2. Runtime stability: multi-GPU, multi-node, and long-running training should not crash, hang, or exit frequently.
    3. Acceptable performance: throughput, communication efficiency, memory usage, and scaling efficiency should remain within an acceptable range.

    The key to domestic GPU training adaptation is not whether the model can run one step. It is whether the model can continue running for many steps, with every step remaining correct.

    2. Why training adaptation often fails: memory, parallelism, and operator bottlenecks

    2.1 Memory pressure and memory optimization

    Large model training requires maintaining much more state than inference. For a typical Transformer-like model, training must store not only model parameters, but also gradients, optimizer states, activations, and many intermediate tensors. As parameter size increases, memory consumption can grow significantly.

    On domestic GPUs, memory capacity, bandwidth, and memory management mechanisms may differ from those of mainstream hardware ecosystems. Therefore, memory optimization should focus on several questions:

    • Can a single GPU hold the model shard?
    • Can activation recomputation effectively reduce peak memory usage?
    • Can mixed precision balance numerical stability and memory consumption?
    • Are parameter sharding and gradient aggregation across GPUs reasonable?
    • Will long sequences or high-dimensional inputs cause memory spikes?

    If teams only consider inference memory usage and ignore backward propagation and optimizer states, training may fail early due to insufficient memory or interruption.

    Memory issues do not always appear as a direct OOM error. Sometimes they appear as slower training, increased communication waiting, frequent cache reclamation, or even a process appearing to hang.

    2.2 Parallel strategy complexity

    When model size exceeds the memory capacity of a single machine, distributed parallel strategies become necessary. Common strategies include data parallelism, tensor parallelism, pipeline parallelism, expert parallelism, and sequence parallelism. These strategies impose different requirements on communication patterns, computation granularity, and memory management.

    A major challenge of domestic GPU training adaptation is that distributed strategies cannot rely only on theoretical reasoning. They must also be validated on real hardware topology to check whether communication efficiency matches the computation workload.

    For example:

    • In data parallelism, gradient synchronization happens frequently, so strong collective communication capability is required.
    • In tensor parallelism, communication inside a single operator is frequent, so inter-GPU links and low-latency communication matter.
    • In pipeline parallelism, layer boundaries must be partitioned carefully to avoid excessive pipeline bubbles.
    • In multimodal models, different submodules may use different precisions or parallel strategies, increasing scheduling complexity.

    Therefore, training adaptation must select strategies based on the specific model structure and hardware interconnect conditions. A parallel strategy that works in theory does not necessarily run stably and efficiently on a real domestic GPU cluster.

    2.3 Operator compatibility and numerical stability

    The training path involves many operators, including matrix multiplication, normalization, activation functions, loss functions, gradient accumulation, gradient clipping, and weight updates.

    Inference usually focuses only on forward output. Training also exposes issues in backward operators, mixed precision scaling, and gradient clipping.

    If some operators on domestic GPUs behave slightly differently from a reference implementation, training may not fail immediately. However, as training progresses, errors may accumulate and eventually appear as abnormal loss, sharply increasing gradient norms, or training divergence.

    During training adaptation, teams should continuously observe the following:

    • Is loss decreasing smoothly?
    • Is gradient norm within a reasonable range?
    • Is the learning rate scheduler working as expected?
    • Are there abrupt changes in parameter updates?
    • Are there numerical overflow or underflow issues?

    These are the basic indicators for validating training stability. For operator adaptation, success is not limited to whether an operator can be called. It also includes whether the operator remains consistent under continuous backward propagation and mixed precision conditions.

    2.4 Long training chains require an engineering foundation

    Small-scale experiments can often be validated by manually checking logs. Large-scale training, however, usually requires automated toolchains.

    Training adaptation is not only an algorithm problem. It is also an engineering problem. Long-running training requires an engineering foundation that supports observability, reproducibility, and rollback, including monitoring, logging, checkpoints, and exception recovery.

    To avoid duplication, this section does not list engineering details here. Monitoring items, log items, and checkpoint items are explained together in Section 5.

    3. Phased training adaptation process: from minimal prototype to multi-node stress testing

    To reduce adaptation risk, it is usually better to proceed through phased validation rather than directly pursuing large-scale training from the beginning.

    Phase 1: Build a minimal trainable prototype

    First, extract a minimal training path from the model definition. The goal is to let the model complete one full forward pass, backward pass, and parameter update under a relatively simple configuration.

    This phase focuses on verifying the following:

    • Can the model load successfully?
    • Is the forward output normal?
    • Are backward gradients non-zero?
    • Can the optimizer perform one parameter update?
    • Is loss finite?

    If the minimal prototype cannot complete one training iteration, expanding it to multi-GPU training has little meaning. This phase should avoid introducing complex parallel strategies too early so that model definition, data loading, optimizer, and basic operator issues can be ruled out quickly.

    Phase 2: Single-node multi-GPU validation

    After the minimal prototype passes, validation can move to single-node multi-GPU execution. This phase focuses on intra-node multi-GPU communication, memory allocation, and parallel strategy correctness. A table-based check can be used:

    Check item Acceptance criteria Common anomalies
    Gradient consistency Aggregated gradients are close to single-GPU gradients Some GPUs have zero gradients, differences are too large, or updates are abnormal
    Loss consistency Losses across GPUs are close and trends are consistent Loss clearly diverges or becomes NaN
    Memory distribution Memory usage is relatively balanced across GPUs One GPU stays near memory limit, memory fragmentation occurs, or OOM appears
    Communication status Collective communication completes without long waits Communication timeout, process hang, or sudden throughput drop
    Parameter update Parameters change after an optimizer step Parameters do not update or update magnitude is abnormal

    Single-node multi-GPU validation is an important stage for checking basic distributed capability. It helps teams first rule out intra-node communication and memory management issues.

    Phase 3: Cross-node joint training test

    After single-node training becomes stable, training can be extended across nodes. Cross-node scenarios are more likely to expose network topology, collective communication, parameter synchronization, and fault recovery issues.

    For a two-node multi-GPU setup, teams should focus on the following:

    • Is cross-node communication stable?
    • Is gradient synchronization correct?
    • Is training loss consistent with the trend observed on a single node?
    • Does network jitter cause training delays?
    • Do all processes remain synchronized during exit?
    • Do numerical anomalies appear during long-running execution?

    Cross-node training is a key validation point in training adaptation because many issues only appear in multi-node environments. Cross-node bandwidth, network interface queue behavior, topology affinity, and communication library parameter settings can all become stability bottlenecks.

    Phase 4: Continuous multi-step stability stress testing

    Short-term training can only show that the model can run. Continuous multi-step training is needed to show that the training path is stable.

    To make the judgment executable, stress tests should define clear conditions. The table below is an example. Real projects can adjust it according to hardware and model scale.

    Item Example condition
    Hardware scale Two nodes, 16 GPUs total, 8 GPUs per node
    Model scale Approximately 7B parameters or the team’s target model scale
    Parallel strategy Data parallelism + tensor parallelism + activation recomputation
    Continuous steps Complete at least 500 optimizer updates continuously
    Loss requirement 100% finite-loss rate; no NaN or Inf
    Gradient norm Set a reasonable upper limit, for example P99 not exceeding 5.0, or calibrate it against a baseline model
    Communication timeout Alert if a single collective communication exceeds a preset threshold, for example 30 seconds
    Memory requirement Per-GPU memory usage remains stable; fluctuations should not be too large; no sustained memory limit usage
    Throughput requirement Throughput decay during continuous execution remains within an acceptable range

    Under the example conditions above, if loss and gradient norm remain finite throughout, with no numerical overflow, abnormal interruption, or continuous communication timeout, the training path can be considered to have good baseline stability under that configuration.

    The meaning is not only how many steps were run. More importantly, it verifies that the training process remains controllable under real update pressure.

    Phase 5: Exception recovery and observability validation

    Large-scale training will not always run without failure. Therefore, the adaptation system must also validate exception recovery capability. Teams should check the following:

    • Is checkpoint saving supported?
    • Is recovery from checkpoints supported?
    • Are logs sufficient to locate issues?
    • Can monitoring metrics detect anomalies in advance?
    • After a training failure, can faulty GPUs or nodes be isolated quickly?

    Risks also need attention:

    • Checkpoint save failures may cause rollback to lose progress.
    • Corrupted data may cause loss jumps.
    • Hanging processes may continue to occupy GPU resources.
    • Long-running training without a watchdog mechanism may waste resources.

    With awareness of these risks, training adaptation can move from a one-time experiment to sustainable engineering practice.

    4. How to interpret core stability indicators? Troubleshooting table

    During training adaptation, training stability should not be judged only by whether loss decreases. It should be evaluated using multiple indicators.

    4.1 Is loss finite and does it follow a reasonable trend?

    Loss is one of the most direct health indicators during training. If loss becomes NaN or Inf, it usually means numerical computation has become abnormal. Possible causes include mixed precision overflow, an overly large learning rate, gradient explosion, abnormal data, or operator implementation issues.

    Stable training usually requires the following:

    • Loss remains finite at every step.
    • Loss follows the expected overall trend.
    • There are no severe jumps.
    • During the warmup stage, training does not diverge prematurely due to learning rate changes.

    4.2 Is gradient norm within a reasonable range?

    Gradient norm reflects whether backward propagation is working correctly. If gradient norm is zero, the model may not be learning effectively. If gradient norm is too large, parameter updates may become unstable.

    During training, teams should observe the following:

    • Is gradient norm finite?
    • Does gradient norm fluctuate within a reasonable range as training progresses?
    • Is gradient clipping effective?
    • Does gradient norm suddenly explode?

    4.3 Are parameter updates continuous?

    Whether the optimizer update step executes successfully is a key part of training adaptation. Training adaptation is not only about one forward and backward pass. It also requires checking whether optimizer.step actually completes parameter updates.

    If parameters do not change, or if the update magnitude is abnormal, the training path has a problem.

    4.4 Are memory and communication stable?

    Stable training is not only numerical stability. It also includes stable resource usage. Teams should check the following:

    • Do GPUs continuously approach the memory limit?
    • Does memory allocation become fragmented?
    • Is communication waiting too long?
    • Do collective communication operations time out frequently?
    • Does training throughput decrease over time?

    If training is normal at the beginning but becomes slower later, it may indicate bottlenecks in caching, communication, or scheduling mechanisms.

    4.5 Are logs and exceptions traceable?

    Every training adaptation should preserve complete logs. Only when logs are traceable can later issue localization have a solid foundation.

    4.6 Common issue troubleshooting table

    Symptom Possible causes Troubleshooting actions Recommended handling
    Loss jumps or NaN/Inf appears Mixed precision overflow, learning rate too high, abnormal data, operator numerical differences Locate the abnormal step; inspect data for that step; disable mixed precision to reproduce; compare with reference implementation Adjust learning rate, fix data, switch precision strategy, or roll back checkpoint
    Abnormal gradient norm Gradient explosion, clipping failure, backward operator issue, abnormal samples Print layer-wise gradients; check clip threshold; compare single-GPU and multi-GPU gradients Enable or fix gradient clipping; skip abnormal samples; reduce learning rate if necessary
    Memory fragmentation or OOM Activation spikes, unreleased cache, uneven sharding, long sequence inputs Inspect memory timeline; reduce batch size or sequence length; check recomputation configuration Adjust parallel strategy, enable activation recomputation, optimize sharding and cache release
    Communication timeout Network jitter, topology mismatch, improper communication library parameters, abnormal node load Check network interface status, link quality, process liveness, and communication logs Optimize topology binding, adjust timeout parameters, switch communication backend, or isolate faulty nodes
    Process hang Collective communication mismatch, deadlock, IO blocking, missing watchdog Check process stack, last logs, node resource usage, and communication call status Add timeout watchdog, fix collective mismatch, restart the job and preserve the scene

    5. Engineering system: monitoring, logs, and checkpoints

    If training adaptation remains only at the temporary script level, it will be difficult to support continuous iteration. A mature solution needs an engineering system that moves model adaptation from manual operation to automated, standardized, and reusable practice.

    To avoid duplication, this section presents monitoring items, log items, and checkpoint items together.

    5.1 Monitoring items

    Monitoring item Purpose Recommendation
    Loss curve Determine whether training converges or diverges Set alerts for NaN/Inf and abnormal jumps
    Gradient norm Determine whether backward propagation is stable Set an upper threshold and observe quantiles
    Learning rate change Determine whether the scheduler behaves as expected Compare with configuration; check warmup and decay
    Training throughput Determine whether performance drops abnormally Monitor throughput decay over continuous windows
    Memory usage Determine whether memory is near the limit or fragmented Record peak, average, and fluctuation
    Communication time Determine whether collective communication is abnormal Alert on timeouts and long-tail latency
    Process liveness Determine whether the job hangs Add heartbeat and watchdog mechanisms
    Checkpoint status Determine whether saving succeeds Verify file integrity after saving

    5.2 Log items

    Log item Purpose Recommendation
    Model configuration Reproduce model structure Save layer configurations, dimensions, attention heads, and related fields
    Parallel strategy Reproduce distributed configuration Record parallel methods, sharding rules, and process mapping
    Environment versions Locate software stack differences Record driver, framework, communication library, and operator library versions
    Data loading information Locate data anomalies Record data sources, indices, random seed, and reading progress
    Training step Locate where the issue occurs Record every step or at fixed intervals
    Loss and gradient norm Determine numerical state Record both scalars and quantiles
    Memory usage Locate resource issues Record per-GPU peak and current values
    Communication time Locate communication bottlenecks Record collective communication start time, end time, and duration
    Exception stack Quickly locate failure points Keep the full stack trace and process ID
    Checkpoint path Facilitate recovery Record path, version, checksum, and save time

    5.3 Checkpoint items

    Checkpoint item Purpose Recommendation
    Model weights Restore model parameters Save sharded weights and verify consistency
    Optimizer state Restore optimizer momentum or second-order state Avoid saving only weights, which may cause recovery deviation
    Learning rate scheduler state Restore training rhythm Record current step and scheduler state
    Data loading progress Avoid repeating or skipping data Save data indices or sampling progress
    Random number state Improve reproducibility Save Python, NumPy, and framework random states where possible
    Training configuration Facilitate reproduction Save the complete configuration and version number
    Save verification Prevent bad checkpoints Perform readability and integrity checks after saving

    6. Sample training loop and dependency notes

    To make the training adaptation process easier to understand, the following pseudocode describes a typical training loop. A real engineering implementation may be much more complex, but the core logic is basically the same.

    The code below assumes the following:

    1. The training framework supports a mixed precision context.
    2. The optimizer supports zero_grad and clears gradients after each parameter update.
    3. Gradient accumulation steps are a positive integer.
    4. The model is initialized before training starts, and the gradient buffer is empty or cleared before the first training run.
    5. The logger and checkpoint modules have been integrated.
    1. # Assumption: model, optimizer, learning rate scheduler, mixed precision context, and logger are initialized
    2. # Assumption: zero_grad is called before training starts to ensure the gradient buffer is empty or zero
    3. for step in range(total_steps):
    4. batch = get_next_batch()
    5. with mixed_precision_context():
    6. output = model(batch)
    7. loss = compute_loss(output, batch.label)
    8. loss = loss / gradient_accumulation_steps
    9. # Backpropagation is executed for each batch, and gradients are accumulated into parameter.grad
    10. loss.backward()
    11. if (step + 1) % gradient_accumulation_steps == 0:
    12. # After gradient accumulation, clip gradients first, then update parameters
    13. clip_grad_norm(model.parameters(), max_norm=1.0)
    14. optimizer.step()
    15. # Clear gradients after parameter update to prepare for the next accumulation round
    16. optimizer.zero_grad(set_to_none=True)
    17. if step % log_interval == 0:
    18. log_metrics(
    19. step=step,
    20. loss=loss.item(),
    21. grad_norm=compute_grad_norm(model.parameters()),
    22. lr=optimizer.lr,
    23. memory_usage=get_memory_usage()
    24. )
    25. if step % save_interval == 0:
    26. save_checkpoint(model, optimizer, scheduler, step)

    In this process, training adaptation should focus on verifying the following:

    • Whether forward and backward computation under mixed_precision_context() are normal
    • Whether loss.backward() generates valid gradients
    • Whether gradient clipping correctly limits gradient norm
    • Whether the optimizer update succeeds
    • Whether logged loss and gradient norm values are finite
    • Whether memory usage and throughput remain stable
    • Whether checkpoints can be saved successfully

    Special attention should be paid to execution order: first perform gradient accumulation, then apply gradient clipping, then call the optimizer update, and finally execute zero_grad. If the order is wrong, gradients may be cleared too early, the clipping target may be incorrect, or parameter updates may become abnormal.

    First-time gradient initialization is also important. After model construction, ensure that parameters have requires_grad=True and that the gradient buffer is not contaminated by previous training.

    7. From “can train” to “ready to train out of the box”

    The ultimate goal of domestic GPU training adaptation is not merely to validate one model. It is to gradually build reusable training capability.

    “Ready to train out of the box” does not simply mean providing hardware. It means enabling developers to complete model migration, training startup, and stable operation within a relatively short time.

    To achieve this goal, the following areas need continuous development:

    1. Operator ecosystem improvement: Training adaptation depends on low-level operator support. Matrix operations, normalization, activation functions, loss functions, and distributed communication must be stably implemented and continuously optimized for critical large-model training paths.
    2. Parallel strategy templating: Common model structures should be paired with parallel strategies, memory optimization schemes, and communication configurations. Turning these into templates can significantly reduce adaptation costs.
    3. Toolchain standardization: The toolchain should cover environment preparation, model conversion, training startup, log collection, monitoring alerts, checkpoint management, and exception recovery.
    4. Stronger observability: Unified logs, metric monitoring, and trace analysis can help quickly determine whether an issue comes from data, model, operators, communication, or hardware.
    5. Automated adaptation flow: From model loading to multi-node training, the adaptation process should be automated as much as possible to reduce manual configuration errors.

    8. Conclusion: How to describe stable training over hundreds of steps

    Completing large model training adaptation on domestic GPUs is an important step toward mature AI infrastructure. Compared with inference deployment, training adaptation involves a more complex computation path, stricter correctness requirements, and a longer stability validation cycle. Only when model loading, parallel sharding, operator adaptation, gradient synchronization, numerical monitoring, and engineering toolchains form a closed loop can the system truly support large model training.

    For statements such as “continuous stable training for hundreds of steps,” it is important to avoid unsupported generalization. A more rigorous approach is to add measurement context.

    For example, in a sample stress test, two nodes with 16 GPUs ran a model of approximately 7B parameters using data parallelism, tensor parallelism, and activation recomputation. The training run completed 500 optimizer updates in about two hours. Observation tools covered loss, gradient norm, memory usage, communication time, and process liveness. Under these conditions, if loss and gradient norm remained finite, and no NaN, Inf, communication timeout, or process hang occurred, the training path can be considered to have basic stability under that configuration.

    This conclusion only applies to the current hardware scale, model size, parallel strategy, and observation conditions. It should not be directly generalized to all models, all clusters, or all software stack versions.

    In the future, as domestic GPU software stacks, operator ecosystems, and training toolchains continue to improve, large model training adaptation will gradually move from point validation toward standardization, automation, and scale. This will provide a foundation for efficiently training more complex models on domestic compute platforms.