Ultra-Large Multimodal Model Training on Heterogeneous Compute: A Native FSDP Practice

    This article examines the engineering challenges of training a 2.8-trillion-parameter multimodal model on heterogeneous AI compute clusters. It covers memory-wall constraints, multimodal communication bottlenecks, and hardware-software coordination, then describes a native FSDP training path built on a general-purpose heterogeneous software stack, including model loading with Meta Tensors, dynamic sharding, gradient synchronization, communication-compute overlap, and cloud-native infrastructure support.

    As AI technology evolves rapidly, large models have entered the “trillion-parameter” era. The industry has recently open-sourced a flagship multimodal model with 2.8 trillion parameters, marking a new level of multimodal understanding capability. However, such a massive parameter scale places severe demands on the underlying AI compute hardware and software stack. How to run the training pipeline efficiently on heterogeneous compute clusters has become a core engineering problem for vendors and developers alike. This article abstracts away specific brands and products and discusses technical approaches and practices for adapting ultra-large multimodal model training to general-purpose AI compute cards and heterogeneous software stacks.

    1. Core Challenges in Ultra-Large Multimodal Model Training

    Training a model at the 2.8-trillion-parameter scale typically involves three major pain points:

    1. Memory-wall limits
      The memory required for model parameters, gradients, and optimizer states is extremely large. Taking FP16/BF16 mixed-precision training as an example, the parameters alone require about 5.6 TB of memory. Adding AdamW optimizer states (momentum and variance) and gradients, total memory demand can easily exceed 22 TB. This far exceeds the physical memory limit of a single eight-GPU machine or even a multi-machine cluster, so efficient sharding strategies are mandatory.

    2. Communication bottlenecks in multimodal data
      A multimodal model contains not only massive language model parameters but also vision encoders, feature alignment networks, and other components. Tensor shapes differ greatly across modalities, so traditional data parallelism in distributed training can trigger frequent and irregular cross-node communication, easily causing network congestion.

    3. Complexity of heterogeneous hardware-software coordination
      Flagship training-and-inference integrated AI compute cards from different vendors have their own architectural characteristics. If the software stack lacks native support for mainstream distributed frameworks, developers often need to make deep modifications to low-level operators, resulting in a huge workload and making training stability difficult to guarantee.

    2. Building a Native FSDP Training Path on a General Software Stack

    To overcome these challenges, a best practice is to build a native FSDP (Fully Sharded Data Parallel) training path on top of a general-purpose heterogeneous software stack. Compared with traditional DDP (Distributed Data Parallel), FSDP shards model parameters, gradients, and optimizer states, and dynamically gathers them when computation requires them.

    1. Coordinated support from heterogeneous compute and software stacks

    In this adaptation practice, the strong compute capability and high-bandwidth memory of flagship training-and-inference integrated AI compute cards are combined with a general-purpose heterogeneous computing software stack to achieve native compatibility with mainstream deep learning frameworks. The software stack hides differences in low-level hardware instruction sets and provides standardized operator interfaces upward, so the upper-level distributed training framework can directly use compute resources without being aware of hardware details.

    2. Building the multimodal training path

    The special characteristic of multimodal models is the heterogeneity of their network structures. When building a native FSDP path, different model components need to be wrapped carefully:

    • Vision encoder: relatively few parameters but large activations. Use smaller FSDP sharding units to reduce computation wait time.
    • Language decoder: extremely large parameter count and the main memory consumer. Use larger sharding units to reduce communication frequency and improve bandwidth utilization.
    • Modality alignment layer: as the connecting bridge, it must ensure that cross-modal feature tensors are correctly synchronized in the FSDP communication group during forward propagation and backward gradient propagation.

    3. Completing the Full Pipeline from Model Loading to Gradient Synchronization

    A mature training pipeline is not limited to forward and backward computation; it also covers the entire process from cold start to persistence.

    1. Model loading and memory peak control

    Loading a 2.8-trillion-parameter model directly can cause an immediate out-of-memory (OOM) failure. In engineering practice, the “Meta Tensor” technique is commonly used. During initialization, the model builds only its topology in CPU memory and does not allocate actual GPU memory. When the model is wrapped by FSDP and distributed across compute nodes, actual memory is allocated on demand and weights are filled in, effectively shaving peaks and leveling loads.

    2. Dynamic sharding scheduling and memory management

    During training, FSDP uses an all_gather operation before forward computation to collect the full parameters required by the current layer. After computation, it immediately releases the full parameters of non-current layers and keeps only shards. In the gradient synchronization stage, a reduce_scatter operation aggregates gradients from each node and then scatters and stores them as shards. This dynamic scheduling mechanism requires the software stack to provide efficient memory pooling and avoid frequent memory allocation and release that can cause memory fragmentation.

    3. Gradient synchronization and communication-compute overlap

    To hide cross-node communication latency, communication and computation must overlap. During backpropagation, after the gradient of a layer is computed, the backward computation of the next layer starts immediately, while the gradient reduce_scatter communication of the current layer is launched asynchronously. The underlying software stack needs to support efficient calls to communication libraries such as NCCL, ensuring that the throughput of high-bandwidth networks such as RDMA is fully utilized.

    The following is a general pseudo-code example for native FSDP multimodal model training, showing the core wrapping and scheduling logic:

    1. import torch
    2. import torch.distributed as dist
    3. from torch.distributed.fsdp import FullyShardedDataParallel as FSDP
    4. # 1. Initialize distributed environment and process group
    5. dist.init_process_group(backend="nccl")
    6. # 2. Build a 2.8-trillion-parameter multimodal model using Meta device
    7. with torch.device("meta"):
    8. model = GiantMultiModalModel()
    9. # 3. FSDP configuration and model wrapping
    10. # Set different sharding strategies for multimodal characteristics
    11. fsdp_config = {
    12. "sharding_strategy": ShardingStrategy.FULL_SHARD,
    13. "cpu_offload": CPUOffload(offload_params=False),
    14. "backward_prefetch": BackwardPrefetch.BACKWARD_PRE,
    15. }
    16. # Move model to GPU and apply FSDP
    17. model = model.to_empty(device="cuda")
    18. model = FSDP(model, **fsdp_config, device_id=torch.cuda.current_device())
    19. # 4. Standard training loop
    20. optimizer = torch.optim.AdamW(model.parameters(), lr=1e-5)
    21. for epoch in range(epochs):
    22. for batch in dataloader:
    23. # Mixed-precision forward pass
    24. with torch.autocast(device_type="cuda", dtype=torch.bfloat16):
    25. loss = model(batch["image"], batch["text"])
    26. # Backward pass (triggers gradient synchronization internally)
    27. loss.backward()
    28. # Optimizer update
    29. optimizer.step()
    30. optimizer.zero_grad()

    4. Coordinated Enablement from Cloud-Native Infrastructure

    In ultra-large model training, hardware adaptation alone is only the foundation; the overall engineering effort also requires deep coordination with cloud-native infrastructure. For example, on Baidu AI Cloud’s compute foundation, its container platform can be used for rapid elastic scheduling of compute nodes, and its object storage service (BOS) can carry massive multimodal training data and frequent model checkpoint persistence. Baidu AI Cloud’s high-performance file storage and log monitoring services can capture resource utilization and communication throughput metrics from each node in distributed training in real time. When gradient synchronization anomalies or node failures occur in the training pipeline, the operations platform can quickly locate, isolate, and restart the faulty node, ensuring continuity for training jobs that last weeks or even months.

    5. Conclusion

    For a multimodal model at the 2.8-trillion-parameter scale, building a native FSDP training pipeline on flagship heterogeneous AI compute cards and a general software stack is an effective path to break memory bottlenecks and improve training efficiency. Through fine-grained control of model loading, dynamic sharding scheduling, and communication-compute overlap, developers can complete the full loop from low-level hardware to upper-level algorithms. In the future, as the heterogeneous computing ecosystem becomes more prosperous and cloud-native technologies are integrated more deeply, the training cost of ultra-large models will be further reduced, driving general artificial intelligence technology toward broader industry scenarios.