Training Trillion-Parameter Multimodal Models on Domestic AI Accelerators: A Practical Adaptation Guide

    This article explains how to adapt trillion-parameter multimodal model training to domestic AI accelerators. It begins with the memory overheads that make training at this scale feasible only through distribution, then shows how FSDP2's sharded data parallelism reduces memory use from being proportional to the full model to being proportional to the model divided by the card count. It then breaks the adaptation work into four stages: model loading and initialization, parameter sharding and scheduling, gradient synchronization and communication optimization, and mixed precision and memory optimization. It also covers the added complexity of multimodal training and the engineering priorities on domestic accelerators, including operator coverage, collective communication, numerical consistency validation, and performance profiling. It closes with five practical recommendations, from getting the pipeline running before optimizing to combining sharded data parallelism with other parallel strategies.

    1. Background: The Training Engineering Challenges of the Trillion-Parameter Era

    When flagship large models grow from tens of billions to trillions of parameters, the core difficulty of training engineering does not come simply from “more parameters.” Instead, the tight coupling among memory, communication, and compute is amplified all at once.

    Consider a trillion-parameter model. Even storing the parameters alone in FP16/BF16 requires roughly 2 TB of memory. Training, however, needs far more than parameter storage. The total memory overhead consists of at least three parts:

    • Model states: parameters, gradients, and the first and second moment estimates stored by optimizers such as Adam. Under mixed-precision training, optimizer states often take up the largest share.
    • Activations: the intermediate activations produced during the forward pass. Their size depends on batch size, sequence length, and the number of model layers.
    • Temporary buffers: communication send/receive buffers, operator workspaces, and the extra overhead caused by memory fragmentation.

    No single accelerator can hold the full model state of a model at this scale. The first priority of training adaptation is therefore to split the model state sensibly across hundreds or even thousands of cards. At the same time, communication overhead must stay manageable and compute utilization should be as high as possible. Solving this is the core task of distributed parallel strategies.

    2. From Data Parallelism to Sharded Data Parallelism: The Core Idea of FSDP2

    The bottleneck of traditional data parallelism

    The simplest distributed approach is data parallelism (DDP). Each card keeps a full copy of the model and processes a different batch of data. Gradients are then kept consistent across cards through gradient AllReduce. This approach is easy to implement, but it has a fatal flaw: every card must hold the full set of parameters, gradients, and optimizer states. For a trillion-parameter model, this is simply impossible in terms of memory.

    The sharded data parallelism approach

    Sharded Data Parallel (SDP) breaks the assumption that each card holds a full model replica. Instead, it splits parameters, gradients, and optimizer states along the data parallel dimension, so each card holds only one shard of the model state. This approach follows the same line of thinking as ZeRO-3-style optimizations, which are widely discussed in the industry: memory consumption drops from scaling with the full model to scaling with the model divided by the number of cards.

    FSDP2 (the second generation of Fully Sharded Data Parallel) builds on this idea. It is centered on a finer-grained, per-parameter sharding model and the distributed tensor (DTensor) abstraction, and it has three key characteristics:

    • Unit-wise sharding: each individual parameter (or parameter group) is the sharding unit, rather than a coarse module-level unit. This makes sharding more flexible and easier to combine with other parallel strategies, such as tensor parallelism and pipeline parallelism.
    • All-gather on demand: when a forward or backward pass needs the full parameters, the shards are temporarily assembled into complete parameters via AllGather and released immediately after use. This keeps memory consumption as low as possible.
    • Better composability: sharding logic is decoupled from the model structure, which makes it easier to build complex multi-dimensional parallel schemes.

    The following pseudocode outlines the skeleton of one training step:

    1. # Pseudocode: illustrates the structure of an FSDP-style training loop,
    2. # not a specific product API
    3. for micro_batch in data_loader:
    4. # Forward pass: FSDP automatically AllGathers parameter shards when needed
    5. # and releases them right after use
    6. loss = model(micro_batch)
    7. # Backward pass: gradients are reduced via ReduceScatter, and each card
    8. # keeps only the gradient shard it is responsible for
    9. loss.backward()
    10. optimizer.step() # The optimizer updates only the local parameter shards
    11. optimizer.zero_grad()

    3. Breaking Down the Full Training Adaptation Pipeline

    What really determines the success or failure of an adaptation is whether these parallel ideas can be implemented in a training pipeline that runs stably and meets performance targets. The full pipeline can be broken down into four interconnected stages.

    3.1 Model loading and initialization

    A trillion-parameter model cannot be loaded into memory all at once, so the pipeline needs sharded loading. Checkpoint files are sliced along tensor dimensions and read directly into the target shard positions on each card. This avoids the memory spikes caused by “load everything first, then split.”

    During initialization, each card’s shard metadata must stay consistent. This includes shapes, dtypes, and shard mappings. Random seeds also need to be aligned across the different parallel dimensions to prevent misaligned initialization.

    3.2 Parameter sharding and scheduling

    Sharding scheduling determines when to all-gather parameters and when to release them. The key is to balance memory consumption against communication frequency:

    • Too coarse (all-gather at the whole-layer level): leads to high memory peaks.
    • Too fine (all-gather at the per-parameter level): causes communication calls to spike and puts heavy pressure on bandwidth.

    In practice, shard units are usually aligned with activation recomputation boundaries. Teams also use communication and computation overlap. While the current layer is being computed, shards for the next layer are prefetched asynchronously in the background. This hides AllGather communication time behind computation and maximizes compute utilization.

    3.3 Gradient synchronization and communication optimization

    During backpropagation, gradients are reduced through ReduceScatter in sharded form. Each card then keeps and updates only the parameters it is responsible for. The main optimization areas are:

    • Communication primitive selection: AllGather and ReduceScatter are the primary communication primitives in sharded scenarios. The underlying collective communication library must implement both efficiently.
    • Communication bucket tuning: setting bucket sizes appropriately helps reduce the latency introduced by small messages. Buckets that are too large, however, increase memory peaks.
    • Gradient accumulation: gradient accumulation reduces the frequency of synchronization while keeping the effective batch size large, which spreads the communication cost across more data.

    3.4 Mixed precision and memory optimization

    Combining BF16/FP16 mixed precision, activation checkpointing, and optimizer state offloading can further reduce peak memory. Activation checkpointing “trades compute for memory”: instead of storing all forward activations, it recomputes them during the backward pass. It is a standard technique for ultra-large-scale training.

    Combining activation checkpointing with sharding requires care. Recomputation boundaries must be coordinated with sharding boundaries to avoid redundant all-gathers and the extra communication they cause.

    4. Additional Engineering Considerations for Multimodal Training

    Compared with pure text models, multimodal training introduces additional engineering complexity:

    • Heterogeneous encoders: modalities such as vision and language are often built from sub-networks with very different structures, so their parameter distributions are uneven. The sharding strategy needs to be tuned separately for each sub-module. Otherwise, the workload can become skewed across cards.
    • Variable-length inputs: in image-text alignment tasks, sequence lengths vary widely. Padding and masking within a batch can have a significant impact on compute utilization, so batching requires more careful organization.
    • Cross-modal attention: cross-modal fusion layers have compute and communication patterns that differ from self-attention. They need additional adaptation in both operator coverage and communication scheduling.

    These characteristics mean that multimodal adaptation cannot simply copy the parallel configuration of pure language models. It must be tuned to the data distribution and operator characteristics of each model.

    5. Key Engineering Priorities for Domestic AI Accelerators

    Adapting a model to domestic AI accelerators means making the parallel logic above work well with the underlying hardware and software stack. The key engineering priorities are:

    • Operator coverage: training pipelines rely on many custom operators, such as various attention, normalization, and activation functions. You need to confirm that the target software stack implements all of the model’s operators completely and with numerical stability. Any missing operators must be filled in through equivalent compositions or custom implementations.
    • Software stack and collective communication: sharded parallelism depends heavily on efficient support for AllGather/ReduceScatter in the underlying collective communication library. It also depends on how well communication and computation overlap is supported.
    • Numerical consistency validation: after adaptation, you must run accuracy alignment tests. Compare the loss curve over several training steps against a reference implementation to confirm there is no precision drift or convergence anomaly.
    • Performance profiling and tuning: use profiling tools to locate communication bottlenecks, operator hotspots, and memory peak points. Then tune sharding granularity, bucket sizes, and overlap strategies item by item to approach the hardware’s peak compute capacity.

    6. Practical Recommendations

    Overall, adapting a trillion-parameter multimodal model for training calls for the following approach:

    1. Get it running before optimizing: first make sure the pipeline is complete and correct at a small scale, then gradually increase the scale and tune performance.
    2. Establish an accuracy baseline: always keep a reproducible accuracy reference. Any optimization must preserve numerical consistency.
    3. Investigate communication first: in ultra-large-scale training, performance bottlenecks are mostly in communication, so communication profiling should be the top tuning priority.
    4. Plan memory by layer: budget memory separately for model states, activations, and buffers. Leave a safety margin for the sharding and recomputation strategies.
    5. Think in terms of composable parallelism: combining sharded data parallelism with strategies such as tensor parallelism and pipeline parallelism as needed is essential for handling the trillion-parameter scale.

    In essence, adapting ultra-large-scale models for training is about finding the best engineering balance under the constraints of memory, communication, and compute. Once you understand the core mechanisms of sharded data parallelism, how to build the full training pipeline, and the key adaptation points for domestic AI accelerators, you can move forward with deploying models at this scale in a systematic way.