Trillion-Parameter Model Training on Domestic AI Computing Platforms: Engineering Practices for Adaptation

    Training trillion-parameter open-source models on self-built AI clusters requires more than loading model weights. This article describes an end-to-end training adaptation path covering model loading and weight mapping, FSDP-based sharding, shard scheduling, and gradient synchronization. It also discusses how to build a native FSDP2 multimodal training path for MoE models, validates software-hardware co-design requirements, and summarizes practical recommendations for large-scale deployment.

    Trillion-Parameter Model Training on Domestic AI Computing Platforms: Engineering Practices for Adaptation

    I. Background: Computing Adaptation Challenges Posed by Very Large Open-Source Models

    In recent years, the open-source community has continued to release flagship-level large models with parameter counts reaching trillions. These models commonly use a mixture-of-experts (MoE) architecture, activating only part of their parameters during inference to control computational overhead while achieving stronger model capabilities. However, open-sourcing a model is only the first step. The key to engineering implementation is making such models run and train effectively across diverse computing environments.

    For teams that want to conduct fine-tuning, continued pre-training, or industry-specific adaptation on self-built AI computing clusters, the challenges are multifaceted. First, model weight sizes are enormous, and a single card’s memory cannot hold the full set of parameters. Second, multimodal inputs make the data pipeline more complex. Third, the MoE architecture places higher demands on parallelism strategies and communication efficiency. Therefore, completing training adaptation for such models around domestically developed training-inference integrated AI accelerator cards and their supporting software stacks is a representative systems engineering task.

    II. Overall Technical Chain for Training Adaptation

    “Training adaptation” does not simply mean enabling a model to load weights. It requires establishing a complete training loop from model loading, parameter sharding, and forward and backward computation to gradient synchronization and parameter updates. The overall chain can be broken down into the following stages:

    1. Model loading and weight mapping: Efficiently load open-source weights, usually checkpoint files stored in shards, into a distributed cluster, and complete tensor name mapping and format conversion.
    2. Parallelism strategy design: For trillion-parameter scale, use fully sharded data parallelism (FSDP) to shard parameters, gradients, and optimizer states across all compute devices, eliminating single-card memory bottlenecks.
    3. Shard scheduling: Determine when parameters are aggregated (all-gather) and when they are released (reshard), balancing memory usage and communication overhead.
    4. Gradient synchronization: During backpropagation, perform reduce-scatter on sharded gradients to ensure gradient consistency across data-parallel replicas.

    III. Building a Native FSDP2 Multimodal Training Path

    FSDP2 is a new generation of fully sharded data parallelism. Compared with earlier versions, it manages model states with finer-grained “per-parameter sharding” and delegates the orchestration of communication and computation to more flexible mechanisms. It is particularly suitable for models such as MoE models that have irregular structures and uneven expert distribution.

    When building a native FSDP2 multimodal training path, the following points require particular attention:

    3.1 Choice of Sharding Granularity

    For MoE models, attention layers, shared feed-forward layers, and expert layers can use different sharding strategies. In practice, standard FSDP sharding is often used for dense parts, while expert parallelism (EP) is combined for expert parts, placing different experts on different device groups to reduce the parameter count per device. An illustrative configuration is shown below:

    1. # Illustrative code: hybrid parallelism strategy
    2. from torch.distributed.fsdp import fully_shard
    3. for layer in model.layers:
    4. fully_shard(layer.mlp.shared_experts) # Shard shared experts with FSDP
    5. fully_shard(layer.attention) # Shard attention layer
    6. # Routed experts are managed by expert parallel groups with all-to-all communication

    3.2 Multimodal Data Pipeline

    Multimodal training requires connecting image and video encoders with the language model. On the data side, issues such as variable-length sequences and dynamically changing image resolutions must be handled. Recommended practices include:

    • Use sequence packing to reduce padding waste and improve effective throughput;
    • Set separate learning rates and freezing strategies for the vision encoder and the language backbone;
    • Perform distributed sampling at the data loading layer to ensure that data across replicas does not overlap.

    3.3 Balancing Communication and Memory

    The core trade-off of FSDP is that more frequent parameter aggregation reduces memory usage but increases communication overhead. The following methods can be used for optimization:

    • Enable communication-computation overlap, prefetching the next layer’s parameters while backward computation is running;
    • Use low-precision communication, such as bf16 gradient reduction, to reduce bandwidth pressure;
    • Combine activation checkpointing to trade computation for memory.

    IV. Importance of Software Stack and Hardware Co-Design

    Another key to completing training adaptation is coordination between the software stack and hardware. Training-inference integrated AI accelerator cards require supporting operator libraries, communication libraries, and compilation toolchains to efficiently map the above parallelism strategies to hardware execution. In engineering practice, the following typically need to be validated:

    • The correctness and performance of core operators, including matrix multiplication, attention, normalization, and MoE routing, on the target hardware;
    • The bandwidth utilization of collective communication primitives, including all-gather, reduce-scatter, and all-to-all, under multi-machine, multi-card topologies;
    • The reliability of checkpoint saving and restoration mechanisms in large-scale clusters.

    For enterprise users, general capabilities provided by cloud platforms, such as container platforms, object storage, and monitoring and alerting, can also be used to build elastic training environments: object storage for managing datasets and checkpoints, container platforms for orchestrating training jobs, and monitoring and alerting systems for tracking memory, throughput, and failure events. This can reduce the operational cost of self-built training infrastructure.

    V. Implementation Recommendations and Best Practices

    1. Validate at small scale first, then scale linearly: First run forward and backward passes on a single machine with multiple cards, then expand to multiple machines, gradually validating gradient correctness and scaling efficiency.
    2. Establish a numerical alignment baseline: Align the loss curve with a reference implementation to detect operator precision or communication logic issues as early as possible.
    3. Monitor memory usage and communication share: Keep the communication time share within a reasonable range, typically recommended to be below 20%–30% of total duration.
    4. Improve fault tolerance mechanisms: Trillion-parameter model training takes a long time, so it must have the ability to save checkpoints periodically and automatically recover from failures.

    VI. Conclusion

    Training adaptation for very large open-source models is essentially a systems engineering effort involving parallelism strategies, data engineering, and software-hardware co-design. By building a native FSDP2 multimodal training path and connecting the complete chain from model loading and shard scheduling to gradient synchronization, developers can efficiently train trillion-parameter models and perform industry-specific adaptation across diverse computing environments, providing a solid technical foundation for autonomous and controllable deployment of large models.