Day-0 Model Adaptation in Practice: Deploying a Trillion-Parameter Sparse Attention Model on Domestic AI Accelerators

    This article examines the technical approach behind achieving Day-0 support for a frontier large language model on a domestic training-inference integrated AI accelerator. It details the core engineering work involved in adapting a 3-trillion-parameter sparse attention model with million-token context support, covering framework customization, operator-level optimization, online MXFP4 weight conversion, and memory optimization strategies. The discussion provides practical insights into how software-hardware co-design enables rapid deployment of cutting-edge AI models on non-native accelerator stacks.

    In AI infrastructure, the gap between the rapid iteration pace of large language models and the adaptation speed of underlying compute platforms remains a central bottleneck for real-world deployment. As frontier models release new architectures and weights at near-monthly intervals, the ability to achieve Day-0 inference—running a model on the same day its weights are publicly released—has become a key measure of an accelerator platform’s technical depth and engineering maturity. This article walks through the technical process and engineering decisions involved in adapting a frontier model with 3 trillion total parameters (MoE architecture) and 1 million-token context support to a domestic training-inference integrated AI accelerator card and its accompanying software stack.

    1. Challenges and Overall Strategy for Day-0 Adaptation

    Day-0 adaptation means that on the same day model weights are released to the open-source community, the compute platform is ready to run inference through a fully integrated stack—from low-level drivers and operator libraries to the high-level inference framework. This requires solving multiple challenges: the model’s 3-trillion-parameter MoE architecture creates significant pressure on memory capacity and bandwidth, while the 1 million-token context window makes full attention computation prohibitively expensive. A traditional dense-model inference approach is insufficient for such workloads.

    The adaptation strategy here rests on four pillars: framework adoption, operator-level rewriting, storage optimization, and precision management. We use a highly extensible open-source inference framework as the base, add a custom acceleration layer, and then perform operator-level optimization tailored to the model’s sparse attention mechanism and mixed-precision expert weights—rather than relying on generic libraries. We also implement fine-grained memory management and online data conversion to work around hardware limitations in certain data format support.

    2. Compute Path Migration and Operator-Level Rewriting

    Migrating community code for a model with new architectural designs into an efficient inference service running on a specific accelerator involves far more than a simple compilation task. It is a system-level engineering effort spanning algorithm mapping and instruction-set optimization.

    Framework-level adaptation: deep customization of SGLang
    We selected the SGLang inference framework as the high-level execution layer. To adapt it to the accelerator’s proprietary instruction set, we maintain a fork (named SGLang-MUSA) that strips out the original framework’s dependencies on specific GPU hardware and reconnects to the vendor-provided MUSA driver and runtime environment. This approach lets us reuse upstream community improvements such as continuous batching, prefix caching, and RadixAttention, ensuring the scheduling layer stays competitive with mainstream closed-source solutions.

    Operator library and compiler co-design
    A single toolchain cannot cover all new operator types. We employ a combined strategy: for critical, compute-heavy operators with fixed patterns, we write and tune them directly in the MATE high-performance operator library. For operators with more complex logic but regular data flow, we use domain-specific languages like Triton-MUSA and TileLang-MUSA for rapid prototyping and auto-tuning. For edge cases involving dynamic shapes or special data layouts, we use the MTCC compiler with inline assembly interfaces. This multi-path approach ensures both standard matrix multiplications and complex gather operations achieve high compute efficiency.

    3. Engineering Long Context with Sparse Attention

    For a model supporting 1 million tokens, full attention is computationally and memory-prohibitive. The target model uses sparse attention (DSA), which requires us to build an execution path precisely matched to that mechanism.

    Index selection and KV cache layout optimization
    In sparse attention, each query token attends only to a selected set of key-value pairs based on criteria such as importance-based Top-k selection, rather than to all historical tokens. The first engineering challenge is making the index-selection operator efficient. We implemented an index-computation kernel that leverages tensor cores to quickly filter relevant KV pairs with low latency. Meanwhile, the KV cache layout must shift from standard contiguous blocks to a block-based or paged layout so that sparse index-based access can work without severe memory fragmentation.

    Pipelining Prefill and Decode paths
    The sparse attention mechanism behaves differently in Prefill and Decode phases, so we customized the execution path separately. During Prefill, which is throughput-bound and highly parallel, we use high-performance sparse attention operators from the MATE library, processing index and attention scores as flattened batched matrix operations. During Decode, which is latency-bound and inherently serial, we switch to lightweight gather-based operators that directly fetch the needed entries from the KV cache and compute attention output on the fly. This avoids thread-warp divergence that sparse operations would otherwise trigger in token-by-token generation.

    4. Online Conversion of Mixed-Precision Expert Weights and Memory Optimization

    In addition to the attention mechanism, the model’s use of MXFP4-format expert weights posed another major challenge. MXFP4 is an extremely low-precision format that significantly reduces model storage and bandwidth requirements. However, the target hardware does not natively support efficient FP4 matrix multiplication.

    Online conversion with reusable FP8 workspace
    A conventional approach is to convert FP4 weights offline to FP8 or BF16 before deployment. But for models with 3 trillion parameters, offline conversion generates enormous temporary files and complicates the deployment process. Instead, we implemented an online conversion mechanism with cross-layer reuse of a temporary FP8 workspace. Rather than storing full FP8 copies in global memory, we allocate a temporary FP8 buffer only for the currently computing expert layer. As the model executes each layer, the scheduler decompresses that layer’s MXFP4 weights, converts them to FP8, and loads them into the workspace for computation. When the next layer begins, the previous workspace is released and reused. This reduces peak memory pressure by roughly 40% compared to full offline conversion, and cuts model load time to minutes.

    Full computation path integration
    The sparse attention path and MXFP4 online conversion must work in harmony with KDA attention state management, cross-layer residual connections, and the model’s visual attention modules for multimodal capability. We integrated these into a complete execution DAG and used a custom asynchronous scheduler with topological ordering to enable pipelined execution—overlapping attention computation with weight conversion across separate streams. This hides conversion latency and results in a fully operational pipeline from model loading and service startup to text and image multimodal inference on the domestic accelerator.

    5. Conclusion and Outlook

    This Day-0 adaptation effort for a trillion-parameter sparse attention model demonstrates the responsiveness and engineering depth of domestic software-hardware stacks when faced with frontier AI architectures. The core takeaway is to avoid merely aiming for “it runs” and instead analyze the model’s algorithm characteristics deeply, then drive coordinated optimization across operator libraries and compilers. With framework-level adaptation, operator-level rewriting, and careful runtime memory management, it is feasible to achieve near-lossless performance on non-native accelerators.

    Looking ahead, as sparse architectures and mixed-precision techniques become more common, software-hardware co-design will only grow in importance. We intend to continue improving the compute density of online decompression kernels and further explore inference optimization strategies for even longer context windows, helping to provide a robust and efficient compute foundation for the broader LLM ecosystem.