Training Trillion-Parameter Multimodal Models on Domestic AI Accelerators: Native FSDP, Pipeline Integration, and Staged Validation
This article examines how to adapt trillion-parameter multimodal models to domestic AI accelerators. It focuses on three major bottlenecks — the memory wall, the communication wall, and numerical consistency — and explains native Fully Sharded Data Parallelism (FSDP) as the core design, including parameter-level sharding and hybrid sharding at scale. It then walks through wiring up the full training pipeline, from model loading and shard scheduling to gradient synchronization and checkpoint-based resumption, followed by the extra constraints of multimodal workloads, a staged validation strategy, and observability practices. Engineers will find a reusable methodology for moving large-scale training to domestic hardware.}
I. Background: Why Trillion-Parameter Multimodal Training Is a New Problem
When model sizes crossed into the trillion-parameter range and text, images, and other modalities were fused natively, the central challenge of training engineering shifted. It is no longer “how large a model can run on a single card,” but “whether a large-scale cluster can train stably, efficiently, and for long stretches.”
Recently, a team in the industry open-sourced a flagship multimodal model with 2.8 trillion parameters. Domestic AI accelerators and their accompanying software stack have since completed the training adaptation. That work connects the full training pipeline, from model loading and parameter-shard scheduling to gradient synchronization. Its significance goes beyond “it runs.” It offers a reusable engineering path for domestic compute to take on ultra-large-scale multimodal training.
Using this work as a starting point, this article abstracts the general methodology and systematically breaks down the key challenges, core designs, and validation methods involved in the adaptation.
II. Three Walls: Understanding the Adaptation Challenges
1. The Memory Wall: Model States Themselves Are Already Massive
Consider mixed-precision training with an Adam-family optimizer. Each parameter requires at least five pieces of data:
- A half-precision (e.g., bf16) copy of the parameter
- A gradient of the same precision
- An fp32 master copy of the parameter
- The fp32 first moment
- The fp32 second moment
Together, these amount to roughly 16 bytes. For 2.8 trillion parameters, the model states alone come to about 44.8 TB, before accounting for activations, temporary buffers, and memory fragmentation. Factor in the high-dimensional outputs of the vision encoder and long multimodal sequences, and no single card can possibly hold it all.
2. The Communication Wall: Larger Parameters, Heavier Synchronization
Under Fully Sharded Data Parallelism (FSDP), each card holds only a shard of the parameters. During the forward and backward passes, cards temporarily reconstruct full parameters via All-Gather. At the end of the backward pass, they reduce gradients via Reduce-Scatter. The larger the model and the wider the cluster, the more communication grows linearly. Once communication cannot overlap sufficiently with computation, the compute of GPUs, NPUs, and other accelerators sits idle in large measure.
3. The Consistency Wall: Numerical Differences Compound During Training
Operator implementations on different hardware (e.g., reduction order, fusion strategy, mixed-precision policy) differ subtly from the reference implementation. Each difference is tiny on its own. Yet across trillions of parameters and tens of thousands of steps, these differences can accumulate. The result may be a loss curve that drifts from the expected trajectory, sudden loss spikes, or even training divergence.
III. Native Fully Sharded Data Parallelism: The Core Design
1. What “Native” Means
“Native” usually carries two meanings:
- Training runs directly on the accelerator vendor’s own operator libraries and collective communication libraries, without extra adaptation patches or third-party acceleration libraries.
- The sharded parallelism scheme is built directly at the training framework layer with semantics consistent with the reference implementation, rather than bolted on from outside the framework.
The benefits are a leaner technology stack, less version coupling, and lower long-term maintenance cost. A native stack also makes full-stack tuning easier, from low-level operators all the way up to high-level training logic.
2. Why Choose Parameter-Level Sharding
The table below compares the trade-offs of mainstream distributed parallelism strategies:
| Strategy | Memory Overhead | Main Communication | Typical Use Case |
|---|---|---|---|
| Data Parallelism (DDP) | Each card holds a full model replica | Gradient All-Reduce | Small to medium models |
| Fully Sharded Data Parallelism (FSDP) | Parameters, gradients, and optimizer states all sharded | All-Gather + Reduce-Scatter | Models with extremely large parameter counts |
| Tensor Parallelism (TP) | A single layer’s parameters split across cards | Frequent intra-layer collective communication | A single layer does not fit on one card |
| Pipeline Parallelism (PP) | Layers assigned to different cards | Point-to-point transfer between adjacent stages | Scaling vertically across nodes |
| Sequence Parallelism (SP) | Intermediate activations split along the sequence dimension | Used together with tensor parallelism | Long-sequence training |
FSDP follows a sharded data parallel (Sharded DDP) paradigm. Each card holds only one shard of the parameters. Parameters are temporarily aggregated on demand during the forward and backward passes and released as soon as computation finishes. This spreads parameters, gradients, and optimizer states across all accelerators. Unlike tensor parallelism, it needs no invasive changes to model code, which makes it well suited to quickly taking on trillion-parameter models.
3. A New Generation of Sharding: The Parameter as the Unit
Traditional sharding implementations typically use a group of parameters (a flat parameter) as the unit. All parameters in a unit are concatenated and then split as one block. This approach has two drawbacks:
- Coarse granularity: parameters can hold one another back.
- Limited flexibility when combined with mechanisms such as tensor parallelism and activation recomputation.
The “FSDP2”-style implementations widely discussed in the industry refine the sharding granularity to a single parameter. Each parameter gets a global sharded view, with the following capabilities layered on top:
- Reshard after forward: full parameters are released promptly once the forward pass ends.
- An explicit mixed-precision policy that separates compute precision from parameter storage precision.
- Composition with activation recomputation and tensor parallelism into 2D or even higher-dimensional hybrid parallelism.
Finer granularity enables more flexible scheduling. It also raises the bar for managing shard metadata, controlling memory allocator fragmentation, and scheduling communication.
4. Combining Sharding Strategies at Scale
At the scale of thousands of cards, the industry commonly adopts a layered strategy:
- Within a high-speed domain (across the accelerators inside one node), apply full sharding. The heaviest communication, namely parameter aggregation and gradient reduction, then runs over high-bandwidth interconnects.
- Between low-speed domains (across nodes), partially replicate parameters. This trades a modest amount of memory for a substantial reduction in cross-node communication.
This is the same idea as Hybrid Sharded Data Parallelism (HSDP): sharding combined with replication. HSDP is often configured separately, in addition to pure FSDP.
IV. Wiring Up the Training Pipeline: From Model Loading to Gradient Synchronization
Open-source ultra-large models typically ship two kinds of assets: weight files in sharded format together with their loading index, and a complete model structure definition. The adaptation effort must establish an accurate mapping between the two and connect the entire training flow into a closed loop.
1. Model Loading: Correct Mapping, On-Demand Allocation
- Map tensors by index: Use the index file to build a “logical parameter name → file → offset range” mapping. Read the tensor slice in each shard directly into the corresponding parameter. This avoids loading the entire model first and then sharding it a second time, which would double peak memory usage.
- Initialize metadata: Build the model skeleton according to the configuration on a meta device. No actual device memory is allocated at this point, which makes it easy to check whether the structure definition matches the weight index.
- Load block by block, lazily: Parameter shards are filled into real memory block by block. For modules that are frozen for now, such as the vision encoder, loading can be staggered or the modules can be offloaded temporarily.
- Convert and verify: Raise clear errors for keys outside the expected set, perform dtype conversion, and validate loading integrity.
Illustrative flow:
def load_sharded_weights(model, checkpoint_dir, fsdp_mesh, dtype=bf16):# 1. Build the skeleton on the meta device; no device memory is usedmodel = build_model_from_config(checkpoint_dir / "config.json", device="meta")# 2. Apply the sharding strategy to get a sharded view of the parametersmodel = fsdp_shard(model, mesh=fsdp_mesh, dtype=dtype)# 3. Read the shard index to build a logical parameter name -> (file, offset) mapindex = load_weight_index(checkpoint_dir / "index.json")# 4. Load block by block; avoids loading the entire checkpoint at oncefor param_name, shard_view in model.sharded_parameters():src_file, offset = index.lookup(param_name)shard_view.copy_(read_tensor_block(src_file, offset, dtype))# 5. Integrity checkverify_checkpoint(model, checkpoint_dir)return model
2. Shard Scheduling: Balancing Memory, Communication, and Stability
- Shard unit size: Units that are too coarse drive up peak memory. Units that are too fine cause All-Gather and Reduce-Scatter call counts to surge. A common choice is a single Transformer block as the unit, with communication bucketing to merge multiple collectives into larger transfers.
- Topology awareness: Align shard groups with the high-speed interconnect domain. Enable shard prefetching in the communication scheduler so that aggregating the next layer’s parameters overlaps with the current layer’s compute.
- Heterogeneous module handling: Frozen modules such as the vision encoder can use a separate sharding strategy. For layers with very few parameters, such as projection layers, their communication can be folded into an adjacent bucket to avoid overhead dominated by small messages.
- Memory and activations: Combine activation recomputation to trade extra compute for memory. Reserve headroom for communication buffers and fragmentation to prevent memory fluctuations during a run.
3. Gradient Synchronization: Hiding Communication Behind Computation
With standard gradient accumulation, synchronization proceeds as follows:
- Forward pass: All-Gather per unit to restore parameters, then release them after computation.
- Backward pass: All-Gather again to restore parameters. Once gradients are computed, Reduce-Scatter to reduce them.
- Optimizer step: After a number of micro-batches have accumulated, each card updates the parameter shard it holds using its optimizer state.
- Next iteration: The parameter shards have been updated and remain consistent across all cards.
Four points matter in practice:
- Overlap: Run communication on a dedicated communication stream so it overlaps with backward computation and the optimizer step.
- Precision: Set reduction precision (e.g., fp32) separately from the communication precision used for parameters and gradients. This balances numerical stability against bandwidth efficiency.
- Synchronization: Use loss scaling, global loss aggregation, and gradient-norm clipping. This prevents shards from applying inconsistent updates because of numerical differences.
- Fault tolerance: Save sharded checkpoints periodically. Support resuming training triggered by step count or elapsed time.
Example code:
def train_step(model, batch, loss_fn, optimizer):# Forward: All-Gather to restore parameters unit by unit; release per policyoutput = model(batch)loss = loss_fn(output, batch["labels"])# Backward: communication stream overlaps with compute stream; reduce grads unit by unitloss.backward()# Gradient clipping: each shard clips locally, then a global reduction gets a unified normgrad_norm = clip_grad_norm_(model.parameters(), max_norm=1.0)# Each card updates the parameter shard it holdsoptimizer.step()optimizer.zero_grad(set_to_none=True)return loss.detach(), grad_norm
4. Closing the Loop: Validating with Checkpoint-Based Resumption
At ultra-large scale, hardware failures and job preemption are hard to avoid. A sharded checkpoint records not only the parameter shard held by each card, but also optimizer states, learning-rate scheduler progress, and random number generator states. Checkpoint-based resumption is the key to closing the “load → schedule → synchronize” loop. Only when the loss curve after resumption aligns with the original training trajectory can you be confident that the entire pipeline is semantically correct.
V. Additional Constraints in Multimodal Scenarios
Compared with text-only models, multimodal training brings some unique challenges:
- Structural heterogeneity: Vision encoders (e.g., ViT-style architectures), projection layers, and the text decoder differ greatly in parameter count. Each needs its own sharding and precision strategy.
- Variable-length inputs: Image resolutions and text lengths vary widely. A common practice is to pack multiple samples into a single sequence and use attention masks to prevent cross-sample interference.
- Long sequences and memory: The number of visual tokens grows quickly with resolution. High-resolution inputs can drive up activation memory sharply, so a combination of techniques such as recomputation and sequence parallelism is needed.
- Load balancing: The multimodal data mix strongly affects convergence speed and per-card compute time. This calls for a stable sampling strategy and global metrics to monitor whether the data mix is taking effect as intended.
VI. Staged Validation: From Correctness to Scaling Efficiency
Adaptation work should not rely on trial and error on the full model. Instead, progress through the following stages, moving on only after each one passes:
- Operator-level validation: Check numerical outputs of the operators involved in the operator library one by one. Focus on reduction, normalization, attention, and mixed-precision operators.
- Single-card convergence validation: Use a small-scale model with a fixed data subset. Compare loss curves and key intermediate tensors against the reference implementation to confirm that the forward and backward logic is consistent.
- Multi-card sharding validation: Enable sharding on a small number of accelerators. Verify that parameters and gradients after All-Gather and Reduce-Scatter match the unsharded baseline. Also check whether memory usage drops roughly linearly as the card count increases.
- Small-scale scaling validation: Plot a parallel efficiency curve to locate communication bottlenecks. Then tune the shard unit size, bucket size, and prefetch depth.
- Full-scale stability validation: Run a thousand-step trial with the full model. Monitor the loss curve, gradient-norm distribution, and memory usage. Confirm there are no abnormal spikes or sustained drift.
VII. Stability and Observability
- Numerical stability measures: bf16 has a wide dynamic range and is generally better suited than half precision for large-model training. If loss spikes occur, consider combining several strategies: skipping anomalous batches, monitoring gradient norms, and tuning hyperparameters.
- Monitoring: Collect throughput (tokens/s), Model FLOPs Utilization (MFU), peak memory, per-collective communication times, and average latency in a unified way. Abnormal fluctuations often point to slow nodes or network issues.
- Logging and alerting: Emit structured training logs and collect them centrally. Combined with common cloud logging, monitoring, and alerting services, this enables timely notifications for training anomalies, process exits, and communication timeouts.
- Job scheduling: Use a container platform and job scheduling system to manage large-scale training jobs. When a node fails, resources are reassembled automatically and training resumes from the latest checkpoint.
VIII. Conclusion
Adapting trillion-parameter multimodal models is, at its core, about building a training pipeline between domestic AI accelerators and mainstream training frameworks that is semantically consistent, performance-controllable, and stable. The core of this approach comes down to four points:
- Start with three ledgers — memory, communication, and compute — to quantify and determine cluster size and parallelism strategy.
- Use native FSDP as the backbone, with topology awareness and sharded replication layered on to control large-scale communication overhead.
- Take “load → schedule → synchronize” as the main line, using checkpoint-based resumption to validate a closed-loop pipeline.
- Rely on staged validation and full-pipeline observability to keep long-running training stable.
For developers and enterprise users, mastering this methodology makes it easier to migrate models of different sizes to domestic compute. It turns compute resources into real model capability.
