Training Trillion-Parameter Open-Source Models on China-Developed AI Accelerators: A Technical Adaptation Practice
This article examines the technical adaptation required to train ultra-large open-source models on China-developed AI accelerators. It explains the transition from inference support to full training, analyzes memory-wall, communication, and multimodal challenges, and breaks down model loading, sharding scheduling, and gradient synchronization. It also summarizes a general methodology covering operator completeness, equivalence validation, parallel strategy tuning, fault tolerance, and data-scheduling coordination.
1. Background: From Inference to Training
In recent years, the open-source community has released flagship models with trillion-scale parameters. These models place extreme demands on training infrastructure. For China’s domestic AI computing ecosystem, adapting such models for training means more than getting them to run. It means that the entire software chain—from low-level operator libraries and communication libraries to parallel frameworks and upper-layer training scheduling strategies—has been tested by real training workloads.
In a recent practice with a China-developed AI accelerator card, a flagship training-and-inference integrated AI compute card and a self-developed general-purpose compute software stack were used to adapt a 2.8-trillion-parameter multimodal open-source model for training. The work established a native Fully Sharded Data Parallel (FSDP2) multimodal training path and connected the full training chain from model loading and sharding scheduling to gradient synchronization. This article does not focus on specific products. Instead, it examines the key problems and solutions in this adaptation process from a general technical perspective.
2. Core Challenges in Ultra-Large Model Training
2.1 The Memory Wall
Under mixed-precision training, the parameters, gradients, and optimizer states of a trillion-parameter model require tens of terabytes of memory for model states alone. A single card’s memory is far from sufficient. Sharding must be used to partition model states across thousands of accelerator cards.
The industry’s common approach is the evolved version of Fully Sharded Data Parallel (FSDP), namely FSDP2. Its core ideas are:
- Parameter sharding: Model parameters are evenly partitioned across devices. During forward and backward computation, full parameter layers are temporarily aggregated on demand through all-gather and released immediately after use.
- Gradient sharding: After backpropagation, gradients are aggregated through reduce-scatter, and each card retains only the shard it is responsible for.
- Optimizer state sharding: The first- and second-order moments of optimizers such as Adam are also stored in shards across cards, so memory usage decreases approximately linearly with the number of cards.
Compared with traditional DP, FSDP2 uses DeviceMesh and DTensor to achieve finer-grained sharding control. It supports partitioning individual Transformer blocks and even individual weight matrices, significantly improving flexibility.
2.2 The Communication-Computation Trade-off
A sharding strategy is essentially a trade-off between computational efficiency and communication overhead. Finer sharding reduces per-card memory pressure but increases communication frequency. Common optimization techniques include:
- Prefetch: While computing the current layer, initiate all-gather for the next layer’s parameters in advance to overlap communication and computation.
- Gradient accumulation: Accumulate gradients across multiple micro-batches before performing reduce-scatter once, amortizing communication cost.
- Hierarchical communication: Prioritize NVLink-class high-speed interconnect for intra-card and intra-node communication, while inter-node traffic uses high-speed Ethernet or RDMA-class networks.
2.3 Complexity of Multimodal Training
Multimodal models usually combine a vision encoder with a language model. Training faces the problem of heterogeneous input processing:
- The data pipeline must support mixed loading and preprocessing of images, text, and other modalities.
- Sequence lengths differ greatly across modalities. Dynamic padding or sequence packing is needed to improve throughput.
- The vision encoder and language model may require different parallel strategies and learning-rate configurations.
3. Breaking Down the Technical Path
3.1 Model Loading and Structure Conversion
The first step is to ensure that the weight format of the open-source model can be correctly parsed by the target software stack. Typical work includes:
# Illustrative pseudocode: sharded loading of a trillion-parameter modelfrom dist_model import DeviceMesh, load_sharded_state_dictmesh = DeviceMesh("gpu", [[0,1,2,3],[4,5,6,7]])model = LLMModel.from_pretrained(checkpoint_dir,device_mesh=mesh,dtype="bfloat16",sharding_plan={"*": "full_shard"} # full sharding)
The loading stage needs to handle shard metadata reconstruction, precision conversion (for example, converting fp32 weights to bf16), and separate initialization of multimodal branch weights. For trillion-parameter models, loading itself often needs to be streamed in stages to avoid memory peaks during checkpoint loading.
3.2 Sharding Scheduling Strategy
At the scheduling level, a hybrid parallel combination of data parallelism (DP), tensor parallelism (TP), pipeline parallelism (PP), and expert parallelism (EP) is commonly used. Take a MoE-like sparse architecture as an example:
- The attention part uses TP to split attention heads.
- Experts in the FFN are distributed across nodes through EP.
- The output layer usually retains a TP+DP combination.
- DeviceMesh describes the multidimensional parallel topology, allowing FSDP2 to further shard parameters along the DP dimension.
The choice of sharding granularity needs to be configured layer by layer according to the model structure. A common and reliable practice is to set separate sharding strategies for the embedding and output head, which consume a large amount of memory, while applying full sharding to the intermediate Transformer blocks.
3.3 Gradient Synchronization and Training Stability
Gradient synchronization in the full training chain must ensure numerical correctness and consistency:
- Gradient bucketing: Gradients are bucketed by a certain number of bytes to reduce the number of communication launches.
- Gradient clipping: Computing the gradient norm across shards requires a global all-reduce aggregation first.
- Mixed precision and loss scaling: Dynamic scaling is used under low-precision training to prevent gradient underflow.
- Redundant computation elimination: Parameter-sharing detection is used to avoid repeated communication.
4. General Methodology for Domestic Software-Stack Adaptation
This adaptation practice suggests a general methodology for adapting large models to domestic computing platforms:
- Operator completeness validation: First run the core operators the model depends on (attention variants, optimizer kernels, communication primitives) and fill in missing implementations.
- Equivalence validation: Align loss curves and gradient norms with training results on reference hardware, and locate sources of numerical differences.
- Parallel strategy tuning: Start with conservative full-shard DP, gradually introduce TP/PP/EP, and use profiling to identify communication bottlenecks.
- Fault tolerance and elasticity: Large-scale training inevitably encounters hardware failures. Asynchronous checkpointing and automatic recovery mechanisms should be used to improve effective training time.
- Data and scheduling coordination: Multimodal data preprocessing should be pipelined on the CPU side to avoid blocking GPU computation.
5. Conclusion and Outlook
Training adaptation of ultra-large open-source models on domestic hardware is a touchstone for the maturity of China’s AI hardware and software ecosystem. The establishment of an FSDP2 multimodal training path shows that domestic accelerator cards are already capable of supporting trillion-parameter-level training in terms of operator library completeness, communication efficiency, and parallel framework compatibility. For developers, understanding the principles of this complete chain—model loading, sharding scheduling, and gradient synchronization—is essential core knowledge for large-model training on any hardware platform. As sparsity, long sequences, multimodal fusion, and other technologies continue to evolve, training infrastructure adaptation will remain an ongoing task.
