LLM Training on Chinese-Developed Accelerators: Stable Operation Across Two Nodes and 16 Cards
Adapting an LLM for training requires more than successful inference. This article explains the distinction between inference adaptation, training adaptation, and pretraining, then examines four essential parts of the training pipeline: weight loading, parameter sharding and memory planning, gradient communication, and numerical stability with checkpoint recovery. The focus is on the engineering requirements for a two-node, 16-accelerator setup.
1. Training Adaptation vs. Inference Deployment
Inference deployment focuses on whether a forward pass produces correct results while meeting latency and throughput requirements. Training requires the same pipeline to remain stable over hundreds or thousands of optimization steps.
Forward computation, backpropagation, gradient communication, optimizer updates, and checkpoint saving must all work reliably. A numerical error at any step can propagate and grow through subsequent updates. Successfully loading a model and generating output therefore validates the inference path—not the training path.
Engineering discussions should distinguish three capabilities:
- Inference adaptation: The model can load and perform inference on the target hardware.
- Training adaptation: The model can complete forward passes, backward passes, and parameter updates on the target hardware, enabling fine-tuning or continued training.
- Pretraining: The model can complete training from random initialization on the target hardware.
These capabilities differ substantially in validation requirements and implementation cost. Successful inference adaptation does not demonstrate pretraining capability. Teams should clearly identify their current stage when planning a project or describing its capabilities externally.
2. Four Critical Parts of the Training Pipeline
2.1 Model Loading and Weight Mapping
LLM weights are often distributed across multiple files. Tensor names, data types, and layouts may not match the runtime’s requirements.
Loading requires three tasks:
- Validate tensor shapes layer by layer.
- Convert data types to the target precision, such as
bfloat16. - Map weights to their corresponding shards.
A tensor shape mismatch can lead to numerical anomalies later in training that are difficult to diagnose. Validate tensor shapes and statistics immediately after loading.
2.2 Parameter Sharding and Accelerator Memory Planning
During training, accelerator memory primarily holds four categories of data: model parameters, gradients, optimizer states, and activations.
A common mixed-precision Adam configuration requires approximately 16 bytes per parameter:
- Low-precision weight: 2 bytes
- Low-precision gradient: 2 bytes
- High-precision master weight: 4 bytes
- Two high-precision optimizer states: 8 bytes combined
For a model with 100 billion parameters, this amounts to approximately 1.6 TB of parameter, gradient, and optimizer state storage. Sharding those states across 16 accelerators leaves roughly 100 GB per card, still exceeding the memory capacity of many individual accelerators.
Additional memory-saving measures, such as activation recomputation, are therefore needed. Sharding must be planned alongside the memory budget; accelerator count alone is not enough.
2.3 Gradient Synchronization and Communication
Fully sharded data parallelism follows a basic pattern:
- During the forward pass, gather the required parameters on demand and release them after computation.
- During the backward pass, reduce gradients and scatter them back to the corresponding shards.
- Let each optimizer update only its local parameter shard.
This process relies heavily on collective communication, including all-gather and reduce-scatter operations.
Communication time varies significantly with inter-node bandwidth and network topology. In a multi-node setup, pay particular attention to network bottlenecks and how effectively communication overlaps with computation.
2.4 Numerical Stability and Checkpointing
Continuously monitor loss, gradient norms, and the magnitude of parameter updates.
If a NaN or Inf appears, stop training immediately and record the current step’s input batch, random seed, and state of each accelerator.
Save checkpoints regularly and verify that, after recovery, the loss curve continues smoothly from its pre-interruption trajectory.
The following pseudocode illustrates the initial setup. Actual interfaces must be adjusted to the training framework and hardware drivers in use.
def run_training(config):model = load_checkpoint(config.ckpt_path, dtype="bfloat16")model = shard_parameters(model, world_size=config.world_size)optimizer = create_optimizer(model.local_params(), lr=config.lr)
