Troubleshooting Training Adaptation for Chinese AI Accelerators in Large Model Training

    This article explains how engineering teams adapt Chinese AI accelerators for large model training and troubleshoot common failures in multi-card and multi-node environments. It covers the differences between training and inference adaptation, key training stages such as model loading, sharding, mixed precision, communication, and checkpoint recovery, as well as validation criteria and production-readiness practices. It helps readers move from basic runnability to stable, reproducible, and maintainable training.

    Troubleshooting Training Adaptation for Chinese AI Accelerators in Large Model Training

    In large model training, engineering teams often ask two questions: how to adapt Chinese AI accelerators for training, and why two-node or multi-card training jobs fail. Training adaptation is not about running one inference pass. It must keep parameter updates correct, stable, and recoverable across long-running, multi-device, multi-stage jobs. This article focuses on the critical training path, troubleshooting checklists, and acceptance criteria, helping teams move from “it can run” to “it can train stably, reproducibly, and operationally.”

    1. Training Adaptation vs. Inference Adaptation

    Inference and training are often discussed together, but their engineering focus is different. Inference mainly concerns forward computation, request throughput, and response latency. Training must handle the full loop: backpropagation, gradient reduction, optimizer state management, parameter updates, checkpoint saving, and recovery after failures.

    Dimension Inference Adaptation Training Adaptation
    Core computation Mainly forward computation Full loop of forward, backward, and parameter updates
    Optimizer Usually not involved Optimizer state must be maintained correctly
    Communication Relatively lighter Gradient synchronization and cross-node communication can be major bottlenecks
    Numerical stability Focuses on whether outputs are reasonable Focuses on loss, gradients, loss scaling, and overflow detection
    Long-term stability Focuses on single or batched responses Focuses on continuous updates, fault recovery, and reproducibility

    Therefore, evaluating whether a Chinese AI accelerator has completed training adaptation is not enough by checking whether it can load a model and produce output. You also need to verify multi-card coordination, complex operator adaptation, long-term stability, fault recovery, and training observability.

    2. Critical Training Adaptation Path

    2.1 Model Loading and Weight Initialization

    The first step is to load the model architecture, weight files, and optimizer configuration into the training environment. For large models, full parameters usually cannot fit on one accelerator card, so model sharding and loading strategies must be designed in advance.

    After model loading and weight initialization, run the loading troubleshooting checklist:

    • Weight format compatibility: Confirm whether the weight file is safetensors, bin, or another format, and avoid incomplete format conversion.
    • dtype consistency: Check whether parameters, gradients, and optimizer states use the expected fp16, bf16, or fp32, and avoid misalignment between master weights and low-precision copies.
    • Shard key completeness: Verify that tensor keys, shard order, and shard sizes are consistent across ranks to avoid missing parameters.
    • Checkpoint compatibility: Confirm that the step, model architecture, optimizer configuration, and scheduler state in the checkpoint match the current job.
    • OOM risk: Memory budget must cover parameters, gradients, optimizer states, and activations, not just model weights.
    • Shape matching: Pay attention to embeddings, positional encodings, intermediate layer dimensions, vocabulary size, and tensor shapes after parallel sharding.

    Recommended troubleshooting order:

    1. Validate the model structure with one card and a small batch.
    2. Print model keys and shapes.
    3. Check rank, world_size, and parallelism settings.
    4. Verify whether the checkpoint is complete.

    If parameters are missing, shapes do not match, or shard order is wrong during loading, later training may start but still produce incorrect results.

    2.2 Parameter Sharding and Parallelism Strategies

    Large model training usually cannot rely on a single card, so parallelism is central to training adaptation. Common strategies include data parallelism, tensor parallelism, pipeline parallelism, sequence parallelism, and parameter-sharding parallelism. In practice, multiple strategies are often combined.

    For Chinese AI accelerator platforms, enabling fully sharded data parallelism or other parameter-sharding paths requires conditional checks. It is not safe to assume that native support means it can be enabled directly. Usually, the following conditions must be met:

    • Whether the number of cards satisfies parallelism and memory-sharding requirements;
    • Whether the parallel combination matches the model architecture;
    • Whether the communication library version supports the target parallelism strategy;
    • Whether the memory budget covers parameters, gradients, optimizer states, and communication buffers;
    • Whether communication and computation can overlap effectively.

    If these conditions are not met, enabling advanced parallelism may cause out-of-memory failures, communication timeouts, or throughput degradation. In engineering practice, start with a small-scale validation, then scale up to a multi-node, multi-card environment.

    2.3 Mixed Precision and Numerical Stability

    Large model training often uses mixed precision to balance compute efficiency and memory usage. A common approach is to use lower precision for some forward and backward computations while keeping high-precision copies of critical parameters and optimizer states.

    Mixed precision can reduce costs significantly, but it can also introduce numerical instability. Build a checklist for common errors:

    • loss or grad_norm becomes NaN or Inf;
    • gradient clipping fails or the threshold is unreasonable;
    • loss scaling behaves abnormally, and dynamic scaling does not recover in time;
    • optimizer state is out of sync with master parameters;
    • some operators overflow or lose precision in low precision;
    • abnormal samples in the data cause sudden loss changes.

    A reasonable troubleshooting sequence:

    1. Confirm whether non-finite values come from loss or grad_norm.
    2. Check whether the data batch is normal.
    3. Verify whether critical operators support the target precision.
    4. Enable overflow detection and dynamic loss scaling.
    5. Check whether gradient clipping is effective.
    6. Roll back to the last valid checkpoint and reduce batch size or adjust the precision strategy.

    Numerical stability should not be judged by a single run. Define clear criteria: loss and grad_norm must remain finite; if non-finite values appear, record the step, data batch, and communication state; repeated anomalies should be treated as training failure or requiring rollback, not as a reason to simply restart and continue.

    2.4 Communication and Gradient Synchronization

    The core of multi-card training is coordination. In each training step, each device completes local computation, then gradients must be reduced, synchronized, and used to update parameters. If communication capacity is insufficient or topology scheduling is poor, training time can increase significantly.

    To locate communication bottlenecks, consider:

    • Separately record computation time, communication time, and idle waiting time by stage;
    • Check whether gradient reduction sufficiently overlaps with computation;
    • Observe whether cross-node training has network jitter or timeouts;
    • Review communication library logs and topology detection results;
    • Compare throughput across different parallelism dimensions;
    • Determine whether synchronization waiting wastes time.

    In a two-node, 16-card environment, cross-node training introduces additional complexity in network communication, process management, and state synchronization. If the platform cannot handle cross-node gradient synchronization reliably, training processes may hang, throughput may drop, and jobs may be interrupted. Therefore, communication adaptation should not only ask whether synchronization works, but also whether it is efficient, observable, and diagnosable.

    2.5 Checkpoints and Failure Recovery

    Large model training is long and expensive. If training is interrupted without a reliable checkpoint mechanism, previous progress may be lost. The training platform should support periodic checkpoint saving and fast recovery after failures.

    Checkpoint consistency checks should at least cover:

    • Model parameters are complete;
    • Optimizer states are complete;
    • Learning rate scheduler state is correct;
    • Current training step is consistent;
    • Random number states are saved;
    • Data loading progress can be resumed;
    • Distributed process states are consistent;
    • Checkpoint files have been fully written to disk and passed validation.

    For long-running jobs, checkpoints affect not only recovery but also operational efficiency. Mature platforms should support automatic saving, version management, incremental storage, and automatic rollback after failures. However, if a checkpoint has not finished writing or fails validation, do not blindly roll back or restart, because that may further damage training progress.

    3. Validation Criteria for Continuous Two-Node Multi-Card Training

    Before discussing continuous two-node multi-card training validation, define the validation criteria. Otherwise, statements such as “completing hundreds of optimizer updates” lack verifiability and cannot serve as acceptance criteria.

    Recommended validation criteria:

    • Test environment: two nodes with multiple cards, or a network and topology close to the target production environment;
    • Optimizer update steps: complete at least 300 valid optimizer updates; for long-period tasks, 1000 steps or more are recommended;
    • Sampling frequency: record loss and grad_norm at every step, and summarize at least every few steps; logs should be traceable;
    • Finite-value threshold: loss and grad_norm must be finite; NaN or Inf should be treated as failure;
    • Test duration: recommended at least 2 hours, or enough to cover one checkpoint save and recovery cycle;
    • Failure criteria: non-finite values, process exit, no updates for multiple consecutive steps, throughput below baseline, or cross-node synchronization timeouts should all be considered validation failures.

    Under these criteria, continuous two-node multi-card training validation matters in three areas:

    1. It validates cross-node coordination by confirming that inter-device communication, process orchestration, and resource scheduling are stable.
    2. It validates backpropagation and optimizer updates by confirming that gradient accumulation, parameter changes, and optimizer state maintenance work correctly.
    3. It validates numerical stability by confirming that loss and gradient norm remain healthy during continuous execution.

    4. From Point Adaptation to an Engineering System

    A successful training job does not mean the platform can provide long-term service. A production-oriented training platform needs a complete engineering system.

    4.1 Operator Adaptation

    Large models involve many operators, including attention computation, normalization, activation functions, matrix multiplication, and loss functions. Operator adaptation must consider not only functional correctness, but also precision deviation, shape compatibility, mixed-precision support, backward gradient support, and room for performance optimization.

    4.2 Distributed Scheduling

    Large-scale training usually involves multi-node, multi-card job orchestration. The platform should support job submission, resource allocation, process startup, log collection, and status monitoring. If scheduling capability is insufficient, a single-point failure can cause the whole training job to fail.

    4.3 Automated Tooling

    Training adaptation often includes repetitive work such as configuration generation, environment validation, performance analysis, log archiving, and checkpoint management. Automated toolchains reduce manual intervention and improve training efficiency. Common capabilities include training job templates, environment dependency detection, configuration consistency checks, metric visualization, anomaly alerts, and automatic recovery policies.

    4.4 Observability

    Training is complex system behavior, so the platform needs strong monitoring and logging. At minimum, monitor device utilization, memory usage, communication bandwidth, compute throughput, loss, gradient norm, learning rate, process liveness, and checkpoint saving status. Weak observability delays problem detection; strong observability improves reliability and operational efficiency.

    4.5 Pre-Production Checklist

    Before production, complete at least the following checks:

    • Are training job templates standardized?
    • Are environment dependencies detected automatically?
    • Are configuration files version-controlled?
    • Are key metrics visualized?
    • Do anomalies trigger alerts?
    • Have automatic recovery policies been validated?
    • Do checkpoints support validation and rollback?
    • Can performance analysis identify bottlenecks?

    5. Illustrative Training Flow

    The following pseudocode shows the core logic of a distributed training loop. It illustrates the inputs, outputs, metric sampling, and rollback conditions to consider in training adaptation.

    1. # Input: model, optimizer, scheduler, data_loader, max_steps, checkpoint_dir
    2. # Output: training logs, loss/grad_norm metrics, and valid checkpoint paths
    3. def run_training(model, optimizer, scheduler, data_loader, max_steps, checkpoint_dir):
    4. for step in range(start_step, max_steps):
    5. batch = data_loader.next(step)
    6. # data_loader.next(step) input: step; output: training batch such as input_ids, labels, and mask
    7. result = train_one_step(model, optimizer, batch)
    8. # train_one_step input: current model, optimizer, and batch
    9. # Output: loss, grad_norm, and updated model and optimizer states
    10. loss = result.loss
    11. grad_norm = result.grad_norm
    12. if not (is_finite(loss) and is_finite(grad_norm)):
    13. log_error(step, loss, grad_norm)
    14. valid_ckpt = get_last_valid_checkpoint(checkpoint_dir)
    15. if valid_ckpt is not None and validate_checkpoint(valid_ckpt):
    16. restore(valid_ckpt)
    17. continue
    18. else:
    19. alert_and_stop(step, reason="checkpoint invalid or missing")
    20. break
    21. scheduler.update()
    22. if step % log_interval == 0:
    23. report_metrics(step, loss, grad_norm)
    24. if step % checkpoint_interval == 0:
    25. ckpt_path = save_checkpoint(model, optimizer, scheduler, step, checkpoint_dir)
    26. validate_checkpoint(ckpt_path)

    In this flow, rollback must satisfy explicit conditions: the checkpoint has been fully written to disk, integrity validation has passed, and the step and model architecture match. If the checkpoint is not validated or not fully written, do not roll back or restart immediately. Instead, stop the job, preserve the current state, and alert for handling.

    6. Conclusion

    Training adaptation for Chinese AI accelerators is not a one-time demonstration. It is a systems engineering effort involving model loading, parameter sharding, mixed precision, gradient synchronization, communication optimization, checkpoints, failure recovery, monitoring, alerting, and automated operations. Completing training adaptation and sustaining continuous updates in a two-node, multi-card environment shows that a domestic compute platform is moving from point validation to systematic engineering.

    For developers and technical decision-makers, understanding the critical training path helps assess the maturity of domestic compute platforms more accurately and provides a reference for building large model training infrastructure. It is especially important to remember: if a checkpoint is not validated or not fully written, do not roll back or restart directly, to avoid losing training progress. Only when operators, parallelism strategies, communication optimization, scheduling systems, and operational tools evolve together can Chinese AI accelerators move from “can train” to “train stably, train efficiently, and train out of the box” in more large model training scenarios.