Trillion-Parameter Model Training on Chinese AI Accelerators: FSDP2 and End-to-End Adaptation
Adapting trillion-parameter multimodal models to Chinese-developed AI accelerators requires more than fitting model weights into device memory. This article examines FSDP2-based sharding, multimodal data pipelines, model initialization, gradient synchronization, checkpoint recovery, and operator validation. It outlines the engineering work needed to establish a stable training workflow and support the transition from training to inference on a shared hardware and software stack.
1. Why Trillion-Parameter Models Challenge Training Infrastructure
The emergence of open-source multimodal models with parameter counts reaching the trillion scale places demanding requirements on training infrastructure. Three constraints are particularly important:
- Device memory: A single accelerator cannot hold all model parameters, optimizer states, and activations.
- Interconnect bandwidth: Combining tensor, pipeline, and data parallelism requires efficient communication both within and across nodes.
- Software stack maturity: Operator coverage and stability determine whether training can run reliably over extended periods.
Adapting these models to Chinese-developed AI accelerators is therefore an end-to-end engineering task. The objective is not simply to make a model run, but to establish production-ready behavior across model loading, shard scheduling, gradient synchronization, and checkpoint recovery.
This article examines the main adaptation requirements using a representative high-end accelerator designed for both training and inference, together with its supporting software stack.
2. Why Use FSDP2 as the Core Parallelism Strategy?
For trillion-parameter models, conventional distributed data parallelism (DDP) replicates the full model state on every device, making its memory requirements impractical. Common alternatives include:
- Tensor parallelism (TP): Splits individual layer weight matrices across devices. It requires frequent communication and is well suited to high-bandwidth device interconnects.
- Pipeline parallelism (PP): Divides the model by layers. It suits deep models but introduces pipeline bubbles that reduce utilization.
- Fully Sharded Data Parallel (FSDP): Shards parameters, gradients, and optimizer states across devices. Parameters are gathered temporarily when needed for forward or backward computation and can be released afterward.
Compared with TP and PP, which require careful partitioning and topology-aware planning, FSDP generally requires fewer changes to model code and less configuration. It also accommodates complex architectures such as multimodal models.
FSDP2 introduces per-parameter sharding rather than relying on flattened parameter groups. This provides finer-grained control in several areas:
- Memory management: Large embedding layers and language-model heads can receive specialized handling, including attention to compatibility issues during meta-device initialization.
- Mixed precision: Parameter and gradient-reduction dtypes can be configured separately to balance memory use and numerical requirements.
- Gradient accumulation: Resharding and synchronization behavior can be tuned to avoid unnecessary communication across accumulation steps.
A simplified FSDP2 setup looks like this:
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, mixed_precision_policy=mp_policy)fully_shard(model, mixed_precision_policy=mp_policy)
On the target accelerator platform, a central adaptation task is ensuring that the collective communication primitives required by sharding—all-gather, reduce-scatter, and all-reduce—work efficiently and reliably in the local software stack. Overlapping communication with computation is also important for hiding communication latency.
3. Building the Multimodal Training Pipeline
Multimodal training differs from text-only training in both data processing and computation.
Data Pipeline
A unified sample format must align text, images, audio, and other modalities within a shared sample stream. A typical approach uses configurable data-mixture ratios, with separate preprocessing and packing for visual encoder inputs.
The goal is to prevent CPU-side preprocessing from becoming the training bottleneck. Common measures include:
- Caching preprocessed data on disk and streaming it as needed during training.
- Storing large raw datasets in object storage and retrieving them through a high-throughput data access layer.
- Using multiprocess or multithreaded data loading alongside asynchronous transfers to accelerator memory.
Compute Pipeline
A multimodal model typically contains a visual encoder, a modality adapter, and a language backbone. These components have different memory footprints and computational characteristics, so they do not necessarily need the same partitioning strategy.
For example, the language backbone can use full sharding, while the decision to shard the visual encoder depends on its parameter count. Selective activation recomputation can then limit peak activation memory.
4. Establishing the Complete Training Workflow
A successful adaptation must connect every stage of the training lifecycle.
4.1 Model Loading and Initialization
Even sharded initialization of a trillion-parameter model can encounter problems with meta-device loading and weight-format conversion.
A common approach is to construct the model structure on the meta device, then stream weights into their assigned shards. This avoids materializing the complete model on any one node and helps prevent device-memory exhaustion during loading.
4.2 Shard Scheduling
Sharding granularity, recomputation policies, and communication bucket sizes must be selected together. These settings determine the trade-off between memory consumption and communication frequency.
Reaching a suitable configuration usually requires multiple profiling iterations rather than a single static setup.
4.3 Gradient Synchronization
During backpropagation, reduce-scatter reduces gradients and distributes the resulting shards to their owners. Each device stores optimizer states, such as first- and second-moment estimates, only for its local parameter shard.
For an illustrative state-memory estimate of roughly 12 bytes per parameter, ideal sharding across (N) devices reduces that component from approximately (12P) bytes per device to (12P/N), where (P) is the parameter count. Actual memory consumption also depends on precision, activations, temporary buffers, and the sharding configuration.
4.4 Checkpoint Recovery and Fault Tolerance
Long-running training requires periodic sharded checkpoints and automated recovery mechanisms.
Container-platform rescheduling can support job-level fault recovery, while logging, monitoring, and alerts track:
- Loss curves.
- Training throughput.
- Time spent in communication.
Checkpointing and recovery should be validated as part of the training workflow, not treated as optional features added after performance tuning.
4.5 A Shared Platform for Training and Inference
An accelerator designed for both training and inference can serve both workloads on the same hardware. With a unified software stack, trained weights can move into inference deployment with fewer format-conversion and migration steps.
This reduces operational overhead and can improve overall accelerator utilization.
5. Common Adaptation Issues and Practical Lessons
Operator Coverage
Specialized operators in multimodal models, such as deformable attention or custom rotary embedding variants, require individual validation.
Small-scale, single-device comparisons of forward outputs and backward gradients provide a practical acceptance check for numerical consistency.
Communication Optimization
Gradient bucketing and communication–computation overlap can improve throughput in suitable workloads. Their effectiveness should be measured through profiling on the target hardware and software stack.
Numerical Stability
BF16 training, gradient clipping, and an appropriate loss-scaling policy where needed are important considerations for stable large-scale training. Precision and scaling choices must be validated for the actual model and operator implementations.
Observability
Establish performance baselines for each training stage, including tokens per second per device. Unexpected deviations should trigger investigation so that data-loading stalls, communication delays, and compute regressions can be identified promptly.
6. Conclusion
Adapting trillion-parameter multimodal training to Chinese-developed AI accelerators tests the maturity of the entire training stack. FSDP2 support is only one part of that work: model initialization, sharded execution, gradient synchronization, checkpoint recovery, and the transition to inference must also function together reliably.
For teams planning large-model training, the central lesson is to advance three workstreams in parallel: model-level parallelism, adaptation to the target accelerator platform, and engineering measures for operational stability.
Continued improvements in operator coverage and communication libraries can further expand the range of large-model workloads these platforms can support.
