Adapting Trillion-Parameter LLM Training on Domestic AI Accelerators: An FSDP2 Deep Dive
A practical guide to adapting trillion-parameter open-source LLMs for training on domestic AI accelerator cards, covering FSDP2 parallelism, multimodal training pipelines, software stack architecture, and engineering best practices for stable, scalable distributed training.
1. Background: Why Training Adaptation Matters for Large Models
In recent years, the parameter scale of open-source large models has kept climbing, from tens of billions to hundreds of billions and even trillions. After a flagship model at the 2.8-trillion-parameter scale was released as open source, how to complete training adaptation across various hardware compute platforms became a question of broad interest to both the community and enterprises. For domestic AI accelerator cards, adaptation is not merely a question of “can it run”—it is a combined test of software stack maturity, parallelism strategy completeness, and engineering pipeline integrity.
“Training adaptation” typically spans three levels:
- Runnable: the model’s operators can be correctly parsed and executed on the hardware;
- Trainable: core training stages such as backpropagation, optimizer updates, and gradient synchronization run stably;
- Scalable: good parallel scaling efficiency at multi-card and multi-node scale.
Only when all three levels are achieved can training adaptation be considered genuinely complete.
2. Hardware and Software Stack: The Adaptation Foundation
2.1 The Role of Unified Training-and-Inference Cards
Mainstream domestic AI accelerators are generally evolving toward “unified training and inference.” Taking a typical flagship unified training-inference card as an example, such products usually offer the following common capabilities:
- High memory capacity and bandwidth: even after quantization and sharding, a trillion-parameter model still requires each card to hold substantial parameters, gradients, and optimizer states. Memory capacity and bandwidth directly determine the upper bound of trainable model size;
- High-speed interconnects: high-speed peer-to-peer interconnects within a node (NVLink-like architecture) and high-speed Ethernet or IB-like networks across nodes support large-scale collective communication;
- Proprietary instruction sets and programming models: hardware vendors typically provide a CUDA-like parallel programming model as the foundation for operator development and framework adaptation.
2.2 Layered Software Stack Architecture
The software stack for domestic accelerators generally follows a layered design:
Application layer: training frameworks / inference engines / business applicationsFramework layer: distributed training strategies, operator dispatch, automatic differentiationRuntime layer: graph compilation, memory management, stream schedulingDriver layer: device drivers, collective communication librariesHardware layer: AI accelerator cards, high-speed interconnects
The core work of training adaptation sits between the framework layer and the runtime layer: ensuring every operator in the model definition has a corresponding high-performance implementation, and ensuring distributed communication primitives work efficiently on the proprietary interconnect.
3. FSDP2: The Parallelism Foundation for Trillion-Parameter Training
3.1 Why Fully Sharded Data Parallelism
For trillion-parameter models, traditional data parallelism (DP) requires every card to hold a full model copy—completely beyond memory capacity. Fully Sharded Data Parallel (FSDP) shards parameters, gradients, and optimizer states across the data-parallel group, temporarily gathering them only when needed for computation, dramatically reducing per-card memory usage.
FSDP2 is an evolved version of this technique. Its core improvement is managing shards based on per-parameter sharding rather than flattening, which brings several advantages:
- More flexible sharding granularity: different modules can use different sharding strategies—for example, full sharding for huge FFN layers, and replication or partial sharding for smaller layers;
- Better mixed-precision support: finer-grained parameter precision management makes it easier to separate bf16 parameters from fp32 master weights;
- Lower memory fragmentation: avoiding the large contiguous memory allocations caused by flattening mitigates fragmentation issues.
3.2 The Value of a Native Training Path
In the adaptation process, “building a native FSDP2 multimodal training path” is a key statement. “Native” means not relying on intermediate translation layers or compatibility patches, but implementing the sharding strategy directly at the framework level. Its value lies in:
- Communication efficiency: collective communication directly connects to the proprietary communication library, reducing relay overhead;
- Stability: avoids subtle problems introduced by compatibility layers, such as incorrectly synchronized gradients or inconsistent shard states;
- Maintainability: future models and new parallelism strategies can be built quickly on the same native path.
3.3 Illustrative Code Structure
The following pseudocode shows FSDP2-style sharding configuration logic (for illustration only, not a specific product interface):
from torch.distributed.fsdp import fully_shard, MixedPrecisionPolicy# Apply full sharding at module granularityfor block in model.transformer_blocks:fully_shard(block,sharding_strategy=ShardingStrategy.FULL_SHARD,mp_policy=MixedPrecisionPolicy(param_dtype=torch.bfloat16,reduce_dtype=torch.float32,),)fully_shard(model)# Shard scheduling: handled automatically by the framework in the training loop# all-gather (forward) -> compute -> all-gather (backward) -> reduce-scatter (gradients)
The runtime behavior behind this logic: before forward computation, the current layer’s parameters are gathered via all-gather and non-local shards are released; they are gathered again during backward; finally, gradient shard synchronization is completed via reduce-scatter. This is the micro-level embodiment of the complete pipeline “from model loading and shard scheduling to gradient synchronization.”
4. Completing the Multimodal Training Pipeline
4.1 What Makes Multimodal Training Special
Modern flagship open-source models mostly use multimodal architectures, typically composed of a vision encoder, a modality alignment module, and a large language model backbone. Adaptation challenges for the multimodal training pipeline include:
- Dense heterogeneous operators: the vision side involves many convolutions, attention variants, and interpolation operators, requiring systematic verification of operator coverage and numerical precision;
- Complex data pipelines: images, video, and text are loaded in mixed batches, and CPU preprocessing overhead can become a bottleneck, requiring asynchronous loading and GPU-based preprocessing optimization;
- Gradient scale disparity: gradient distributions differ significantly across modality branches, requiring careful gradient clipping and loss weighting strategies.
4.2 Four Key Stages of the Full Pipeline
A complete training adaptation is usually verified stage by stage:
- Model loading: verify compatible parsing of weight formats, sharded loading, and metadata integrity, ensuring ultra-large checkpoints can be loaded in a streaming, parallel fashion;
- Shard scheduling: verify correct splitting and gathering timing of FSDP2 shards across parallel groups (data parallel, tensor parallel, pipeline parallel);
- Forward and backward computation: compare loss and gradient values layer by layer, aligning precision against a reference implementation (such as CPU or a mature GPU platform), generally requiring relative error within an acceptable threshold;
- Gradient synchronization and optimizer updates: verify gradient consistency after reduce-scatter synchronization and the correctness of master-weight updates under mixed precision.
A silent error at any stage (such as a missed gradient synchronization) will cause abnormal training loss or failure to converge, so end-to-end verification matters more than single-point performance optimization.
5. Engineering Best Practices
Based on common industry practice, when adapting large model training on domestic compute platforms, consider the following:
- Operator coverage first: before launching large-scale training, perform a static graph traversal, compile a list of missing operators, and fill the gaps as a priority;
- Small-scale convergence validation: first verify that the loss curve matches a reference platform using a reduced configuration (fewer layers, less data), then scale up to full size;
- Communication-computation overlap: configure prefetching and asynchronous communication so that all-gather/reduce-scatter overlaps with computation to improve MFU;
- Fault tolerance and resumable training: trillion-parameter training runs are long, so asynchronous checkpoint saving and automatic fault recovery are essential;
- Observability: use monitoring, alerting, and logging capabilities to track memory, communication bandwidth, and loss curves in real time for fast anomaly diagnosis.
6. Conclusion
Completing training adaptation for a trillion-parameter open-source model on domestic AI accelerators signals that the domestic software and hardware ecosystem is rapidly maturing its engineering capabilities in the large model era. Behind it lies a full systems engineering effort spanning low-level operators, parallelism strategies, and training pipeline validation. For teams planning large model training on heterogeneous compute, understanding parallelism techniques such as FSDP2, prioritizing end-to-end correctness verification, and building training infrastructure on general-purpose cloud storage, monitoring, and container platforms are the essential path to stable, efficient training.
