Key Techniques for Adapting Ultra-Large Mixture-of-Experts Model Training

    This article describes a general methodology for training trillion-parameter Mixture-of-Experts (MoE) models on self-built AI compute clusters. It covers the memory, communication, and multimodal workload challenges of a 2.8-trillion-parameter model, then explains how to build a native FSDP2 multimodal training pipeline, optimize engineering for heterogeneous workloads, and maintain training stability and observability.

    As the parameter counts of open-source large language models move into the trillion range, training such models on self-built AI compute clusters has become a core challenge for many enterprise technical teams. Recently, a research institution open-sourced a flagship MoE model with 2.8 trillion total parameters, which drew wide attention to engineering approaches for training ultra-large models. Setting aside any specific product, this article describes a general methodology for adapting ultra-large model training on AI accelerators that support both training and inference, together with a unified software stack. It focuses on the design approach and engineering details of a native FSDP2 multimodal training pipeline.

    1. Why Training Trillion-Parameter Models Is So Difficult

    Before discussing adaptation approaches, we need to identify the hard constraints that a 2.8-trillion-parameter model places on the training system.

    1. Memory pressure grows by orders of magnitude

    Under the commonly used estimation method, mixed-precision training requires several copies of state for each parameter. These include the parameter copy, gradients, and optimizer states such as the first and second moments. Even with activation recomputation and mixed-precision strategies, the total state of a trillion-parameter model far exceeds the memory of a single accelerator. Large-scale parallel sharding is therefore required to fit it. In MoE architectures, each token activates only a subset of experts, but all expert weights must still reside in cluster memory. The total memory requirement does not drop because activation is sparse.

    2. Communication overhead becomes the throughput bottleneck

    MoE routing introduces extra All-to-All communication. Each token must be dispatched to the devices hosting its assigned experts, and the results must be gathered back to their original positions after computation. As expert parallelism increases, this communication volume grows quickly with cluster size. At the same time, gradient synchronization along the data parallel dimension and activation transfer along the tensor parallel dimension compete for network bandwidth. The strategy for overlapping communication with computation directly determines the actual compute utilization (MFU) of the cluster.

    3. Multimodal training pipelines are more complex

    Flagship models often support multiple modalities, such as text and images. The data pipeline must therefore handle heterogeneous inputs. Vision encoders and language models have very different computational characteristics, sequence lengths vary widely, and load imbalance within a batch becomes significant. The training framework must support flexible sharding strategies and dynamic scheduling. Otherwise, much of the compute is wasted while devices wait or sit idle.

    4. Long training runs demand high stability

    Training a trillion-parameter model often takes weeks or even months and involves thousands of accelerators. During that time, hardware failures, network jitter, and software exceptions almost always occur. Checkpoint resumption, health checks, automatic fault isolation, and fast recovery are foundational capabilities that a training system must have.

    2. Building a Native FSDP2 Multimodal Training Pipeline

    To address these challenges, many teams are building multimodal training pipelines on native FSDP2 (Fully Sharded Data Parallel, version 2). The core idea is to fully shard model parameters, gradients, and optimizer states across devices. Each accelerator holds only one slice of the global state. Before a computation, the required parameters are temporarily gathered with All-Gather. They are released immediately after the computation finishes.

    1. Connecting the full pipeline, starting from model loading

    The training pipeline starts with model loading. For trillion-parameter models, reading all weights into a single node’s memory and then distributing them is not feasible. Instead, each process reads only the shard it is responsible for. Combined with tensor-level lazy initialization and the sharded checkpoint format, this reduces loading time from hours to minutes. After loading, the framework wraps the model according to the sharding strategy. The result is a model that is logically complete but physically distributed.

    1. # Illustrative pseudocode: sharding wrap and loading flow
    2. from distributed.fsdp import fully_shard
    3. for layer in model.layers:
    4. fully_shard(layer, mesh=device_mesh) # Shard layer by layer to reduce peak memory
    5. fully_shard(model, mesh=device_mesh)
    6. # Distributed loading: each rank reads only its local shard
    7. state_dict = load_sharded_checkpoint(ckpt_path, rank=rank, world_size=world_size)
    8. model.load_state_dict(state_dict, assign=True)

    2. Fine-grained shard scheduling

    A key improvement in FSDP2 over earlier versions is its explicit sharded representation based on DTensor. This makes the mapping between parameter partitions and the device mesh clearly visible. In engineering practice, per-layer wrapping is recommended over wrapping the whole model at once. With per-layer wrapping, the framework can prefetch the next layer’s parameters while the current layer is computing. This overlaps communication with computation and significantly reduces exposed communication time. For MoE models, expert parameters and non-expert parameters should be handled differently. Expert parameters are typically combined with the expert parallel dimension. Dense non-expert parameters use standard data parallel sharding. Both are managed together through a composed device mesh.

    3. Gradient synchronization and backward pass optimization

    During the backward pass, FSDP2 uses Reduce-Scatter to reduce gradients and store them in place as shards. Two points matter most for optimization. First, the gradient bucketing strategy must balance bucket size. Small buckets cause frequent communication calls and higher overhead. Large buckets delay the start of communication and weaken the overlap. Second, gradient communication should be suppressed during gradient accumulation. The reduction should run only once, before the optimizer step, to avoid unnecessary bandwidth use.

    3. Engineering Optimizations for Multimodal Workloads

    1. Coordinating heterogeneous computation

    Vision encoders usually have high computational density but relatively few parameters. Language models are the opposite. A sound approach lets the two components use different parallelism strategies and sharding granularities. At the boundary between them, activations should be converted to a compatible layout. This avoids extra reshuffling overhead caused by inconsistent tensor layouts.

    2. Sequence load balancing

    Sequence lengths in multimodal samples vary widely, so fixed batch sizes create significant compute bubbles. Common industry practices include:

    • Dynamic batching by token count, also known as sequence packing.
    • Context parallelism for very long sequences, which splits them across devices.
    • Length-aware data distribution at the data loading layer, which keeps the compute load on each device roughly equal.

    3. Joint tuning of memory and performance

    Activation checkpointing is the main way to control memory, but full recomputation adds roughly 30% extra compute. In practice, selective recomputation works better. It applies only to operators that use a lot of memory and are cheap to recompute, such as intermediate attention results. Combined with memory pool management to reduce fragmentation, this balances throughput and memory usage.

    4. Training Stability and Observability

    A large-scale training system is valuable because it runs reliably, not just because it can run at all. Teams should implement the following capabilities:

    • Pre-training cluster health inspection, including stress tests of compute, communication, and storage links.
    • Monitoring of key metrics during training, including loss curves, gradient norms, communication time, memory usage, and hardware temperature, with tiered alerts.
    • Periodic sharded checkpoint writes and verification. This ensures that training can resume from the most recent checkpoint after any interruption and keeps losses from failures within acceptable limits.

    Enterprises can also use general infrastructure services from cloud providers, such as container platforms, object storage, monitoring and alerting, and log services. These help teams quickly build scheduling and observability systems for training jobs and reduce the cost of self-managed operations.

    5. Summary

    Adapting training for a 2.8-trillion-parameter model is fundamentally a systems engineering task. It requires coordinated optimization of the software stack, the parallelism strategy, and the hardware cluster. The native FSDP2 multimodal training pipeline connects model loading, shard scheduling, and gradient synchronization. This provides a repeatable approach for running ultra-large models on diverse AI hardware. As open-source model sizes continue to grow, technical teams that master this methodology will be well positioned to build their own large model training capabilities.