Training Trillion-Parameter Multimodal Models on Domestic AI Compute Platforms: A Practical FSDP Adaptation Guide
As open-source models reach multi-trillion parameters with multimodal capabilities, adapting training pipelines to domestic AI accelerators has become a critical engineering challenge. This article explains how Full Sharded Data Parallel (FSDP) works, including the improvements in newer FSDP2 implementations, and walks through the key adaptation steps on domestic AI hardware: operator and communication library coverage, lazy weight loading with meta-device initialization, shard scheduling for heterogeneous multimodal modules, and gradient synchronization for numerical stability. It also covers system-level performance optimization strategies and offers practical recommendations for enterprises building large-scale training capabilities on domestic compute platforms.
Training Trillion-Parameter Multimodal Models on Domestic AI Compute Platforms
Background: Training Challenges in the Trillion-Parameter Era
As large model technology rapidly evolves, the open-source community keeps producing flagship models with parameter counts in the trillions, most of which offer multimodal capabilities spanning text and images. While these models deliver stronger capabilities, they place unprecedented demands on training infrastructure:
- Massive memory pressure: Even with mixed-precision training, model weights alone can consume several terabytes of memory. Add optimizer states and gradients, and a single card falls far short—large-scale distributed training is mandatory.
- Significant communication overhead: The larger the parameter scale, the greater the communication volume for gradient synchronization and shard aggregation. Cluster network bandwidth and topology directly determine training throughput.
- High hardware-software co-design requirements: Training frameworks are optimized by default for mainstream accelerators. Running them on domestic AI accelerator cards requires deep adaptation of operators, communication libraries, and memory management.
Recently, a domestic chip vendor completed training adaptation for a flagship open-source trillion-parameter model using its flagship training-and-inference AI accelerator card and accompanying software stack. The vendor built a multimodal training path with native support for the new generation of Full Sharded Data Parallel (FSDP), establishing a complete training pipeline from model loading and shard scheduling to gradient synchronization. This article uses that milestone as an entry point to systematically review the general technical principles and engineering methods behind such adaptation efforts.
Core Technology: How Full Sharded Data Parallel (FSDP) Works
Full Sharded Data Parallel is one of the mainstream approaches for training extremely large models today. Its core idea: instead of having every device hold a complete model replica, all three types of data—model parameters, gradients, and optimizer states—are sharded and evenly distributed across all compute devices in the cluster.
2.1 Comparison with Traditional Data Parallelism
In traditional data parallelism (DP), each card holds the full model and only the data is split. After backpropagation, gradients are synchronized via AllReduce. This is simple to implement but suffers from severe memory redundancy, making it unsuitable for extremely large models.
The fully sharded approach eliminates this redundancy entirely:
- Before the forward pass: AllGather aggregates the parameter shards needed by the current layer into complete parameters.
- After computation completes: Non-local parameter shards are immediately released, keeping only the portion each device owns.
- During backpropagation: Parameters are gathered again; after gradients are computed, ReduceScatter reduces and scatters gradients across devices.
- During parameter updates: Each device updates only its local parameter shards using its local gradient and optimizer state shards.
2.2 Improvements in the New Generation of Sharding (FSDP2)
The newer sharding implementation (commonly known as FSDP2 in the industry) brings significant upgrades to the programming model, with typical characteristics including:
- Sharded tensors as the fundamental abstraction: Parameters are represented as logically distributed tensors, so developers can write model code as if working with ordinary tensors while the framework handles sharding details automatically.
- More flexible combinations of parallelism dimensions: It naturally composes with tensor parallelism, pipeline parallelism, and expert parallelism, fitting the sparse computation patterns of Mixture-of-Experts (MoE) architectures.
- Finer-grained communication-computation overlap: By scheduling AllGather and ReduceScatter per layer (or even per submodule), communication is hidden beneath computation, improving device utilization.
A representative sharding configuration looks like this:
# Illustrative code: apply full sharding with Transformer layers as the unitfrom torch.distributed.fsdp import fully_shardfor layer in model.transformer_blocks:fully_shard(layer) # Each submodule is sharded independently; communication is pipelined per layerfully_shard(model) # The root module acts as a fallback, handling the embedding layer and output head# Training can then proceed as with an ordinary modelfor batch in dataloader:loss = model(batch).lossloss.backward()optimizer.step()optimizer.zero_grad()
This declarative sharding style greatly reduces the difficulty of adapting multimodal models—heterogeneous submodules such as vision encoders and text decoders can each use different sharding granularities.
Key Engineering Steps in Training Adaptation
Completing training adaptation on domestic AI accelerator cards is not simply about “getting the code to run”—it requires打通 the entire hardware-software stack layer by layer. Based on public information and common industry practice, the main steps are as follows.
3.1 Software Stack and Operator Adaptation
Domestic accelerators typically provide their own programming models and compute libraries (analogous to the CUDA ecosystem). Adaptation work starts with:
- Core operator coverage: High-frequency operators such as matrix multiplication, attention, normalization, and activation functions must have high-performance implementations. Missing operators need to be developed against low-level programming interfaces or optimized through operator fusion.
- Communication library adaptation: Collective communication primitives such as AllGather, ReduceScatter, and AllToAll (essential for MoE) must be optimized for the chip interconnect topology, making full use of high-bandwidth intra-node interconnects and inter-node networks.
- Framework compatibility layer: The distributed interfaces of mainstream deep learning frameworks must seamlessly call into the underlying domestic software stack, minimizing changes to upper-level training scripts.
3.2 Model Loading and Weight Sharding
Trillion-parameter models are typically stored as hundreds of shard files, and the loading stage must address:
- Lazy loading: Each process reads only the parameter shards it is responsible for, avoiding out-of-memory failures caused by every device loading the full weights.
- Meta-device initialization: The model structure is first built on a “meta device” (a logical device that allocates no actual memory), then weights are materialized segment by segment according to the sharding plan.
- Checkpoint format conversion: The officially released weight format is converted into a sharded format that the distributed training framework can consume directly, ensuring numerical consistency.
3.3 Shard Scheduling Strategy
Multimodal models are highly heterogeneous in structure, so shard scheduling requires careful design:
- For compute-intensive but relatively parameter-light modules such as the vision encoder, coarser-grained sharding can reduce communication frequency.
- For large-scale sparse expert layers, expert parallelism should be combined so different experts are distributed across different devices, with activations exchanged via AllToAll.
- For modules tied to large vocabularies, such as embedding tables and output heads, sharding along the vocabulary dimension prevents any single card from carrying an oversized vocabulary matrix.
3.4 Gradient Synchronization and Numerical Stability
The final link in the training pipeline is ensuring the correctness and stability of gradient synchronization:
- Communication precision: Gradients can be communicated in BF16 to reduce bandwidth pressure, but the optimizer should keep FP32 master weights to avoid precision loss over long training runs.
- Distributed gradient clipping: Computing the global gradient norm requires first reducing the local norms of sharded gradients across devices, then applying unified clipping.
- Mixed-precision loss scaling: Properly configure the loss scaling factor and its dynamic adjustment strategy to prevent gradient underflow at low precision.
General Strategies for Performance Optimization
Completing adaptation is only the starting point; achieving usable or excellent training efficiency requires system-level optimization:
- Communication-computation overlap: Leverage the natural per-layer scheduling of sharding to prefetch parameter shards for layer N+1 while computing layer N, hiding communication latency behind computation.
- Activation checkpointing: Save only key checkpoints of intermediate activations and recompute the rest during backpropagation, trading a small amount of compute for substantial memory savings.
- Memory fragmentation management: Use scalable memory allocation strategies (such as segment-based allocators) to avoid unexpected out-of-memory failures caused by fragmentation during long training runs.
- Parallelized data pipelines: Run multimodal data preprocessing (image decoding, text tokenization) asynchronously on the CPU side as a pipeline, combined with data prefetching, to prevent compute devices from sitting idle.
- Monitoring and fault tolerance: Use logging services and monitoring alerts to track throughput, memory usage, and communication latency on each device in real time. Periodic checkpoints and fast recovery mechanisms minimize losses from hardware failures interrupting training.
Recommendations for Enterprises
This adaptation case shows that domestic AI compute is gradually maturing for ultra-large-scale model training. For enterprises planning to build independent training capabilities, we recommend:
- Prioritize platforms with verified hardware-software co-design: The training pipeline spans frameworks, drivers, and communication libraries. Choosing a compute platform already validated against mainstream open-source models significantly reduces trial-and-error costs.
- Organize training code around standard interfaces: Write code based on the standard sharding abstractions of mainstream distributed training frameworks to maintain portability across hardware platforms.
- Leverage general-purpose cloud capabilities: Training data can be stored in object storage, job scheduling can run on container platforms, and training observability can combine logging services with monitoring alerts to build a complete training engineering system. Major cloud providers offer these common product categories as building blocks for training infrastructure.
- Adopt a validate-then-scale methodology: First verify numerical correctness and convergence trends on a small number of devices, then scale up incrementally to the target size, avoiding wasted resources from launching directly at full scale.
Conclusion
Training adaptation for trillion-parameter multimodal models is a systems engineering effort spanning sharding algorithms, hardware-software co-design, communication optimization, and engineering safeguards. The fact that a domestic training-and-inference compute platform has completed full training pipeline adaptation for a cutting-edge open-source flagship model demonstrates that the entire path—from model loading and shard scheduling to gradient synchronization—is now engineering-feasible. As the software ecosystem continues to mature, domestic AI compute is positioned to play an increasingly important role in large model training, offering the industry more diverse and more independent infrastructure choices.
