Training Ultra-Large Multimodal Models on Heterogeneous Compute: A Practical Adaptation Guide

    This article outlines a practical workflow for adapting ultra-large multimodal model training to heterogeneous AI compute clusters. It covers memory estimation for trillion-parameter models, FSDP2-based per-parameter sharding, module-level sharding for vision and language components, forward scheduling with All-Gather and release or prefetch tradeoffs, and backward synchronization considerations. The focus is on calculating resource requirements first, then building the training path, and validating the setup end to end.

    Introduction: Training Challenges for Trillion-Parameter Multimodal Models

    Recently, several flagship multimodal models with parameter counts approaching 3 trillion have been open-sourced. They perform strongly on image-text understanding and cross-modal reasoning. When training such models, teams usually encounter insufficient GPU memory first, then find that multi-GPU communication slows training, and only later realize that the underlying software stack also needs adjustment. This article follows the sequence of “calculate resources first, build the training path next, and perform end-to-end validation last” to summarize how to adapt very large models on heterogeneous AI compute clusters.

    Calculate the Memory Budget First

    Memory estimation is the first step in choosing a parallelism strategy. Taking a 2.8-trillion-parameter model as an example, BF16 compute weights alone occupy 2.8×10^12 × 2 bytes, or about 5.6 TB.

    In mixed-precision AdamW training, each parameter typically also requires the following:

    • BF16 compute weights: 2 bytes
    • BF16 gradients: 2 bytes
    • FP32 master weights: 4 bytes
    • AdamW first moment: 4 bytes
    • AdamW second moment: 4 bytes

    This totals about 16 bytes per parameter, so a 2.8-trillion-parameter model needs about 44.8 TB. This number does not include activations. Activations depend on batch size and sequence length and must be estimated separately.

    If the cluster has 512 GPUs and weights, gradients, and optimizer states are evenly sharded, each GPU holds about 44.8 TB ÷ 512, or about 87.5 GB, of long-term state. This is an idealized estimate. During training, some full parameters are temporarily restored, and activations also consume memory, so the actual peak will be higher.

    The vision encoder and language model in a multimodal model have different compute characteristics. The vision part leans toward convolution and local attention, while the language part relies on large-scale self-attention. The two parts differ significantly in parameter volume and memory access patterns, so sharding units should be divided by module rather than applied uniformly across the whole model.

    Build an FSDP2 Multimodal Training Path

    1. Per-Parameter Sharding: Long-Lived State Is About 1/N

    FSDP2 shards by parameter, splitting each parameter along dimension 0 across GPUs. Weights, gradients, and optimizer states are stored as shards, so each GPU’s long-lived state is about 1/N of the full state.

    Note that 1/N describes the long-term resident state. When computing a layer in the forward pass, All-Gather is needed to restore the full parameters of that layer, which temporarily consumes memory. Therefore, per-GPU peak memory is roughly the long-term shard plus the full parameters of the largest layer, plus activations.

    The vision encoder and language model can each be treated as independent sharding units. Appropriate module boundaries can avoid memory load imbalance caused by differences in parameter volume between the two parts. The following code is illustrative; module names should be adjusted to the actual model:

    1. from torch.distributed.fsdp import fully_shard
    2. # First shard each layer, then shard the root module so each shard unit is managed independently
    3. for block in model.vision_encoder.blocks:
    4. fully_shard(block)
    5. for block in model.language_model.layers:
    6. fully_shard(block)
    7. fully_shard(model)

    2. Forward Scheduling: Gather by Layer, Release After Use

    The forward pass triggers All-Gather before computation of each layer and releases parameters not owned by the current GPU after computation. In this way, the memory peak is determined by the parameters of a single layer rather than the parameters of the entire model.

    Frameworks often prefetch the next layer’s parameters on the communication stream while computing the current layer. Prefetching allows communication and computation to overlap, but it consumes additional temporary memory.

    FSDP2 also provides the reshard_after_forward option to trade off memory and communication. Keeping full parameters after the forward pass can avoid one All-Gather during backward, at the cost of using more memory. When memory is tight, keep the default release strategy. When communication pressure is high and memory has headroom, consider retaining parameters.

    3. Backward Synchronization: Trigger Reduce-Scatter After Each Layer’s Gradients Are Computed

    Backpropagation is the most communication-intensive stage. After each layer’s gradients are computed, Reduce-Scatter is triggered. FSDP2 registers backward synchronization for each sharding unit.