Training a Trillion-Parameter Model on a Domestic AI Compute Platform: A Full-Sharding Data Parallel Practice
This article details the engineering practice of adapting a flagship open-source multimodal model for training on a domestic all-in-one AI compute platform. It covers the technical challenges of trillion-parameter training, the core methodology of full-sharding data parallelism, the coordination of training-inference hardware with the software stack, and typical problems encountered in real-world deployment, along with their solutions. The article also discusses the industry significance and future outlook of such adaptation efforts.
Training a Trillion-Parameter Model on a Domestic AI Compute Platform: A Full-Sharding Data Parallel Practice
1. Background: Training Engineering Challenges in the Era of Trillion-Parameter Models
In recent years, the parameter scale of open-source large models has continued to climb. Flagship models have reached the trillion-parameter level and commonly adopt the Mixture-of-Experts (MoE) architecture to balance model capacity with inference cost. Meanwhile, model capabilities have expanded from pure text to multimodal understanding and generation, and the composition of training data has evolved from single-domain text corpora to heterogeneous mixtures of images, text, audio, and video.
The leap in parameter scale imposes severe demands on training infrastructure:
- Memory pressure: Even with low-precision storage, the parameters, gradients, and optimizer states of a trillion-parameter model far exceed the memory capacity of a single GPU, making large-scale distributed training a necessity.
- Communication bottlenecks: As parallelism scales to thousands or even tens of thousands of accelerators, the communication overhead of gradient synchronization and parameter sharding becomes a decisive factor in training throughput.
- Software stack maturity: The co-optimization of training frameworks, operator libraries, communication libraries, and hardware directly determines whether a compute platform can support real production-grade training tasks, not just inference deployment.
Against this backdrop, the successful training adaptation of a flagship open-source large model on a domestic training-inference integrated AI accelerator and its accompanying software stack carries significant engineering validation value. It demonstrates that the domestic compute platform is capable of carrying the complete training pipeline for ultra-large-scale models, rather than being limited to lightweight tasks such as fine-tuning or inference.
2. Core Technical Approach: Full-Sharding Data Parallelism
2.1 Why Full-Sharding Data Parallelism Is Required
Traditional data parallelism (DP) maintains a complete copy of the model on each accelerator and only aggregates gradients. When model parameters reach hundreds of billions or even trillions, a single accelerator cannot hold a full copy, making standard DP impractical. Full-sharding data parallelism addresses this by partitioning model parameters, gradients, and optimizer states across the data-parallel dimension, allowing each accelerator to hold only 1/N of the data. During computation, the required shards are gathered on demand.
For a model with total parameters P and parallelism degree N, the per-accelerator memory footprint is ideally reduced from O(P) to O(P/N), enabling the training of trillion-scale models on clusters with thousands of accelerators.
2.2 Improvements in the New Generation of Sharding Mechanisms
The new-generation full-sharding data parallel implementation (often referred to as the second-generation sharding scheme) introduces several important improvements over earlier versions:
- Tensor-granularity shard management: The sharding unit is refined from “module-level” to “tensor-level”, allowing more flexible scheduling of parameter sharding, gathering, and release. This avoids peak memory waste caused by keeping entire layer parameters resident on the accelerator.
- Fine-grained overlap of communication and computation: In the forward pass, the parameter shards required by the next layer are prefetched ahead of time. In the backward pass, gradient reduction overlaps with subsequent computation, hiding communication as much as possible under computation.
- Effective control of memory fragmentation: Streaming allocation and release of parameter shards reduce the risk of memory fragmentation during long training runs, improving stability for large-batch scenarios.
2.3 Building a Native Multimodal Training Path
For multimodal flagship models, the adaptation constructs a native full-sharding multimodal training path rather than simply patching a text-only training process. This path addresses three key components:
(1) Model Loading
Trillion-parameter model weight files are enormous. The loading phase must solve two engineering issues: first, distributed loading, where each process reads and materializes only its own shards, avoiding the need to assemble the full weight set on a single node before broadcasting; second, the unification and conversion of checkpoint formats, ensuring that open-source released weights map one-to-one to the shard layout used inside the training framework. A common approach is lazy loading with on-demand materialization, paired with building the model structure using metadata tensors first, then streaming weight data in.
(2) Shard Scheduling
Multimodal models typically consist of a vision encoder, a language backbone, and a projection alignment module, each with significantly different parameter sizes and computational characteristics. Shard scheduling must handle:
- Differentiated parallel strategies for heterogeneous modules—the vision encoder has relatively compact parameters and can adopt a lower sharding degree, while the language backbone requires full sharding;
- A combination of expert parallelism and data parallelism for MoE layers, where expert weights are sharded along the expert dimension, and gating and shared parameters are sharded along the data-parallel dimension;
- Consistent sharding under dynamic batching, ensuring correctness of gradient reduction when samples of varying lengths and modalities are mixed in training.
(3) Gradient Synchronization
Gradient synchronization is critical for both training correctness and efficiency. In engineering implementation, it typically includes:
- Gradient bucketing: combining multiple small gradient tensors into larger communication units to reduce the number of communication invocations;
- Combined reduce-and-scatter primitives: first performing global reduce-sum, then scattering the result back to each process according to the parameter shard layout;
- Precision strategy: using low-precision gradients during communication to reduce bandwidth consumption, while maintaining high precision for master weights and optimizer states, balancing convergence stability and communication efficiency.
A representative training main loop is shown below:
# Illustrative pseudocode for a full-sharding training loopmodel = build_model(meta_init=True) # Meta initialization, no actual memory allocatedmodel = shard_model(model, strategy="full") # Fully shard parameters/gradients/optimizer statesload_checkpoint_sharded(model, ckpt_dir) # Each process loads only its local shardoptimizer = build_optimizer(model) # Optimizer states are created alongside shardsfor step, batch in enumerate(dataloader):batch = dispatch_multimodal(batch) # Dispatch multimodal datawith autocast(precision="mixed"):loss = model(batch) # Forward: gather parameters on demand, release after useloss.backward() # Backward: gradient shard reduction overlaps with computationoptimizer.step() # Update only the local shardsoptimizer.zero_grad(set_to_none=True)
3. Synergy of Training-Inference Integrated Hardware and Software Stack
3.1 The Value of a Training-Inference Integrated Architecture
A training-inference integrated AI accelerator means that the same hardware platform can handle both large-scale training and high-concurrency inference. The practical value of this architecture lies in:
- Unified resource pool: Training and inference share the same pool of accelerators, avoiding the scheduling fragmentation and migration overhead of heterogeneous clusters;
- Closed-loop pipeline: The model undergoes training, evaluation, and deployment on the same platform, reducing operator compatibility and precision alignment issues during cross-platform porting;
- Cost optimization: During off-peak training periods, compute capacity can be elastically switched to inference services, improving overall utilization.
3.2 The Role of the Software Stack in Adaptation
Whether hardware capabilities are realized depends on the completeness of the software stack. A full training adaptation typically covers the following layers:
| Layer | Key Work |
|---|---|
| Driver and runtime | Memory management, stream scheduling, multi-accelerator interconnect abstraction |
| Communication library | Performance tuning of collective communication primitives on the proprietary interconnect topology |
| Operator library | High-performance implementations of frequently used training operators (attention, normalization, expert routing, etc.) |
| Framework adaptation layer | Integration and semantic alignment of sharding mechanisms in the distributed training framework |
| Model layer | Weight format conversion, numerical precision validation, convergence alignment testing |
The most easily overlooked aspect is numerical correctness verification. Completing “it runs” is only the first step; the adaptation can only be considered complete when the training results are verified to be mathematically consistent with a reference implementation by comparing intermediate activation values layer by layer and aligning loss curves.
4. Typical Problems and Countermeasures in Engineering Deployment
Based on common practices in ultra-large-scale model training, the following issues frequently arise during deployment:
- Excessive communication overhead. Countermeasures include increasing the global batch size to amortize communication, enabling communication-computation overlap, and arranging process placement in a topology-aware manner so that high-frequency communication stays within high-bandwidth interconnect domains.
- Uncontrolled peak memory usage. Countermeasures include activation recomputation (trading computation for memory), further sharding of optimizer states, and tuning the parameter prefetch window at the layer granularity.
- MoE load imbalance. Expert routing naturally suffers from skew. It is necessary to introduce a load-balancing auxiliary loss and monitor the compute time variance across expert accelerators to prevent the “barrel effect” from dragging down overall throughput.
- Long-duration training and fault tolerance. Training on thousands of accelerators spans weeks, and hardware failures are inevitable. The system must have second-level failure detection, automatic isolation, and incremental checkpoint recovery to keep failure impact within minutes.
- Multimodal data throughput. Visual data decoding and augmentation often become the input pipeline bottleneck. Asynchronous prefetching, heterogeneous decoding, and sample packing are commonly used to ensure compute units do not idle while waiting for data.
5. Industry Significance and Outlook
From an industry perspective, the end-to-end training adaptation of a flagship open-source model on a domestic compute platform conveys several clear signals:
- Rising capability boundaries: Domestic compute has moved from “can run inference” to “can train”, and the target is the largest open-source flagship models available, validating the completeness of the distributed training stack;
- Mutual ecosystem reinforcement: The open-source community gains a richer set of compute options, while the compute platform refines its software stack through real large-model workloads, creating a positive feedback loop;
- A clear path to independent controllability: The full-stack integration from underlying drivers to upper-level training frameworks provides a reusable engineering paradigm for independent and controllable large-model training.
In the future, as model scales continue to grow, context lengths expand, and multimodal fusion deepens, the focus of training adaptation will shift from “making it run” to “making it run well”—pursuing higher effective compute utilization, shorter convergence cycles, and lower training costs on homogeneous large-scale clusters. This will remain a long-term proposition for all compute platforms and software stack vendors.
