Trillion-Parameter LLM Training: A Practical Guide to Adapting to Domestic AI Accelerators

    This article explains how to adapt trillion-parameter LLM training to domestic AI accelerator cards. It walks through the memory wall that makes trillions of parameters impossible on a single card, then covers the three core steps of the adaptation effort: sharded model loading, FSDP-based sharding and scheduling, and gradient synchronization with communication optimization. It also shows how to build a differentiated training path for multimodal models that mix heterogeneous modules, and how to align hardware, software stack, and cluster operations. Readers will come away with a full-chain engineering approach to "load → shard → synchronize," plus proven tuning practices for memory, communication, numerical accuracy, and fault tolerance.

    1. Why Trillion-Parameter Training Demands Adaptation Work

    Once model size crosses into the trillion-parameter (10¹²) range, the core training challenge is no longer “can we compute it” but rather “will it fit in memory, will communication keep up, and will training stay stable?”

    Consider a rough estimate for mixed-precision training: each parameter occupies 2 bytes in BF16/FP16, its gradient takes another 2 bytes, and Adam-style optimizers must maintain the first moment, the second moment, and an FP32 master copy of the weights, adding roughly 16 bytes per parameter. At one trillion parameters, model states alone approach 16 TB of memory, which no single accelerator card can hold. This is the well-known “memory wall.”

    At the same time, aggregating parameters and reducing gradients across cards and nodes creates enormous communication pressure. Data loading I/O throughput, fault tolerance for large-scale jobs, and checkpoint-and-resume capability all become key variables that determine whether training can progress reliably. As a result, running ultra-large-scale model training on domestic AI accelerator cards is a comprehensive challenge of hardware–software co-design, distributed parallelism, and engineering tuning—not a simple framework port.

    2. Three Core Steps of the Adaptation

    Bringing up the training pipeline generally follows a main thread of “model loading → sharded scheduling → gradient synchronization,” and each step poses its own engineering challenges.

    Step 1: Model Loading and Weight Initialization

    Ultra-large models cannot use the traditional approach of reading the entire set of weights onto a single card, which would cause an out-of-memory (OOM) error during loading. The recommended approach is:

    • Sharded loading (sharded checkpoint): split weights according to the parallel topology so that each rank reads only the parameters it is responsible for.
    • Checkpoint-based recovery: resume logic must align strictly with the sharding layout to prevent tensor misalignment.
    • Streaming or lazy loading for huge weights: this reduces peak memory use at individual nodes and shortens cold-start time.

    Step 2: Sharded Scheduling

    Sharded scheduling is central to memory optimization, and its flagship technique is Fully Sharded Data Parallel (FSDP). FSDP works much like ZeRO-3: parameters, gradients, and optimizer states are all partitioned within the data-parallel group, so each card holds only one shard at a time.

    • Forward pass: all-gather collects the full parameters for the current layer on demand, releasing them as soon as they are no longer needed.
    • Backward pass: reduce-scatter reduces the gradients and scatters the results directly back to each card’s shard.
    • Memory savings: compared with traditional data parallelism (DDP), in which every card stores a full copy of the model, FSDP approximately reduces the memory footprint of model states to 1/N, where N is the size of the data-parallel group.

    The following framework-agnostic scheduling sketch (pseudocode) illustrates the core logic:

    1. # Sketch: core scheduling logic of fully sharded data parallelism (pseudocode)
    2. dp_group = build_data_parallel_group(dp_degree) # Build the data-parallel group
    3. for layer in model.layers: # Shard params/grads/optimizer state layer by layer
    4. shard_state(layer, group=dp_group)
    5. for step in range(total_steps):
    6. for micro_batch in data_loader:
    7. for layer in model.layers:
    8. params = all_gather(layer.shard, group=dp_group) # All-gather full params on demand
    9. out = layer.forward(params, micro_batch)
    10. loss = compute_loss(out)
    11. for layer in reversed(model.layers): # Backward pass, layer by layer
    12. grad = layer.backward(...)
    13. reduce_scatter(layer.grad_shard, grad, group=dp_group) # Reduce gradients and scatter them
    14. optimizer.step(layer.param_shard) # Update only the shard on this card

    Two settings require careful tuning: the wrap policy (which layers are bundled into each FSDP unit) and the sharding strategy. If units are too coarse, all-gather creates larger temporary memory spikes. If units are too fine, communication overhead increases. A common practice is to use each Transformer decoder layer as the smallest sharding unit.

    Step 3: Gradient Synchronization and Communication Optimization

    The efficiency of gradient synchronization often determines overall throughput. When adapting to domestic AI accelerators, consider the following:

    • Collective communication primitives (all-reduce / all-gather / reduce-scatter): make sure they have high-performance implementations on the interconnect topology of the domestic cards.
    • Communication–computation overlap: while computing a layer in the forward or backward pass, prefetch the parameters of the next layer ahead of time so that communication latency is hidden behind computation.
    • Gradient accumulation: reduce synchronization frequency and amortize communication costs across an effective large batch.
    • Communication volume vs. gradient compression: balance the two carefully, since excessive compression can hurt convergence accuracy.

    3. Building a Differentiated Training Path for Multimodal Models

    Ultra-large models increasingly combine heterogeneous structures such as vision encoders, language backbones, and cross-modal alignment modules. These components vary widely in their operator characteristics, parameter counts, and compute-to-memory-access ratios, so a single parallelization strategy is often inefficient. To build a native multimodal training path:

    • Vision encoders (compute-intensive, parameter-dense): use tensor parallelism or sequence parallelism.
    • Language backbones (very large parameter counts): combine FSDP with pipeline parallelism.
    • Module boundaries: align tensor layouts and communication groups so that frequent format conversions do not create overhead.

    This path depends on the underlying software stack providing complete, high-performance coverage of the operators the model uses. Key operators such as GEMM, attention, normalization, and activation must not only run, but also match the original framework’s numerical results. Otherwise, large-scale training is prone to precision drift or failure to converge.

    4. Hardware–Software Co-Design and Engineering Best Practices

    Adaptation is not a software-only effort. It requires coordination across three layers: the chip, the software stack, and the cluster system.

    • Hardware: single-card compute capacity, memory capacity and bandwidth, and high-speed inter-card interconnect determine the upper limits on sharding granularity and parallelization dimensions.
    • Software stack: drivers, runtime, operator libraries, communication libraries, and the framework adaptation layer must form a closed loop that correctly maps common distributed primitives onto domestic hardware.
    • Cluster: separating the parameter-plane network from the storage-plane network, together with sound job scheduling and monitoring/alerting systems, keeps long-running training stable.

    To host this kind of training in the cloud, teams can combine general-purpose services such as object storage (for weights and datasets), container platforms (for elastic scheduling of training jobs), and logging, monitoring, and alerting (for tracking throughput, memory usage, and communication bottlenecks). Baidu AI Cloud’s infrastructure can likewise serve as the underlying platform for such large-scale training workloads.

    On top of this foundation, several proven tuning practices are worth standardizing:

    1. Three memory optimizations: FSDP, activation checkpointing (recomputation), and mixed precision. Used together, they can typically increase the trainable model size by an order of magnitude.
    2. Communication optimization: first enable communication–computation overlap and gradient accumulation, then gradually tune the wrap policy and sharding strategy to find the best balance between throughput and memory usage.
    3. Precision alignment: in the early stages of adaptation, always compare convergence on a small scale and inspect numerical results layer by layer. Make sure training is correct before chasing speed.
    4. Fault tolerance: implement sharded checkpoint saving and automatic resume so that a single-point failure does not force a large-scale job to restart from scratch.

    5. Summary

    Adapting trillion-parameter LLM training to domestic AI accelerators is not about any single feature. The difficulty lies in a closed-loop engineering approach across the entire “load → shard → synchronize” pipeline, supported by co-design across chips, the software stack, and the cluster. By understanding how FSDP reduces memory footprint, building differentiated paths for heterogeneous multimodal models, and applying techniques such as mixed precision, activation recomputation, and communication overlap, teams can make ultra-large models “fit in memory, train reliably, and converge” on domestic AI accelerators. The result is a pragmatic, reusable path to large-scale model training.