Trillion-Parameter Multimodal Model Training on Domestic AI Accelerators: A Practical Adaptation Guide
A trillion-parameter-class multimodal model has now been open-sourced, signaling that training and reproducing such models has moved from paper experiments to engineering practice. This guide explains how to adapt a 2.8-trillion-parameter multimodal model to domestic AI accelerators, using next-generation sharded data parallelism (FSDP2) as the core training path. The real goal is not running a single iteration, but making training correct, stable, and efficient across thousands of cards. It systematically covers model structure analysis, parallelism strategy, memory budgeting, model loading, FSDP2 sharded scheduling, communication-computation overlap, gradient synchronization, multimodal data organization, numerical alignment, and long-run stability, and ends with an actionable checklist and a reusable "analyze–budget–shard–align–tune–operate" methodology.
Introduction: Trillion-Parameter Multimodal Training Enters the “Engineering Adaptation” Phase
Recently, a research team open-sourced a multimodal large model with a total of 2.8 trillion parameters. Training and reproducing trillion-parameter models has moved from “paper experiments” to “engineering practice.” At the same time, domestic AI accelerators are being used to take on such ultra-large-scale training workloads. A complete adaptation approach has emerged in the industry: built on domestic training-and-inference integrated AI accelerator cards and their supporting software stack, it constructs a multimodal training path centered on next-generation sharded data parallelism (FSDP2), connecting the full pipeline of model loading, sharded scheduling, and gradient synchronization.
From an engineering perspective, the real value of this kind of work lies not in “whether it can run a single iteration,” but in turning “running” into “running correctly, running stably, and running efficiently.” There are three concrete concerns:
- Correctness: The forward output, backward gradients, and loss curve must stay consistent with the reference implementation;
- Stability: Thousands of accelerators running continuously for weeks or even months require fault recovery and slow-node detection;
- Efficiency: Compute utilization, communication overlap, and spare memory headroom determine the true training cost.
Using this scenario as a thread, this article strips out specific product information to remain vendor-neutral, and systematically walks through the key aspects of training a trillion-parameter multimodal model on domestic compute: architecture analysis, parallelism strategy, sharded training paths, gradient synchronization, numerical alignment, and stability guarantees. It closes with a practical checklist you can apply directly.
Part 1: Breaking Down the Problem — Where Trillion-Parameter Multimodal Training Gets Hard
1.1 The Memory Wall from Parameter Scale
For trillion-parameter models, the first training challenge is that the state memory far exceeds the capacity of a single card or even a single node. With mixed-precision training and an Adam-family optimizer, memory usage can be roughly estimated by “bytes per parameter”:
- Master weights: fp32 parameters plus their first- and second-order moments, 12 bytes in total;
- Compute copies: bf16/fp16 parameters and gradients, 4 bytes in total.
That adds up to about 16 bytes per parameter. Even without counting activations, 2.8 trillion parameters require roughly 44.8 TB of memory just to hold the model state. At 64 GB per card, this part alone needs about 700 cards to shard across. Model parallelism is therefore not an “optional optimization” but a hard prerequisite.
1.2 MoE Sparse Architecture: The Mismatch Between Compute and Memory Demand
Flagship models commonly adopt a Mixture-of-Experts (MoE) sparse architecture, where the total parameter count and the per-token activated parameter count often differ by an order of magnitude:
- Memory dimension: All expert parameters must reside in memory, so memory pressure scales with total parameters;
- Compute dimension: Each token passes through only a few routed experts, so compute consumption scales with activated parameters.
This leads to two direct conclusions:
- You cannot rely solely on the theoretical ceiling of “peak compute ÷ (6 × activated parameters × token count),” because the all-to-all communication introduced by expert routing often becomes a hidden bottleneck;
- Load balancing directly determines hardware utilization. Devices hosting hot experts take on more computation and slow down the entire training group, while an overly large capacity factor simply wastes memory and compute.
1.3 Multimodal Inputs: Highly Irregular Sequences
Pure text training deals with relatively regular sequence lengths; multimodal training is different:
- Images are converted to tokens by a vision encoder and inserted into the text sequence, with resolutions and aspect ratios varying enormously;
- Sequences from modalities such as video and documents can be much longer;
- Sample lengths within the same batch can differ by several times or even tens of times.
If you still organize batches the traditional way — “take the longest sample and pad the shorter ones with zeros” — a large amount of compute gets consumed on meaningless padding. Adapting multimodal training is not just about “getting the vision encoder to run”; it also involves a series of changes to data organization, loss masking, positional encoding, and variable-length attention.
1.4 Common Obstacles in Cross-Hardware Migration
Migrating training from a familiar environment to new hardware and a new software stack typically runs into four kinds of problems:
- Operator gaps: Special activation functions, attention variants, and normalization implementations may lack high-performance implementations on the target platform, forcing a fallback to generic operators;
- Numerical differences: Different underlying math libraries, reduction orders, and fusion strategies cause small deviations in forward outputs and gradients, which in extreme cases can trigger loss spikes or even divergence;
- Communication library differences: Collective communication interface semantics, topology awareness, and multi-stream overlap mechanisms are not fully consistent, affecting the efficiency of communication-computation overlap;
- Ecosystem toolchain differences: The level of support for capabilities such as mixed-precision strategies, gradient accumulation, and sharded checkpoint saving and loading varies.
The value of hardware vendors and model teams completing adaptation jointly lies precisely here: converging scattered problems into a verifiable engineering process.
Part 2: Three Preparations Before Adaptation — Model Analysis, Parallelism Strategy, and Memory Budget
2.1 Model Structure Analysis: First Understand “What to Compute”
The first step in adaptation work is a systematic breakdown of the model structure. Taking a mainstream multimodal large model as an example, it typically consists of four parts:
- Vision/multimodal encoder: Converts images or videos into visual features;
- Modality connector: Usually a multi-layer perceptron or lightweight attention module that maps visual features into the language model’s feature space;
- Large language model backbone: A Transformer decoder that carries the vast majority of parameters;
- Output head and loss functions: Language modeling loss, with some models also including auxiliary losses related to visual understanding.
The analysis should produce at least the following information:
- The parameter distribution across sub-modules, and the ratio of total to activated parameters;
- Whether the modules contain custom operators or dynamic control flow (such as MoE routing and variable-length visual tokens);
- Which parts of the computation graph depend on global information (such as cross-modal attention and MoE gating), since they directly constrain how the model can be sharded.
2.2 Parallelism Strategy: Two-Dimensional Grouping as a Common Starting Point
Large-model training parallelism essentially means partitioning the model and data along multiple dimensions:
| Parallelism dimension | What is partitioned | Main benefit | Main cost |
|---|---|---|---|
| Sharded data parallelism (FSDP/ZeRO) | Parameters, gradients, optimizer states | Memory shared across cards, no model code changes needed | One parameter all-gather and gradient reduce-scatter per step |
| Tensor parallelism (TP) | Matrix operations within a single layer | Reduces per-card activation memory | Intra-layer all-reduce, sensitive to inter-card bandwidth |
| Expert parallelism (EP) | Different MoE experts | Shares expert parameter volume | All-to-all communication, risk of load imbalance |
| Pipeline parallelism (PP) | Splitting stages by layer | Reduces per-card parameters and activations | Pipeline bubbles, complex scheduling |
| Context/sequence parallelism (CP/SP) | Sequence dimension | Supports ultra-long sequences | Attention computation needs special implementation |
When choosing, three points matter most:
- Network topology: High-frequency communication like TP should be confined to the high-speed interconnect among cards within a single node; FSDP shards, PP pipelines, and EP all-to-all are handled across nodes;
- Scale elasticity: Sharded data parallelism scales well with cluster size and works well as the base dimension;
- Composability with other parallelism: Some implementations do not coexist well with TP or EP, requiring extra changes when combined.
2.3 Memory Budget: Working Backward from a “Ledger” to Cluster Size
The memory budget is the starting point for adaptation decisions. Per-card memory usage can be broken into four items:
- Sharded model state: Roughly “16 bytes × total parameters ÷ number of cards in the shard group”;
- Unsharded parameters: If “reshard after forward” is disabled, the all-gathered copy of the same set of parameters stays resident between the forward and backward passes, on the same order of magnitude as item 1;
- Activations: Related to “number of layers × per-layer activations × degree of recomputation,” and, with attention implementations and recomputation strategies, usually far lower than the model state;
- Fragmentation and temporary buffers: Communication buffers, memory allocator fragmentation, peak activations from the vision encoder, and so on.
In practice, you can estimate with:
Per-card state memory ≈ 16 × total parameters ÷ number of cards in shard groupMinimum cluster size ≈ (16 × total parameters + activation and buffer reserve) ÷ per-card memory capacity
With 2.8 trillion parameters and 64 GB per card, the model state alone needs about 700 cards to hold; adding activations, fragmentation, and fault-tolerance headroom, the actual cluster size usually needs to scale noticeably above this baseline.
Part 3: Model Loading — From Single-Node Weights to a Large-Scale Cluster
3.1 Loading Strategy: Validate on a Single Card First, Then Scale Out
Open-source model weights are usually released as tensor-sharded files, with a reference implementation of the model structure and loading logic. The recommended order for adaptation is:
- On a single card, validate the loading logic, tokenization, and data pipeline using a smaller subset (such as only the first few layers of the language backbone);
- On a single node with multiple cards, validate sharded loading and sharded checkpoint read/write;
- On multiple nodes with multiple cards, validate collective communication and fault recovery.
Each time you scale up a level, set a clear “pass criterion” (loss alignment, no memory overflow, no communication timeout) to avoid letting problems surface only at large cluster scale.
3.2 Loading Modes: Full-Card Loading vs. Sharded Loading
- Full-card loading: Every card reads the complete weights and then shards them. Simple to implement, but memory and I/O overhead grow linearly with cluster size;
- Sharded loading: Each card reads only the shards it is responsible for, and uses distributed checkpoint capabilities to save and restore the sharded parameters, gradients, and optimizer states.
For large-model training, prefer the latter: both training startup time and checkpoint save time improve significantly as card count grows, and resuming from checkpoints preserves consistency in the parallelism configuration.
3.3 Precision and dtype Alignment
The most easily overlooked aspect in loading is numerical precision:
- Confirm the actual dtype of the weight files matches the training precision (such as bf16);
- Keep master weights and optimizer states at higher precision, to avoid update amounts being swallowed by rounding;
- Watch for differences in how normalization-layer epsilon and residual connections behave under different precisions.
It is recommended to perform a “weight fingerprint check” after loading: compute the norm or hash of several key tensors and compare against the reference implementation to quickly detect loading misalignment or transpose errors.
Part 4: Sharded Scheduling — Building a Sharded Training Path Around FSDP2
4.1 Key Changes in FSDP2 vs. the Previous Generation
FSDP2 refers to the new generation of sharded data parallelism, whose interface is characterized by “per-parameter sharding.” The representative usage is to call fully_shard in place on a module, rather than wrapping the entire model with a wrapper as the old version did. Compared with the old FSDP, it mainly offers the following changes:
| Comparison dimension | Old FSDP | FSDP2 |
|---|---|---|
| Sharding granularity | Per flattened parameter (FlatParameter) | Per individual parameter tensor |
| Data representation | Relies on a dedicated flat structure | Based on distributed tensors (DTensor), composable with tensor parallelism |
| Checkpoints | Must merge and split flattened parameters | Sharded save/load, reshards more naturally when topology changes |
| Mixed-precision policy | Via parameter configuration | Controlled per-parameter and per-module, more flexible |
The practical significance of “per-parameter sharding” is:
- Parameters are no longer concatenated into one large flat tensor; gradients and optimizer states map one-to-one with parameters, making debugging and checkpoint handling more intuitive;
- Parameters are expressed as DTensors that describe their sharding placement, and can be uniformly orchestrated with the DTensors produced by tensor parallelism;
- Within a single step, only the current layer’s parameters need to be all-gathered to participate in computation, and can be released as soon as computation finishes, providing finer granularity for “computation/communication overlap” and “resharding.”
import torchfrom torch.distributed.device_mesh import init_device_meshfrom torch.distributed.fsdp import fully_shard# 1. Build a two-dimensional device mesh: (dp_replicate, dp_shard)# dp_shard usually corresponds to the intra-node high-speed interconnect domain;# dp_replicate replicates across nodes# (device_type is determined by the specific hardware backend; a generic device type is used here for illustration)mesh = init_device_mesh("cuda", (dp_replicate, dp_shard),mesh_dim_names=("dp_replicate", "dp_shard"))# 2. Apply FSDP2 layer by layer: shard at the "decoder layer" granularity, not all at oncefor layer in model.decoder.layers:fully_shard(layer, mesh=mesh["dp_shard"])# 3. Sub-modules such as the vision encoder follow the same approach; choose sharding granularity by their own size# 4. Finally wrap the root module so that all its parameters, gradients, and optimizer states are sharded as DTensorsfully_shard(model, mesh=mesh)
4.2 Hybrid Sharding (HSDP): Two-Dimensional Grouping of Shard and Replicate Domains
The hybrid sharding strategy (HSDP) of “shard within a node, replicate across nodes” is almost a must-have for trillion-parameter training:
- Benefit: The gradient reduce-scatter completes only within the intra-node shard domain, and across nodes only the gradients of each node’s representative need to be synchronized;
- Cost: Each node in the replicate domain holds its own copy of the shard, so memory usage grows with the size of the replicate domain.
Therefore, the replicate domain size is essentially a “memory vs. cross-node communication volume” trade-off knob. When intra-node interconnect bandwidth is high, confining the shard domain to a single node is often more efficient than global sharding.
4.3 reshard_after_forward: The Trade-off Between Memory and Communication
“Whether to immediately reshard after the forward pass” directly affects per-step communication volume:
- Resharding enabled: One all-gather each in the forward and backward passes, with low memory usage;
- Resharding disabled: The forward all-gather result is retained for reuse in the backward pass, saving the backward all-gather, but activation memory increases significantly.
In practice, you can configure this per layer: enable resharding on the backbone decoder layers that hold large parameters to control memory; disable resharding on modules with few layers but intensive computation (such as the output head) to save communication. This strategy is best measured at a smaller scale first, then extrapolated to the full configuration.
4.4 Combining with TP, EP, PP, and CP
FSDP2 solves “how sharded parameters are scheduled along the computation flow,” but it is not isolated; in real training it is often stacked with other parallelism dimensions:
- TP + FSDP2: Tensor parallelism splits a single layer’s matrices across the TP group, and FSDP2 continues to shard along the DP dimension. Both are based on DTensor, so you must ensure the “sharding layout” and “TP split layout” are composable, avoiding extra reordering or duplication;
- EP + FSDP2: Expert parameters are distributed across devices via expert parallelism, and FSDP2 then shards the “isomorphic expert replicas.” The key is to keep the expert-routing all-to-all and the FSDP parameter all-gather from interfering with each other at the stream level;
- PP + FSDP2: Split pipeline stages by layer, and shard within each stage to reduce per-card parameters and activation usage;
- CP/SP + FSDP2: In long-sequence scenarios, split the attention computation along the sequence dimension, with especially noticeable benefits when there are many visual tokens.
Part 5: Sharded Scheduling Details — Overlapping Communication and Computation
The execution order of a single FSDP2 step can be abstracted as:
Forward: all-gather(parameters) → compute → release parameters → next layerBackward: all-gather(parameters) → compute gradients → reduce-scatter(gradients) → next layer
If executed strictly serially, communication time adds directly to per-step latency. In engineering, overlap is mainly improved through three types of techniques:
- Asynchronous collective communication + multiple streams: Launch the parameter all-gather ahead of time to run in parallel with the previous layer’s computation;
- Bucketing: Pack multiple parameters/gradients into buckets to reduce the number of small messages and lower communication launch overhead;
- Recomputation and communication staggering: Place recomputation within the waiting window of the all-gather, filling communication gaps with compute.
When evaluating overlap effectiveness, it is recommended to collect the following metrics:
- The proportion of “communication wait” in per-step time;
- Tokens processed per card per second (tokens/s/GPU);
- Actual bandwidth utilization of all-gather and reduce-scatter within the shard group.
Any “trade memory for recomputation” strategy should be validated with this set of metrics to confirm it genuinely yields end-to-end throughput gains, rather than being decided by gut feeling.
Part 6: Gradient Synchronization — From Gradient Accumulation to the Distributed Optimizer
6.1 Skipping Synchronization During Gradient Accumulation
Gradient accumulation is a standard technique for enlarging the effective batch size and smoothing training. If a reduce-scatter is performed every step during accumulation, communication volume multiplies. FSDP2 provides an interface to skip synchronization during accumulation, performing gradient reduction only on the last micro-batch:
# Illustration: skip gradient sync during accumulation; reduce only on the last micro-batchfor step, micro_batches in enumerate(loader):for i, mb in enumerate(micro_batches):# set_requires_gradient_sync controls whether reduce_scatter is triggered during backwardset_requires_gradient_sync(model, is_last=(i == len(micro_batches) - 1))loss = compute_loss(model, mb)loss.backward()optimizer.step()optimizer.zero_grad(set_to_none=True)
Note that skipping synchronization means each card keeps local gradients during accumulation, so operations like gradient norm and gradient clipping must be executed uniformly after synchronization; otherwise the per-card clipping coefficients will differ, causing the parameter shards to “drift.”
6.2 Gradient Clipping and Gradient Norm
In sharded scenarios, the “global gradient norm” must be reduced across the shard group before it is computed. A typical approach is to first use all-reduce to aggregate the local sum of squares of each shard, then take the square root to get the global norm, and finally clip uniformly. If a single-card norm is used by mistake, the effective learning rate will change with the sharding scheme, making the training curve hard to reproduce.
6.3 Distributed Optimizer States
The states of Adam-family optimizers (first- and second-order moments) are usually stored as shards that map one-to-one with the parameters. When adapting, confirm:
- Whether the optimizer states use the same sharding layout as the parameters;
- Whether the optimizer states can be correctly resharded to a new parallelism topology when saving/restoring checkpoints;
- Under mixed precision, whether the master weights are saved at higher precision, to avoid precision drift during long training runs.
6.4 Additional Synchronization in MoE Scenarios
Gradient synchronization in MoE adds two layers of complexity over dense models:
- Routing statistics synchronization: The load-balancing loss depends on the global token distribution, so routing statistics must be synchronized within the expert parallelism group;
- Capacity factor and drop policy: Dropping over-capacity tokens changes the effective gradient, so adaptation should stay consistent with the reference implementation, or the loss curve will show a systematic bias.
Part 7: Multimodal Training Path — Data Organization Determines Compute Efficiency
7.1 Sample Packing
The most common source of efficiency waste in multimodal training is padding. The recommended packing strategy is:
- Concatenate multiple image-text samples into one long sequence, and construct the attention mask by “sample boundaries” to avoid cross-sample attention leakage;
- Reset positional encoding independently per sample, rather than using global continuous numbering;
- Apply the loss mask only to the parts that need loss computation (such as text response tokens); visual tokens are usually not counted in the language loss.
# Illustration: batch construction after packing multimodal samples# input_ids: [B, L] already concatenated by sample boundaries# position_ids: [B, L] counts from 0 again within each sample# loss_mask: [B, L] 1 means counted in the loss, 0 means ignored# attn_mask: for variable-length scenarios, commonly expressed as "sequence length array + block-diagonal mask" to represent sample boundariesbatch = {"input_ids": input_ids,"position_ids": position_ids,"loss_mask": loss_mask,"seq_lens": seq_lens, # true length of each sample, used to build the block-diagonal mask}
7.2 Independent Scheduling of the Vision Encoder
The vision encoder often has a small parameter count but heavy per-sample computation and large sequence-length variation. Two engineering points matter:
- Dynamic batching: Batch by the number of images rather than the number of samples, to avoid a few large images slowing down the whole batch;
- Separate precision strategies: The vision encoder can run inference at lower precision while the connector and language backbone keep training precision, reducing the amplification of numerical errors at the cross-modal alignment point.
7.3 Freeze and Unfreeze Strategies
Multimodal training is usually done in stages: first freeze the vision encoder and language backbone and train only the connector, aligning visual features to the language space; then gradually unfreeze. When adapting, this strategy must be mapped into a combination of “parameter requires_grad + reshuffling the shard group,” ensuring frozen modules do not participate in gradient reduction and avoiding communication waste from empty-gradient shards.
Part 8: Numerical Alignment — The “Acceptance Criteria” for Adaptation Quality
The hardest part of cross-hardware adaptation to quantify is “whether it is correct.” It is recommended to establish three levels of acceptance:
8.1 Operator-Level Alignment
Run single-operator comparison tests on key operators (attention, normalization, activation functions, loss functions):
- Two scenarios: random input tensors and real activation distributions;
- Record maximum absolute error, relative error, and output distribution statistics (mean, variance, quantiles);
- For accumulative operators (such as matrix multiplication), pay extra attention to differences caused by reduction order.
8.2 Single-Layer and Single-Step Alignment
Run the reference and target implementations with fixed inputs, and compare forward outputs and backward gradients layer by layer. If a layer’s deviation amplifies noticeably, it usually points to a problem with that layer’s fused operators or precision strategy, rather than random fluctuation.
8.3 End-to-End Loss Curve Alignment
Under a small-scale configuration (such as reduced layers and a smaller data subset), compare the loss curves over the first few hundred steps of training:
- Focus on curve shape, descent rate, and spike locations;
- If there is a systematic offset, check the data pipeline (packing, masking, positional encoding) and optimizer hyperparameter propagation first;
- If there are sporadic spikes, first investigate communication timeouts, gradient overflow, and mixed-precision scaling factors.
These three levels of acceptance should be codified into automated tests and incorporated into every adaptation regression, rather than being a one-off manual check.
Part 9: Stability and Operations — The Bottom Line for Long Training Runs
Trillion-parameter training can easily run for weeks, and stability often affects actual delivery more than peak performance:
- Fault recovery: Sharded checkpoints + asynchronous saving ensure fast recovery from the latest checkpoint after a single-point failure, and the recovered parallelism topology stays consistent with the original;
- Slow-node detection: Identify abnormal cards through the distribution of collective communication times and isolate them promptly, avoiding “one slow card slowing down the whole cluster”;
- Observability: Collect loss, gradient norm, learning rate, communication time, and memory watermark in a unified way, set threshold alerts, and automatically save the scene on anomalies;
- Numerical health inspection: Periodically sample statistics (such as norms and extremes) of weights and optimizer states, and roll back promptly upon detecting abnormal drift.
When running such training in the cloud, common capabilities can usually be leveraged to reduce operational cost:
- Use object storage to hold datasets and checkpoints, and a container platform to handle orchestration and elastic scheduling of training jobs;
- A monitoring and alerting service handles metric collection and anomaly notification;
- A logging service handles centralized retrieval of training logs.
Part 10: Implementation Checklist
Consolidating the above into an executable checklist, adaptation work can proceed in order:
- Complete model structure analysis, clarifying each sub-module’s parameter count and custom operator list
- Work backward from the memory ledger to determine cluster size and parallelism strategy combination
- Confirm the weight loading mode (full-card/sharded) and dtype precision strategy
- Apply FSDP2 layer by layer, configuring the two-dimensional grouping of shard and replicate domains
- Set resharding strategy per module, and measure the memory-communication trade-off point
- Skip synchronization during gradient accumulation, and perform global gradient clipping uniformly
- Complete sample packing, positional encoding reset, and loss mask construction
- Build three-level numerical alignment tests: operator-level, layer-level, and end-to-end
- Deploy slow-node detection, threshold alerts, and automatic scene saving
- Continuously tune with tokens/s/GPU and communication-wait ratio as core metrics
Conclusion
Adapting trillion-parameter multimodal models to domestic compute is essentially translating a “model definition” into a “hardware-executable sharded scheduling graph”:
- Sharded data parallelism (FSDP2) handles the even distribution of memory across parameters, gradients, and optimizer states, plus layer-by-layer scheduling;
- Hybrid sharding and resharding strategies find a balance point between memory and communication;
- Data packing and multimodal scheduling determine whether compute is effectively utilized;
- Layered numerical alignment and long-run operations determine whether training can stably converge to the expected outcome.
For engineering teams, what is most worth accumulating is not the conclusion of any single adaptation, but the reusable methodology of “analyze–budget–shard–align–tune–operate.” Hardware will iterate and models will evolve, but this process can continuously bring new models and new hardware into a controllable training system quickly.
