Trillion-Parameter Multimodal Training on Domestic Training and Inference Compute: A Native FSDP2 Approach

    This article explains how a domestic compute vendor adapted an open-source trillion-parameter multimodal flagship model for training using training-and-inference integrated AI accelerators and a self-developed software stack, built around a native FSDP2 multimodal training path. It breaks a reusable training pipeline into six layers, then walks through the core engineering concerns: metadata-first model loading with streaming shard placement, shard scheduling and memory budgeting, gradient synchronization and numerical stability, and throughput, long-run stability, and fault tolerance. It closes with a practical deployment checklist for validating sharding plans, tuning shard granularity and prefetch depth, and building observable, reproducible, recoverable training runs.

    1. Background: Why Trillion-Parameter Multimodal Training Is an Engineering Challenge

    Over the past year, the parameter counts of multimodal large models have climbed quickly, with flagship models entering the trillion-parameter range. Once parameter scale crosses a certain threshold, the focus of training engineering shifts from “how to write the model structure” to “how to build the distributed pipeline.” The reason is straightforward: a single accelerator’s memory cannot hold the full parameters, optimizer states, and activations, so sharding and parallelism must spread that state across hundreds or thousands of devices. Multimodal inputs make tensor shapes highly variable, which further amplifies the risk of load imbalance and communication jitter.

    A domestic compute vendor recently completed training adaptation for an open-source trillion-parameter multimodal flagship model. Using training-and-inference integrated AI accelerators and a self-developed software stack, the team built a native FSDP2 multimodal training path that connects the full chain from model loading and shard scheduling to gradient synchronization. The technical value here is not that “it ran once,” but that a reusable engineering path has been established. This article uses that scenario as a thread and abstracts a general methodology from it.

    2. Overall Architecture: What a Complete Training Pipeline Contains

    A reusable trillion-parameter training pipeline can usually be split into six layers:

    1. Storage and data layer: persisting, indexing, and streaming massive image-text samples;
    2. Data preprocessing layer: tokenization, image decoding and resizing, multimodal alignment, and packing;
    3. Model construction layer: parameter initialization, structure partitioning, and precision strategy;
    4. Sharding and parallelism layer: parameter sharding, optimizer state sharding, pipeline and sequence parallelism;
    5. Compute and communication layer: operator implementations, communication primitives, and overlap scheduling;
    6. Fault tolerance and observability layer: checkpoint resume, metrics collection, and anomaly localization.

    The original adaptation chose native FSDP2 as the sharding backbone. In essence, this makes the fourth layer thinner and the fifth layer more thorough: instead of relying on manual partitioning of complex 3D parallelism, it uses unified sharding semantics to describe parameters, gradients, and optimizer states, letting the framework handle scheduling details.

    3. Key Point 1: Model Loading and Initialization

    A trillion-parameter model cannot be read into memory all at once and then sharded; it must be loaded and sharded at the same time. There are two common approaches:

    • Metadata first: construct a shell model on each device (without allocating real storage), and read the configuration and layer structure;
    • Streaming fill: read shard files layer by layer from storage and write them directly into the locally responsible shard regions.

    Illustrative pseudocode:

    1. # 1) Build a shell model that only records structure and shapes
    2. model = build_model_from_config(cfg, meta_only=True)
    3. # 2) Build a sharding plan: each device holds a subset of parameters
    4. shard_plan = build_shard_plan(model, world_size=rank_num)
    5. # 3) Stream weights and place them by shard, avoiding full residency
    6. for layer in model.layers:
    7. tensor = load_shard_from_storage(layer.name, shard_plan[layer.name])
    8. shard_plan[layer.name].copy_(tensor)
    9. # 4) Delay optimizer state allocation; create it lazily on the first step
    10. optimizer = build_optimizer(model, shard_state=True, lazy_init=True)

    There are three engineering essentials. First, the loading process should support checksum verification to avoid silently reading a bad shard. Second, initialization must be reproducible: random seeds and the tensor-parallel partition order need to be fixed. Third, loading time should overlap with first-step compilation time; otherwise, the startup phase wastes a large amount of accelerator time.

    4. Key Point 2: Shard Scheduling and Memory Budget

    The core idea of FSDP2 is “aggregate when needed, release when done.” When computing a layer in the forward pass, an all-gather pulls in the complete parameters for that layer and releases them immediately after computation, keeping only the local shard. Memory usage is therefore roughly inversely proportional to the world size.

    The memory budget can be roughly expressed as:

    1. Memory ≈ parameter shard + gradient shard + optimizer state shard + peak activations + communication buffer + fragmentation headroom

    There are several tuning levers:

    • Shard granularity: wrap at the “layer” or “layer group” level; too fine a granularity causes a surge in communication calls, while too coarse raises peak memory;
    • Prefetch depth: launch all-gather several layers ahead to hide communication behind computation;
    • Bucket merging: combine multiple small shards into a single communication to reduce launch overhead;
    • Fragmentation control: set memory pool policies and allocation limits to reduce fragmentation jitter during long stable runs.

    Multimodal scenarios require extra attention: activation memory on the image branch is strongly correlated with sequence length, while the text branch is strongly correlated with the number of tokens in the batch. Their peaks are not synchronized, which can easily cause “one device to blow up first.” A practical approach is to set per-modality sample limits within a batch and align the peak curves across ranks.

    5. Key Point 3: Gradient Synchronization and Numerical Stability

    After backpropagation, sharded gradients need to be reduced across devices. FSDP2 typically uses bucketed all-reduce with in-place accumulation (reduce-scatter semantics), so each device keeps only the gradient portion it is responsible for and then hands it to the local optimizer for updates.

    For numerical stability, four points are worth attention:

    1. Mixed precision strategy: compute in low precision, while keeping the master copy of parameters and optimizer states in higher precision;
    2. Loss scaling: dynamically adjust the scaling factor during low-precision backpropagation to avoid gradient underflow;
    3. Gradient clipping: global norm clipping must be computed consistently across all shards; otherwise, the clipping ratio will be misaligned;
    4. Randomness control: derive seeds per rank for data order, image augmentation, and dropout masks to ensure reproducibility.

    Illustrative configuration:

    1. precision:
    2. compute: bf16
    3. master_weights: fp32
    4. loss_scale: dynamic
    5. grad_sync:
    6. bucket_mb: 200
    7. overlap: true
    8. clip_norm: 1.0
    9. checkpoint:
    10. interval_steps: 200
    11. shard_save: true
    12. async_save: true

    6. Key Point 4: Throughput, Long-Run Stability, and Fault Tolerance

    The real cost unit of trillion-parameter training is “effective accelerator hours,” so long-run stability matters more than peak throughput.

    • Communication and computation overlap: hide all-gather and all-reduce as much as possible inside operator execution windows;
    • Load balancing: sort and pack multimodal samples by estimated cost to reduce waiting caused by long-tail samples;
    • Checkpoint resume: save in shards to shorten save and restore time; after resuming, verify the optimizer step count and learning rate schedule state;
    • Observability: collect per-step time, communication ratio, peak memory, and abnormal ranks, and use log services and monitoring alerts to judge trends;
    • Fault isolation: automatically remove and regroup slow or dropped devices to avoid a single point dragging down the whole.

    7. Deployment Checklist

    1. First validate the sharding plan and numerical consistency on a small-scale cluster, then scale up;
    2. Fix random seeds and data order, and establish a “same config, same result” baseline;
    3. Do a two-dimensional sweep over shard granularity and prefetch depth to find the inflection point between memory and throughput;
    4. Set independent batch and sequence limits for multimodal inputs;
    5. Regularly rehearse save and restore procedures, and factor restore time into capacity planning;
    6. Unify metric definitions across the full pipeline to avoid attribution difficulties caused by each layer collecting its own statistics.

    8. Conclusion

    Adapting trillion-parameter multimodal training is essentially about turning the five stages of “load, shard, compute, synchronize, and save” into an observable, reproducible, and recoverable pipeline. The native sharding path reduces the complexity of parallelism configuration and frees engineering effort for data quality, load balancing, and long-run stability. For developers, once this general methodology is mastered, they can quickly build a reliable training pipeline when facing models of different scales and compute of different forms.