Trillion-Parameter Large Model Training on Domestic Compute: Adaptation Practices

    This article examines the engineering challenges of training trillion-parameter large models on domestic AI accelerators and software stacks. It covers the main adaptation difficulties, including operator coverage and numerical alignment, memory capacity limits, and the coupling between communication and parallelism. It focuses on Fully Sharded Data Parallel (FSDP) as a core parallel strategy, then walks through the key stages of a complete training pipeline: model loading, shard scheduling, and gradient synchronization. It also discusses software stack coordination and practical engineering lessons, including precision validation, operator fallback monitoring, communication-computation overlap, and fault tolerance.

    1. Background: New Training Challenges from Ultra-Large-Scale Models

    As flagship model parameter counts enter the trillion range, simply increasing the number of accelerators no longer improves training efficiency linearly. Trillion-parameter models far exceed traditional models in three dimensions: memory footprint, computation graph size, and communication overhead. As a result, training such models places extremely demanding requirements on hardware compute, interconnect bandwidth, and software stack maturity.

    At the same time, compute autonomy has become a practical industry requirement. Being able to run the full training task of an open-source trillion-parameter model on domestic AI training and inference accelerators and a vendor’s self-developed software stack is an important indicator of the maturity of the domestic compute ecosystem. Recently, a domestic compute platform completed native training adaptation for an open-source trillion-parameter flagship model. Its technical path has broad reference value.

    2. Core Challenges in Training Adaptation

    Adapting a large model to a new hardware platform is essentially a “deep adaptation” task rather than a simple port. Three major challenges typically arise:

    • Operator coverage and precision alignment: Model forward and backward computation involves a large number of operators. The new platform must provide high-performance implementations for key operators and ensure that numerical precision aligns with mainstream reference implementations. Otherwise, loss divergence or abnormal convergence may occur.
    • Memory capacity bottleneck: Even when trillion-parameter weights, gradients, and optimizer states are distributed across thousands of accelerators, the memory pressure on each accelerator remains substantial. Techniques such as parameter sharding and activation recomputation are therefore essential.
    • Coupling between communication and parallel strategies: Different parallel dimensions, including data parallelism, tensor parallelism, and pipeline parallelism, are sensitive to inter-accelerator interconnect bandwidth. If the parallel strategy does not match the hardware topology, communication can become the bottleneck.

    3. Fully Sharded Data Parallel as the Core Parallel Strategy

    To address memory pressure, the industry commonly adopts the idea of Fully Sharded Data Parallel (FSDP): model parameters, gradients, and optimizer states are evenly partitioned across compute units. They are temporarily aggregated only when needed for forward and backward computation and are released immediately after computation, reducing memory overhead from growth with accelerator count to scaling down as the number of accelerators increases.

    Within this approach, the native implementation emphasizes two points:

    1. Deep integration with the runtime: Sharding logic works closely with the compute scheduler, avoiding the overhead and compatibility issues introduced by an additional framework layer.
    2. Scalable hybrid parallelism: On top of pure data parallelism, tensor parallelism and pipeline parallelism can be combined to partition trillion-parameter models across multiple dimensions, balancing memory efficiency and communication efficiency.

    The following pseudocode illustrates how a sharding strategy may be organized. It is intended only to express the logic and does not represent a specific product interface.

    1. # Example: initialization skeleton for Fully Sharded Data Parallel (FSDP)
    2. import torch
    3. from torch.distributed.fsdp import fully_shard # Conceptual illustration
    4. def build_model(model_cls, world_size):
    5. model = model_cls() # Construct the trillion-parameter model
    6. # Shard parameters, gradients, and optimizer states across compute units
    7. sharded_model = fully_shard(
    8. model,
    9. shard_placement="full", # Full sharding
    10. reshard_after_forward=True, # Reshard after forward pass to release memory
    11. mixed_precision="bf16", # Mixed precision to balance accuracy and throughput
    12. )
    13. return sharded_model
    14. # Training loop
    15. for step, batch in enumerate(dataloader):
    16. loss = sharded_model(batch).loss
    17. loss.backward() # Trigger gradient synchronization and reduction
    18. optimizer.step() # Update sharded parameters
    19. optimizer.zero_grad()

    4. Three Key Stages to Enable a Complete Training Pipeline

    A workable training pipeline must cover all of the following stages:

    1. Model Loading

    The model architecture must be correctly parsed on the domestic platform, weights must be loaded properly, and the model must be converted from the reference format to the memory layout used by the target platform. This stage requires checking tensor shapes, data types, and naming mappings to ensure that weights are loaded without loss.

    2. Shard Scheduling

    The model partitioning scheme must be mapped to specific physical compute units, with partition granularity optimized according to the hardware topology, including intra-card interconnect, inter-card interconnect, and cross-node networks. Reasonable scheduling can significantly reduce cross-node communication and improve overall utilization.

    3. Gradient Synchronization

    During backpropagation, gradients produced by each shard must be reduced according to the corresponding parallel dimension using operations such as reduce-scatter or all-reduce. Gradient synchronization must overlap with computation, hiding communication behind computation. Otherwise, communication overhead will directly slow down training.

    5. Software Stack and Ecosystem Coordination

    The maturity of the underlying software stack determines how deeply adaptation can be achieved. A complete domestic software stack usually needs to coordinate across the following layers:

    • Heterogeneous computing programming interfaces: Provide operator libraries, communication libraries, and memory management capabilities aligned with the mainstream ecosystem.
    • Mixed precision support: Use lower-precision formats such as BF16 or FP16 by default to improve throughput, while retaining FP32 accumulation on critical paths to ensure numerical stability.
    • Debugging and observability: Provide logs, monitoring, and performance profiling capabilities to help diagnose issues such as operator fallback and communication bottlenecks.

    When upper-layer training frameworks can invoke these capabilities non-invasively, developers can perform training tasks on domestic platforms with a development experience close to that of the mainstream ecosystem.

    6. Engineering Practices

    During practical adaptation, the following recommendations are worth considering:

    • Validate precision first: Use a small model or a small-scale dataset to verify whether the loss curve aligns with the reference implementation before scaling up to trillion-parameter scale.
    • Monitor operator fallback: If some operators lack high-performance implementations and fall back to inefficient paths, this should be detected and optimized as early as possible.
    • Overlap communication and computation: Fully overlapping gradient synchronization with backward computation is a key technique for improving large-scale training efficiency.
    • Stability and fault tolerance: In ultra-large-scale training, node failures are difficult to avoid. A checkpoint mechanism should be introduced to ensure recoverability.

    7. Conclusion

    Training adaptation for trillion-parameter large models tests the combined strength of hardware compute, software stack ecosystem maturity, and parallel engineering capabilities. By building a native Fully Sharded Data Parallel path on domestic training and inference accelerators and self-developed software stacks, and by systematically enabling the complete pipeline of model loading, shard scheduling, and gradient synchronization, domestic compute platforms are becoming capable of supporting flagship large-model training.

    For developers, understanding these adaptation challenges and engineering practices can help make large-model training and migration more efficient in the broader trend toward compute autonomy.