Domestic GPU Achieves Day-0 Adaptation for Trillion-Parameter Model: A Deep Dive into the Critical Path

    This article examines how a domestic AI accelerator completed Day-0 adaptation for a 3-trillion-parameter MoE model with a 1-million-token context window. It breaks down the full technical chain: migrating the inference engine from SGLang, mapping standard and custom operators onto the chip via compiler and operator libraries, handling MXFP4 expert weights through on-the-fly conversion and cross-layer workspace reuse, and balancing memory bandwidth against compute density. The article also distills engineering lessons on software-hardware co-design and what developers should evaluate in a domestic compute software stack.

    Background: Large-Model Compute Localization Enters the “Day-0” Era

    As large models cross the trillion-parameter threshold, inference serving places extremely strict demands on accelerator memory capacity, compute density, and the depth of software ecosystem adaptation. For domestic AI accelerator chips, whether they can complete adaptation at the first opportunity—“Day-0”—after the weights of the latest top open-source model are released has become a key test of software stack maturity and engineering delivery capability.

    Recently, an advanced large model with 3 trillion parameters (using a MoE architecture, with a vast total parameter count but limited activated parameters per inference) officially opened its weights. The model not only supports an ultra-long context window of up to 1 million tokens, but also demonstrates outstanding performance on benchmarks for agent tasks, code generation, and long-range planning, ranking first among open-weight models. For compute infrastructure providers, quickly and efficiently migrating such a frontier model seamlessly onto domestic accelerator cards—while ensuring inference performance and functional completeness are not compromised—is a systemic engineering effort involving multi-layer coordination across compilers, operator libraries, runtime scheduling, and memory management.

    This article uses the adaptation of this model as a case study to dismantle the complete technical chain from model structure adaptation to inference engine porting to low-level operator optimization, and to explore the common challenges and solution paradigms that domestic AI compute platforms face in deploying large models.

    1. Inference Engine Migration and Compute Path Reconstruction

    1.1 Engine Adaptation Strategy Based on Open Ecosystems

    When facing structurally complex frontier models, writing inference kernels from scratch is not a wise choice. The industry’s mature path is secondary development and low-level adaptation based on open-source high-performance inference frameworks such as SGLang and vLLM. In this adaptation effort, the technical team adopted a similar strategy: using SGLang—which supports multimodal and high-concurrency inference—as the upper-layer skeleton, and through its underlying abstracted scheduling and execution interfaces, mapping the key operators in the model definition one by one onto the compute units of the domestic accelerator card.

    The key to this process is “inheriting” rather than “rewriting.” The team needed to deeply understand the upstream model’s network structure (such as Transformer layer variants and improved attention mechanisms) and use hardware abstraction layer interfaces to convert computation graphs built by frameworks such as PyTorch into executable kernels on the target hardware. Here, the compiler and operator library play a central bridging role. Through a self-developed operator library and DSL compilers compatible with domains such as Triton and TileLang, the team successfully compiled the model’s standard operators (such as matrix multiplication and activation functions) and custom operators (such as sparse attention) into machine code adapted to the specific accelerator microarchitecture.

    1.2 Collaborative Work Between Compiler and Operator Library

    For the entirely new computation patterns introduced by this model, software stack adaptation is far from simple API replacement. For example, when handling the model’s sparse attention (DSA, an attention approximation algorithm designed for ultra-long contexts), the MUSA software stack completed a delicate connection from upper-layer indexing logic down to low-level kernels:

    • Index and cache layout: The DSA mechanism requires attention computation only on a subset of critical Key/Value pairs. The software stack needs to redesign the memory layout of the KV Cache to ensure that KV blocks selected by sparse indexing can be accessed with high bandwidth and low latency. This involves restructuring originally contiguous KV storage into block-based, paged management and optimizing cache hit rates.
    • Separation of Prefill and Decode paths: In the prefill stage, because a large number of input tokens must be processed in parallel, compute intensity is high; in the decode stage, it shifts to memory-bound autoregressive generation. The adaptation team customized sparse attention compute kernels separately for these two stages to ensure high hardware utilization under different compute characteristics.
    • Integration with state management: The model’s KDA (key-value state manager), together with cross-layer residual connections and visual attention (the model has multimodal capabilities), forms a complete execution chain. This means the sparse attention operator does not work in isolation; it must precisely interface with upstream state reads and downstream residual aggregation. Any timing misalignment or data format mismatch in any link will cause inference failure.

    2. Mixed Precision and Expert Parallelism: The Trade-off Between Memory and Compute

    2.1 Practical Handling of MXFP4 Expert Weights

    This trillion-parameter model adopts an extreme model compression strategy: the weights of its expert networks (Expert Weights) are stored in MXFP4 (a 4-bit microscaling floating-point format). Although this greatly reduces the memory footprint of the model, it brings severe challenges to actual inference computation—the native compute units of current mainstream accelerators (such as Tensor Cores or matrix engines) typically do not support direct operations on this format.

    The technical team did not choose a simple brute-force offline full decompression scheme, because although it would simplify the computation flow, it would sharply amplify memory usage and could even exceed the accelerator card’s capacity limit. Instead, it adopted a more refined dynamic conversion strategy:

    • Online conversion: Before expert weights are scheduled to compute units, dedicated conversion units inside the hardware (or optimized kernels) decompress MXFP4 data in real time into the higher-precision format required for computation (such as FP16/BF16).
    • Cross-layer workspace reuse: To avoid the overhead and fragmentation caused by repeatedly allocating and releasing memory, the team designed an FP8 workspace (intermediate buffer). Because the MoE model activates only part of the experts in a single inference, this workspace can be reused in sequence by expert computations across different layers. This design overlaps data conversion and matrix operations in the time dimension, effectively hiding the latency overhead of format conversion and achieving a Pareto optimum between memory usage and compute efficiency.

    2.2 The Art of Balancing Memory Bandwidth and Compute Density

    In LLM inference, especially in online conversion mode, memory bandwidth often becomes the bottleneck. Reading 4-bit weights and converting them to 16-bit computation means that the actual amount of data moved from memory is far smaller than the amount of data required for computation, which instead alleviates bandwidth pressure. On the other hand, the conversion process itself consumes extra compute cycles. Therefore, the core of adaptation work lies in accurately measuring and balancing these two factors. Through low-level performance analysis tools, developers can observe the impact of different conversion granularities (such as row-wise or block-wise conversion) on pipeline stalls, and then adjust the kernel’s parallel thread count and data block size to ensure that the conversion engine and matrix multiplication engine can work in parallel without blocking each other.

    3. Key Lessons for Engineering Deployment

    3.1 The Necessity of Software-Hardware Co-Design

    The success of this Day-0 adaptation was not accidental; it relied on early precise anticipation of model structure evolution and modular design of the software stack. The operator library provides rich atomic operations, the compiler has flexible code generation capabilities, and the runtime scheduler can dynamically orchestrate tasks according to model structure.

    • Standardized interfaces: Defining a unified parallel programming interface similar to CUDA but independent of specific hardware is key to attracting developers to migrate their ecosystems.
    • Automated toolchains: For patterns that repeatedly appear in models (such as MoE routing and sparse attention), provide auto-tuning tools to reduce the manual work of writing kernels.

    3.2 Implications for the Developer Ecosystem

    For developers hoping to use domestic compute in the large-model era, they should not focus only on a chip’s peak compute. They should pay more attention to the following capabilities of its software stack:

    1. Model migration cost: How well are mainstream open-source frameworks (such as HuggingFace Transformers and vLLM) supported? Is it necessary to modify a large amount of model definition code?
    2. Custom operator extensibility: When encountering entirely new operators in a model, are there convenient DSLs (such as Triton-like languages) or low-level APIs for quickly implementing high-performance kernels?
    3. Long-context support: As context windows evolve toward millions of tokens, KV Cache management strategies (such as the degree of PagedAttention adaptation) directly determine whether a model can run within limited memory.

    Conclusion

    This example shows that domestic AI accelerator cards are already capable of taking on the world’s most frontier large models, but behind this lies a deep campaign spanning compilers to operator libraries, and memory management to parallel scheduling. As more models adopt mixed precision and sparsification techniques, how to compensate for generational gaps in hardware architecture through software-defined optimization will be an important topic for the continued evolution of domestic compute. Future competition will be competition between ecosystem completeness and engineering depth, and Day-0 adaptation capability is precisely the most valuable ticket in this competition.