Trillion-Parameter Multimodal Training on Domestic AI Accelerators: Key Adaptation Points
This article outlines the practical adaptation work required to run trillion-parameter multimodal training on domestic AI accelerators. It follows the full training pipeline: hardware and software stack checks, FSDP2 sharding and memory accounting, distributed model loading, shard scheduling and communication overlap, gradient synchronization, checkpoint resume, and staged validation. The focus is on prerequisites, reproducibility, and bottleneck diagnosis rather than peak compute claims. Readers get a checklist for validating single-card, single-node multi-card, multi-node, and resume scenarios, along with scope limits for applying the method to other clusters.
1. Why Start With the Training Pipeline
For ultra-large model training, the hard part is often not peak compute but whether the entire pipeline can close the loop. Here, the pipeline means model weight loading, parameter sharding, forward computation, backward gradient synchronization, and checkpoint resume after failures. If any stage is broken, later performance numbers cannot be reproduced.
Multimodal models add another layer of complexity. The vision encoder, language model backbone, and cross-modal alignment modules differ greatly in parameter scale and activation characteristics, so a single sharding strategy can hardly serve all three at once. Adaptation work should therefore answer two questions first: what prerequisites does each stage need, and how should issues be located when they occur.
2. Hardware and Software Stack: The Starting Point for Adaptation
Most training-oriented AI accelerators use a unified training/inference design, so the same hardware can be used for both inference deployment and training. During adaptation, three capabilities usually need to be confirmed: whether memory capacity and bandwidth are sufficient to hold large tensors, whether inter-card interconnect can support low-latency collective communication, and whether mixed-precision compute units support the selected FP32, BF16, or FP16 formats.
The software stack generally has three layers. The first is the compiler and operator library, which maps operators such as matrix multiplication and attention to hardware instructions. The second is the communication library, which implements collective communication primitives such as All-Reduce, All-Gather, and Reduce-Scatter. The third is the adaptation layer of the distributed training framework. On a domestic software stack, the work usually concentrates on the third layer: enabling the framework’s distributed strategies to recognize the new hardware’s communication capabilities and memory characteristics.
3. FSDP2 Sharding: How to Calculate the Memory Ledger
Fully Sharded Data Parallel (FSDP2) is the main path in this adaptation. It shards parameters, gradients, and optimizer states across all devices. When computing a layer, the framework temporarily retrieves the full parameters of that layer through All-Gather and releases them immediately after computation. During backpropagation, gradients are reduced directly to their respective shards through Reduce-Scatter.
Memory estimation should first clarify how many bytes each parameter occupies. Taking the Adam optimizer commonly used in mixed-precision training as an example, the optimizer-related state for each parameter includes the FP32 master weight, the first moment m, and the second moment v, totaling about 12 bytes. Of this, m and v together account for about 8 bytes. Excluding activations, with 1 trillion parameters, this state alone requires about 12 TB of memory. This scale shows that a single card cannot hold it, so sharding is mandatory.
Compared with traditional data parallelism plus pipeline parallelism, FSDP2 does not require manual pipeline stage partitioning, so there is no pipeline bubble problem. Sharding granularity is managed by the framework, and user code changes are relatively small.
Sharding a multimodal model requires layered handling. Three practices are common. First, image and text sequences need to be unified into variable-length tensors, with bucketing to reduce padding waste. Second, different modules should use different sharding granularities. If small modules are All-Gathered frequently, communication volume will be amplified, so coarser granularity can be appropriate. Third, gradients from the vision branch and language branch must merge correctly during backpropagation, which should be verified through numerical comparison.
The following is illustrative logic for sharding configuration, not directly runnable code. Actual interfaces and parameters are subject to the documentation of the framework version in use.
# Illustrative logic: set FSDP2 sharding granularity by module for a multimodal modelfor name, module in model.named_children():if is_vision_encoder(name):wrap_fsdp(module, shard_granularity="coarse")elif is_language_backbone(name):wrap_fsdp(module, shard_granularity="layer", offload_optimizer=True)else:wrap_fsdp(module, shard_granularity="layer")
4. Model Loading: Decide Who Reads Which Shard First
Loading a trillion-parameter model is itself a distributed problem. A common approach is to first build a model skeleton on CPU without real weights, then let each rank read the parameter slice that belongs to it according to the sharding rules.
The prerequisites for this step are specific. First is storage bandwidth. If all ranks read from the same storage at the same time, loading may take hours, so this should be measured in advance. Second is the sharded file format. A sharded format with an index file is preferable, so each parameter can be located in a specific file. Third, the rank-to-shard mapping must be deterministic; the same configuration should produce the same mapping in every startup. Fourth is weight validation, including file checksums, shape checks, and data type conversion. For example, when converting FP32 weights to BF16, the conversion range should be recorded. Fifth is a failure retry mechanism; when a single file read fails, only that file should be retried rather than restarting the whole job.
Without these conditions, the loading step cannot be reproduced, and problems often appear only on the second startup.
5. Shard Scheduling: How to Overlap Communication and Computation
Shard scheduling determines whether communication can be hidden by computation. Three optimization points are most commonly used.
The first is prefetching. While computing layer N in the forward pass, asynchronously initiate All-Gather for layer N+1 parameters in the background. Prefetching requires extra memory buffers, and excessive prefetch depth can raise peak memory.
The second is communication hiding under gradient accumulation. Overlapping Reduce-Scatter with the forward computation of the next micro-batch can reduce waiting time. Its effect depends on micro-batch size; if the micro-batch is too small, computation time is insufficient to cover communication.
The third is timely memory release. Release aggregated parameters immediately after use to prevent peak memory from exceeding the limit.
During tuning, three metrics should be observed: communication wait ratio, peak memory, and micro-batch size. Looking only at throughput cannot tell whether the bottleneck is in computation or communication.
6. Gradient Synchronization: Trade-offs Between Efficiency and Numerical Stability
The efficiency of cross-node gradient synchronization directly affects scaling efficiency. Three common engineering practices are used.
Gradient bucketing merges multiple small tensors into communication buckets to improve bandwidth utilization. Bucket size needs to be adjusted according to network conditions. Overlapped reduction allows backpropagation and gradient communication to proceed at the same time.
Low-precision or compressed communication can reduce cross-node traffic, but it introduces numerical error. It is only suitable for scenarios with higher error tolerance and requires a fallback plan. One approach is to monitor the loss curve; if abnormal fluctuations appear, switch back to FP32 communication immediately and record the step at which the switch occurred for later analysis.
7. Checkpoint Resume: Ensuring Training Can Recover
Training at the 10,000-accelerator scale will inevitably encounter hardware failures. The basic mechanisms for ensuring completion of long-cycle training include asynchronous checkpoint saving, periodic health probing, faulty node isolation, and recovery from the latest checkpoint.
The sharded structure of FSDP2 requires checkpoints to be saved by shard as well. During recovery, each rank loads only its local slice, and recovery time is significantly shorter than loading full weights.
Saving successfully is not enough. After recovery, training continuity should be verified. The most direct check is to compare loss values for several steps before and after the recovery point. If an obvious jump appears, optimizer state or random number state was not fully restored.
8. Staged Validation Checklist
Adaptation work should proceed in the following order, with each stage passing before moving to the next.
| Stage | Validation Content | Pass Criteria |
|---|---|---|
| Single-card operators | Numerics and performance of core operators | Error versus reference implementation within an acceptable range; performance meets expectations |
| Single-node multi-card | Collective communication and sharding logic | Parameters consistent across ranks; communication wait ratio stable |
| Multi-node scaling | Cross-node communication and gradient synchronization | Loss curve broadly consistent with reference implementation; scaling efficiency measurable |
| Checkpoint resume | Checkpoint saving and restoration | Loss continuous after recovery; training step and random state correct |
Numerical consistency is the common red line across all stages. The mixed-precision strategy and loss scaling logic must be aligned with the reference implementation.
9. Applicable Scope and Limitations
The methods described here come from adaptation practice under specific hardware, software versions, and model scales. Different cluster network topologies, storage performance, and framework versions will change the conclusions. Before applying them, readers should complete single-card and single-node validation in their own environment, then extend to multiple nodes.
Getting the training pipeline to run only shows that the basic flow is usable. Long-term stability, convergence under different data distributions, and scaling efficiency at larger scale still require validation in more scenarios.
