Training Trillion-Parameter Models on Domestic AI Accelerators: Key Practices

    How can AI accelerator cards with limited memory train models with trillions of parameters? This article walks through the key practices for adapting a 2.8-trillion-parameter multimodal model using FSDP2-based sharding, covering resource estimation, parallelism and sharding strategies, and communication optimization for large-scale distributed training.

    1. Background

    Large model parameter counts have grown from the billions to the trillions. An open-source community recently released a multimodal model with roughly 2.8 trillion parameters, capable of understanding and generating text, images, and audio. A domestic AI accelerator vendor announced that it had completed training adaptation for this model using its unified training-and-inference accelerator card and in-house software stack, building a multimodal training pipeline based on FSDP2.

    This information comes primarily from the vendor’s public adaptation report. The report does not disclose the complete hardware configuration, network topology, or test scripts, so the figures cited here should be treated as reference only. This article focuses on the technical approach, which readers can use as a practical checklist.

    2. Estimate Resource Requirements First

    Before training begins, estimate memory and storage needs. If weights are stored in bf16, the weights of a 2.8-trillion-parameter model total roughly 5.6 TB (2.8×10^12 × 2 bytes). With the Adam optimizer storing fp32 master weights, momentum, and variance, each parameter requires about 12 additional bytes, bringing optimizer states to roughly 33.6 TB. Adding gradients and activations, the full training state exceeds 40 TB.

    This means a single-node, multi-card setup cannot hold the entire model. Even with 100 GB of memory per card, storing just the weights would require dozens of cards, so sharding is essential—parameters, gradients, and optimizer states must be split across many cards.

    Before getting started, write down the following numbers:

    • Total parameter count, and the parameter share of each module
    • Memory limit and actual usable memory per card
    • Target sequence length and global batch size
    • Size of a single checkpoint and available write bandwidth

    These numbers drive every subsequent design decision.

    3. Choosing Parallelism and Sharding Strategies

    Trillion-parameter models typically require a combination of parallelism schemes. The common combination is data parallelism, tensor parallelism, and pipeline parallelism—known as 3D parallelism. For long sequences, sequence parallelism or context parallelism is also needed to distribute activation memory.

    FSDP2 is a more recent sharding scheme. It shards at parameter granularity, calling the sharding API once per module so that parameters, gradients, and optimizer states exist only as local shards. During the forward pass, parameters are gathered on demand and released afterward, reducing peak memory usage.

    The following code is illustrative; API names and usage should follow the official documentation for your PyTorch version:

    1. from torch.distributed.fsdp import fully_shard
    2. # Shard layer by layer: each Transformer block is sharded independently,
    3. # and full parameters are released after the forward pass
    4. for block in model.language_model.layers:
    5. fully_shard(block, reshard_after_forward=True)
    6. # Wrap the outermost layer to handle the remaining parameters
    7. fully_shard(model)

    Multimodal models should not apply the same strategy to every submodule. Vision encoders have relatively few parameters but large activations, so they can be kept fully on each card, with gradients synchronized only across the data-parallel dimension. Language decoders have the most parameters and should use full sharding. The two sharding strategies need separate configuration, and memory usage should be validated with small-scale experiments before full training begins.

    4. Communication and Gradient Synchronization

    Gradient synchronization is the dominant communication cost in large-scale training. As the number of cards grows, both communication volume and synchronization latency increase.

    The FSDP training loop can be broken into three steps, and understanding them helps with performance debugging:

    1. Before the forward pass, run AllGather per layer to collect the full parameters needed by that layer.
    2. During the backward pass, once each layer’s gradients are computed, run ReduceScatter to reduce and shard the gradients, so each card keeps only its own gradient shard.
    3. The optimizer updates only the local parameter shards. Before the next forward pass, parameters are collected again via AllGather.

    Common optimization techniques include:

    • Overlapping communication and computation: initiate ReduceScatter early during backpropagation and prefetch parameters while computing the next layer.
    • Tiered communication: use high-speed interconnects within a node and RDMA networking across nodes, scheduling the two levels separately.
    • Gradient compression: TopK sparsification or quantization can reduce communication volume, but may affect convergence and should be validated with controlled experiments.