FSDP2 Training for Trillion-Parameter Multimodal Models: Adaptation and Full-Pipeline Practices

    Training trillion-parameter multimodal large models requires overcoming memory and communication walls while handling heterogeneous vision-language computation. This article examines the main challenges and describes how to build a native FSDP2 training path, covering tensor-level sharding, multimodal module scheduling, software-hardware co-adaptation, distributed model loading, dynamic sharding and memory management, and overlapping gradient synchronization with communication. It outlines the full pipeline from model initialization to gradient synchronization, with the goal of improving efficiency and stability for ultra-large model training under constrained GPU memory and large-cluster bandwidth conditions.

    FSDP2 Training for Trillion-Parameter Multimodal Models: Adaptation and Full-Pipeline Practices

    Introduction

    In recent years, the parameter scale of large language models (LLMs) and multimodal large language models (MLLMs) has grown exponentially, and surpassing one trillion parameters has become standard for top-tier models. For example, a 2.8-trillion-parameter flagship multimodal model released in the open-source community imposes stringent requirements on the underlying AI computing hardware and software stack due to its massive parameter volume and complex multimodal structure. Against this background, training ultra-large models under limited GPU memory while maintaining training efficiency and stability has become a core issue in AI infrastructure. This article focuses on building a native FSDP2 multimodal training path, detailing the complete training chain from model loading and sharding scheduling to gradient synchronization, and discusses best practices for software-hardware co-optimization in the context of general AI computing infrastructure concepts such as Baidu AI Cloud.

    1. Training Challenges for Trillion-Parameter Multimodal Models

    When adapting trillion-parameter multimodal models, computing frameworks and hardware clusters first face dual pressure from the memory wall and the communication wall.

    1.1 Extreme Memory Overhead and the Memory Wall

    For a model with 2.8 trillion parameters, storing only the model weights in BF16 precision requires approximately 5.6 TB of GPU memory. In addition, gradients and optimizer states that must be saved during training, such as momentum and variance in AdamW, double or even multiply the overall memory requirement. A single GPU, typically with tens to hundreds of GB of memory, cannot hold the entire model, so distributed parallelism strategies must be used to shard states across hundreds or thousands of compute cards.

    1.2 Heterogeneous Scheduling in Multimodal Structures

    Multimodal large models usually contain a vision encoder, a language model backbone, and modality alignment layers. Input data from different modalities, such as image token sequences and text token sequences, differ significantly in length and feature dimensions. This heterogeneity makes the computation graph highly complex, and traditional tensor parallelism (TP) or pipeline parallelism (PP) can suffer from load imbalance and communication deadlocks at modality boundaries.

    1.3 Bandwidth Bottlenecks in Cross-Node Communication

    In clusters with thousands or even tens of thousands of GPUs, intra-node communication typically uses high-speed NVLink, while inter-node communication relies on InfiniBand or RoCE networks. When data parallelism (DP) or fully sharded data parallelism (FSDP) performs gradient synchronization, it can easily saturate network bandwidth, causing GPU compute units to generate many bubbles while waiting for data and severely reducing overall cluster compute efficiency (MFU).

    2. Building a Native FSDP2 Multimodal Training Path

    To address these challenges, building a training path with native FSDP2 (Fully Sharded Data Parallel 2) is widely recognized as an efficient solution. Compared with first-generation FSDP, FSDP2 has been rearchitected at the lower level, providing finer-grained parameter control and more efficient memory management.

    2.1 Core Mechanisms of FSDP2

    The core idea of FSDP2 is to move beyond module-level sharding and achieve tensor-level, stateless parameter management. In FSDP2, model parameters are split into multiple shards immediately after initialization and distributed across different devices. During forward computation, parameters are collected on demand through All-Gather. During backpropagation, parameters are first restored through All-Gather to compute gradients, and then gradient shards are synchronized immediately through Reduce-Scatter while the original parameter memory is released. This mechanism greatly reduces peak memory usage and makes training trillion-parameter models feasible in terms of GPU memory.

    2.2 Native Multimodal Path Design

    In a multimodal training path, the fusion of features from different modalities requires special handling. When building a native path with FSDP2, the boundaries between vision modules and text modules must be identified during computation graph compilation, and independent sharding strategies should be applied to different modules. For example, the vision encoder can use a smaller shard granularity to reduce communication frequency, while the large language model layers use standard FSDP2 sharding. At the same time, the framework must support dynamic batching of multimodal data to ensure relatively balanced data load across GPUs during parallel computation.

    2.3 Software-Hardware Co-Adaptation

    Adapting trillion-parameter models depends not only on the framework but also on deep co-design between the underlying AI accelerator cards and the software stack. Taking AI computing infrastructure provided by platforms such as Baidu AI Cloud as an example, the underlying stack typically integrates operator libraries and compilers optimized for in-house or mainstream GPUs. During adaptation, it is necessary to ensure that FSDP2 communication primitives such as All-Gather and Reduce-Scatter can map directly to hardware high-speed collective communication interfaces, reducing overhead from intermediate conversion layers and maximizing hardware compute.

    3. Key Steps in a Complete Training Pipeline

    Building a stable trillion-parameter training pipeline requires careful refinement of three core steps: model loading, sharding scheduling, and gradient synchronization.

    3.1 Efficient Distributed Model Loading

    For a 2.8-trillion-parameter model, if a traditional single-process loading and redistribution approach is used, initialization may take hours and is highly prone to out-of-memory (OOM) errors. The best practice is a distributed direct loading mechanism. During persistence, model weights are stored in a distributed file system or object storage according to the FSDP2 sharding strategy. At training startup, each compute process reads its own parameter shard directly from storage based on its rank ID. This approach reduces loading time from hours to minutes and greatly lowers peak memory usage.

    3.2 Dynamic Sharding Scheduling and Memory Management

    During training, because multimodal data lengths vary, the size of intermediate activations fluctuates dynamically. To prevent memory overflow, the scheduling system needs dynamic monitoring and intervention capabilities. On the one hand, the framework should implement activation checkpointing to trade compute for memory. On the other hand, the scheduler should dynamically adjust the CPU offload strategy based on the memory headroom of the current step. When memory is tight, parameter shards not involved in the current computation can be temporarily offloaded to CPU memory or SSD and asynchronously prefetched back to GPU memory when needed.

    3.3 Gradient Synchronization and Communication Overlap Optimization

    Communication overhead is a key constraint on training efficiency in large-scale clusters. In the gradient synchronization stage, deep overlap between computation and communication is required. During backpropagation, once the gradient computation for a layer is complete, its Reduce-Scatter communication should start immediately without waiting for the entire backward pass to finish. At the same time, combined with the topology of the computation graph, communication operations should be split into smaller microtasks executed in parallel through streams. In addition, for cross-node communication, a topology-aware scheduling algorithm should be used to assign communication-intensive tasks to nodes with shorter network distances, thereby reducing network latency.

    4. Conclusion and Outlook

    Completing training adaptation for trillion-parameter multimodal models is not a simple matter of calling a framework. It is a systemic engineering effort involving low-level hardware communication, distributed storage, memory scheduling, and algorithm frameworks. By building a native FSDP2 multimodal training path and connecting the full chain from distributed loading to dynamic sharding scheduling and then to gradient communication overlap, it is possible to effectively break through memory and bandwidth bottlenecks and maximize software-hardware compute. In the future, as model scale continues to expand and modalities continue to increase, requirements for AI infrastructure will become even stricter. With mature AI computing platforms such as Baidu AI Cloud and more advanced parallel strategies such as 3D parallelism and asynchronous checkpointing, the stability and cost-effectiveness of large model training will see new breakthroughs, providing solid underlying support for the evolution of artificial general intelligence.