Adapting Trillion-Parameter MoE Model Training on Domestic AI Computing Platforms

    This article details the engineering practice of adapting a 2.8-trillion-parameter Mixture of Experts (MoE) large language model for training on a domestic AI computing platform. It explores the core challenges of memory walls, sparse computation, and software stack ecosystem compatibility. Furthermore, it presents the technical approach of building a native FSDP2 multimodal training path, covering model loading, sharding scheduling, gradient synchronization, and best practices for large-scale training engineering.

    Adapting Trillion-Parameter MoE Model Training on Domestic AI Computing Platforms

    1. Background: New Training Adaptation Challenges Posed by Ultra-Large Open-Source Models

    Recently, the industry open-sourced a flagship Mixture of Experts (MoE) large language model with a total parameter count reaching 2.8 trillion. Its parameter scale, expert routing architecture, and multimodal capabilities position it at the forefront of current open-source models. While the open-sourcing of such models provides high-quality foundational assets for the industry, it simultaneously imposes unprecedented adaptation requirements on underlying computing platforms.

    For domestic AI computing platforms, the ability to promptly complete the training adaptation for such flagship models is a critical measure of the maturity of their software and hardware stacks. Training adaptation differs significantly from inference adaptation: inference only requires correct forward computation and acceptable performance, whereas training necessitates full-pipeline support for backward propagation, gradient synchronization, optimizer state management, and checkpoint read/write operations. The requirements for operator coverage, memory management, communication library stability, and framework compatibility are magnitudes higher.

    This article systematically deconstructs the key technical paths and methodologies based on the engineering practice of adapting this 2.8-trillion-parameter model using a domestic training-and-inference integrated AI card and its accompanying software stack.

    2. Three Core Challenges in Trillion-Scale MoE Model Training

    2.1 Memory Wall: The Triple Pressure of Parameters, Gradients, and Optimizer States

    Taking the 2.8-trillion-parameter model as an example, even when using BF16 precision for storage, the model weights alone require approximately 5.6TB of memory. In a training scenario, gradients and optimizer states must also be saved. If a common adaptive optimizer is used, its momentum and second-moment states will further multiply the memory consumption several times. Clearly, no single card or machine can accommodate this; it relies entirely on distributed parallelism strategies to shard the states across hundreds or thousands of accelerator cards.

    2.2 Sparse Computation and Load Balancing Issues in MoE Architecture

    MoE models contain a large number of expert networks within each Transformer layer, with each token activating only a small fraction of these experts. While this sparse activation characteristic reduces the computational volume for a single forward pass, it introduces new engineering problems. Expert parallelism requires placing different experts on different devices, and token-to-expert routing generates All-to-All communication. Furthermore, when routing is imbalanced, it easily leads to some devices being overloaded while overall throughput is dragged down.

    2.3 Completeness Requirements for Software Stack Ecosystem Adaptation

    Mainstream open-source large models are typically developed based on mature GPU ecosystems. Their training scripts rely heavily on specific operator implementations, communication primitives, and parallel framework interfaces. Reproducing equivalent capabilities on a domestic platform requires the software stack to provide semantically aligned operator libraries, compatible distributed communication interfaces, and complete support for mainstream training framework extension mechanisms. The absence of any single link in this chain will cause the training pipeline to break.

    3. Technical Route: Building a Native FSDP2 Multimodal Training Path

    To address the above challenges, the core of this engineering practice is to build a native multimodal training path based on Fully Sharded Data Parallel 2nd generation (FSDP2) technology, rather than a simple porting of an interface compatibility layer.

    3.1 Why FSDP2?

    The core idea of FSDP is to shard model parameters, gradients, and optimizer states across the data parallelism dimension. Each device holds only a 1/N replica of the state, fetching the complete parameters on-demand via all-gather during computation, and releasing them immediately afterward. Compared to the first-generation implementation, FSDP2 employs a finer-grained sharding abstraction in its design, supports flexible splitting along the parameter tensor dimension, and explicitly orchestrates the pipelining of communication and computation. This brings three major benefits:

    • Higher Memory Efficiency: Finer sharding granularity and controllable gather windows result in smoother peak memory usage.
    • Better Communication Overlap: Parameter prefetch and gradient reduction can overlap with computation, hiding communication overhead.
    • Improved Composability: It can be orthogonally combined with strategies like tensor parallelism and expert parallelism, making it suitable for complex structures like MoE.

    3.2 Trade-offs Between Native Path and Compatibility Layer Path

    An effortless approach is to “translate” existing training scripts to run on domestic platforms via a compatibility layer. However, in ultra-large-scale training, this path often exposes issues such as high performance overhead, long debugging chains, and inconsistent boundary behaviors. This practice opted for the native path: directly implementing the complete pipeline from model loading and sharding scheduling to gradient synchronization based on the platform’s self-developed software stack, ensuring that the behavior of each stage is observable and tunable. While this choice requires a larger upfront investment, it ensures controllable training efficiency and stability, and deposits reusable infrastructure for the rapid adaptation of future models.

    3.3 Special Handling for Multimodal Training

    This flagship model features multimodal capabilities. The computational characteristics of the vision encoder and the language model in the training pipeline differ significantly: the former is compute-intensive with memory usage fluctuating based on resolution, while the latter is dominated by sequence length. The training path requires applying differentiated sharding and checkpoint strategies to different sub-modules, and uniformly scheduling the data loading pipeline to prevent multimodal data preprocessing from becoming a throughput bottleneck.

    4. Three Key Stages of the Complete Training Pipeline

    4.1 Model Loading and Weight Sharding

    The weight file of a trillion-parameter model itself reaches the terabyte level. The loading phase needs to support streaming reads and distributed parallel loading: each process reads only the shards it is responsible for, avoiding memory and IO bottlenecks caused by centralized loading. Additionally, it must handle weight format conversion, tensor naming mapping, and the reordering of expert weights to ensure that the loading results align strictly with the parallel strategy.

    4.2 Sharding Scheduling and Computation-Communication Overlap

    During the training step, the scheduler orchestrates the timing of parameter aggregation layer by layer: initiating the gather communication for a layer’s parameters before the forward propagation reaches it, and immediately triggering gradient shard reduction after the backward propagation is complete. Through meticulous double-buffering and stream scheduling, the majority of communication can be hidden under computation. For MoE layers, it is also necessary to orchestrate the All-to-All communication for expert parallelism and alleviate expert skew through routing balance constraints (such as auxiliary load balancing loss).

    4.3 Gradient Synchronization and Mixed Precision Management

    In BF16 mixed precision training, the communication and accumulation precision of gradients must be carefully designed. Communication can use lower precision to save bandwidth, but the master weights and optimizer state updates must retain high-precision copies to prevent precision drift during long-term training. Gradient synchronization employs a bucketed reduction strategy, merging the communication of multiple small tensors into large block transmissions to improve network utilization. Meanwhile, the training framework must feature gradient anomaly detection and automatic recovery mechanisms to cope with the inevitable hardware fluctuations in ultra-large-scale clusters.

    5. Best Practices for Engineering Implementation

    Based on this adaptation practice, several universally valuable experiences for the industry can be summarized:

    1. First Connect, Then Optimize: Prioritize verifying the correctness of the training pipeline with a smaller-scale homogeneous model (aligning the loss curve with the baseline), then scale up to the full parameter size to locate issues in a layered manner.
    2. Establish Numerical Alignment Baselines: Comparing the layer-by-layer output and loss descent curve with a reference implementation under the same data and random seed is the most reliable method to verify the correctness of operators and parallel strategies.
    3. Joint Modeling of Communication and Memory: Before determining the parallel sharding scheme, theoretically estimate memory usage and communication volume to avoid blind trial and error.
    4. Design Checkpoint Strategies Upfront: Checkpoint read/write for trillion-parameter models is notably time-consuming. Sharded asynchronous disk writes should be adopted, alongside support for rapid recovery after training interruptions.
    5. End-to-End Observability: Establish a monitoring and alerting system for key metrics such as communication latency, memory watermarks, and expert load distribution, ensuring that performance degradation during long-cycle training can be detected promptly.

    6. Conclusion

    Successfully completing the training adaptation of the 2.8-trillion-parameter flagship MoE model marks a new milestone for domestic training-and-inference integrated computing platforms in terms of software stack completeness, distributed training capabilities, and ultra-large-scale engineering. By constructing a native FSDP2 multimodal training path, the entire pipeline from model loading, sharding scheduling to gradient synchronization has been systematically connected. This methodology is not only applicable to this specific model but also provides a reusable technical paradigm for the rapid deployment of future ultra-large-scale open-source models on domestic computing power. As the scale of open-source models continues to climb, software-hardware co-designed training engineering capabilities will become the core battlefield for AI computing infrastructure competition.