Training Ultra-Large Models on Domestic AI Accelerators: A Practical Adaptation Guide
A hands-on methodology for adapting trillion-parameter model training to domestic AI accelerator platforms. This article covers building a fully sharded training pipeline, combining multiple parallelism strategies, managing GPU memory, optimizing communication, and establishing production-grade stability practices — everything needed to move from "it runs" to "it runs reliably at scale."
Training Ultra-Large Models on Domestic AI Accelerators: A Practical Adaptation Guide
Introduction
As large language models scale from tens of billions to hundreds of billions and beyond, training workloads place unprecedented demands on the underlying compute platform. The industry has recently open-sourced flagship Mixture-of-Experts (MoE) models at the multi-trillion-parameter scale. These models require careful optimization not only for inference but also for training, placing extremely high requirements on accelerator architecture, interconnect bandwidth, and software stack maturity. At the same time, a growing number of enterprises want to adapt large model training to domestic AI training-and-inference accelerators to reduce dependence on a single hardware ecosystem.
Rather than focusing on any specific product, this article takes a general technical perspective and systematically lays out a complete methodology for adapting ultra-large model training on domestic compute platforms, covering training pipeline construction, distributed parallelism, memory management, communication optimization, and stability guarantees.
1. Goals and Challenges of Training Adaptation
“Training adaptation” is not merely about making a model “run” on new hardware. It means achieving three levels of objectives:
- Functional correctness: The full forward, backward, and parameter update pipeline must be numerically correct, with the training loss curve matching the reference implementation or converging in an explainable way.
- Usable performance: The cluster’s Model FLOPs Utilization (MFU) must reach an acceptable level, with a reasonable communication-to-computation ratio and no obvious performance bottlenecks.
- Engineering stability: Support for continuous long-duration training on thousands to tens of thousands of accelerators, with checkpoint recovery, fault self-healing, and precision validation as production-grade capabilities.
Ultra-large models — especially MoE architectures — present key adaptation challenges: massive memory pressure from parameters and activations, load imbalance caused by expert routing, cross-node communication overhead, and the need to verify operator coverage and numerical consistency on new hardware.
2. Building a Natively Fully Sharded Training Pipeline
For trillion-parameter models, the industry commonly adopts Fully Sharded Data Parallel (FSDP) as the main training approach. The core idea is to shard parameters, gradients, and optimizer states across all devices along the data-parallel dimension, so each device holds only 1/N of the shards. Full parameters are aggregated on demand via collective communication during forward and backward passes.
Building this pipeline requires the following key pieces:
- Model loading and initialization: Support direct loading from sharded checkpoints, avoiding materializing the full parameters on a single device; apply lazy initialization to very large vocabulary embedding layers and MoE expert layers.
- Sharding strategy: Wrap modules at a fine granularity (e.g., each Transformer Block) and set a reasonable minimum sharding unit to balance communication frequency against memory savings.
- Gradient synchronization and reduction: During backpropagation, sharded gradients are accumulated via Reduce-Scatter. Data types must be aligned with the communication backend (e.g., BF16 gradients with FP32 master weights).
A schematic training loop looks like this:
for step, batch in enumerate(dataloader):with autocast(dtype="bfloat16"):loss = model(batch) / grad_accum_stepsloss.backward() # triggers automatic reduction of sharded gradientsif (step + 1) % grad_accum_steps == 0:clip_grad_norm_(model.parameters(), max_norm=1.0)optimizer.step()optimizer.zero_grad()lr_scheduler.step()
When landing this pipeline on a domestic compute platform, the critical work is ensuring the software stack fully supports the required collective communication primitives, mixed-precision semantics, and sharding mechanisms, and filling in any missing fused operators.
3. Combining Multiple Parallelism Strategies
Data parallel sharding alone cannot support training models with trillions of parameters. In practice, multiple parallelism dimensions must be combined:
- Tensor Parallelism (TP): Splits matrix multiplications within a single layer along a dimension. Best suited to high-bandwidth intra-node interconnects, typically limited to a single machine to control communication volume.
- Expert Parallelism (EP): MoE experts map naturally across devices, with tokens dispatched and collected via All-to-All communication. Routing load balancing is critical — use auxiliary load-balancing losses or capacity factor tuning.
- Pipeline Parallelism (PP): Splits the model by layers across nodes, using micro-batch scheduling (e.g., interleaved scheduling) to reduce pipeline bubbles.
- Sequence/Context Parallelism (SP/CP): For long-context training, splits the sequence dimension to relieve activation memory pressure.
When combining parallelism dimensions, follow the principle of “communication-intensive dimensions within a node, communication-sparse dimensions across nodes,” and validate the combination through simulation against the actual cluster topology before finalizing.
4. Memory Management and Performance Optimization
Accelerator memory is the scarcest resource in ultra-large model training. Common techniques include:
- Activation checkpointing: Store only the inputs of intermediate layers and recompute activations during backpropagation, trading roughly 30% extra compute for several times the memory savings. Can be enabled selectively per layer.
- Optimizer state sharding: Use a sharded optimizer so that momentum, second-moment estimates, and other states are split along with parameters.
- Communication-computation overlap: Prefetch parameter aggregation (All-Gather) ahead of the next layer’s computation and pipeline gradient reduction with backward computation to maximize hiding of communication latency.
- Operator fusion and kernel tuning: Fuse hot operators such as attention, RMSNorm, and RoPE, and tune kernels for the target hardware’s instruction set and on-chip memory.
5. Stability Guarantees and Acceptance Criteria
Production-grade training requires a solid reliability framework:
- Checkpoint recovery: Periodically save sharded checkpoints, with support for weight resharding when loading under a different parallelism configuration.
- Fault detection and self-healing: Use heartbeat monitoring and communication timeout detection to locate faulty nodes, automatically remove them, and resume training.
- Numerical consistency validation: On a small-scale cluster, compare the first few steps of loss against a reference implementation; deviations should stay within an explainable mixed-precision range.
- Performance baseline acceptance: Use MFU and per-token training time as core metrics, and build a regression test suite for performance.
Conclusion
Adapting ultra-large model training to domestic compute platforms is a systems engineering effort spanning frameworks, operators, communication, scheduling, and reliability. By using Fully Sharded Data Parallel as the backbone, layering on tensor, expert, and pipeline parallelism, and adding memory management and a reliability framework, teams can build a complete training pipeline from model loading to gradient synchronization. For teams looking to run large model training on domestic platforms, general cloud capabilities — such as container platforms, object storage, and monitoring and alerting services offered by providers like Baidu AI Cloud — can help quickly set up the training infrastructure, so teams can focus on the model and algorithms themselves.
