Training a 2.8-Trillion-Parameter Multimodal LLM: A Complete FSDP2 Practice on Domestic AI Accelerators
This article explains how to adapt the training of a 2.8-trillion-parameter multimodal model on domestic AI accelerator cards and their software stack. It covers why FSDP2 was chosen as the core sharding strategy, the three key stages of the training pipeline (model loading, shard scheduling, and gradient synchronization), the extra complexity introduced by multimodal workloads, and the validation steps required for numerical correctness, fault tolerance, and long-term stability.
1. Background: Training Challenges in the Trillion-Parameter Era
The industry recently open-sourced a flagship multimodal model with 2.8 trillion parameters. Models at this scale impose extreme demands on training infrastructure: a single accelerator’s memory is far from sufficient to hold the full model weights, optimizer states, and activations, so multi-dimensional parallelism and fine-grained memory management are essential. Meanwhile, as domestic AI accelerator cards continue to improve in compute density, interconnect bandwidth, and software ecosystem, completing the training adaptation of ultra-large models on domestic compute platforms has become an important indicator of the maturity of domestic AI infrastructure.
This article focuses on one theme: how to build a complete training pipeline—spanning model loading, shard scheduling, and gradient synchronization—on domestic training-and-inference AI cards with their supporting software stack.
2. Core Technology Choice: Why FSDP2
2.1 Fundamentals of Fully Sharded Data Parallelism
The core idea of Fully Sharded Data Parallel (FSDP) is to shard model parameters, gradients, and optimizer states across the data-parallel group. Each GPU temporarily aggregates and releases parameters on demand at different stages of training, compressing memory usage to a fraction—or even less—of the original footprint.
Compared with the traditional combination of data parallelism (DP) and tensor parallelism (TP), FSDP offers:
- More regular communication patterns: parameter gathering and gradient reduction both occur within the data-parallel communication domain, with a clear topology that is easy to co-optimize with high-speed interconnects;
- Low code invasiveness: the training script only needs to wrap the model with a sharding policy; the model architecture itself does not need to be rewritten;
- Strong composability: it can be layered with pipeline parallelism, context parallelism, and other strategies to form multi-dimensional hybrid parallelism.
2.2 Key Improvements in FSDP2
FSDP2 introduces a per-parameter sharding design, using DTensor as the unified abstraction for sharding state. Compared with earlier implementations that rely on flattened parameters, this provides:
- Finer sharding granularity: each parameter is sharded independently, avoiding the extra memory copies and resharding overhead caused by flattening;
- Cleaner decoupling from optimizers, quantization, and offloading mechanisms, making it easier to compose various memory optimization techniques on demand;
- Direct sharding of mixed-precision parameters, yielding more significant memory savings in low-precision training.
A highly simplified sharding example:
from torch.distributed.fsdp import fully_shard, MixedPrecisionPolicymp_policy = MixedPrecisionPolicy(param_dtype=torch.bfloat16,reduce_dtype=torch.float32,)for block in model.layers:fully_shard(block, mesh=dp_mesh, mp_policy=mp_policy)fully_shard(model, mesh=dp_mesh, mp_policy=mp_policy)
By applying sharding layer by layer to each Transformer block, parameters are gathered and released on demand during forward and backward computation—effectively trading compute time for memory space.
3. Three Key Stages of the Multimodal Training Pipeline
The original work emphasizes “building a complete training pipeline from model loading and shard scheduling to gradient synchronization.” These three stages form the backbone of ultra-large-scale training.
3.1 Model Loading: Checkpoint Recovery and Initialization
Weights of trillion-scale models are typically stored in a distributed sharded format. The loading stage must address:
- Metadata consistency validation: ensuring tensor shapes and data types in the checkpoint exactly match the current model definition;
- Resharding: when the training parallelism differs from the parallelism at save time, tensors must be re-sharded according to the target topology;
- Streaming loading: avoiding loading full weights into memory at once; instead, shards are read in a streaming fashion and sharded on the fly, reducing peak CPU memory.
3.2 Shard Scheduling: Overlapping Compute and Communication
FSDP2 executes an “all-gather parameters → compute → release” loop in every forward pass. To hide communication latency, parameter gathering is typically overlapped with the previous layer’s computation, and communication traffic is prioritized (parameter/gradient traffic ahead of activation-related traffic). Illustrative logic:
with mesh:for block in layers:# Prefetch the next layer's parameters, overlapped with current layer computationprefetch(block_next)out = block(out)
3.3 Gradient Synchronization: Reduction and Bucketing
After backpropagation, gradient shards on each GPU must be reduced. A common engineering approach is “gradient buckets + overlapped reduction”: gradients are organized into buckets at shard granularity; each bucket performs a local reduce-scatter first, while inter-bucket communication overlaps with remaining computation. For mixed-precision training, reduction precision is generally kept at FP32 to avoid numerical drift caused by long-term low-precision accumulation.
4. Additional Complexity from Multimodality
Compared with pure language models, multimodal training introduces extra engineering challenges:
- Heterogeneous branches: the vision encoder, projection layers, and language model backbone have different parameter counts and compute characteristics, requiring differentiated sharding policies and micro-batch sizes at module granularity;
- Data pipeline: mixed datasets of images, video, and text need a unified packing and bucketing mechanism to avoid compute waste caused by imbalanced sequence lengths across modalities;
- Peak memory management: vision-side activations are large, so activation checkpointing is typically used to control peak memory, with selective partitioning of recomputation regions.
5. Adaptation Validation and Stability Assurance
After building the training pipeline, systematic validation is required:
- Numerical equivalence validation: at a very small configuration, compare loss curves and gradient norms between a single-GPU baseline and the distributed implementation to confirm that sharding and mixed-precision changes introduce no numerical anomalies;
- Fault tolerance and checkpoint resume: injection-based fault testing (simulating process crashes and node disconnections) to verify the integrity of checkpoint save/restore and the consistency of resumed training accuracy;
- Long-term stability: multi-day continuous training while monitoring loss divergence, communication health, and hardware status metrics.
6. Conclusion and Outlook
The training adaptation of this 2.8-trillion-parameter multimodal model on domestic accelerator cards validates the feasibility of an FSDP2-centered sharded training system on the domestic hardware-software stack. It also reflects that domestic AI infrastructure is moving from “capable of inference” toward “capable of training trillion-scale models.” As interconnect bandwidth, compiler optimization, and operator libraries continue to mature, the ecosystem completeness of domestic compute platforms for large-model training will keep improving, offering the open-source community richer compute options for large-scale training practices.
