Training Trillion-Parameter Large Models on Domestic AI Accelerators: A Practical Adaptation Guide
As large language models scale toward trillions of parameters, adapting training to fit them becomes a systems engineering challenge spanning hardware, the software stack, and parallelism strategy. This article explains how to estimate memory usage in mixed-precision training, why a single card cannot hold a trillion-parameter model, and how Fully Sharded Data Parallel (FSDP) shards parameters, gradients, and optimizer states across many cards. It walks through the three critical stages of the training pipeline—model loading, shard scheduling, and gradient synchronization—alongside the special engineering considerations of multimodal training, the co-optimization of the software stack with domestic AI accelerators, and practical recommendations for developers. Readers will gain a clear understanding of the underlying mechanisms and techniques needed to take large-model training from merely running to running stably and running well.
1. The Trillion-Parameter Era: Why Training Adaptation Has Become a Central Problem
As large language models scale from hundreds of billions to trillions of parameters, the compute, memory, and communication resources required for a single training run grow exponentially. The industry has converged on one conclusion: once parameter count enters the trillion range, traditional single-machine training or naive data parallelism breaks down entirely—a single accelerator card cannot hold the full model’s parameters, gradients, and optimizer states. As a result, “training adaptation” is no longer a simple framework port; it is a systems engineering effort that spans hardware, the software stack, and parallelism strategy.
2. The Memory Bottleneck: Understanding the Core Contradiction
To grasp why training adaptation is difficult, start with a basic memory-usage estimate. Take mixed-precision training as an example: memory consumption is dominated by four components—model parameters, gradients, optimizer states (such as momentum and variance terms), and activations produced during the forward pass.
For a model with P parameters, just the parameters, gradients, and optimizer states typically require roughly 16×P bytes of memory (accounting for FP32 master weights and optimizer states). If P reaches a trillion (10¹²), these three components alone approach 16TB of memory, far exceeding the physical capacity of any single card.
Memory usage ≈ parameters + gradients + optimizer states + activations≈ (2 + 2 + 12) × P bytes (in mixed precision, parameters/gradients stored in BF16, optimizer states in FP32)
This contradiction defines the first-order problem of training adaptation: how to partition a model that cannot fit on a single card across hundreds or thousands of cards, while preserving numerical correctness and efficient communication.
3. Fully Sharded Data Parallel: The Core Path to a Breakthrough
Fully Sharded Data Parallel (FSDP) is the mainstream technical approach for addressing this contradiction. Its core idea: on top of data parallelism, further shard the model parameters, gradients, and optimizer states along the parameter dimension and distribute them across compute nodes, rather than keeping a full replica of the model on every card as in traditional data parallelism.
Its working mechanism can be broken into three phases:
- Forward pass: all-gather the full parameters of the current layer from each node on demand, then release them immediately after computation—turning “parameters resident in memory” into “parameters flowing on demand.”
- Backward pass: compute gradients layer by layer and reduce-scatter them, so each card keeps only the gradients for the parameter shard it owns.
- Optimizer step: each card performs the optimizer update only on the parameter shard it holds, achieving sharded storage of optimizer states.
This “zero redundancy” strategy yields a direct memory benefit: per-card memory usage is roughly inversely proportional to the total number of cards. A schematic pseudocode expresses the wrapping approach:
# Illustrative code: model wrapping approach for Fully Sharded Data Parallel (pseudo-code, structure only)model = FullyShardedDataParallel(model,sharding_strategy = "FULL_SHARD", # Shard parameters, gradients, and optimizer states entirelyauto_wrap_policy = transformer_layer, # Auto-shard at Transformer layer granularitymixed_precision = "bf16", # Mixed precision to reduce memory and bandwidth pressure)
It is worth stressing that finer sharding granularity is not always better. Wrapping at the Transformer layer as a unit (auto-wrap) is an engineering compromise: too coarse a granularity weakens the memory optimization, while too fine a granularity introduces heavy small-operator communication overhead. In practice, this boundary usually requires repeated tuning based on the model’s structural characteristics.
4. Three Key Stages of the Full Training Pipeline
To get a native FSDP training path to run end to end, you must connect the complete loop from model loading to gradient synchronization; a break at any stage causes training to stall or produce anomalous results.
1. Model Loading
A trillion-parameter model cannot be loaded into a single card’s memory as one file. The adaptation typically uses a “metadata first + layer-wise loading” strategy: first construct an empty shell of the model in a low-memory environment (recording only the shapes and types of layers and parameters), then stream-load the real weights according to the sharding rules and assign them to the corresponding nodes. This approach avoids a memory peak explosion during loading and leaves room for weight-format conversion (for example, converting from a general checkpoint format to a sharded format).
2. Shard Scheduling
Shard scheduling decides “which layer’s parameters go on which card, and when they are all-gathered or released.” It is tightly coupled with the compute graph and pipeline partitioning. Sound scheduling must balance three goals: memory balance (avoiding individual nodes becoming bottlenecks), communication overlap (running parameter gathering in parallel with computation as much as possible to hide latency), and load balance (avoiding nodes waiting out of sync). In cross-node scenarios, you also need to account for bandwidth topology, keeping high-frequency communication within the same node’s inter-card links where possible.
3. Gradient Synchronization
Gradient synchronization must ensure that all nodes obtain a consistent gradient view after backpropagation, while preventing numerical overflow or precision loss under mixed precision. In implementation, reduce-scatter is typically used to shard-reduce the gradients, combined with gradient accumulation and gradient clipping to stabilize training. If the model combines tensor parallelism, pipeline parallelism, and data parallelism (i.e., multi-dimensional parallelism), gradient synchronization must also coordinate with the communication groups of each dimension to avoid communication deadlocks and redundant synchronization.
5. Special Engineering Considerations for Multimodal Training
Compared with text-only models, multimodal models (which handle text, images, audio/video, and other inputs simultaneously) face additional engineering constraints in training adaptation:
- Heterogeneous tensors and memory peaks: the tensor shapes of different modality encoding branches vary widely, and memory usage fluctuates sharply during the forward pass, requiring finer control over activation recomputation and batch organization.
- Multi-branch parallel partitioning: submodules such as the text tower and vision tower have imbalanced parameter counts, and a simple whole-model partition easily causes load skew, so differentiated partitioning and wrapping strategies usually need to be designed for different submodules.
- Data pipelines and preprocessing: decoding, alignment, and augmentation of multimodal data can become throughput bottlenecks and must be sufficiently overlapped with computation to avoid GPUs waiting on data.
6. Co-Optimization of the Software Stack and Hardware
The essence of training adaptation is to precisely align the abstract semantics of a general-purpose training framework with the underlying capabilities of domestic AI accelerators. This requires the software stack to complete adaptation at several levels: at the operator level, it must cover all computation and communication operators needed for forward and backward passes and guarantee numerical consistency; at the communication level, it must interface with inter-card high-speed interconnects and collective communication libraries so that operations such as all-gather and reduce-scatter execute efficiently; and at the driver and runtime level, it must mask hardware differences and provide a stable execution environment upward.
In practice, this kind of training typically runs on elastic cloud compute, using container platforms for environment consistency, monitoring and alerting systems to observe memory and throughput, and logging services to track abnormal nodes—these general cloud capabilities together support the stable scheduling and rapid troubleshooting of large-scale distributed training jobs.
7. Engineering Recommendations for Developers
Drawing on the points above, here are a few actionable recommendations:
- Estimate first, then shard: before starting, make a quantitative estimate of memory and communication volume, and use it to determine the required card count and parallelism combination, avoiding blind resource stacking.
- Start from conservative parallelism: first verify that FSDP can run a small-scale version, then gradually introduce tensor parallelism and pipeline parallelism to handle more extreme scales.
- Watch numerical consistency: under mixed precision, always enable loss scaling and gradient clipping, and apply precision fallback to critical layers to prevent training divergence.
- Overlap communication with computation: sound shard scheduling and pipeline-bubble control often improve effective compute utilization more than simply adding cards.
- Build observability: continuously monitoring memory, throughput, communication share, and node health is the prerequisite for long training runs to avoid silent failures.
8. Conclusion
Training adaptation for trillion-parameter large models is a concentrated expression of the synergy among hardware compute, parallelism strategy, and engineering capability. FSDP fundamentally resolves the contradiction of insufficient single-card memory through sharded storage of parameters, gradients, and optimizer states; and connecting the three stages of model loading, shard scheduling, and gradient synchronization determines whether this training path can truly converge stably. For teams that want to conduct large-model training and R&D on domestic compute platforms, understanding these underlying mechanisms and mastering the combination techniques of multi-dimensional parallelism is the key step from “being able to run” to “running stably and running well.”
