Trillion-Parameter Multimodal Training on Domestic GPUs: A Complete Native FSDP2 Adaptation Walkthrough

    This article offers a complete walkthrough of adapting a 2.8-trillion-parameter flagship multimodal model for training on domestically developed GPUs through a native FSDP2 (second-generation Fully Sharded Data Parallel) pipeline. It explains the memory, communication, and stability pressures of trillion-scale training and the added complexity of multimodal architectures, then shows why a native path avoids the hidden costs of extra compatibility layers. It breaks the training pipeline into four key steps—model loading, sharding scheduling, gradient synchronization, and optimizer/checkpointing—and covers expert parallelism, hybrid-parallel placement, and multimodal load balancing. It closes with a layered validation approach, a troubleshooting checklist, and engineering best practices that help developers reuse the same path on their own models and hardware.

    I. Introduction: Why Trillion-Parameter Multimodal Training Needs Dedicated Adaptation

    Recently, a domestic AI company open-sourced a flagship multimodal model with 2.8 trillion parameters. Shortly after, a domestic GPU vendor completed the training adaptation of this model using its flagship unified training-and-inference accelerator card and an in-house GPU software stack. This adaptation established a native FSDP2 (second-generation Fully Sharded Data Parallel) multimodal training path, connecting the complete training pipeline from model loading and sharding scheduling to gradient synchronization.

    The value of this kind of adaptation goes well beyond simply “getting the model to run on domestic cards”:

    • Training as validation. Training is the most demanding scenario for memory usage, operator coverage, and numerical precision. Only when a model can run forward and backward passes stably in training mode and update correctly can we say its software and hardware stack is capable of supporting trillion-scale models.
    • A reusable path for developers. The core deliverable of this effort is a general-purpose native FSDP2 path, not tied to any specific model structure. Similar trillion-parameter models—whether text-only or multimodal—can migrate to domestic GPUs along this same path.

    1. Three pressures introduced by trillion-parameter scale

    Memory pressure. Taking the Adam optimizer as an example, the parameters, gradients, and optimizer states (first and second moments) together amount to roughly a dozen times the byte size of the parameters under a typical mixed-precision configuration. Adding activations, communication buffers, and temporary workspaces, the training memory requirement for a trillion-parameter model reaches the tens-of-terabytes range—far beyond what a single card or even a single node can hold.

    Communication pressure. Under data parallelism, every training step must gather parameters and reduce gradients for each layer. The finer the distributed strategy and the more sharding units, the more frequent the communication. Once communication cannot overlap with computation, precious compute is spent waiting.

    Stability pressure. The larger the model, the greater the impact of device failures, node jitter, and training divergence on progress. A single restart without checkpoint support can mean days of compute lost.

    2. Added complexity from multimodal structures

    • Heterogeneous structure. A typical multimodal model consists of a vision encoder, projection layers, a language model backbone, and encoding modules for modalities such as text and audio. These parts differ markedly in parameter density, operator types, and compute/memory access patterns.
    • Uneven length distribution. The number of image, audio, and text tokens spans a wide range, and sequence lengths vary significantly within the same batch.
    • Compounding complexity. If the backbone uses a Mixture-of-Experts (MoE) architecture, expert parallelism adds dynamic routing and all-to-all communication on top, further amplifying load imbalance.

    3. The basic logic of domestic GPU adaptation

    Adapting to domestic GPUs is essentially a bottom-up capability alignment. Upper-layer training scripts do not need to concern themselves with hardware details; the real challenges concentrate in the two lower layers:

    Layer Main content Adaptation focus
    Application layer Training scripts, data pipeline, checkpointing strategy Aligns with framework-native capabilities; no hardware-specific code
    Parallelism layer Data / tensor / pipeline / expert parallelism Consistent device mesh and communication primitive semantics
    Framework operator layer Matmul, normalization, attention, collective communication Operator coverage, numerical precision, communication-computation overlap
    Hardware runtime layer Compute cores, high-bandwidth memory, inter-GPU interconnect, device drivers Compute, memory capacity, and interconnect bandwidth set the upper bound of any parallel strategy

    II. Overall approach: Let the native path do more

    Much domestic hardware adaptation work tends to introduce an extra adaptation layer. For example, mapping existing collective communication calls onto a domestic communication library through a compatibility interface. This approach starts fast but tends to leave hidden risks in several areas:

    • Feature gaps, such as certain new parallel primitives not yet covered;
    • Performance loss, such as extra copies or synchronization points;
    • Semantic deviations, such as handling of non-contiguous tensors or mixed precision not matching expectations.

    This adaptation chose a “native FSDP2” path, which has two implications:

    1. Domestic GPUs are fully incorporated into FSDP2’s own device backend, with parameter sharding, communication, and memory management all executed by native FSDP2 logic;
    2. The in-house GPU software stack natively provides the key capabilities FSDP2 requires—communication primitives, tensor sharding descriptions, and mixed-precision policies—without depending on an external compatibility layer.

    This brings three benefits:

    • Removing one layer of intermediate conversion reduces hidden overhead;
    • Clear problem-localization boundaries, with framework behavior having explicit, checkable semantics;
    • Training scripts can stay consistent with the general ecosystem, with no “custom retrofit” of the model structure needed for a particular card.

    III. Key steps: How native FSDP2 connects the training pipeline

    3.1 Core mechanisms of native FSDP2

    FSDP2 underwent substantial rework on top of the previous generation of Fully Sharded Data Parallel. Its key change can be summarized as “parameter-centric”:

    Dimension Previous-generation FSDP Native FSDP2
    Sharding granularity Concatenates a group of parameters into a flat parameter and shards it as a whole Shards parameter by parameter, each expressed as a distributed tensor (DTensor) carrying sharding placement information
    Parallelism composition Complex to combine with tensor parallelism DTensor naturally composes multiple sharding schemes, making it easy to mix with tensor parallelism
    Parameter access Restores the whole group to full parameters during forward Automatically triggers collective communication when accessing non-local parameters; clear logic
    Checkpointing Must first gather full parameters to a single GPU; single-GPU memory bottleneck Sharded state dicts can be saved and loaded directly; each GPU reads and writes its own
    Wrapping mode Automatic wrapping Manual sharding of specified modules; sharding boundaries are controllable

    For multimodal models built from Transformer blocks plus a vision encoder and multiple modality branches, “controllable sharding boundaries” are especially important: developers can choose different sharding and mixed-precision strategies for different modules.

    The illustrative code below is only to explain the principle; refer to your framework version for exact interfaces:

    1. import torch
    2. import torch.distributed as dist
    3. from torch.distributed.device_mesh import init_device_mesh
    4. from torch.distributed.fsdp import MixedPrecisionPolicy, fully_shard
    5. # 1. Initialize the process group and build a 1D data-parallel device mesh
    6. dist.init_process_group(backend="your_backend") # use the communication backend that matches the current GPU platform
    7. rank = dist.get_rank()
    8. world = dist.get_world_size()
    9. mesh = init_device_mesh("cuda", (world,), mesh_dim_names=("dp",))
    10. # 2. Define the mixed-precision policy: bf16 compute, fp32 reduce, balancing throughput and numerical stability
    11. mp_policy = MixedPrecisionPolicy(
    12. param_dtype=torch.bfloat16,
    13. reduce_dtype=torch.float32,
    14. )
    15. # 3. Shard layer by layer: split the language model backbone into blocks and wrap each one
    16. blocks = build_language_backbone_blocks(model) # extract Transformer blocks according to the model structure
    17. for i, block in enumerate(blocks):
    18. # reshard_after_forward:
    19. # release full parameters right after forward -> saves memory, but backward needs another all-gather
    20. # keep full parameters after forward -> no repeated communication in backward, but higher memory use
    21. # recommended: enable when memory is tight; disable when memory is ample but communication bandwidth is limited
    22. reshard = i >= 1
    23. fully_shard(block, mesh=mesh, mp_policy=mp_policy, reshard_after_forward=reshard)
    24. # 4. Shard the vision encoder the same way
    25. for i, vision_block in enumerate(build_vision_blocks(model)):
    26. fully_shard(vision_block, mesh=mesh, mp_policy=mp_policy, reshard_after_forward=True)
    27. # 5. Shard the model root last so the outermost parameters are also included
    28. fully_shard(model, mesh=mesh, mp_policy=mp_policy)
    29. # 6. In manual wrapping mode, parameter initialization must be synchronized across all ranks before sharding
    30. for module in model.modules():
    31. if hasattr(module, "reset_parameters") and getattr(module, "is_sharded", False):
    32. module.reset_parameters() # prevent ranks from initializing differently and diverging
    33. dist.barrier()
    34. # 7. Load the sharded checkpoint: each rank reads only the shard it is responsible for
    35. state = {"model": model.state_dict()} # by default returns a sharded state in DTensor form
    36. ckpt_path = f"/ckpt/step_10000/model_state_rank{rank}.pt"
    37. state.update(torch.load(ckpt_path, map_location="cpu", weights_only=True))
    38. model.load_state_dict(state)

    This code reflects a three-layer design:

    • Device-agnostic: sharding, communication, and mixed precision are all executed natively by FSDP2, so the GPU platform only needs to provide a correct communication backend;
    • Fine-grained control: each Transformer block and each vision block can independently decide whether to reshard after the forward pass;
    • Memory-friendly: saving and loading are done on the sharded state dict, so full weights no longer need to be moved onto a single GPU.

    3.2 Step 1 — Model loading: avoiding the “single-GPU memory wall”

    In the previous generation, a checkpoint was typically read into memory in full by a single process and then distributed to each rank. Take 2.8 trillion parameters as an example: the parameter bytes alone reach tens of terabytes. Storing weights in bf16 would require about 5.6 TB (2.8×10¹² × 2 bytes). No single node’s memory can handle this, so native FSDP2 adopts sharded saving and sharded loading:

    • Each rank reads only its own shard file, sharply lowering peak GPU memory and host memory usage;
    • When converting from a single-GPU aggregated format, prefer a format that supports lazy loading to avoid expanding the full weights at once;
    • Also pay attention to weight-name mapping, conversion of tensor-parallel sharding schemes, and the integrity of non-model assets such as the tokenizer.

    3.3 Step 2 — Sharding scheduling: hiding communication inside computation

    Under data parallelism, the execution of each Transformer block can be abstracted as a loop of “all-gather parameters → compute → reshard”. Training efficiency depends mainly on three things:

    • Prefetch depth: while the current block computes, launch the all-gather for the next block’s parameters ahead of time so communication overlaps with computation;
    • Whether to reshard after forward: directly affects peak memory and repeated communication during the backward pass;
    • Communication volume distribution: if sharding units are too large, each communication takes long and is hard to fully hide behind computation; if too fine, launch overhead and synchronization counts increase.

    On a GPU platform, the key is not adding new features but making collective operations such as all-gather and reduce-scatter truly execute asynchronously and concurrently with matrix computation, while maintaining a stable overlap rate across different topologies (multiple cards on one node, multiple nodes across machines).

    3.4 Step 3 — Gradient synchronization: reduce-scatter in the backward pass

    During the backward pass, each sharded unit computes its gradients in turn and performs reduce-scatter, so each GPU ultimately holds only the portion of gradients it is responsible for. The optimizer states are then updated by the same sharding rules. This is where problems most often arise:

    • Reduction precision. Accumulating massive gradients in bf16 easily loses precision, so use fp32 for reduction;
    • Distributed consistency of gradient clipping. The global gradient norm must be computed across all ranks, including ranks in expert-parallel and other dimensions. If the aggregation scope is incomplete, the clipping threshold becomes distorted;
    • In-place operations and autograd. Some operators write into the gradient buffer in place; if their semantics are inconsistent on domestic cards, this shows up as missing gradients or numerical anomalies.

    3.5 Step 4 — Optimizer and checkpointing: the safety net for long, stable training

    • Optimizer state sharding: first and second moments are also saved sharded by parameter, so memory usage is inversely proportional to the data-parallel scale;
    • Periodic sharded checkpoints: each rank saves only its own portion, and save time shortens as the parallel scale grows;
    • Complete resume state: beyond the model and optimizer, you must also save the learning-rate scheduler state, RNG state, data-loading progress, and training step count;
    • Checkpoint verification: the loss curve after resuming should match uninterrupted training—an important criterion for validating adaptation quality.

    IV. Advanced challenges: Expert parallelism and multimodal load balancing

    4.1 Expert parallelism: communication and load challenges from dynamic routing

    The MoE layer uses a gating network to select a few experts for each token. When experts are spread across different GPUs, two rounds of all-to-all communication are required: first send tokens to the GPU holding the corresponding expert, then gather them back after computation. This raises three issues:

    • Load skew. The GPU hosting a popular expert handles too many tokens, slowing down the entire training step;
    • The cost of fixed-capacity strategies. Once a capacity limit is set per expert, the excess is dropped or bypassed. Too small a capacity hurts model quality, while too large wastes compute;
    • All-to-all efficiency. Irregular data exchange places higher demands on the communication library and must overlap well with computation.

    Common countermeasures include a load-balancing auxiliary loss, reasonable capacity factors, and validating all-to-all stability across different data distributions on the domestic GPU communication library.

    4.2 Hybrid parallelism: partitioning the device mesh by hardware topology

    Trillion-parameter models usually combine multiple parallelism strategies at once. Common dimension combinations are as follows:

    Parallelism dimension What it partitions Typical placement principle
    Data parallelism (incl. FSDP) Splits by sample; parameters stored as shards Scales across nodes
    Tensor parallelism Single-layer weight matrices Placed within the high-speed inter-GPU domain whenever possible
    Expert parallelism Different experts Depends on routing scope; often overlaps with data parallelism
    Pipeline parallelism Different layers Across nodes, combined with micro-batch scheduling
    Sequence / context parallelism Long-sequence dimension Handles very long text and multimodal tokens

    In the native FSDP2 path, tensor parallelism is expressed via distributed tensors and combines naturally with FSDP sharding, so multi-dimensional partitioning needs no separate retrofit for domestic cards. The core of the placement principle is: keep the most communication-intensive dimensions within the highest-interconnect-bandwidth range whenever possible.

    4.3 Multimodal load balancing: keeping every GPU busy

    The efficiency bottleneck of multimodal training often lies not in compute but in uneven load:

    • Length imbalance. Some GPUs handle long video samples while others handle short text, creating bubbles in computation and communication;
    • Modality imbalance. The compute volume of different modality branches differs significantly;
    • Encoder heterogeneity. The vision encoder’s parallelism differs from the language backbone, and different ranks hold different parameter counts.

    Three common approaches in practice:

    • Bucket and batch by sequence length, combined with sample packing, to reduce padding waste;
    • Configure sharding strategies separately for the vision encoder;
    • Monitor per-rank step time and communication volume to locate slow nodes and load skew.

    V. Adaptation validation: from a single GPU to the full pipeline

    Acceptance of a hardware-software co-adapted solution should proceed in layers, with clear pass criteria at each layer:

    Validation level What to validate Pass criteria
    Operator level Numerics of operators such as matmul, normalization, and attention Error stays within the allowed range vs. the reference implementation
    Model level Forward output and backward gradients Compared against reference hardware results; deviation within the acceptable range for mixed precision
    Small-scale convergence Training for hundreds to thousands of steps Loss curve trend matches the reference implementation
    Full-scale stability The complete training pipeline No gradient anomalies, checkpoints recoverable, continuous loss after resuming

    A special note: because hardware differs, collective communication reduction orders differ, and low-precision formats like bf16 carry inherent error, the per-step loss across platforms cannot be bit-for-bit aligned. A reasonable goal for adaptation acceptance is that trends and convergence behavior stay consistent within an acceptable deviation range.

    VI. Typical problems and a troubleshooting checklist

    Symptom Possible cause Investigation direction
    Abnormal model output after loading Inconsistent parameter initialization after manual sharding Synchronize initialization before sharding or load official weights
    Excessively high memory peak No resharding after forward, or too many activations retained Enable block recomputation and adjust the resharding strategy
    Throughput far below expectation Communication not overlapping with computation, or collectives taking an inefficient path Check the communication backend configuration and overlap capability
    NaN or spikes in loss Insufficient reduction precision, or global norm computed over an incomplete set of ranks Use fp32 for gradient reduction; verify the norm aggregation scope
    Large throughput fluctuation in expert layers Skewed routing load; hot experts slow down the whole step Add a load-balancing loss; monitor per-expert token counts
    Loss jumps after resuming Scheduler, RNG state, or data progress not restored Complete the checkpoint contents; run interrupt-resume consistency tests
    Some nodes slow down Node throttling, interconnect anomalies, or data-loading bottlenecks Compare per-rank step time; check hardware and storage metrics

    VII. Engineering practice recommendations

    1. Pin the software stack version. Containerize the driver, GPU runtime, collective communication library, and training framework together to avoid version drift across nodes.
    2. Prepare the data pipeline ahead of time. Decoding, resizing, and packing multimodal data is costly; use enough loader processes and cache preprocessed results.
    3. Save checkpoints in layers. Name shard files by dimension such as data parallelism and expert parallelism, and periodically verify recoverability.
    4. Build observability. Collect per-rank memory, utilization, communication volume, and step time, and use a unified logging service with monitoring and alerts to spot slow nodes and anomalous trends. Training artifacts and checkpoints can be stored in persistent storage such as object storage and coordinated with a container platform for job orchestration and elastic scheduling.
    5. Build reusable adaptation capabilities. The experience above can be distilled into a methodology for training adaptation on domestic hardware. Baidu’s PaddlePaddle, for example—a deep learning framework independently developed in China—also offers distributed capabilities such as data parallelism, tensor parallelism, pipeline parallelism, and grouped sharding (Sharding), giving developers multiple levels of choice for adapting to domestic hardware.

    Conclusion

    The training adaptation of this trillion-parameter multimodal model on domestic GPUs truly connects more than just one model’s training pipeline—it establishes a reusable native FSDP2 path: sharded model loading, sharding scheduling that overlaps with communication, numerically safe gradient synchronization, and controllable expert parallelism and multimodal load. For developers, the next step is to reuse this path on their own models and data, and to validate it item by item against the layered validation checklist. In the end, the maturity of hardware-software co-design should be measured by the “effective compute” of long-running, stable training at the thousand- and ten-thousand-GPU scale.