Training Trillion-Parameter Sparse Models on Domestic AI Chips: Key Adaptation Points

    Sparse Mixture-of-Experts (MoE) models with trillions of parameters push training challenges from the algorithm level to the systems level. This article covers the essential adaptation work for training a 2.8-trillion-parameter sparse model: the capability boundaries of FSDP2 sharding, model loading and shard planning, gradient synchronization and communication overlap, memory and communication troubleshooting, and checkpointing with fault tolerance. All figures presented are estimates or starting points that must be validated on the target cluster.

    1. Background: Parameter Scale Pushes Training to the Systems Level

    Sparse Mixture-of-Experts (MoE) models have become a common architecture for very large language models. The 2.8-trillion-parameter sparse model open-sourced by an AI lab is one example. MoE activates only a subset of experts per step, so compute is far lower than that of a dense model with the same parameter count. However, all parameters must still reside in the cluster, so storage and communication pressure does not shrink along with the number of activated parameters.

    With data parallelism alone, every GPU must hold a complete model replica, which is infeasible at the trillion-parameter scale. With tensor parallelism alone, cross-device communication grows with the number of shards and is bounded by interconnect bandwidth. Training adaptation must therefore address four problem classes at once: parallelization strategy, memory, communication, and fault recovery.

    The source material provides no throughput numbers, loss curves, or training durations, so this article discusses only methods and approaches, without evaluating final results.

    2. Hardware and Software Stack Prerequisites

    Training adaptation depends on two prerequisites. The first is hardware: per-card memory capacity and bandwidth should be taken from the specification sheet of the specific chip model; this article cites no concrete values. The second is the software stack. You need to confirm which PyTorch distributed interfaces the vendor’s software stack supports—for example, process groups, DeviceMesh, and DTensor in torch.distributed, plus the coverage of collective communication operators. Version mismatches are often the main blocker early in adaptation, so a minimal working case should be validated before any real work begins.

    3. The Capability Boundaries of FSDP2

    The core of FSDP2 is per-parameter sharding. Each parameter is represented as a DTensor and sharded along a specified device mesh, so each card holds only its own portion. This reduces the per-card footprint of parameters, gradients, and optimizer states, but it does not provide parallelism capabilities specific to multimodal models. In a multimodal model, the vision encoder, the language model, and the expert networks often require different sharding scopes, and developers must compose device meshes and parallel strategies per module.

    The table below compares three common sharding schemes.

    Dimension FSDP1 FSDP2 DeepSpeed ZeRO
    Sharding unit Flattened parameters Individual parameters (DTensor) Optimizer states, gradients, parameters (by stage)
    Per-module sharding Wrapping via auto wrap policy Per-module fully_shard calls Via configuration and module wrapping
    MoE expert parameters Requires extra handling Experts placed on a separate device mesh Requires extra expert-parallel configuration

    Combining MoE with FSDP has one important constraint. Expert parameters are typically held by an expert-parallel group, so the sharding group must be kept separate, and the communication groups for gradient reduction must be designed independently. Misconfiguration can cause gradients to be averaged incorrectly or dropped. Run a gradient consistency check with a small model before going to production.

    4. Model Loading and Shard Scheduling

    4.1 How to Load Ultra-Large Weights Reproducibly

    The full model cannot be instantiated in a single process first. The standard approach has three steps.

    1. Build the model structure on the meta device, which allocates no real memory.
    2. Call the sharding interface on each module to obtain the sharded parameters on each card.
    3. Read weights per shard via the distributed checkpoint interface (torch.distributed.checkpoint), so each rank reads only the portion it owns.

    If the weights use the sharded safetensors format, the weight_map in the index file records which file each parameter lives in. At load time, each rank uses this map to open only the files it needs, avoiding every node reading all weights simultaneously. After parameters are materialized, values are written in from the checkpoint.

    Optimizer states are allocated only at the first step, so memory peaks higher on the first step than on later ones. When debugging OOM, check the first step first.

    4.2 How to Plan Sharding So Communication Does Not Become the Bottleneck

    Shard planning answers two questions: which parameters sit on the same group of cards, and which link each class of communication traverses. General rules:

    • The most communication-intensive parallel groups, such as MoE All-to-All, should sit within a node or within the same high-speed interconnect domain.
    • FSDP sharding groups, which synchronize only once at the end of backward, can span nodes and ride the RDMA network domain.
    • The shape of the device mesh must match the cluster topology. A mismatch usually does not throw an error—it just shows up as low throughput.

    The names and bandwidths of interconnect domains must follow the vendor’s cluster documentation; do not apply topology terminology from other platforms directly.

    Before starting, use a script to estimate per-card memory and per-step communication volume. If either number exceeds budget, adjust the sharding plan before launching a long job.

    5. Gradient Synchronization and Communication Overlap

    During the forward pass, FSDP aggregates parameters with All-Gather; during backward, it reduces gradients with Reduce-Scatter, so each card keeps only the gradients of its own shard. Compared with traditional all-reduce, per-card communication volume decreases as the number of shards increases.

    Whether communication can be hidden by computation depends on prefetch and resharding settings. FSDP2’s reshard_after_forward controls whether non-local parameters are released after the forward pass. Enabling it saves memory, but parameters must be gathered again during backward, increasing communication. This is a direct memory-versus-communication trade-off and should be decided by measured throughput under the target configuration.

    6. Troubleshooting Memory and Communication

    6.1 How to Estimate the Memory Bottleneck of Trillion-Parameter MoE Training

    Using the standard mixed-precision Adam accounting, each parameter takes about 16 bytes: 2 bytes for BF16 weights, 2 bytes for BF16 gradients, 4 bytes for the FP32 master copy, and 8 bytes for Adam’s first and second moments. For 2.8 trillion parameters, parameter-related state totals roughly 44.8 TB.

    Number of sharding cards State per card (approx.)
    512 87.5 GB
    1024 43.75 GB

    This figure excludes activations, communication buffers, framework overhead, and memory fragmentation. The real budget should leave headroom on top of this and be calibrated with a scaled-down model. MoE’s sparse activation reduces compute, not parameter storage.

    6.2 How Aggressive Should Activation Recomputation Be?

    Activation recomputation trades extra forward computation for memory. Checkpoints are saved only at layer boundaries, and intermediate activations are recomputed during backward. Recomputation increases compute time; the increase depends on model structure and how many layers are recomputed, so it must be measured under the target configuration. Start with the most memory-constrained layers, expand gradually, and record peak memory and per-step time at each step.

    6.3 How to Handle Memory Fragmentation

    The typical symptom of fragmentation is that total memory appears sufficient, yet a single large allocation fails. The recommended order of actions:

    1. Inspect allocator statistics to confirm the proportion of reserved-but-unused memory.
    2. Tune allocator parameters, such as increasing block size or enabling expandable segments. Refer to the vendor documentation for the specific environment variables.
    3. Preallocate fixed-size buffers early in training to reduce dynamic allocation.

    6.4 How to Set All-to-All Communication Parameters

    All-to-All message size directly affects bandwidth utilization. Use a collective-communication benchmark script to sweep message sizes on the target cluster, record bandwidth, and pick a packing granularity from the plateau region of the curve. Do not copy values from other clusters.

    7. Fault Tolerance and Checkpointing

    7.1 How to Design Checkpoints

    Each rank saves its own shard, accompanied by a global metadata file recording the version, step count, shard layout, and the location of optimizer states. Saving can run asynchronously, but the previous save must complete before the next one starts.

    The save interval requires two numbers: the time of a single save, and the maximum acceptable training rollback. If a single save takes T, the saving overhead should stay below some fraction of total training time, while the training time lost to a single failure must also remain acceptable. Together, these two constraints bound the interval from below and above. The ratios and time values are set by the team according to the importance of the job.

    Validation is mandatory after recovery. After loading, compare the loss on a fixed mini-batch against the value recorded before saving; the deviation should be within tolerance. Also verify that the step counter, RNG state, and learning-rate scheduler state are consistent.

    7.2 How to Set Communication Timeouts

    Setting collective-communication timeouts lets a hung job surface early. The timeout should be clearly longer than the slowest normal step, with headroom for checkpoint saving.

    Automatic retry of an individual collective is not recommended. Collectives require synchronized participation from all ranks in the group, and a single rank retrying alone can easily cause state inconsistency. A safer approach is to terminate the job when a timeout is detected and restart the whole job from the most recent checkpoint.

    The fault-tolerance mechanisms in the source material specify no versions, thresholds, or recovery metrics, so the parameters above are only starting points that must be validated on the target cluster.

    8. Selection Recommendations

    1. First confirm whether the software stack can run the PyTorch distributed interfaces you use. If it can, prefer the native FSDP2 path: model code changes are minimal and future upgrades are easier. If it cannot, evaluate the coverage of the adaptation layer, substitute implementations for missing operators, and whether the checkpoint format can interoperate with native tooling.
    2. Run sharding simulations before starting work to estimate per-card memory and per-step communication. If either exceeds budget, adjust the plan first.
    3. When training and inference share a cluster, isolate resources between the two workload types, and clearly assign responsibility for checkpoint format conversion. If training and inference use different parallel layouts, weights must be converted to the target layout before loading.

    9. Conclusion

    This article has walked through the main stages of adapting trillion-parameter sparse model training: the capability boundaries of FSDP2 sharding, model loading and shard planning, gradient synchronization, memory and communication troubleshooting, and checkpointing with fault tolerance. Most of these methods depend on specific hardware and software versions. The numbers in this article are estimates or starting points; final parameters must be determined through measurement on the target cluster.