Trillion-Parameter LLM Training on Homegrown AI Compute: A Full-Stack Adaptation Path

    This article outlines the engineering path for adapting homegrown AI compute to trillion-parameter language model training. It covers the memory wall and FSDP2/DTensor sharding, multimodal training complexity, operator and compiler coverage, the three stages of model loading, sharding scheduling, and gradient synchronization, plus the value of integrated training and inference and practical validation recommendations.

    1. Background: Compute Adaptation Challenges in the Trillion-Parameter Era

    A flagship open-source model with 2.8 trillion parameters was recently released, making it one of the largest open-source models by parameter count. A language model at this scale places extreme demands on training infrastructure: it requires not only sufficient memory capacity and interconnect bandwidth, but also deep software-stack support for distributed training primitives.

    Meanwhile, domestic AI compute chips have been catching up quickly in hardware specifications. What ultimately determines whether they can handle large-model training, however, is the maturity of the software ecosystem. A complete large-model training adaptation is essentially a systematic validation of the entire chain: hardware, compiler, distributed framework, and parallel strategy. Using this type of adaptation work as an entry point, this article reviews the key technical stages and general engineering methods for trillion-parameter model training adaptation.

    2. Core Difficulties in Training Adaptation

    2.1 The Memory Wall and Sharding Strategies

    The weights of a trillion-parameter model far exceed the memory capacity of a single device. For an estimated 2.8 trillion parameters, storing weights alone in half precision requires multiple terabytes of memory. Add optimizer states, which are usually several times the parameter count, plus activations, and multi-level sharding and offloading strategies become mandatory.

    The mainstream approach today is the Fully Sharded Data Parallel (FSDP) paradigm. FSDP2, a newer implementation, uses the lower-level DTensor tensor-distribution abstraction rather than earlier wrapper-based implementations. This enables it to:

    • Precisely control sharding granularity along parameter dimensions, such as sharding by Transformer layer;
    • Support metadata initialization before sharding, including meta device initialization, to avoid allocating a full copy of model memory on every device;
    • Compose orthogonally with mixed-precision training, gradient checkpointing, and other mechanisms to trade off memory and compute overhead flexibly.

    The first step in adaptation is to confirm that the chip software stack natively supports these FSDP2 semantics, rather than providing only a simplified form of data parallelism.

    2.2 Complexity of Multimodal Paths

    Modern flagship models are generally multimodal architectures, in which a vision encoder and a language model work together through a connector module. Adapting a multimodal training path is more complex than adapting a text-only model for several reasons:

    1. Heterogeneous data flow: Feature tensors produced by the vision encoder from images differ greatly from text tokens in shape and sequence-length distribution, which places requirements on dynamic-shape compilation optimization.
    2. Two-stage training: Training usually starts with the connector module and then jointly unfreezes the language model. Parameter freezing and sharding configurations must switch flexibly across stages at the framework level.
    3. Data packing: Variable-length image-text samples require an efficient packing strategy. Adaptation must verify that attention masks and positional encodings compute correctly on non-contiguous sequences.

    2.3 Operator and Compiler Coverage

    Domestic chips typically use in-house compute architectures and corresponding software stacks that provide CUDA-like programming models and operator libraries. Adaptation requires checking every operator used by the model one by one: from basic matrix multiplication, LayerNorm, and RoPE rotary positional encoding to fused operators, flash-attention-like implementations, and MoE routing if expert parallelism is involved. Missing operators must be filled in through custom operator interfaces and validated for numerical consistency against reference implementations, usually within single-precision floating-point tolerance.

    3. Three Key Stages of the Full Training Pipeline

    A qualified training adaptation is generally described as connecting the complete pipeline from model loading and sharding scheduling to gradient synchronization. Each stage has a different focus:

    1. Model loading. Using the meta device mechanism, the model first builds its computational graph as an “empty shell,” after which parameters are materialized into each device’s memory according to the sharding strategy. This stage validates the framework’s ability to handle extremely large parameter graphs and the stability of the chip-side memory allocator under frequent allocation and release.

    2. Sharding scheduling. In the training loop, sharded parameters must be reassembled through all-gather before forward computation and reduced through reduce-scatter after backward computation. The scheduler must correctly manage communication-computation overlap; otherwise, interconnect bandwidth becomes a throughput bottleneck. During adaptation, profiling tools are typically used to locate communication stalls and adjust shard granularity and prefetch strategies.

    3. Gradient synchronization. This involves data-parallel all-reduce and, when expert parallelism is enabled, all-to-all. Master weight updates under mixed precision, gradient clipping, and other operations must also execute correctly under distributed semantics. The validation method at this stage is gradient consistency comparison: under a small-scale configuration, compare the loss curve and gradient norm from domestic chips with those from a mature solution.

    4. Engineering Value of Integrated Training and Inference

    The positioning of “integrated training and inference” deserves emphasis. Traditionally, training cards and inference cards belong to different product lines, so a trained model still requires additional deployment adaptation. Integrated training and inference means that training and inference share the same hardware architecture, software stack, and operator library. The benefits include:

    • Consistent precision semantics: Training and inference use the same numerical implementation, reducing online quality drift caused by training-inference deviation;
    • Lower migration cost: Models can move smoothly from the training cluster to inference services without a second adaptation;
    • Unified ecosystem: Developers need to master only one toolchain and programming interface, reducing maintenance burden.

    From an industry perspective, the significance of validating this capability is that it demonstrates domestic compute can handle not only inference but also the full workflow of large models from pretraining to fine-tuning. This has symbolic value for building self-reliant AI infrastructure.

    5. General Adaptation Practices

    Teams planning to train large models on heterogeneous compute can refer to the following general practice path:

    1. Validate from small to large: First run the complete training loop on a smaller-parameter model, compare loss convergence curves and numerical precision, and then scale gradually to the target size.
    2. Establish a baseline: Under the same data and hyperparameters, compare throughput (tokens/s) and memory usage against a mature compute platform to quantify adaptation quality.
    3. Freeze in stages: For multimodal models, validate the language backbone first, then introduce the vision branch, and locate problematic modules step by step.
    4. Prioritize stability stress testing: Memory leaks, communication timeouts, NaN divergence, and similar issues during long continuous training often appear only after several hours.
    5. Monitoring and observability: Integrate logging services and monitoring/alerting systems, and build dashboards for gradient norms, communication time, and device utilization to support rapid anomaly diagnosis.

    6. Conclusion

    Trillion-parameter model training adaptation is a systematic engineering effort involving distributed parallel strategies, operator ecosystems, compiler optimization, and stability engineering. Native support for FSDP2 and a complete training pipeline mark a key leap for the domestic compute software stack from being able to run inference to being able to perform training. As open-source large models and domestic compute continue to co-evolve, large-model training engineering on heterogeneous compute will keep maturing, providing a more solid technical foundation for diversified AI infrastructure supply.