Training Trillion-Parameter Large Models on Domestic AI Accelerators: A Complete Guide to Adaptation

    Training trillion-parameter models on AI accelerators whose software stacks differ from the mainstream ecosystem is a system-level engineering effort spanning hardware, operators, communication, and data flow. This article explains why training adaptation is a required step, examines the memory and communication walls that emerge at trillion-parameter scale, and shows how Fully Sharded Data Parallel (FSDP) serves as the backbone strategy. It then covers building a multimodal training pipeline and the key engineering practices for operator coverage, memory and communication optimization, and training stability. Developers working in heterogeneous compute environments will find a practical map of the complete adaptation path.

    1. The Training Challenges of Trillion-Parameter Models

    When a flagship model scales into the trillion-parameter range, training is no longer a question of “can it run at all” but a full-blown system engineering problem. Parameters, activations, and optimizer states stack together, so a single card’s memory can no longer hold the complete model and distributed parallel sharding becomes mandatory. Multimodal models add further coupling between the vision encoder and the language backbone, making the data flow even more complex.

    At this scale, training adaptation faces three main challenges:

    • The memory wall: memory occupied by parameters, gradients, and optimizer states (such as Adam’s first and second moments) grows linearly or even multiplies with parameter count, and must be split across multiple cards and machines through sharding.
    • The communication wall: after sharding, each card holds only part of the parameters, and the forward and backward passes require frequent gather and reduce operations. The communication volume and the cluster’s interconnect bandwidth directly determine scaling efficiency.
    • Software-hardware co-design: domestic AI accelerators differ from the mainstream ecosystem in their instruction sets, operator implementations, and collective communication libraries. Models cannot simply be run as-is and need a complete adaptation and tuning workflow.

    2. Why Training Adaptation Is a Necessary Step

    Mainstream large-model frameworks are often deeply optimized for specific hardware. When a model is moved onto domestic AI accelerators, the problems concentrate at three levels:

    1. Operator level: operators such as attention, normalization, and activation functions in the model need efficient implementations on the target card’s software stack. Missing or incompatible operators must be filled in or replaced.
    2. Communication level: the performance of collective communication primitives (such as all-gather, reduce-scatter, and all-reduce) in a heterogeneous interconnect environment must be verified and tuned.
    3. Framework level: parallel strategies, mixed precision, and checkpointing need to be integrated with the target hardware’s software stack.

    In essence, training adaptation is about closing the full loop of model loading → sharding scheduling → forward computation → backward computation → gradient synchronization → parameter update, so that the model can run stably and reproducibly on the domestic compute platform and reach usable efficiency.

    3. The Core: Fully Sharded Data Parallel (FSDP)

    Among the many distributed parallel strategies, Fully Sharded Data Parallel (FSDP) is currently a general-purpose technical approach for training super-large models. Its core idea is to shard parameters, gradients, and optimizer states along the data-parallel dimension across compute cards, temporarily aggregating the full parameters only when they are actually needed.

    Its typical workflow is as follows:

    1. Forward pass:
    2. 1. All-gather the full parameters of the current layer on demand
    3. 2. Complete the forward computation of that layer
    4. 3. Immediately after computation, release the aggregated parameter copy (free the full weights)
    5. Backward pass:
    6. 1. All-gather the layer's parameters again for gradient computation
    7. 2. Immediately reduce-scatter the gradients after computing them
    8. 3. Each card keeps only the gradients for the parameter shard it owns
    9. Optimizer step:
    10. 1. Each card updates only the parameter shard it holds
    11. 2. Parameter update completes without aggregating the full gradients

    Compared with traditional data parallelism (where each card holds a full model copy), FSDP minimizes memory redundancy. Compared with tensor parallelism and pipeline parallelism, it is easier to deploy on general clusters and less invasive to model code. Its key advantage lies in overlapping communication with computation: parameter aggregation (communication) can run in parallel with the previous layer’s computation, hiding most of the communication overhead.

    4. Building the Multimodal Training Pipeline

    For multimodal models, the training pipeline must additionally handle the interaction between the image/video encoder and the language backbone. The adaptation process usually needs to connect the following pieces:

    • Model loading: register submodules of different modalities (vision encoder, projector, language backbone) uniformly into the sharding framework, and clarify which modules participate in sharding and which stay at a smaller scale to avoid over-sharding.
    • Sharding scheduling: set sharding strategies for different layers. Parameter-dense backbone layers use full sharding, while communication-sensitive or parameter-light modules can use a hybrid strategy to reduce frequent all-gathers.
    • Multimodal data flow: image/video inputs need preprocessing and encoding, and their activations are often larger than pure text. Batch size and sequence length must be controlled reasonably to avoid activation memory overflow.
    • Gradient synchronization: all modules that participate in sharding perform gradient reduction uniformly in the backward pass, ensuring consistency of parameter updates and stable convergence.
    1. # Illustrative pseudocode: FSDP-sharded loading of a multimodal model
    2. for submodule in [vision_encoder, projector, language_model]:
    3. wrap_fsdp(
    4. submodule,
    5. sharding_strategy="FULL_SHARD", # Full sharding
    6. mixed_precision=bf16_policy, # Mixed precision
    7. forward_prefetch=True, # Forward parameter prefetch to overlap communication
    8. )

    5. Key Engineering Points and Tuning Practices

    To truly achieve “runs, runs fast, and runs stably,” work must continue in the following directions:

    1. Operator adaptation and coverage: inventory all operators in the model, compare them against the target software stack’s operator library, implement or equivalently replace missing operators, and verify correctness through numerical precision comparison.
    2. Memory optimization: combine techniques such as activation checkpointing, gradient accumulation, and mixed precision (BF16/FP16) to trade computation for space when memory is constrained.
    3. Communication optimization: set sharding granularity and communication bucket sizes reasonably, enable parameter prefetching and compute-communication overlap, and reduce synchronization waits.
    4. Stability assurance: configure periodic checkpoints for long-running training so that training can resume from the latest state after an interruption, and monitor gradients for NaN/Inf.
    5. Cluster and storage: training datasets are massive, so object storage typically holds samples, a container platform schedules distributed jobs, and a monitoring and alerting system tracks throughput and hardware status, forming a complete training infrastructure.

    6. Summary

    Adapting trillion-parameter multimodal large models to domestic AI accelerators is a system engineering effort spanning hardware, operators, communication, frameworks, and data flow. Its core is to use mature parallel strategies such as Fully Sharded Data Parallel as the backbone, connect the full training loop from model loading and sharding scheduling to gradient synchronization, and then supplement it with engineering measures such as operator coverage, memory and communication optimization, and stability assurance. For developers, understanding each link in this adaptation path is key to efficiently and reliably running large-model training in heterogeneous compute environments.