Trillion-Scale Multimodal Model Training: FSDP Sharding, Adapting the Full Training Pipeline
As models cross the trillion-parameter mark, full model states can reach tens of terabytes, making sharding a prerequisite rather than an optimization. This article examines the memory wall, communication wall, and scheduling challenges of multimodal training, then explains how Fully Sharded Data Parallel (FSDP) and the FSDP2 sharded tensor (DTensor) design divide parameters, gradients, and optimizer state across ranks. It also maps the three layers needed to adapt trillion-parameter training to a specific hardware and software stack (operators and runtime, collective communication, and the training framework) and the three steps that connect it into one pipeline (model loading, shard scheduling, and gradient synchronization). It closes with key throughput optimizations. The result is a transferable blueprint for teams building large-scale distributed training infrastructure.
Trillion-Scale Multimodal Model Training: FSDP Sharding, Adapting the Full Training Pipeline
Introduction: Why “Trillion Parameters” Is a Qualitative Turning Point
As models grow from billions of parameters to hundreds of billions and then cross the trillion-parameter mark, training is no longer a linearly growing engineering problem. Instead, the entire set of systemic challenges has to be rethought from the ground up.
Take a flagship multimodal model with roughly 2.8 trillion parameters. Under a mainstream mixed-precision strategy, each parameter needs not just its weights and gradients, but also the optimizer’s first- and second-order moments and a high-precision master weight copy. That brings the memory footprint per parameter to more than ten bytes. As a rough estimate, the model states alone approach tens of terabytes, far beyond the capacity of a single accelerator, let alone a single node.
The conclusion is unavoidable: without sharding, the model cannot be trained. At its core, trillion-parameter training is a systems engineering effort that answers one question: how to break an unmanageable model state into manageable pieces, compute them in parallel, and communicate them efficiently. Adding multimodal inputs such as text, images, and audio compounds the complexity. Each modality requires its own encoding, and cross-modal alignment adds more computation and scheduling demands on top. This article follows one adaptation effort that brought trillion-parameter training to a domestic AI accelerator, an AI chip developed in China, and extracts a technical path that can be applied more broadly.
1. Three Core Challenges of Trillion-Parameter Multimodal Training
1.1 The Memory Wall: Sharding Is a Prerequisite, Not an Optimization
The first bottleneck is that a single accelerator’s memory cannot hold the model state. Data parallelism (DDP) scales along the data dimension, but every device still keeps a full copy of the model, so it does nothing to resolve the memory wall. Storing parameters, gradients, and optimizer states as shards is therefore a necessary condition for training trillion-parameter models, not a nice-to-have optimization.
1.2 The Communication Wall: The Deeper the Sharding, the Heavier the Communication
Sharding relieves memory pressure but introduces additional collective communication overhead:
- During the forward pass, parameters scattered across ranks must be temporarily gathered into complete shards.
- During backpropagation, gradients must be reduced and redistributed.
As the cluster grows, so does the volume of communication. Without mechanisms to overlap computation and communication, GPUs and other accelerators sit idle waiting for data transfers and compute utilization drops sharply.
1.3 Heterogeneous Compute: Scheduling Multimodal Workloads
The subnetworks of a multimodal model differ dramatically in structure, compute density, and memory footprint. Text attention layers, vision encoders, and cross-modal alignment modules all have distinct computational profiles. Applying one uniform parallelism strategy across all of them often leads to load imbalance. This requires a training framework that supports flexible combinations of parallelism strategies, so each module can be sharded and scheduled differently.
2. FSDP: How Full Sharding Works
Fully Sharded Data Parallel (FSDP) has become the standard approach for trillion-parameter training. In an FSDP data-parallel group, every rank holds and manages a slice of the model’s parameters, gradients, and optimizer states. As a result, the total memory footprint of the model state is spread across all ranks.
The key difference from traditional DDP lies in the communication pattern:
- Forward pass: A layer’s parameters are all-gathered on demand to form the complete set needed for computation, then released immediately after use to keep peak memory under control.
- Backward pass: Gradients go through reduce-scatter, which reduces them and distributes the resulting slices to their respective ranks. No single device needs to retain the full gradient set.
- Optimizer step: Each rank updates only the parameter slice it owns, avoiding redundant computation.
FSDP’s second-generation implementation, commonly known as FSDP2, introduces the sharded tensor (DTensor) abstraction. Sharding shifts from being an implicit operation on flattened parameters to an explicit expression along tensor dimensions. Compared with the older approach of flattening an entire layer’s parameters into a large array, this tensor-semantics-based sharding is easier to make compatible with other components, easier to compose, and easier to debug. These qualities make it a particularly good fit for structurally complex models like multimodal ones.
3. Three Layers of Training Adaptation
Adapting a trillion-parameter model to a specific hardware and software stack usually requires connecting three layers from the bottom up.
3.1 Operator and Runtime Adaptation
A model’s computation graph ultimately executes as a large number of operators, including matrix multiplication, attention, normalization, and activation. The goal at this layer is to make these operators run efficiently on the target accelerator. This involves:
- Mapping high-frequency operators to hardware-efficient instructions and fusing operators (for example, fusing LayerNorm with the linear layer that follows it) to reduce reads and writes of intermediate tensors;
- Ensuring numerical stability across operators under mixed precision, with sensitive operators kept in higher precision;
- Integrating memory allocation and GPU memory management to prevent out-of-memory (OOM) errors caused by fragmentation.
3.2 Communication Library and Collective Communication Adaptation
FSDP’s efficiency depends heavily on how well collective communication primitives such as all-gather, reduce-scatter, and all-reduce are implemented over the accelerator’s high-speed interconnect. The adaptation needs to ensure that:
- The communication library fully utilizes high-bandwidth links between cards (such as NVLink-type interconnects or equivalent high-speed buses);
- Communication and computation can run concurrently on separate streams so that they overlap;
- Large and small messages use different communication algorithms, so that latency from frequently triggered small messages does not accumulate.
3.3 Framework-Layer Adaptation
At the top sits the training framework. Adaptation here covers distributed tensor abstractions, parallelism configuration, checkpoint formats, and fault tolerance. This layer determines whether developers can express complex parallel logic through simple interfaces. It marks the dividing line between “usable” and “a pleasure to use.”
4. Three Steps to Connect the Full Training Pipeline
A successful trillion-parameter adaptation must connect the entire path, from model loading to gradient synchronization.
4.1 Model Loading
A trillion-parameter model cannot be loaded as a single file onto a single device. At load time, weights must be read in sharded format. Each shard’s target rank and device must be resolved, and shard metadata must be built while loading. A properly sharded checkpoint can significantly reduce both startup time and peak memory usage.
4.2 Shard Scheduling
Shard scheduling controls when each rank gathers, and when it releases, the parameters of each layer. A good scheduling strategy follows a simple principle: “gather when needed, discard once done.” It should also overlap the all-gather for the next layer with computation on the current layer. This hides communication latency and keeps peak memory low.
4.3 Gradient Synchronization
Once backpropagation finishes, gradients must be reduced across ranks and distributed back as slices. Each rank then updates the parameter slice it owns. The correctness and efficiency of gradient synchronization directly determine convergence quality and training throughput. It is a non-negotiable part of the pipeline.
The pseudocode below illustrates the core flow of the pipeline. It uses no framework-specific APIs.
# Illustrative pseudocode: forward / backward / update flow under full sharding# Each rank holds only one slice (shard) of the parameters: shard_param# 1) Forward: all-gather the full parameters on demand, then release them right awayfull_param = all_gather(shard_param, group=dp_group) # Gather the complete weightsoutput = model.forward(inputs, full_param)release(full_param) # Release promptly to control peak memory# 2) Backward: reduce-scatter the gradients, reducing and distributing them as slicesgrad_shard = reduce_scatter(full_grad, group=dp_group) # Reduce and distribute gradient slices# 3) Optimizer: update only on the local shardoptimizer.step(grad_shard, shard_param) # Each rank updates its own slice
5. Key Practices for Performance Optimization
With the pipeline connected, further throughput gains can come from the following areas:
- Computation/communication overlap: Prefetching the next layer’s parameters before they are needed hides communication behind computation. This is one of the most effective ways to improve compute utilization.
- Activation recomputation: Instead of storing all intermediate activations for backpropagation, recompute the ones that are needed. This trades compute for memory and eases pressure on activation memory.
- Selective checkpointing: Enable recomputation only for modules that are compute-heavy and memory-hungry, balancing speed against memory usage.
- Mixed-precision training: Run the forward and backward passes in lower precision, while keeping optimizer states and master weights in higher precision. This balances convergence stability with throughput.
- Combining multiple parallelism dimensions: When a single device cannot hold one layer, combine tensor parallelism, pipeline parallelism, and FSDP into a two- or even three-dimensional parallelization scheme.
6. Conclusion and Outlook
Adapting trillion-parameter multimodal models for training is ultimately systems engineering. Its goal is a dynamic balance among three factors: memory, communication, and heterogeneous compute. FSDP breaks the memory wall by sharding parameters and eases the communication wall by overlapping computation with communication. Sharded checkpoint formats and gradient synchronization mechanisms then link model loading, shard scheduling, and gradient synchronization into a complete, usable training pipeline.
From an engineering perspective, a successful adaptation depends not only on low-level optimizations of hardware operators and communication libraries. It depends just as much on the framework layer expressing parallelism clearly. As domestic AI accelerators and in-house software stacks continue to mature, combining general-purpose training paradigms with capabilities such as elastic cloud compute, containerized scheduling, and monitoring and alerting can help teams move trillion-parameter models from “it runs” to “it runs reliably and runs fast.” For developers focused on large-scale distributed training, understanding FSDP’s sharding semantics and the design trade-offs of end-to-end pipeline scheduling is the key starting point for mastering this capability.
