Training Trillion-Parameter Multimodal Models: A Practical Guide to Native Adaptation

    Trillion-parameter multimodal models push distributed training well beyond the point where a compatibility layer is enough. This article uses a recent training-adaptation case as a starting point to unpack the core challenges of large-scale multimodal training and how to address them: the memory wall of holding hundreds of terabytes of model state, the communication cost of collective operations, and the numerical risks introduced by low precision and sparse expert routing. It then lays out a hardware-software co-design methodology and explains a native training path built around Fully Sharded Data Parallel (FSDP), including model loading, shard scheduling, and gradient synchronization, illustrated with sample pseudocode. It also covers memory optimization, hybrid parallelism with expert parallelism, performance tuning, long-run stability, and a troubleshooting checklist for developers working on large-model training and compute platforms.

    Recently, reports emerged that a domestic AI chip vendor completed the training adaptation of an open-source multimodal model at the 2.8-trillion-parameter scale. Using its flagship AI training-and-inference accelerator card and a self-developed software stack, the vendor built a native Fully Sharded Data Parallel (FSDP) training path that connected the full pipeline from model loading and shard scheduling to gradient synchronization.

    An adaptation like this may look like nothing more than “getting it to run,” but behind it is a systematic validation of a trillion-parameter training system. This article uses that practice as a thread to break down the core challenges and practical paths for training ultra-large multimodal models, for developers working on large-model training and compute platform engineering.

    1. Why trillion-parameter multimodal training needs dedicated adaptation

    The traditional approach is to get a model running on a mainstream open-source framework, then have the hardware vendor add a compatibility layer on top so that training “works.” This may be enough for small and medium-scale scenarios, but when facing trillion-parameter multimodal models, the contradictions surface all at once.

    • Highly uneven parameter distribution: The parameter counts of the vision encoder and the language backbone differ enormously. If you conservatively apply uniform recomputation and sharding strategies to every layer, the vision portion ends up over-optimized while the language backbone is left under-provisioned.
    • Irregular multimodal inputs: Image resolutions, image-text ratios, and video frame counts all vary, so sequence lengths fluctuate and tensor shapes are hard to fix statically.
    • Sparse expert structures introduce dynamic load: Mixture-of-Experts (MoE) structures make the compute volume change with routing decisions, which static compilation and static scheduling cannot fully cover.

    A compatibility layer can only solve “can it run,” not “does it run stably and fast.” To approach the training efficiency of mainstream hardware, you must do native adaptation at the operator, communication, and parallelism-strategy levels.

    2. Three challenges: memory, communication, and stability

    2.1 The memory wall: model state alone needs hundreds of terabytes

    Under mixed-precision training, the memory cost of an Adam-class optimizer scales with parameter count as follows:

    • Parameters: ~2 bytes in bf16, plus 4 bytes for the fp32 master weights;
    • Gradients: ~2 bytes in bf16;
    • Optimizer states: 4 bytes each for the first and second moments, totaling 8 bytes.

    That is roughly 16 bytes per parameter. Model state alone therefore needs about 16 TB of memory at the trillion-parameter scale, equivalent to the full capacity of hundreds of high-memory accelerators. Forward activations are equally significant: multi-layer Transformers retain large amounts of intermediate results, and long text and high-resolution images further inflate activation memory.

    2.2 The communication wall: communication volume and topology constraints

    FSDP requires two kinds of collective communication per training step:

    • All-Gather: collecting parameters layer by layer during forward and backward;
    • Reduce-Scatter: reducing gradients and distributing gradient shards during backpropagation.

    As single-card compute keeps rising while interconnect bandwidth grows more slowly, communication tends to become the bottleneck. In addition, clusters use a tiered topology of “high-speed interconnect within a node, network interconnect between nodes,” and cross-node collective communication is significantly more expensive than intra-node communication.

    2.3 Stability: numerical risks under low precision and sparse routing

    • Low-precision compute: bf16 has a large dynamic range but only a 7-bit mantissa, so rounding error can accumulate during long-sequence training;
    • Gradient reduction: low-precision reduction may overflow or lose precision when gradient magnitudes vary widely;
    • Expert routing: load skew overloads some experts while leaving others idle, reducing throughput and destabilizing training;
    • Mixed sharding: when the vision tower and the language tower use different sharding schemes, inconsistent tensor-layout conversion also introduces numerical differences.

    3. Adaptation methodology: from “compatible running” to “native efficiency”

    For the challenges above, the general industry methodology can be summarized as “hardware-software co-design, advancing layer by layer”:

    1. Clear division of labor: the hardware side provides operator libraries, communication libraries, compiler optimizations, and driver toolchains; the framework side handles parallelism strategies, mixed precision, and fault tolerance.
    2. Prefer native implementations: build the training path directly on the self-developed software stack instead of patching layer upon layer onto a third-party framework.
    3. Layered validation: advance step by step from operator-level, to single-card-level, to small-scale-cluster-level, to full-scale-cluster-level, establishing a numerical comparison baseline against a reference implementation at each layer.

    Notably, a training-and-inference integrated design lets training and inference share the same operator libraries and communication components, which can significantly reduce the cost of maintaining two stacks. At the same time, the numerical stability experience gained on the training side can feed back into inference deployment.

    4. The core: a native training path with FSDP as the backbone

    4.1 How FSDP works

    Fully Sharded Data Parallel (FSDP) can be understood as the engineering realization of “zero-redundancy” data parallelism. Its operation works as follows:

    1. Collect on demand: when forward computation reaches a given layer, all data-parallel ranks use All-Gather to temporarily reconstruct the full parameters for that layer.
    2. Release after compute: once that layer finishes computing, the parameter shards not owned by the current rank are released immediately.
    3. Backward reduction: when backpropagation reaches that layer, parameters are gathered again to compute gradients, and Reduce-Scatter then reduces and distributes the gradients to each rank.
    4. Sharded update: the optimizer only updates the parameter shards and corresponding optimizer states it holds locally.

    Compared with traditional data parallelism, the number of parameter copies, gradient copies, and optimizer-state copies all drop from N to roughly 1/N (where N is the data-parallel degree), at the cost of a few extra parameter-collection operations per step.

    The newer generation of implementations (generally called FSDP2) has several key improvements over earlier versions:

    • expressing parameters, gradients, and optimizer states uniformly as sharded tensors;
    • offering a simpler, more composable module-wrapping approach;
    • managing mixed-precision configuration centrally;
    • pairing flexibly with custom device meshes.

    These features make it easier to stack with strategies such as tensor parallelism and context parallelism to form a hybrid parallelism system.

    4.2 Three key points of the native path

    (1) Model loading: reject “load everything, then shard”

    Loading the full weights on a single process and then sharding them can exhaust memory during weight loading alone. The native path determines each rank’s weight-loading manifest based on the target parallelism topology and reads only the tensor slices corresponding to its local shard directly from the checkpoint. This avoids full loading and lets loading time scale horizontally with cluster size.

    (2) Shard scheduling: use the Transformer block as the basic unit

    The basic granularity for sharding is usually the Transformer Block. Combined with a prefetch mechanism where “a layer’s parameters are gathered before the next layer’s forward pass begins,” parameter collection can overlap with the previous layer’s backward computation. Prefetch depth requires a trade-off:

    • Prefetching too early: multiple shards reside in memory at the same time;
    • Prefetching too late: each layer stalls waiting before its computation;
    • Combined with communication bucketing, this further reduces the fixed overhead of a single communication operation.

    (3) Gradient synchronization: low-precision reduction, high-precision accumulation

    • Communication volume: bf16 gradient reduction halves the communication volume compared with fp32;
    • Reduction order: Reduce-Scatter runs in rank order, so the accumulation order is deterministic and results are reproducible;
    • Numerical risk: bf16 accumulation may lose precision over long reduction chains. In practice, this often requires the communication library to promote to higher-precision accumulation before reducing, or to fall back on gradient scaling and periodic high-precision checks;
    • Debugging requirements: collective communication has strict semantics — every rank must participate in the same operation in the same order and with matching shapes. During adaptation, the framework layer must validate the consistency of gradient shard shapes and call order across ranks.

    4.3 Sample code: the core structure of the training loop

    The following pseudocode shows the core structure of an FSDP training path. Interface names are illustrative only:

    1. # Core structure of an FSDP training loop (illustrative, not tied to a specific framework's API)
    2. from distributed import init_process_group, init_device_mesh
    3. # 1. Initialize the distributed environment: the communication backend must match the target hardware's communication library
    4. init_process_group()
    5. # 2. Build the device mesh: the data-parallel dimension is for full sharding, the tensor-parallel dimension is for intra-layer sharding
    6. mesh = init_device_mesh(dim_names=("dp", "tp"))
    7. model = build_multimodal_model(model_cfg) # Vision encoder + language backbone
    8. for block in model.transformer_blocks:
    9. wrap_shard(block, mesh=mesh["dp"]) # Shard at the granularity of Transformer blocks
    10. wrap_shard(model) # Shard the root module
    11. # 3. Mixed precision: bf16 compute, fp32 master weights; activations selectively recomputed per block
    12. model.enable_mixed_precision(compute_dtype="bf16", param_dtype="bf16",
    13. reduce_dtype="bf16", accumulate_dtype="fp32")
    14. model.enable_activation_checkpointing(per_block=True)
    15. # 4. Build a shard-aware optimizer
    16. optimizer = build_sharded_optimizer(model)
    17. # 5. Training loop
    18. for step, batch in enumerate(data_loader, start=resume_step):
    19. with model.no_sync() if accumulation_step else null_context():
    20. loss = compute_loss(model(batch), batch.labels)
    21. loss.backward() # Triggers parameter All-Gather and gradient Reduce-Scatter during backprop
    22. optimizer.step()
    23. optimizer.zero_grad()
    24. if step % checkpoint_interval == 0:
    25. save_distributed_checkpoint(model, optimizer, step) # Each rank saves its local shard

    5. Memory optimization: fitting more useful compute into limited memory

    FSDP alone can still not hold a trillion parameters, so multiple memory-optimization techniques need to be combined.

    5.1 Activation recomputation: from “store everything, compute everything” to “selective recomputation”

    • Full recomputation: only each layer’s input is stored, and the forward pass is re-executed during backprop — trading memory for compute;
    • Selective recomputation: for a Transformer, the attention portion’s activation cost grows with the square of the sequence length, while parts such as the MLP are cheap to recompute. In practice, typically only attention is recomputed while the remaining activations are kept as-is, achieving a good balance between memory and speed;
    • Separate configuration for the vision tower: the vision encoder has relatively few parameters, but high-resolution inputs produce large numbers of patch tokens. Its sharding and recomputation strategies can be configured separately to avoid waste from a one-size-fits-all approach.

    5.2 Gradient accumulation and micro-batches

    When the global batch size is fixed, you can reduce the per-card micro-batch and increase the number of gradient-accumulation steps to lower the instantaneous activation peak. Note two points:

    • During gradient accumulation, the sharded parameters are re-gathered on the backward pass of each micro-batch, so communication volume grows linearly with the number of accumulation steps;
    • If you use the optimization of “skipping gradient reduction during accumulation,” make sure the last micro-batch correctly triggers the reduction.

    5.3 Offloading optimizer states and tiered storage

    When memory is still tight, the optimizer-state update step can be offloaded to host memory, letting the CPU perform the parameter update. This is a typical compute-for-memory trade across memory tiers; the cost is increased data transfer between CPU and GPU, so the benefit should be evaluated against iteration time.

    5.4 Dynamic-shape management

    Multimodal input lengths vary widely, and fixed-length padding wastes a lot of ineffective compute. Bucketing by length and balancing sample lengths in scheduling can reduce the padding ratio and keep the proportion of tokens actually involved in computation as high as possible.

    6. Hybrid parallelism: coordinated design with expert parallelism

    When the data-parallel degree is insufficient to distribute model state, you need to stack other parallelism dimensions on top of full sharding. Common choices are:

    Strategy Sharding target Main communication Typical use case
    Tensor parallelism Weight matrices within a single operator All-Reduce / All-Gather Layers with large per-layer parameter counts, high intra-node interconnect bandwidth
    Expert parallelism Individual experts in expert layers All-to-All Large-scale sparse MoE models
    Context parallelism The sequence dimension Distributed attention communication Long text, high-resolution multimodal inputs
    Pipeline parallelism Model stages divided by layer Point-to-point send/receive Many layers, need for cross-node sharding

    A special note on combining FSDP with expert parallelism:

    • Double-sharding of expert weights: if experts are first distributed by expert parallelism and then wrapped as a whole in full sharding, the expert parameters are sharded twice;
    • Repeated token collection: after each token is routed into its Top-K experts, it is processed K times in a single forward pass. If the expert parameters are fully gathered for every expert computation, communication volume is amplified K-fold;
    • Trade-offs: in practice, experts are often kept as replicas within a node and participate in computation via replication, while the non-expert portions use full sharding. This trades more memory for less communication.

    Whatever combination you use, two principles should be followed:

    • Bandwidth affinity: keep communication-intensive dimensions inside a node as much as possible — for example, constrain tensor parallelism and expert parallelism to a single node, and let cross-node links carry dimensions with less communication;
    • Compute-communication overlap: overlap computation and communication as much as possible to reduce pipeline bubbles and communication waits.

    7. Performance tuning: finding the real bottleneck

    7.1 Establish baseline metrics

    • Tokens per second per GPU (Tokens/s/GPU): the most direct throughput metric;
    • Model FLOPs Utilization (MFU): the actual effective compute divided by the hardware’s theoretical peak compute, reflecting the combined impact of parallel efficiency, communication overhead, and recomputation overhead;
    • Communication ratio and pipeline bubble rate: obtained from the timeline views of performance-analysis tools.

    It is recommended to fix the three factors — “model size, parallel configuration, input distribution” — before comparing, to avoid distorted conclusions.

    7.2 Layer-by-layer analysis of time cost

    1. Operator level: focus on operators that are low in share but high in time cost, such as padding waste in variable-length attention;
    2. Compute level: compare single-card compute time with overall iteration time; a large gap indicates waiting;
    3. Communication level: examine the wait time and bandwidth utilization of All-Gather and Reduce-Scatter;
    4. Data level: check whether data loading is a bottleneck, such as excessive time spent decoding high-resolution images.

    7.3 Common optimization techniques

    • Compute graph optimization: operator fusion, memory reuse, and making dynamic control flow static;
    • Communication optimization: set bucketing sizes reasonably to avoid frequent small messages, and align communication scheduling with the topology;
    • Compiler optimization: compile shape-stable parts such as the vision encoder ahead of time to reduce runtime scheduling overhead.

    8. Stability assurance: the unavoidable issue in long training runs

    A single training run of a trillion-parameter model often lasts weeks or even months, so stability matters just as much as throughput.

    • Checkpoint and resume: distributed checkpoints save each rank’s local shard, avoiding the memory and I/O pressure of aggregating to a single node; on resume, the random-number state, data-sampling position, and optimizer step must be synchronized, or the loss will be discontinuous;
    • Fault localization: use communication timeout detection and key-tensor statistics (gradient norms, activation mean and variance) to quickly determine whether an issue is a data problem, a hardware problem, or a numerical problem;
    • Elastic fault tolerance: on node failure, the ideal behavior is to automatically isolate the faulty node, reconstruct the training topology, and resume from the latest checkpoint rather than aborting the entire run;
    • Numerical consistency validation: after adaptation, use a small-scale model to compare the loss curves step by step between the domestic accelerator and mainstream hardware, and scale up only after confirming the deviation is within an acceptable range.

    9. Troubleshooting checklist

    Symptom Common cause Investigation direction
    Out-of-memory during the loading phase Loading full weights on a single process before sharding Load shards directed by the parallelism topology and set a memory limit for the loading phase
    Iteration time far higher than expected Communication not overlapped, improper prefetch depth Timeline analysis, adjust prefetch and bucketing strategies
    Loss becomes NaN Low-precision reduction overflow, learning rate too high, expert routing imbalance Raise the gradient-reduction accumulation precision, lower the learning rate, add routing-balance constraints
    Loss jumps after resume Random-number state or data-sampling position not restored Check checkpoint metadata completeness and data loader state
    Training process hangs Inconsistent collective-communication call order or mismatched shapes Inspect distributed calls within conditional branches and shape-validation logs

    10. Conclusion

    Training adaptation for trillion-parameter multimodal models is fundamentally a collaborative engineering effort across compute hardware, the communication system, and distributed training frameworks. With FSDP as the backbone, complemented by native implementations of model loading, shard scheduling, and gradient synchronization, and stacked with memory optimization and hybrid parallelism, you can move from “getting the model to run” to “training that runs stably and fast.”

    For teams building AI compute platforms, the methodology behind the work is even more worth noting: a native path is better than layer upon layer of patches, layered validation is better than a full-scale launch, and stability matters just as much as throughput. As the domestic hardware and software ecosystem continues to mature, this kind of adaptation work will gradually move from a “one-off breakthrough” toward a “standardized process.”