Trillion-Parameter Multimodal LLM Training: A Full-Pipeline Adaptation Guide

    A practical guide to adapting trillion-parameter multimodal large models for training across the entire pipeline—from weight loading and multi-dimensional parallelism to gradient synchronization, checkpointing, and long-run stability. Using a flagship ~2.8T MoE multimodal model and a native FSDP2-based training path as reference points, the article breaks down the core engineering conflicts (memory, communication, heterogeneity, and hardware differences), the key challenges of adapting to domestic AI accelerators, a five-stage rollout, common pitfalls, and a reusable tuning checklist. Developers and enterprise users can follow a "correctness first, then scalability, then stability" path to build a reproducible, evolvable training engineering system in a multi-hardware environment.

    1. Introduction: Why Trillion-Parameter Multimodal Training Is a Full-Pipeline Effort

    Recently, an open-source community released a flagship trillion-parameter (roughly 2.8T) multimodal large model. It uses a Mixture-of-Experts (MoE) sparse-activation architecture that activates only a subset of expert parameters per token, so it can hold massive amounts of knowledge while keeping the compute for a single forward pass within a trainable range. It also natively supports images, video, audio, and ultra-long context, and its training data is dominated by interleaved image-text, video, and text samples.

    Soon after, a domestic AI accelerator vendor announced that it had completed training adaptation for this model. The hardware is a flagship training-and-inference unified compute card, and the software is built on a self-developed AI stack, with a native FSDP2 multimodal training path that covers the full chain from model loading and shard scheduling to gradient synchronization. These specifics are not the focus of this article, but they reflect a broader trend: as compute supply becomes increasingly diverse, “training adaptation” is emerging as an independent discipline within large-model engineering.

    Training adaptation means making an existing model definition train efficiently and stably on a specific hardware and software stack. It is not simply “getting the model to run”—it means satisfying three constraints at the same time—correctness, efficiency, and stability:

    • Correctness: the loss curve matches the baseline, gradient values show no anomalies, and optimizer state can be restored correctly;
    • Efficiency: single-card throughput, multi-card scaling efficiency, and the overall training cycle meet budget;
    • Stability: at a scale of hundreds to thousands of cards, the job runs continuously for weeks or even months, and single-point failures can be quickly detected, isolated, and recovered.

    For a trillion-parameter MoE multimodal model, these constraints simultaneously run into the following engineering conflicts:

    1. Memory conflict: the memory footprint of parameters, optimizer states, and activations rises sharply with scale;
    2. Communication conflict: parameter sharding brings frequent parameter aggregation, while expert parallelism introduces irregular all-to-all communication;
    3. Heterogeneity conflict: image and video encoders, the long-sequence backbone, and sparse experts differ markedly in operator composition and compute characteristics;
    4. Hardware-difference conflict: different platforms differ in operator coverage, communication implementation, and numerical behavior.

    Adaptation therefore cannot be a local patch targeting “a single operator” or “one communication path.” It must span the entire pipeline:

    Weight loading → Parallelism and sharding design → Forward/backward computation → Gradient synchronization and parameter update → Checkpointing and fault tolerance

    The sections below follow this pipeline and provide actionable design principles, implementation points, and tuning recommendations.

    2. Breaking Down the Full Training Pipeline

    2.1 Model Loading: Get Semantics Right Before Chasing Efficiency

    The first step of adaptation is to correctly map the open-source model weights into the parameter structure of the target training framework. The weights of a trillion-parameter MoE model can reach several TB; loading may look trivial, but it hides a number of risks.

    Unified representation and metadata

    First, establish a “single source of truth”: the model structure should be described uniquely by a single config (JSON/YAML), with layer structure, expert count, modality branches, and attention parameters all derived from that config, so hand-written code never drifts from the configuration. Weight loading should match by state-dict keys rather than relying on a fixed read order. Before loading, verify file integrity via hash checks; after loading, sample-check the mean, variance, and norm of key tensors.

    Weight layout conversion

    MoE models typically pack the weights of multiple experts into fused tensors, and inference implementations often store QKV projections or gate/up/down projections in merged form. A training framework’s sharding unit and communication implementation may require a specific layout, so you need bidirectional conversion logic between the “inference/release layout” and the “training layout,” with explicit conventions for:

    • the ordering of the expert dimension;
    • the sharding axis and alignment requirements;
    • whether non-contiguous views are allowed.

    Shard-level loading and streaming conversion

    For weights at the multi-TB scale, centralized loading causes two problems: high memory pressure on the head node before startup, and long startup wait times. A more robust approach is “shard-level streaming loading”: each training process reads only the shards it is responsible for and, after memory-mapping and layout conversion, writes them directly to the target device. This reduces both metadata overhead and initialization time.

    Example logic (interface names are illustrative only):

    1. # 1) Read the global weight index; verify file integrity and shard mapping
    2. index = load_index(ckpt_dir, verify_hash=True)
    3. placements = build_placements(index, device_mesh=mesh) # Compute each tensor's shard from the parallel topology
    4. # 2) Each process streams its own shards, reading only the local byte ranges
    5. for tensor_name, shard in placements.local_shards():
    6. raw = mmap_read(index.file_of(tensor_name), shard.byte_range)
    7. local = convert_layout(raw, target=spec_of(tensor_name)) # Layout conversion: fusion/transpose/alignment, etc.
    8. model_state[tensor_name].copy_(to_device(local))
    9. # 3) Sample-based verification after loading
    10. verify_samples(model_state, index.stats)

    2.2 Sharding and Scheduling: Four-Dimensional Parallelism and Fixed-Size Sharding

    “Sharding and scheduling” generally refers to designing and combining the parallelism strategy with the parameter-sharding scheme. A trillion-parameter model cannot fit on any single accelerator card and must be split across multiple dimensions:

    Sharding dimension Sharding target Primary communication pattern Typical role
    Data parallel / parameter sharding Parameters, gradients, optimizer states Parameter aggregation, gradient reduction Reduce per-card memory, provide a global batch
    Tensor parallel A single layer’s weight matrix Intra-layer collective communication Reduce per-layer parameter and activation memory
    Pipeline parallel Modules split by layer/stage Adjacent-stage point-to-point transfer Reduce the number of layers per card
    Sequence parallel Sequence dimension Collective communication coordinated with TP Reduce long-sequence activation memory
    Expert parallel Expert instances All-to-all Carry MoE sparse parameters

    It is worth stressing that more parallelism dimensions are not necessarily better. Each added dimension introduces another class of communication pattern and another class of failure point, and the overall complexity grows additively. A sensible path in practice is:

    1. First use “parameter sharding + optimizer-state sharding” to solve the memory problem for the dense parameters;
    2. When long sequences make activation memory the bottleneck, introduce tensor parallelism or sequence parallelism;
    3. When the model has enough layers that several complete stages fit on a single card’s pipeline, introduce pipeline parallelism;
    4. When the number of experts and the expert capacity grow beyond what parameter sharding can carry, introduce expert parallelism.

    The native FSDP2 sharding view

    Native FSDP2 represents every parameter tensor as a “distributed tensor,” where each parameter carries its own device mesh and placement information. Sharding therefore has three characteristics:

    • Fine-grained: a single tensor can be a sharding unit, with no need to flatten an entire layer and split it uniformly;
    • Composable: different submodules can reside on different device meshes, so it naturally connects with tensor parallelism and expert parallelism;
    • Metadata-driven: sharding information travels with the tensor, so checkpoint saving, weight export, and parallelism changes are all based on the same metadata.

    Compared with the traditional “split into fixed-size chunks” approach, sharding and scheduling must answer not just “how big is each chunk,” but “along which axis is each parameter split, and in which communication group does it live?”

    Example configuration (interface names are illustrative only):

    1. # Global device mesh: organize processes as pipeline stage × tensor parallel × data parallel
    2. mesh = init_device_mesh(shape=(num_pp, num_tp, world_size // (num_pp * num_tp)),
    3. dim_names=("pp", "tp", "dp"))
    4. model = build_model_from_config(cfg) # Both structure and weights come from the config
    5. # Dense backbone: shard with FSDP2 along the data-parallel dimension, one parameter tensor at a time
    6. fsdp2_shard(model.backbone, mesh=mesh["dp"])
    7. # Tensor-parallel linear layers: split weights along the tensor dimension, comm confined to the TP group
    8. parallelize_linear(model.backbone, mesh=mesh["tp"], style="column_row")
    9. # Modality encoders and MoE expert layers: assign their own sharding mesh
    10. # (expert layers are usually split along the expert-parallel dimension)
    11. shard_modal_encoder(model.vision_encoder, mesh=mesh["dp"])
    12. shard_experts(model.moe, mesh=mesh["ep"], expert_parallel=True)
    13. # After pipeline stage partitioning, activations are passed point-to-point between stages
    14. model = pipeline_parallelize(model, mesh=mesh["pp"])

    Pipeline scheduling and load balancing

    For a multimodal MoE model, pipeline partitioning needs extra attention to load balancing:

    • The modality encoders and the backbone layers have different compute characteristics, so their per-step compute time should be estimated separately;
    • After multimodal samples are packed, the modality composition of each micro-batch can vary widely, so you should try to make the estimated time of each stage as close as possible;
    • You can adopt interleaved stage scheduling, letting one device carry several non-contiguous layer blocks to shrink pipeline bubbles.

    2.3 Forward and Backward Computation: Special Issues from Multimodality and MoE

    Aligning and packing multimodal inputs

    Before training, interleaved image-text, video, and audio samples must be unified into a sequence representation the model can consume. Key practices include:

    • Use sample packing—concatenate multiple short samples into a fixed-length sequence to reduce compute wasted on padding;
    • Pass sample boundaries into the attention computation so that different samples do not attend across each other;
    • Make explicit the concatenation order of modality embeddings and text token embeddings, the modality-type markers, and how position encodings are interpolated.

    These details may seem trivial, but they directly determine whether training numerically aligns with the reference implementation.

    Long context and variable-length attention

    Visual and video tokens significantly lengthen the sequence. The memory footprint of attention implementations is typically quadratic in sequence length, so it is advisable to use an efficient implementation that does not explicitly materialize the full attention matrix, combined with variable-length attention and sequence parallelism to control the memory peak for long-sequence samples.

    MoE routing and expert-parallel communication

    An MoE layer first routes tokens to different experts, then computes each expert separately, and finally aggregates the results. When experts are split across devices, tokens must be rearranged at two levels—“grouping by expert within a device” and “across devices”—and the core is two all-to-all communications.

    From an engineering standpoint, pay attention to:

    • Compute-communication overlap: start transfers block by block per expert before the gate computation finishes;
    • Capacity factor and load-balancing auxiliary loss: too small a capacity drops tokens, while too large wastes memory and compute; both need to be tuned together with the balancing loss;
    • Linking expert-weight sharding with parameter sharding: each local expert instance is itself still a dense matrix and can continue to be included in FSDP2 parameter sharding.

    2.4 Gradient Synchronization and Parameter Update: The Core of FSDP2

    The standard FSDP2 execution flow can be summarized as:

    Parameter sharding (resident in memory) → Prefetch and aggregate parameters layer by layer during the forward pass → Compute → Release the aggregated parameters → Aggregate again during the backward pass → Compute gradients and reduce them to the owning shard → Update the sharded parameters

    Compute-communication overlap is the key to scaling efficiency, and there are four main classes of tunable parameters:

    Tunable Role Tuning recommendation
    Bucketing strategy Determines the granularity of aggregation/reduction Buckets too small mean more communication; buckets too large mean higher peak memory and a smaller overlap window
    Prefetch depth Aggregates parameters of subsequent layers ahead of time Too deep raises the memory peak; set a hard cap
    Reduction trigger Reduce per bucket, or reduce after accumulation With many gradient-accumulation steps, consider merging the number of reductions
    Compute/communication stream allocation Avoids the two competing for resources Assign dedicated streams based on hardware capability to reduce synchronization points

    Two easily overlooked details also matter:

    • Graph capture: on models with complex operator dependencies and abundant dynamic control flow, capturing the graph ahead of time and eliminating per-operator dispatch overhead on the host often noticeably reduces cross-card “waiting on synchronization.”
    • Gradient accumulation: FSDP2 triggers reduction on each backward pass by default. When there are many gradient-accumulation steps, evaluate whether delaying reduction to the end of the accumulation cycle is more worthwhile—provided memory can hold the un-reduced gradients.

    For the parameter-update stage, two more recommendations:

    1. Keep the sharded form before and after the update: parameter shards, gradient shards, and optimizer-state shards correspond one-to-one; avoid aggregating full parameters before updating, which instantly spikes the memory peak;
    2. Master-weight precision: when weights are stored in BF16, it is advisable to keep a higher-precision master weight during reduction and optimizer updates, or adopt strategies such as stochastic rounding, to suppress slow weight drift.

    2.5 Checkpointing and Elastic Recovery: Infrastructure for Stable Long Runs

    The checkpoint of a trillion-parameter model can itself reach several TB, and the traditional “each process writes a full copy of its own state” approach leads to write amplification, head-node overload, and excessively long save times. A more reasonable approach is:

    • Sharded checkpoints: each process saves only its local parameter shard and optimizer-state shard, while a unified metadata file records tensor names, shapes, and placement information;
    • Topology decoupling: on resume, shards are re-mapped according to the new topology, supporting elastic scaling and parallelism-strategy changes;
    • Asynchronous saving: data is first copied to host memory, and a background thread then writes it to shared or object storage, minimizing blocking of the main training loop;
    • Integrity verification: record checksum information at save time and verify before loading, to avoid “silent corruption” leading to anomalous loss after resume.

    At the same time, the following framework built-in capabilities should stay enabled:

    • Re-sampling of lost batches and restoration of data-loader state;
    • Restoration of random-number-generator state;
    • Restoration of gradient-clipping norm and learning-rate scheduler state.

    Together they ensure the training trajectory stays continuous after resume.

    For stability, use logging and monitoring/alerting services to set threshold alerts on the following signals:

    • Step time rising persistently (slow nodes);
    • Abnormal growth in device memory (leak or cache fragmentation);
    • Communication timeouts or error codes;
    • Sudden loss spikes to NaN/Inf.

    Once an anomaly is found, use the container platform’s health checks and task-rescheduling mechanism to migrate the job to healthy nodes and resume from the most recent checkpoint.

    3. Core Challenges of Adapting to Domestic AI Accelerators

    On top of the pipeline above, adapting to domestic AI accelerators brings additional challenges from hardware and software-stack differences.

    3.1 Software-Stack Layers and Operator Coverage

    From bottom to top, the training software stack can be roughly divided into: driver and runtime → communication library → operator library/compiler → framework backend → training framework. Adaptation usually follows a bottom-up order:

    1. First validate driver, runtime, and communication connectivity with a small model;
    2. Then validate the operator library with single-operator precision tests;
    3. Finally run end-to-end training validation.

    The operator-adaptation checklist should at least cover:

    • Normalization (e.g., LayerNorm, RMSNorm);
    • Rotary position embedding;
    • Various attention implementations (including grouped-query attention and variable-length attention);
    • Gated activations such as SwiGLU;
    • MoE routing and grouped-expert computation;
    • Convolution and interpolation operators in image/video encoders.

    Among these, grouped-expert MoE computation and long-sequence attention often lack ready-made efficient implementations and must be integrated via the framework’s custom-operator extension mechanism, with numerical comparison performed after integration.

    3.2 Communication Adaptation and Topology Awareness

    The algorithm choice of the collective-communication library significantly affects large-model training performance:

    • Gradient reduction for data parallelism is well suited to ring-reduction algorithms;
    • Aggregation/reduction for tensor parallelism is usually completed within a single machine’s high-speed interconnect domain and is better suited to symmetric-bandwidth exchange algorithms;
    • All-to-all for expert parallelism is sensitive to link fairness and commonly uses direct-exchange implementations.

    In practice, confirm that the communication library has topology awareness enabled: build communication groups in the hierarchy of “single-machine high-speed interconnect domain → intra-machine PCIe/cache-coherent links → inter-machine network,” and try to keep tensor-parallel groups within the same high-speed interconnect domain. For inter-machine scenarios, also enable protocol-acceleration capabilities (such as a fused protocol) to reduce small-packet transfer overhead.

    3.3 Numerical Consistency and Mixed Precision

    The same model can show subtle numerical differences across platforms. Common sources include:

    • Normalization operators using different reduction orders;
    • Different approximate implementations of exp, softmax, and similar operations;
    • Inconsistent data types for reduction under mixed precision;
    • Different random-number-generator implementations.

    It is advisable to establish a tiered acceptance process:

    1. Single-card, single-operator level: compare the max absolute error and relative error of key operators;
    2. Single-layer forward/backward level: compare activations and gradients under a fixed random seed;
    3. Small-scale end-to-end level: compare the loss over the first several steps under the same data order.

    Only when errors at every tier fall within acceptable ranges should you move to large-scale training. At the same time, define explicit precision for numerically sensitive parts (such as loss reduction, gradient-clipping norm, and the optimizer’s first/second moments), to avoid a “one-size-fits-all” mixed-precision policy.

    4. Performance Optimization: From “Runnable” to “Efficient”

    Once functionality works, tune systematically around the core metric of “per-step time.” Per-step time can be decomposed as:

    Compute time + parameter aggregation/gradient reduction communication + expert all-to-all communication + pipeline bubbles + host-side scheduling and data waiting

    Methods for locating bottlenecks

    • Use the framework’s built-in profiling tools, or the vendor’s performance-profiling capabilities, to collect operator timelines and communication timelines;
    • Compare the overlap ratio between the “compute stream” and the “communication stream” on the timeline;
    • Check for frequent host-device synchronization (e.g., printing tensors one by one, or control flow that depends on tensor values).

    Dimension-by-dimension optimization

    • Compute side: enable operator fusion and graph-mode execution; use the runtime memory pool to reduce repeated allocation/free; set recomputation granularity sensibly;
    • Communication side: adjust bucket size and prefetch depth; pipeline the expert all-to-all in per-expert blocks;
    • Pipeline side: adjust stage partitioning and micro-batch count to compress bubbles;
    • Data side: run parallel decoding and preprocessing in data-loader processes, combined with local caching and shared storage; use variable-length sequence packing to reduce padding.

    Scaling-efficiency validation

    Validate scaling efficiency at small and medium scales: as the card count grows, per-card throughput should stay relatively stable and overall throughput should scale near-linearly. If the scaling curve bends noticeably, it usually points to a rising communication share or load imbalance. At that point, go back and re-evaluate at the parallelism-strategy level rather than merely tuning communication parameters.

    5. Implementation Roadmap: Five Stages

    Stage Goal Key tasks Passing criteria
    Stage 1: Loading validation Weight semantics are correct Weight conversion, shard-level streaming load, sample verification Key tensors match; single-card forward pass completes
    Stage 2: Single-card baseline Compute path is correct Operator adaptation, custom-operator integration, precision comparison Single-step loss is within threshold of the reference implementation
    Stage 3: Small-scale parallelism Parallel path is correct FSDP2 sharding, gradient synchronization, checkpoint save/restore Multi-card loss matches single-card; resume trajectory is continuous
    Stage 4: Scalability tuning Reach target throughput Parallel-strategy search, communication overlap, pipeline balancing Scaling efficiency and per-step time meet expectations
    Stage 5: Long-run stability Support long training cycles Fault self-healing, slow-node detection, async checkpointing Fault-recovery time is controllable during continuous running

    6. Common Pitfalls

    1. Adapting only for a single card: running on one card does not mean multi-card correctness. Problems in sharding, reduction, all-to-all, and similar stages often surface only at multi-card scale.
    2. Guessing the parallel strategy: setting parallelism degrees by intuition without analyzing model structure, interconnect topology, and batch size easily leads to a communication bottleneck or out-of-memory.
    3. Masking numerical problems with tuning: when loss goes abnormal, suspecting the learning rate first instead of checking operator precision and reduction order may misdiagnose an adaptation defect as a hyperparameter issue.
    4. Tightly coupling checkpoints with parallel topology: binding the save format to a fixed parallelism degree makes scaling require costly conversion—or even make resuming impossible.
    5. Ignoring the data side: the bottleneck of a trillion-parameter model is sometimes not compute but data decoding, packing, and I/O. Multimodal data is large and costly to decode, so it especially needs early stress testing.
    6. Ignoring the tail effect: in long runs, an occasional slow node drags down overall throughput, so routine health checks and automatic isolation are needed.

    7. A Reusable Tuning Checklist

    • Weight-conversion scripts support bidirectional conversion and hash verification;
    • Sharding information is managed uniformly as metadata, supporting topology-decoupled checkpoints;
    • Tensor-parallel groups reside in the same high-speed interconnect domain, with the number of inter-machine groups minimized;
    • Both parameter aggregation and gradient reduction implement compute-communication overlap;
    • Expert all-to-all is pipelined in per-expert blocks, with load-balancing auxiliary loss enabled;
    • Pipeline stages for the modality encoders and backbone are partitioned by measured per-step time;
    • A three-tier numerical acceptance process (operator, layer, end-to-end) is established;
    • Slow-node detection, fault isolation, and automatic resume form a closed loop;
    • Key training metrics across the whole run are connected to monitoring and alerting.

    8. Conclusion

    Adapting trillion-parameter multimodal model training is, at its core, a co-design of three things: model structure, parallel strategy, and hardware capability. A native parameter-sharding approach like FSDP2 lets sharding information flow with the tensors and connects naturally with heterogeneous multimodal structures and MoE expert parallelism; meanwhile, the difficulty of adapting to domestic AI accelerators concentrates at three levels: operator coverage, communication implementation, and numerical consistency.

    For developers and enterprise users, follow a path of “correctness first, then scalability, then stability”: start from loading validation, pass through the five stages—single-card, small-scale parallelism, scalability tuning, and long-run stability—and complement them with robust checkpointing, fault tolerance, and monitoring.

    When running this kind of training in the cloud, you can combine it with a container platform for environment standardization and job orchestration, use object storage to carry massive training data and checkpoints, and rely on logging and monitoring/alerting for real-time observability of long-run training. In this way, you can build a reproducible, evolvable large-model training engineering system in a multi-hardware environment.