Adapting a Domestic AI Chip for Training a 2.8 Trillion Parameter Large Model

    This article details the adaptation practice of training a 2.8 trillion parameter sparse expert model on a domestic AI chip. It covers the hardware and software foundation, the native FSDP2 multimodal training pipeline, memory scheduling, communication topology-aware task allocation, and fault tolerance mechanisms. The practice achieved a 72.6% Model FLOPs Utilization (MFU) and an 89.2% scaling efficiency across 256 nodes, validating the feasibility of training ultra-large sparse models on the domestic hardware stack.

    Background and Challenges: The Training Dilemma of Ultra-Large Sparse Models

    As large model parameter scales enter the trillion-level, traditional training frameworks face three major pain points: the memory wall, the communication wall, and the scheduling wall. Taking a 2.8 trillion parameter sparse expert model as an example, it adopts a Mixture of Experts (MoE) architecture with only about 20 billion activated parameters. However, after complete weight sharding, multi-node collaborative storage is required. If a traditional combination of data parallelism and tensor parallelism is used, memory usage will exceed single-node memory capacity, and cross-node communication overhead grows quadratically with the number of experts. Therefore, the core challenge of training adaptation lies in efficiently completing parameter loading, sharding scheduling, and gradient synchronization without sacrificing training stability.

    Hardware and Software Stack: The Foundation for Training Adaptation

    This adaptation is based on a flagship AI compute card (supporting BF16/FP8 mixed precision, with a single-card memory capacity of 192GB) and a self-developed MUSA software stack. The MUSA stack provides a CUDA-like programming interface and supports PyTorch native distributed extensions (DTensor, FSDP, etc.). The key design lies in mapping MoE operations, such as expert routing and multicast communication, into underlying hardware primitives through compiler-level operator fusion, avoiding frequent kernel launch overhead.

    Training Path Design: Native FSDP2 Multimodal Training Pipeline

    The original approach adopts a three-stage design: “model loading → sharding scheduling → gradient synchronization.” However, engineering implementation must address the following details:

    1. Model Loading and Memory Pre-allocation

    The 2.8 trillion parameters are stored in Safetensors format, and the loading phase needs to handle nearly ten thousand small files. The practice adopts a “two-stage loading” method: first, scan the metadata to establish a parameter index mapping, and then read in parallel by buckets according to expert IDs, thereby avoiding file lock contention. Simultaneously, “uniformly sharded” memory pages are pre-allocated for each parameter tensor, and a NUMA-aware allocator is used to reduce cross-memory access latency.

    2. FSDP2 Sharding Strategy: From Unified Sharding to Hierarchical Sharding

    The improvement of FSDP2 over FSDP1 lies in supporting custom sharding by parameter dimensions, rather than just by hierarchy. For the MoE model, the following strategies are adopted:

    • Shared weight layers (Attention/FFN): Uses bidirectional sharding (splitting weights evenly along rows and columns), combined with gradient prefetch to achieve overlap of computation and communication.
    • Expert layers: Logically grouped by expert name. Each node holds a complete expert replica, and routing is performed through intra-group Expert Parallelism (EP). The key here is dynamically adjusting the sharding granularity: when expert popularity is uneven, “hot expert replication” (copying high-load experts to multiple nodes) is enabled to reduce cross-node access.
    • Sparse gradients: Gradient synchronization uses Segment Sparse AllReduce, synchronizing only non-zero gradient indices, reducing communication volume to about 15% of full gradients.

    3. Gradient Synchronization and Optimizer State Management

    The AdamW optimizer is used during training, and its state quantities (first-order moment, second-order moment) are the same size as the parameters. To reduce memory usage, optimizer states are sharded across processes, and a “compute after sharding” update strategy is adopted: after backpropagation, each process only updates its local shard’s gradients, and then obtains the complete weights through AllGather. In addition, a delayed synchronization mechanism for gradient compression is implemented: allowing global gradient synchronization every K steps, during which local gradient accumulation is used. Experiments show that when K=8, the convergence curve is almost identical to the fully synchronized baseline, but communication pressure is reduced by 60%.

    Key Engineering Optimizations

    Memory Scheduling: KV Cache and Activation Recomputation

    Multimodal training needs to process both image and text sequences simultaneously. The intermediate activations of the vision encoder occupy huge space. A 4-layer interval Checkpointing (recomputation) strategy is adopted, reducing activation peak from 120GB per card to 60GB. Simultaneously, for attention computation, a “Sliding Window Attention + Sparse FlashAttention” hybrid kernel is implemented to reduce on-chip memory access.

    Communication Topology-Aware Task Allocation

    The MUSA software stack supports intra-node NVLink (equivalent) and cross-node RoCE (equivalent) network topology detection. The scheduler allocates layers with strong interactions (where the same expert is accessed by multiple tokens) to the same node, reducing cross-node multicast. Measured cross-node communication proportion dropped from 32% to 18%.

    Fault Tolerance and Checkpoint Resumption

    Training cycles last for months, requiring handling of single-card failures. A key-value pair-based transparent checkpoint is implemented: asynchronously storing parameter shards and optimizer states to a parallel file system every 10 minutes. During fault recovery, only the data shards of the failed node are rebuilt, while other nodes keep running, reducing recovery time from hours to minutes.

    Performance Validation and Metrics

    The complete training adaptation of the 2.8 trillion parameter model was completed on a cluster of 256 nodes (8 cards per node). Key results:

    • Throughput: Stably achieved processing about 3500 tokens/s/card (average sequence length 4096), with a Model FLOPs Utilization (MFU) of 72.6%;
    • Scaling Efficiency: When scaling from 64 nodes to 256 nodes, the communication overhead growth curve is sub-linear, with a scaling efficiency of 89.2%;
    • Convergence Stability: Adopted adaptive loss scaling and gradient clipping (threshold 1.0), with no divergence or NaN phenomena occurring.

    Summary and Outlook

    This adaptation practice validates the feasibility of the domestic AI compute card on ultra-large sparse models. The core technical paths—native FSDP2 sharding, hierarchical memory planning, sparse gradient communication, and fault-tolerant architecture—are all universally applicable. Future exploration can further focus on automatic sharding strategy search based on reinforcement learning, as well as optimizing expert parallel layout combined with super-node interconnect architectures (such as high-speed direct connect topologies) to support higher-spec trillion-level dense model training. For enterprise users, this solution provides a replicable technical template, lowering the barrier to initiating large model training on the domestic hardware stack.