Training Trillion-Parameter Open-Source LLMs on Domestic Compute: A Practical Guide to FSDP2 Adaptation
As open-source large language models scale into the trillion-parameter era with Mixture-of-Experts architectures, training infrastructure faces unprecedented challenges in memory capacity, communication overhead, and hardware-software co-design. This article examines a real-world adaptation practice in which a multi-trillion-parameter open-source flagship model was trained on domestic AI accelerators using a native FSDP2-based multimodal training pipeline. It systematically breaks down the key technical problems involved: why Fully Sharded Data Parallel is essential at this scale, how FSDP2's per-parameter sharding works and synergizes with expert parallelism, the end-to-end adaptation chain from weight loading and communication optimization to gradient synchronization and numerical stability, software-stack and hardware co-optimization, and engineering best practices for teams migrating ultra-large open-source models to their own compute environments.
Training Trillion-Parameter Open-Source Models on Domestic Compute: A Practical Guide to FSDP2 Adaptation
1. Background: Open-Source Models Enter the Trillion-Parameter Era
In recent years, the parameter counts of open-source large language models have climbed steadily—from tens of billions, to hundreds of billions, and now to multi-trillion-parameter Mixture-of-Experts (MoE) architectures. This leap in scale brings significant gains in model capability, but it also poses unprecedented challenges for training infrastructure: the memory of a single accelerator card is nowhere near enough to hold a complete model; traditional data parallelism collapses under communication overhead and memory redundancy; and co-optimization between the training framework and the underlying hardware becomes the decisive factor.
Recently, a team in the industry open-sourced a flagship model with parameters at the multi-trillion scale, and a domestic AI compute hardware vendor completed training adaptation for this model on its training-and-inference accelerator cards and self-developed software stack. The team built a native Fully Sharded Data Parallel (FSDP2) multimodal training path, connecting the complete training chain from model loading and shard scheduling to gradient synchronization. This practice is a valuable reference: it demonstrates the feasibility of training ultra-large open-source models on a domestic compute foundation, and it offers developers a reproducible engineering methodology. This article uses it as an entry point to systematically dissect the key technical problems in adapting trillion-parameter model training.
2. Why Trillion-Parameter Models Require Fully Sharded Data Parallelism
2.1 The Memory Wall: The Fundamental Limit of Traditional Data Parallelism
In classic Distributed Data Parallel (DDP), every accelerator card must hold a complete copy of the model parameters, gradients, and optimizer states. For a multi-trillion-parameter model, even with mixed-precision training, the parameters alone require several terabytes of memory; adding gradients and optimizer states (which typically multiply the footprint several times over) pushes single-card memory requirements into impossible territory. Clearly, the “full replica on every card” approach fails completely at the trillion-parameter scale.
2.2 The Sharding Philosophy of FSDP2
The core idea of Fully Sharded Data Parallel is to partition model parameters, gradients, and optimizer states along the data-parallel dimension across all participating accelerators, so that each card holds only 1/N of the total. When forward or backward computation needs the complete parameters of a given layer, they are temporarily gathered via the all-gather communication primitive and released immediately after computation; gradients are reduced directly in sharded form via reduce-scatter. As a result, per-card memory usage drops to roughly 1/N of the full amount, making it possible to train trillion-parameter models on clusters of hundreds or thousands of accelerators.
The second-generation implementation (commonly called FSDP2) improves on the earlier version in a key way: it manages sharding at per-parameter granularity instead of flattening by module. This design brings three benefits:
- More flexible parameter grouping: Different layers and different experts can adopt differentiated sharding strategies, which is especially well suited to MoE architectures where dense layers and expert layers coexist.
- More efficient communication overlap: All-gather operations can be scheduled in a streaming fashion alongside computation, enabling fine-grained pipelined overlap of communication and computation.
- Lower memory fragmentation: The lifecycle of sharded tensors is more controllable, yielding better memory stability over long training runs.
2.3 Synergy with MoE Architectures
Multi-trillion-parameter open-source flagship models generally adopt Mixture-of-Experts architectures, in which each token activates only a subset of expert sub-networks. Training adaptation requires combining Expert Parallelism (EP) with Data Parallelism (DP): expert parameters are partitioned across devices by group, and tokens are routed to their assigned experts via all-to-all communication. FSDP2’s per-parameter sharding mechanism naturally composes with expert parallelism—the dense parts use standard sharding, while the expert parts are further sharded within expert-parallel groups—striking a balance between memory footprint and communication overhead.
3. Dissecting the End-to-End Training Adaptation Chain
“Completing training adaptation” is not a single action but an end-to-end chain spanning the software stack to cluster scheduling. It can be broken down into four key stages.
3.1 Model Loading and Weight Conversion
The weight formats and sharding layouts published with open-source models often do not match the sharding layout of the target training framework. The first step of adaptation is to build an efficient weight-loading pipeline:
- Streaming loading: For terabyte-scale weight files, lazy loading or memory mapping is essential to avoid reading everything into host memory at once and triggering OOM.
- Shard remapping: Tensors in the checkpoint must be re-partitioned according to the target parallel strategy. Common approaches include loading full shards first and re-sharding on-device, or reading directly in the target layout during loading.
- Precision and format verification: Confirm the data type of the weights (e.g., bf16), the quantization scheme (if quantized weights are released, verify whether they should be dequantized for training or at what precision they participate in computation), and that details such as normalization layers and rotary position embeddings are configured consistently with the inference side.
3.2 Shard Scheduling and Communication Optimization
Once the sharding strategy is set, the engineering focus shifts to communication efficiency. On large-scale clusters, training throughput is often bound by collective communication overhead. Typical optimizations include:
- Overlapping communication with computation: Prefetch the parameter shards needed by the next layer while the current layer computes, hiding all-gather behind computation.
- Gradient bucketed reduction: Merge the reduce-scatter of many small tensors into larger communication blocks to improve network bandwidth utilization.
- Topology-aware scheduling: Based on the bandwidth differences between high-speed intra-node interconnects and inter-node networks, map sharding groups and parallel groups sensibly so that high-frequency communication stays on high-speed links.
- Layered parallel composition: In practice, FSDP is combined with Tensor Parallelism (TP), Pipeline Parallelism (PP), and Expert Parallelism (EP). For trillion-parameter models, a common configuration is TP within nodes and PP plus DP across nodes, matching the network bandwidth available at each level of the hierarchy.
3.3 Gradient Synchronization and Numerical Stability
In ultra-large-scale training, gradient synchronization is not only a communication problem but also a numerical correctness problem. Adaptation work must focus on verifying:
- Correctness of gradient accumulation: With an extremely large global batch, multi-step gradient accumulation is usually required; sharded gradients must not be reduced prematurely or reduced twice during accumulation.
- Mixed-precision strategy: The precision configuration of master weights, gradients, and optimizer states (e.g., fp32 master weights + bf16 computation) must match the hardware’s numerical unit capabilities, with loss scaling to prevent gradient underflow.
- Loss spike monitoring: Occasional loss spikes are common in trillion-parameter training. Robust monitoring and alerting are needed to observe gradient norms and loss curves in real time, with automatic rollback to the most recent healthy checkpoint when necessary.
3.4 The Multimodal Training Path
New-generation flagship open-source models typically have multimodal capabilities, so training adaptation must also cover heterogeneous modules such as vision encoders. The additional challenge of multimodal training is that vision encoders and language models differ enormously in parameter scale and compute density, so a uniform sharding strategy leads to load imbalance. A sensible approach is to manage the parallel strategies of the vision tower and the language model separately, inserting the necessary communication and synchronization points at the feature-alignment boundary, and making the image preprocessing pipeline asynchronous and pipelined so that data feeding does not become the bottleneck.
4. Software Stack and Hardware Co-Design: The Deep Water of Adaptation
Native operators and communication libraries in training frameworks are usually optimized for a specific hardware ecosystem. Completing adaptation on heterogeneous compute requires substantial work at the software-stack level:
- Operator coverage and equivalence verification: Confirm that all operators required by the model—especially attention variants, MoE routing, and normalization operators—are correctly implemented on the target software stack, and align numerical precision against a reference implementation through unit tests.
- Fused operators and compilation optimization: Use graph compilation and operator fusion to reduce memory reads/writes and improve compute unit utilization; the throughput impact is often multi-fold.
- Communication library tuning: Adjust parameters such as chunk sizes and the number of concurrent streams in collective communication to match the characteristics of the underlying interconnect.
- Checkpointing and fault tolerance: In ultra-large-scale training, hardware failures are the norm rather than the exception. Support asynchronous, incremental checkpoint saving, write checkpoints to persistent media such as object storage, and enable fast training recovery after failures.
5. Best Practices for Engineering Implementation
For teams planning to migrate ultra-large open-source models to their own compute environments for training, the following path is recommended:
- Start small, then scale: First run the complete chain (loading, sharding, synchronization, saving) on a smaller version of the model; verify numerical correctness before scaling to full size.
- Establish a benchmark comparison: Train a few steps with a small amount of data on a small cluster and compare the loss curve against the official or reference implementation; discrepancies should be within an explainable range.
- Layered stress testing: Stress-test single-card compute, intra-node communication, and inter-node communication separately, locate the bottleneck, and then tune the system as a whole.
- Comprehensive observability: Training metrics, memory headroom, communication latency, and hardware health should all feed into a unified logging service and monitoring/alerting system.
- Balance elasticity and cost: Use a container platform to orchestrate training jobs, combining job queuing with checkpoint-resume capability so that critical jobs keep moving forward when compute is tight.
6. Conclusion
Training adaptation for trillion-parameter open-source models is, at its core, a systematic engineering validation across four layers: framework, software stack, hardware, and cluster. Fully sharded parallelism represented by FSDP2—combined with refined communication scheduling, numerical-stability safeguards, and fault-tolerance mechanisms—makes it a reality to train frontier open-source models on a domestic AI compute foundation. As open-source models continue to grow in scale and multimodal capabilities continue to converge, this end-to-end adaptation capability will become a core competency for enterprises building sovereign AI infrastructure, and it lays a solid foundation for downstream domain-specific fine-tuning and inference deployment.
