Practice of Training Adaptation for Ultra-Large Open-Source Models on Domestic AI Accelerators
This article explains why training adaptation is harder than inference deployment for large language models. It walks through five stages of the training pipeline on domestic AI accelerators: model loading, parameter sharding, operator alignment, cross-node gradient synchronization, and optimizer safeguards. It also covers how to verify stable, continuous training, troubleshoot common problems, and apply these practices in engineering work.
1. Background: Why Training Adaptation Is Harder Than Inference Deployment
Deploying a large model usually happens in two stages. The first is inference deployment, where the goal is to make trained weights produce correct outputs on the target hardware. The second is training, where the goal is to complete a full loop on the target hardware: forward computation, backpropagation, gradient synchronization, and parameter updates. Training places much higher demands on hardware, communication, and numerical stability than inference does. Every update accumulates error, so a single anomaly can make results hundreds of steps later meaningless.
For open-source models with close to 3 trillion parameters, the memory of a single accelerator card cannot hold the full set of parameters, gradients, and optimizer states. Multiple cards and multiple machines must work together. As a result, the core question of training adaptation has changed from “Can it compute?” to “Can it compute stably and continuously?”
2. Adaptation Versus Pretraining
Two concepts need to be clarified first. Training adaptation means getting the training code path of an existing open-source model to run on a specific hardware platform, and verifying the correctness of its parallelism strategy, operator implementations, and communication links. Pretraining means starting from random initialization and training a foundation model on large-scale data. The two differ in engineering effort and validation criteria. Completing an adaptation does not mean the model’s original weights came from that hardware, and it does not mean the model was fully pretrained on that hardware.
Three checks indicate whether an adaptation can be trusted:
- The training code path fully covers loading, sharding, synchronization, and updates.
- The validation scale includes cross-node communication.
- The results include reproducible numerical metrics.
3. Five Key Stages of the Training Pipeline
3.1 Model Loading and Initialization
Loading a large model should not require a single process to read all weights into memory. A common approach is for each process to read only the parameter shards it is responsible for, directly from storage. All processes must also use the same random seeds, initialization methods, and configuration. Otherwise, gradient synchronization may produce deviations that are difficult to trace.
3.2 Parameter Sharding Strategy
Fully sharded data parallelism splits parameters, gradients, and optimizer states across all processes in the training job. Before a forward pass, parameters are gathered as needed, and they are released after the computation finishes. As the number of processes grows, the memory footprint per process drops roughly in proportion. The cost is higher communication volume. The shard granularity should balance network bandwidth against available memory. Multimodal models also need separate shard boundaries for the vision encoder and the language backbone, so that neither submodule becomes a bottleneck.
3.3 Forward Pass, Backward Pass, and Operator Adaptation
Training involves a wider range of operators than inference. Besides matrix multiplication and attention, it includes normalization layers, backward implementations of activation functions, data type conversion under mixed precision, and recomputation introduced by gradient checkpointing. During adaptation, each operator should be checked against a reference implementation for numerical error, and the tolerance threshold should be recorded explicitly.
3.4 Gradient Synchronization and Cross-Node Communication
In multi-node training, gradient reduction is usually the main bottleneck for both performance and stability. Engineers need to confirm the communication topology and the correctness of collective operations, and they need to check timeout settings across nodes. A common failure occurs when one process exits early or receives data with a mismatched shape, which blocks the whole job. For this reason, each training step should include timeouts and health checks.
3.5 Optimizer Updates and Numerical Protection
Before each optimizer update, apply gradient clipping and log the gradient norm. If a non-finite value appears, skip that update immediately, save the current state, and roll back to the most recent checkpoint. This prevents the abnormal value from spreading through later steps.
4. How to Verify Continuous, Stable Operation
A single forward pass that succeeds does not show that the training process is usable. More convincing verification covers four areas:
- Scale: Cover the complete process group across multiple machines and cards, and confirm that every process takes part in gradient synchronization.
- Duration: Complete hundreds of consecutive optimizer updates without interruption.
- Numerics: Record the loss and gradient norm at every step, and confirm that both stay finite with no overflow.
- Consistency: After synchronization, the loss should match across all processes. A deviation beyond the tolerance counts as an anomaly.
Example pseudocode:
for step in range(total_steps):batch = load_local_shard(step)loss = forward(model, batch)backward(loss)grad_norm = clip_gradients(model.parameters(), max_norm)if not (is_finite(loss) and is_finite(grad_norm)):save_snapshot(step)rollback_to_last_checkpoint()breakoptimizer.step()optimizer.zero_grad()log_metrics(step, loss, grad_norm)
Consider a validation run on two machines with 16 accelerator cards in total, running 400 consecutive optimizer updates. The key requirement is that every step leaves traceable metrics. Knowing only whether the job finished cannot reveal numerical drift or intermittent communication faults in the middle of the run.
5. Common Problems and Troubleshooting
- Peak memory exceeds expectations: Check the shard boundaries, confirm that activations are not stored in full, and confirm that gradient checkpointing is active.
- Multi-node results differ from single-node results: First check random seeds, whether data partitioning duplicates or skips samples, and the order of reduction operations.
- Loss spikes during training: Check the learning rate warmup configuration, the loss scaling factor under mixed precision, and whether particular samples contain abnormal inputs.
- Intermittent timeouts: Check for packet loss on the network, node load, and scheduling preemption.
6. Practical Recommendations
- Validate on a small single machine first, then scale to multiple machines.
- Keep a comparison script against the reference implementation for each critical operator.
- Include numerical health checks in every training step instead of analyzing problems afterward.
- Build checkpointing and resume-from-failure mechanisms, and rehearse the recovery process regularly.
- Record adaptation results separately from pretraining results, so that adaptation tests are not mistaken for evidence of the model’s original training source.
Following these practices, a team can turn training adaptation from a one-time demonstration into a repeatable, auditable engineering capability.
