Trillion-Parameter Training on Domestic AI Accelerators: FSDP Adaptation and Practice Guide
A practical guide to training trillion-parameter large models on domestically developed AI accelerators with Fully Sharded Data Parallel (FSDP). It explains why this kind of training is a systems engineering problem, how to estimate memory needs beyond parameter storage, and what software stack and parallelism checks to complete before scaling out. It then walks through FSDP in detail, from its benefits and operation sequence to the full training pipeline, covering model loading, shard-to-device mapping, activation management, and gradient synchronization. It also addresses multimodal training, performance tuning, fault recovery, and troubleshooting. Finally, it compares FSDP with ZeRO-3, tensor parallelism, pipeline parallelism, and expert parallelism, so you can choose an approach that fits your model size, interconnect bandwidth, and memory budget.
1. Key Takeaway: Trillion-Parameter Training Is a Systems Engineering Problem
What makes or breaks trillion-parameter model training is rarely a single algorithmic breakthrough. It is how well the hardware, software stack, and parallelism strategy work together. Once the parameter count reaches the trillions, no single accelerator can hold the full model state, so training has to run in a distributed, multi-node, multi-GPU setup.
Domestic AI accelerators do provide the base compute needed for large model training. The real engineering challenge, though, is turning “the hardware works” into “the model can be trained, training can scale, and failures can be recovered from.”
Teams starting an adaptation project should focus on three questions first:
- Do we have enough memory? Single-card compute is not the only thing that matters.
- Have the operators, frameworks, and communication libraries been version-aligned?
- Does the training pipeline support checkpointing, monitoring, and fault recovery?
2. Memory Estimation: A Trillion Parameters Is Not “Tens of TB”
Suppose a trillion-parameter model stores its weights in FP16 or BF16. Each parameter then takes about 2 bytes, so the parameters alone need roughly:
1,000,000,000,000 × 2 bytes ≈ 2 TB
Training uses far more memory than the weights alone, though. Device memory also holds gradients, optimizer states, activations, communication buffers, and temporary tensors. With a common Adam-family optimizer, parameters, gradients, and optimizer states together typically push the model state into the multi-TB range, anywhere from a few TB to well over ten TB. Long sequences, large batches, or large amounts of intermediate activations can push total memory use above 8–16 TB, sometimes higher still.
A realistic memory estimate therefore has to account for:
- Precision: FP16, BF16, FP32
- Optimizer: SGD, Adam, AdamW, Adafactor, and others
- Parallelism strategy: FSDP, ZeRO-3, tensor parallelism, pipeline parallelism
- Sequence length and batch size
- Memory-saving features: activation recomputation and optimizer state offloading
- Platform differences: drivers, framework versions, and communication library implementations on domestic accelerators
3. Hardware–Software Co-Design: Two Adaptation Tracks
3.1 Adapting the Low-Level Operators and Software Stack
Large models rely on a wide range of operators: matrix multiplication, attention, normalization, activations, loss functions, and more. To train on domestic accelerators, these operators must match the semantics of mainstream frameworks and meet both accuracy and performance requirements. Common problems include:
- Missing operators or incomplete operator coverage
- Numerical instability under mixed precision
- Operator performance below expectations
- Framework versions that do not match driver versions
- Communication libraries or collective communication primitives that are incompatible
Adaptation teams should work from a basic acceptance checklist:
- Operator coverage: Are all critical operators supported?
- Accuracy tests: Do the forward pass, backward pass, and loss curve behave correctly?
- Communication bandwidth tests: Do
all-gather,reduce-scatter, andall-reducerun stably? - Training throughput baseline: Does throughput in tokens/s or samples/s meet expectations?
- Version matrix: Are driver, firmware, framework, communication library, and model code versions pinned?
3.2 Adapting the Parallel Training Strategy
Once the hardware supports the basic operators, the next step is deciding how to split the model, the data, and the optimizer state across devices. Common options on domestic platforms include:
- Fully Sharded Data Parallel (FSDP)
- ZeRO-3
- Tensor parallelism
- Pipeline parallelism
- Expert parallelism
- CPU/NVMe offloading
A “train-and-serve on one stack” setup adds another requirement. The same infrastructure has to handle the high memory use and heavy communication of training, as well as the low latency and stability demands of inference. Acceptance testing therefore cannot stop at “does it run?” It also needs to cover training throughput, peak memory usage, communication efficiency, and long-term stability.
4. FSDP: A Critical Path for Trillion-Parameter Training
Fully Sharded Data Parallel (FSDP) takes a simple idea: instead of keeping the full model parameters, gradients, and optimizer states on every device, it splits them across multiple devices. Each device holds only a fraction of each shard. When a forward or backward pass needs a parameter, FSDP gathers the required shards on demand.
4.1 Main Benefits
- Lower per-device memory pressure: Each device holds only part of the model parameters, gradients, and optimizer states.
- Better scalability: You can fit larger models by adding devices, without changing the model architecture.
- Suitability for large models: FSDP is a natural fit when the model is far too large for a single device’s memory.
One caveat matters: the claim that “memory drops almost linearly with the number of devices” needs a boundary condition. Per-device memory shrinks roughly in proportion to the number of shards only when you consider the model state alone. That means ignoring activations, communication buffers, temporary tensors, memory fragmentation, and other framework overhead. In real projects, activations, communication buffers, and temporary tensors do not necessarily scale down linearly. Always measure with your actual framework, version, batch size, and sequence length.
4.2 The Key FSDP Operation Sequence
In FSDP training, the order of parameter gathering and gradient reduction matters a lot. A typical sequence looks like this:
- Before the forward pass (or during it): Use
all-gatherto collect the parameter shards needed for the current computation, on demand. - After the forward pass: Release parameter shards that are no longer needed to keep peak memory low.
- During the backward pass: Gather parameter shards on demand to compute gradients.
- After the backward pass: Use
reduce-scatterto reduce and shard the gradients. - Optimizer step: Each device updates only the parameter shard it owns.
- Clear gradients: Start the next iteration.
Pseudocode:
# Pseudocode: schematic of the FSDP training loopfor batch in data_loader:# Forward pass: all-gather the current layer's parameter shards on demand.# Release the gathered parameters after computation to lower peak memory.with shard_gather():loss = model(batch)# Backward pass: gather parameter shards on demand and compute their gradients.loss.backward()# After backward: reduce-scatter to reduce gradients and synchronize shards.# The optimizer updates only the shard owned by the local device.with shard_reduce():optimizer.step()optimizer.zero_grad()
In real implementations, overlapping communication with computation, shard granularity, and when parameters are released all have a major effect on throughput. The pseudocode only illustrates the training semantics; it is not a production implementation.
5. The Full Training Pipeline: From Loading to Synchronization
A training pipeline that runs and scales needs to cover the following stages.
5.1 Model Loading and Initialization
Trillion-parameter checkpoints are usually enormous, so loading them carries real memory risks. Recommended practices:
- Load weights from sharded checkpoints or read large files in chunks. Do not load all weights at once in a single process.
- Map shards by rank so each device loads only the parameters it owns.
- Do not let every process load the full weight set, or host memory can run out.
- Pin the framework and version dependencies: training framework, distributed backend, accelerator driver, and communication library.
- Add explicit errors and retry logic for failed loads, missing weights, and rank mapping errors.
- Keep the initialization logic aligned with the FSDP sharding strategy, so shard IDs match the device mapping.
5.2 Shard Scheduling and Device Mapping
How parameter shards map to devices directly affects memory balance and communication efficiency. The scheduling strategy needs to balance:
- Computation graph topology
- Inter-node bandwidth
- Device interconnect topology
- Shard gather frequency
- Number of cross-node communications
With poor shard scheduling, training can bottleneck on communication even when each device has plenty of compute.
5.3 Forward Computation and Activation Management
At large scale, activation memory use can exceed expectations. It grows quickly with long sequences, multimodal inputs, or large batches. Common ways to control it:
- Activation checkpointing (activation recomputation)
- Gradient accumulation
- Dynamic batch size adjustment
- Sequence parallelism
- Not retaining unnecessary intermediate tensors
5.4 Gradient Synchronization and Parameter Updates
Gradient synchronization is the most communication-heavy part of FSDP. The steps are:
- Before or during the forward or backward pass:
all-gatherparameter shards - After the backward pass:
reduce-scattergradient shards - The optimizer updates local shards
- Clear gradients once synchronization is complete
This stage is highly sensitive to interconnect bandwidth and communication library efficiency. When communication is slow, you get accelerators sitting idle, lower throughput, and even training hangs.
6. Multimodal Training Pipelines: Sharding Heterogeneous Inputs
Multimodal models typically take in heterogeneous inputs such as images, text, and audio. Compared with text-only models, they need extra work during adaptation.
6.1 Data Loading and Preprocessing
Different modalities differ in data format, resolution, sample rate, and token length, so they need a unified data pipeline:
- Images: resolution, patch splitting, and memory use in the vision encoder
- Text: sequence length, tokenizer version, and padding strategy
- Audio: sample rate, mel-spectrograms, frame length, and encoding overhead
6.2 Encoder Sharding
Vision, text, and audio encoders have different architectures, so a single sharding strategy will not fit all of them. In practice:
- Use FSDP or ZeRO-3 for the backbone network.
- Shard or apply tensor parallelism to the larger vision encoder.
- Evaluate the audio encoder’s memory use separately, based on its frame count and convolutional structure.
- Watch peak memory and communication overhead closely in the modality fusion layers.
6.3 Cross-Modal Alignment and Memory Hotspots
Multimodal training tends to develop memory hotspots, such as:
- Image-text alignment layers
- Cross-modal attention
- Visual feature projection layers
- Audio feature fusion layers
- The high-resolution image input stage
Profile memory usage and communication for these hotspots separately. Otherwise, a local bottleneck can stall the entire training run.
7. Performance Tuning and Troubleshooting Checklist
Getting the training pipeline working is only the first step. Running it stably and efficiently requires ongoing tuning. The main areas to focus on:
7.1 Overlapping Communication and Computation
Schedule parameter gathering and gradient reduction to overlap with the forward and backward passes. This hides some of the communication latency. Without overlap, training can stall while waiting on communication.
7.2 Fine-Grained Memory Management
Combine several techniques:
- Parameter sharding
- Optimizer state offloading
- Activation recomputation
- Gradient accumulation
- Smaller batches or shorter sequences
- Freeing temporary tensors
7.3 Numerical Stability
Large model training is sensitive to precision. After adapting to a domestic platform, verify:
- Whether forward outputs match expectations
- Whether backward gradients look normal
- Whether the loss diverges
- Whether NaN or Inf values appear
- Whether results are reproducible across precision modes
7.4 Fault Tolerance and Recovery
Long training runs must account for node failures. Set up periodic checkpointing, and keep in mind that a checkpoint can lose the most recent few steps. Keep several recent checkpoints and support resuming from them. Key practices:
- Save checkpoints at regular intervals
- Validate checkpoints
- Keep backups of multiple versions
- Isolate faulty nodes
- Automate the recovery flow
- Track training progress
7.5 Common Bottleneck Troubleshooting
| Symptom | Likely causes | Metrics to check |
|---|---|---|
| OOM | Activations too large, too few shards, memory fragmentation | Peak memory, batch size, sequence length |
| Hang | Communication blocking, rank mismatch, node failure | Communication logs, rank status, collective communication latency |
| Missing operators | Inconsistent software stack versions | Operator coverage list, framework version |
| Accuracy issues | Mixed precision, differences in operator implementations | Loss curve, gradient norm, NaN/Inf |
| Low throughput | Communication bottleneck, insufficient overlap | tokens/s, MFU, communication bandwidth |
| Recovery failure | Corrupt checkpoint, version change | Checkpoint validation, version matrix |
8. Choosing a Parallelism Strategy: FSDP Is Not the Only Answer
FSDP scales well from single-node, multi-GPU training to multi-node, multi-GPU training for large models. In very large clusters, though, FSDP alone is not always the best choice. Common strategies compared:
| Strategy | Best fit | Communication cost | Engineering complexity |
|---|---|---|---|
| FSDP | Parameter sharding, insufficient memory, general large model training | Medium–high; relies on all-gather and reduce-scatter | Medium |
| ZeRO-3 | Similar to FSDP; shards optimizer states, gradients, and parameters | Medium–high | Medium |
| Tensor parallelism | Layers whose parameters alone are too large; high-speed intra-node interconnects | High; heavy intra-layer communication | High |
| Pipeline parallelism | Very large models, scaling across nodes | Medium; pipeline bubbles | High |
| Expert parallelism | MoE models, expert routing training | High; relies on routing communication | High |
In practice, teams often combine these into hybrid parallelism. For example, FSDP or ZeRO-3 can handle data and parameter sharding, tensor parallelism can handle large operators within a single layer, and pipeline parallelism can reduce cross-node communication pressure. When the model grows further, or FSDP’s communication cost becomes too high, consider hybrid parallelism, expert parallelism, or CPU/NVMe offloading instead.
9. Practical Q&A: What to Choose, How to Do It, and Common Mistakes
How do I get trillion-parameter training running on domestic accelerators?
Recommended path:
- Validate operators and numerical accuracy on a single card.
- Validate FSDP on a single node with multiple cards.
- Scale out to multiple nodes and test interconnect bandwidth.
- Add checkpointing and fault recovery.
- Run long-duration stability tests and tune throughput.
When should I use FSDP?
FSDP is a good fit when:
- The model’s parameters exceed a single device’s memory.
- The cluster has a high-bandwidth interconnect.
- You want to make few changes to the model architecture.
- You need to scale quickly to multiple nodes.
Relying on FSDP alone is a poor fit when:
- Single layers are extremely large and clearly bottleneck on communication.
- The model is a complex MoE architecture.
- Memory hotspots are concentrated in activations or temporary tensors.
- You need maximum throughput and can maintain a complex parallelism strategy.
What are the common mistakes?
- Estimating parameter memory only, and ignoring optimizer states and activations.
- Assuming per-device memory always drops linearly with the number of devices.
- Loading the full weights in every process, causing host memory to run out.
- Not pinning framework, driver, and communication library versions.
- Running without checkpoints, so long training runs fail.
- Focusing only on peak compute and ignoring communication bandwidth.
- Failing to evaluate memory hotspots for multimodal inputs separately.
What else should I watch for?
- Establish a small-scale baseline before scaling out the cluster.
- Keep version matrices and experiment records.
- Set up logging and alerts for OOM, hangs, and accuracy issues.
- Back up checkpoints regularly.
- Monitor training throughput, memory, communication, and MFU in a single, unified view.
10. Conclusion
Adapting trillion-parameter models to domestic accelerators is, at its core, a systems engineering effort that brings hardware and software together. Every step demands solid distributed training engineering skills: aligning operators, estimating memory, sharding with FSDP, building multimodal pipelines, recovering from checkpoints, and troubleshooting performance.
Rather than depending on a single platform or trick, the more important goal is a transferable methodology. It should let you choose flexibly among pure FSDP, hybrid parallelism, expert parallelism, and offloading, based on model size, cluster bandwidth, and memory constraints. Only then can domestic AI infrastructure truly support large model training that is long-running, stable, and reproducible.
