Deep Adaptation of a Chinese LLM to a Domestic AI Chip: How Prefill Utilization Approaches Hardware Peak Performance

    This article examines how model–chip co-optimization enables a Chinese large language model to achieve approximately 425 TFLOPS during Prefill—98.5% of the chip’s theoretical peak—and about 372 TFLOPS during Decoding. It explains the role of head-dimension-128 fused attention kernels, the performance differences between Prefill and Decoding, and what model-specific operator implementations reveal about practical hardware adaptation. The article also summarizes optimization principles that developers can apply to other inference workloads.

    1. Background: Why Model–Chip Co-Optimization Matters

    The upper limit of large-model inference performance is never determined solely by a chip’s advertised compute capability. In practice, it is shaped by four layers of factors: algorithm structure, operator implementation, compiler toolchain, and hardware characteristics. The same model can deliver performance that differs by several times depending on how its operators are implemented.

    When a leading model vendor contributes dedicated fused-operator code for a Chinese AI chip to its open-source inference repository, the technical significance goes far beyond an ordinary feature update. It indicates that:

    • The model team is no longer treating the domestic chip as a fallback target for basic compatibility, but is optimizing specifically for its hardware characteristics.
    • The optimization has achieved measurable results: approximately 425 TFLOPS during Prefill, equivalent to 98.5% of the chip’s theoretical peak, and approximately 372 TFLOPS during Decoding, or about 86.1% utilization.
    • “Official contribution + dedicated implementation files” provides stronger technical evidence than marketing claims because the code can be inspected and verified line by line.

    Evidence collected from the open-source community shows a clear progression. First, support code for the chip platform was released, with official statements identifying the applicable model versions. Later, the core inference repository added fused operators targeting a specific attention mechanism, along with numerous dedicated operator implementation files named for particular model versions. The code also explicitly identifies the model type through enumerations.

    This step-by-step deepening of support is consistent with the typical engineering process for software–hardware co-optimization.

    2. Core Technical Analysis: Why the head128 Fused Operator Matters

    2.1 Computational Characteristics of Multi-Head Latent Attention

    Modern efficient attention mechanisms significantly reduce KV-cache memory usage through low-rank compression. However, their execution pipelines often contain long chains of small operators. If normalization, rotary positional embeddings (RoPE), attention computation, and data-type conversion are executed independently, they introduce three major sources of overhead:

    1. Memory-traffic amplification: Intermediate results must be repeatedly moved between on-chip buffers and external memory.
    2. Kernel-launch overhead: A large number of small operators amplifies the fixed cost of scheduling and launching kernels.
    3. Idle compute capacity: Memory-bound operations occupy execution windows that could otherwise be used for computation.

    2.2 The Engineering Value of Fused Operators

    A fused operator, or fused kernel, performs several of these operations within a single kernel invocation. This is a typical optimization strategy that trades additional computation for reduced memory traffic.

    With a common configuration such as head_dim=128, a fused operator can:

    • Combine normalization, positional encoding, core attention computation, and precision conversion into one kernel.
    • Substantially reduce global reads and writes of intermediate tensors, alleviating memory bottlenecks.
    • Keep compute units busy during Prefill, a phase dominated by large GEMM operations. This is a major reason Prefill utilization can approach 98.5% of the theoretical peak.

    The difference between the unfused and fused execution structures can be illustrated as follows:

    1. # Before fusion: multiple independent kernel calls
    2. x = layer_norm(x)
    3. x = rope(x, pos)
    4. attn_out = mha_attention(x, kv_cache)
    5. x = cast_to_fp32(attn_out)
    6. # After fusion: a single kernel call
    7. x = fused_norm_rope_attention_cast(x, kv_cache, pos)

    2.3 Why Prefill and Decoding Have Different Utilization Rates

    Prefill processes long input sequences with a high degree of parallelism, making it a compute-intensive workload that can approach the hardware’s theoretical limit.

    Decoding generates one token at a time. Its batch dimension is more constrained, and memory access accounts for a larger share of the workload. As a result, utilization in the mid-80% range is already considered excellent in industry practice.

    Achieving high utilization in both phases suggests that the optimization covers the full inference path rather than targeting only benchmark-friendly scenarios.

    3. What Dedicated Operator Instances and Model-Version Markers Reveal

    The presence of numerous dedicated implementation files tied to specific model versions, together with explicit model-type enumerations such as constants in the style of ModelType::V41, reveals two important engineering signals.

    1. Customization at the graph-compilation level: Dedicated computational graphs can be generated for a specific model architecture, avoiding the performance loss associated with generic execution paths. This reflects the idea that the model itself should be treated as part of the hardware workload and therefore as an optimization target.
    2. Verifiable version alignment: Explicitly declaring the supported scope—for example, limiting an implementation to a particular model version—helps prevent misuse. It also shows that the optimization was delivered as a fully validated engineering implementation rather than as incidental compatibility.

    4. Lessons for Developers: How to Apply This Optimization Methodology

    Even developers who do not work directly on chip adaptation can draw broadly applicable lessons from this approach:

    • Eliminate chains of small operators first: Use operator fusion and graph optimization in inference or training workloads to reduce the number of kernel launches.
    • Optimize Prefill and Decoding separately: The two phases have different bottlenecks, so each should have its own performance baseline and optimization strategy.
    • Use measurable metrics to guide optimization: Treat hardware peak utilization as a north-star metric. This helps prevent local improvements that produce little overall impact.
    • Prioritize open-source evidence: Compared with claims made during product announcements, repository commits, performance test scripts, and dedicated implementation files provide more reliable technical evidence.

    5. Conclusion

    When leading large-model vendors begin adapting Chinese AI chips through official code, dedicated operators, and measured performance close to the hardware peak, the ecosystem combining Chinese models with Chinese chips is moving from a slogan toward an engineering reality.

    For developers, this provides both a clear example of software–hardware co-evolution and a reusable methodology for performance optimization. Whether this approach can continue to scale across more model sizes and future chip generations remains an issue worth tracking and validating through further implementation evidence.