FSDP2 in Practice: Adapting Training for a 2.8-Trillion-Parameter Multimodal Model

    This article walks through adapting a 2.8-trillion-parameter multimodal model for training with FSDP2. It covers memory budgeting, sharded weight loading, two-level sharding, gradient synchronization pipelines, adaptation to the MUSA software stack, end-to-end checkpointing and recovery, and monitoring metrics for scaling efficiency. The figures are mostly estimates or starting values, so readers should calibrate them against their own clusters.

    Introduction: As Models Grow, the Bottleneck Shifts from Compute to the System

    When a foundation model reaches the trillion-parameter scale, single-node multi-GPU setups with simple data parallelism no longer work. Beyond 100 billion parameters, training speed is usually limited by memory capacity, cross-node communication efficiency, and data scheduling, not by the compute power of a single GPU.

    This article uses the training adaptation of a 2.8-trillion-parameter multimodal model as an example. It outlines the full path from loading weights to resuming training from checkpoints. The numbers are mostly estimates or suggested starting values. Readers should calibrate them against their own clusters.

    1. Calculating the Memory Budget

    Before training, you need to know the total memory required. For a model with 2.8 trillion dense parameters, the estimate based on bytes per parameter is as follows:

    Item Precision Bytes per Parameter Total
    Working weights BF16 2 5.6 TB
    Gradients BF16 2 5.6 TB
    Master weight copy FP32 4 11.2 TB
    Adam first moment FP32 4 11.2 TB
    Adam second moment FP32 4 11.2 TB
    Total (excluding activations) 16 44.8 TB

    With 80 GB per GPU, the model state alone requires about 560 GPUs’ worth of memory. Activations, communication buffers, and memory fragmentation consume additional space. The model state must therefore be sharded across many GPUs.

    The characteristics of multimodal data make this harder. Image, video, and text sequences vary widely in length. Pure data parallelism leaves compute unevenly distributed across GPUs, so some GPUs sit idle while others become bottlenecks. Activation recomputation reduces activation memory but adds forward-pass compute. Whether to use it depends on the remaining memory headroom.

    2. FSDP2 Sharding and Model Loading

    1. Environment Information to Fix Before Training

    The sharding scheme is sensitive to software versions. Before launching, record and pin the following: the PyTorch and FSDP2 interface versions, the MUSA driver and software stack versions, the communication library version, the network type within and between nodes (NVLink domain, RoCE, or InfiniBand), and the sharding dimension and gradient bucket size. Without this information, the steps cannot be reproduced.

    2. Offline Weight Rearrangement and Streaming Load

    A complete weight file cannot be loaded into GPU memory at once, so the loading method needs to be designed specifically. It has three main steps:

    • Offline rearrangement: Split dense weight matrices into blocks along the sharding dimension, and store each shard as a separate file. For example, a (1024, 1024) matrix can be split by rows into 8 blocks of 128 rows each, with the file location of each block recorded.
    • Streaming reads: Use memory mapping so that each process reads only the shards it is responsible for. This avoids having every GPU read the full weights into host memory (CPU RAM).
    • Index service: Record the mapping between shards and devices, storage addresses, and version numbers. At startup, validate the index before loading to prevent duplicate loads or version mismatches.

    3. Two-Level Sharding and Temporary Full Parameters

    Each GPU holds only 1/N of the model parameters, where N is the total number of GPUs. The scheme uses two levels of sharding. Within a node, communication runs over the NVLink domain. Between nodes, data is exchanged over RoCE or InfiniBand.

    During the forward pass, All-Gather temporarily collects the full parameters for the current layer. Once that layer finishes computing, its parameters are released immediately. During the backward pass, Reduce-Scatter completes gradient reduction and distributes the results back to each GPU.

    The key to understanding peak memory usage is that the peak occurs when a single layer’s parameters are gathered. The full model is never in memory at the same time. Finer shard granularity lowers this peak but increases the number of communication operations, so the granularity has to be balanced between the two.

    3. Gradient Synchronization Pipeline

    Traditionally, gradient synchronization starts only after the backward pass for the entire batch finishes. This adaptation switches to a bucketed pipeline:

    • Bucketed communication: Gradients are grouped into buckets by layer. As soon as a layer’s backward pass finishes, communication for its bucket starts, without waiting for the whole model. Bucket size can start at 25 MB and be adjusted based on the ratio of communication time to compute time.
    • Dual-stream parallelism: Communication and computation run on separate streams and synchronize through stream events. In the MUSA software stack, this corresponds to independent stream and event interfaces. For specific API names, refer to the documentation for the version in use.
    • Static graph orchestration: The Transformer computation graph has a relatively fixed structure, so the forward and backward passes are compiled into a static execution graph. All-Gather and Reduce-Scatter are instantiated as concrete operators and inserted into gaps in the computation.

    A static graph creates opportunities for overlap but does not guarantee full overlap. The actual overlap rate depends on the sharding level, bucket size, and network bandwidth. Use a profiling tool to measure communication wait time for each step rather than assuming communication is fully hidden.

    4. Hardware-Software Co-Design: Adapting to the MUSA Software Stack

    Peak hardware compute does not equal effective compute. The maturity of the software stack determines how large the gap between them is. This adaptation focused on two main areas.

    1. Memory Pooling

    Before training starts, a large block of GPU memory is reserved at once and divided into regions for parameters, gradients, activations, and communication buffers. During execution, most memory allocations happen inside the pool, which significantly reduces dynamic allocation and deallocation.

    Pooling lowers the likelihood of fragmentation and allocation failures but cannot eliminate fragmentation completely. Measure its effect using three metrics: pool capacity utilization, fragmentation rate, and the number of failed memory allocations.

    2. Operator Fusion

    In multimodal models, there is substantial cross-attention computation between the vision encoder and the text decoder. Rather than executing operators one by one, the software stack fuses LayerNorm, the QKV projection, and attention computation into a single kernel. Fusion reduces the number of kernel launches, avoids writing intermediate results back to memory, and lowers memory bandwidth pressure. During the backward pass, intermediate states are recovered through recomputation, which saves more memory.

    5. End-to-End Pipeline and Checkpoint Recovery

    The complete training loop includes loading model parameters, preprocessing multimodal data, the forward pass, the backward pass, gradient aggregation, parameter updates, and checkpoint saving. Each stage must be validated as part of the chain, because a failure in any one stage interrupts training.

    Checkpoints for trillion-parameter models often reach tens of terabytes. This adaptation uses asynchronous sharded saving, which overlaps storage writes with subsequent computation. During recovery, shards are read in parallel, and their version numbers and shard indexes are checked for consistency. After any training interruption, run a recovery drill periodically to confirm that the checkpoints are actually usable.

    6. Observability and Scaling Efficiency

    Monitoring should cover both computation and communication. The table below defines each metric and suggests a starting alert threshold. These thresholds are empirical values, not measured results from this practice. Adjust them based on your historical baselines.

    Metric Measurement Method Suggested Alert Threshold
    Compute unit utilization Fraction of time each GPU’s compute units are busy, averaged over a 1-minute window Drops more than 10% below the historical baseline
    All-Gather time share Communication wait time within a step divided by total step time Exceeds 20%
    Inter-node link congestion Duration for which link bandwidth utilization stays high Above 80% for more than 5 minutes
    Scaling efficiency Actual throughput divided by (number of GPUs × baseline single-GPU throughput) Below 80% of baseline

    Scaling efficiency must be reported with the GPU count, topology, and batch size. For example, use an 8-GPU run as the baseline, then record throughput at 64 and 256 GPUs. Without these conditions, scaling efficiency figures cannot be compared.

    7. Launch Checklist

    • Before loading: Verify the number of weight shards, their hash values, and version numbers, and confirm that the index matches the files.
    • Sharding configuration: Record the GPU count N, the sharding strategy within and between nodes, and the wrapping granularity for each layer.
    • Communication tuning: Use a profiling tool to measure communication wait time per step, and adjust bucket size incrementally.
    • Fault tolerance: Set the checkpoint save interval, confirm that asynchronous writes succeed, and complete one recovery drill.
    • Monitoring: Configure alerts using the metrics in Section 6, and keep historical baselines.

    8. Summary and Takeaways

    First, computing platforms provide the foundation, but the depth of software stack adaptation determines the effective compute you get. Second, parallelism strategies need to be refined for the model structure and network topology, and FSDP2 is no exception. Third, getting a training run to work is only the starting point. Stability, fault recovery, and cost control determine whether large models can keep being iterated on over time.

    As parameter counts continue to grow, end-to-end automated search and compilation optimization will become more important. Much of the effort in training adaptation will shift toward these areas.