Instruction-Level Analysis: How Domestic AI Chips Are Reshaping LLM Inference Costs

    This article breaks down large language model inference down to the instruction and execution-path level to explain where inference costs actually come from. It separates Prefill and Decode workloads, shows why Decode is constrained by memory bandwidth, and examines how compressed and sparse attention, supernode interconnects, memory hierarchies, and Mixture-of-Experts routing shift the bottleneck toward communication. It also covers the software stack—compiler operator fusion, low-precision formats, and memory reuse—and the observable metrics worth tracking, such as fusion rate, bandwidth utilization, and tail latency percentiles. Finally, it outlines a four-step migration path from an existing stack to a domestic chip platform: baseline capture, shadow traffic, staged cutover, and continuous observability.

    1. Why Instruction-Level Analysis Matters More Than “Does It Run”

    Discussions of domestic AI chips often stop at a binary question: can they replace existing hardware? Once large models move into high-concurrency online serving, however, commercial viability is decided by different metrics—cost per token, tail latency stability, and memory bandwidth utilization under long contexts. Evaluation has to move down to the instruction and execution-path level: how operators are fused, how tensors are partitioned, how communication overlaps with computation, and whether memory accesses are compressed. These details together determine the effective compute a piece of hardware can actually deliver.

    Path-level or instruction-level analysis means using dedicated software and hardware to record a program’s execution trace, timing, and performance counters inside the chip, reconstructing the full path a single inference request takes from entering the runtime to producing its final output. Its value is turning a paper metric like peak compute into real, explainable, and optimizable bottlenecks.

    2. Structural Breakdown of Inference Cost: Prefill and Decode Are Two Different Workloads

    LLM inference typically splits into two phases with very different hardware demands:

    • Prefill: processes the input prompt in one pass; compute-intensive with high parallelism, mainly consuming matrix-multiply throughput.
    • Decode: generates tokens autoregressively one at a time; memory-access-intensive with low parallelism, mainly consuming memory bandwidth and scheduling efficiency.

    In practice, the two workloads are often deployed on separate resource pools—the former optimized for supply throughput, the latter for cost per token. Decode is the most expensive phase because every generated token requires re-reading the weights and the ever-growing context cache, leaving compute largely idle while bandwidth becomes the hard constraint.

    A schematic cost-attribution logic can be expressed as:

    1. # Illustrates cost attribution logic only; not any vendor's real billing rule
    2. def per_token_cost(decode_ms, qps, node_price_per_hour, tokens_per_req):
    3. node_cost_per_ms = node_price_per_hour / 3600 / 1000
    4. return decode_ms * node_cost_per_ms / max(qps, 1e-6) / tokens_per_req

    The variables that can genuinely be optimized cluster in three places: reducing decode_ms (scheduling and operator efficiency), raising qps (batching and concurrency orchestration), and cutting wasted memory accesses (cache compression and low precision).

    3. The Memory-Access Dividend from Attention Evolution

    Recent mainstream designs are moving away from standard multi-head attention toward variants centered on compression and sparsity: carrying the key-value cache in a lower-dimensional latent space, or letting each query attend to only a few selected history blocks. The engineering implication is direct—both the capacity and the read volume of the context cache shrink substantially.

    Take million-token contexts as an example. If the cache is stored in low precision and selected sparsely at block granularity, the data that must be moved per token can drop by an order of magnitude. This gain is amplified in the Decode phase because it acts directly on the bandwidth bottleneck. One caveat: sparsification introduces extra operators for selection, sorting, and block indexing. If the hardware and compiler cannot fuse these small operators into the main compute flow, scheduling overhead will eat the benefit. This is exactly where instruction-level analysis proves most valuable: it quantifies whether fusion actually happened.

    4. Key Chip-Side Capabilities: Supernode Coordination and the Memory Hierarchy

    Facing trillion-parameter models and extremely long contexts, a single card’s memory cannot hold everything, so high-speed multi-card, multi-node interconnect and a unified memory view are required. The industry commonly adopts a tightly coupled “supernode” topology that brings dozens to over a hundred accelerators into a low-latency domain, making cross-card access approach local access in latency terms.

    Three capabilities need to be in place together to support this topology:

    1. High-bandwidth memory and a sensible memory hierarchy, so residency policies for weights and caches stay predictable.
    2. Low-latency collective communication across cards and nodes, supporting hybrid partitioning of tensor parallelism and expert parallelism.
    3. Runtime scheduling that overlaps computation and communication, so communication is hidden behind computation rather than waited on serially.

    5. Mixture-of-Experts Models: Communication Is the Real Battleground

    Mixture-of-Experts architectures distribute parameters across multiple expert units, with each token activating only a few of them. This lowers per-token compute but shifts pressure onto routing and all-to-all communication. The engineering priorities are:

    • Route balancing: avoid hot experts that skew load, otherwise overall throughput is held back by the slowest node.
    • Communication-computation overlap: split dispatch and aggregation into pipeline stages that interleave with expert computation.
    • Precision tiering: routing and scoring can use lower precision, while the main matrix multiplies keep the precision needed to preserve quality.

    Pseudocode for the scheduling skeleton:

    1. # Illustrative pipelined scheduling skeleton for expert parallelism
    2. for stage in pipeline:
    3. tokens = route(tokens, top_k=2) # routing scores
    4. dispatch(tokens, overlap_with=stage.gemm) # dispatch overlapped with compute
    5. out = expert_forward(tokens) # expert computation
    6. combine(out, overlap_with=stage.next) # aggregation overlapped with next stage

    6. The Software Stack: Compilers, Fused Operators, and Low Precision

    Hardware advantages do not materialize on their own; the compiler and operator libraries sit in between. Three things decide real efficiency: whether operator fusion covers the actual compute graph, whether low-precision formats are supported end to end, and whether memory allocation is reusable to avoid repeated allocation. Low precision (8-bit floating point and narrower quantized formats) reduces both bandwidth and capacity pressure, but it must be paired with per-channel scaling, outlier handling, and keeping critical layers at higher precision to hold output quality.

    Three observable metrics are worth tracking during evaluation: operator fusion rate, bandwidth utilization, and tail latency percentiles. Average latency alone hides long-tail jitter, and the online serving experience is decided by the tail.

    7. Migration Decisions: How to Judge the Right Time to Switch

    Migrating from an established ecosystem to a domestic foundation is essentially a reassessment of cost structure, not a one-time swap. A four-step approach is recommended:

    1. Fix the baseline: record current cost per token, P99 latency, and concurrency ceiling.
    2. Shadow traffic: replay real requests in mirror mode and compare output consistency and quality metrics.
    3. Staged cutover: take on memory-access-intensive workloads like Decode first, then gradually bring in Prefill.
    4. Continuous observability: bring bandwidth utilization, fusion rate, and communication share into monitoring, alerting, and logging.

    When model architecture and chip characteristics are co-designed, gains stop coming from single-point optimization and instead come from the whole chain—model, compiler, operators, runtime, and cloud service—converging together. At that point migration tends to become irreversible, because the cost advantage keeps reinforcing itself.

    8. Conclusion

    Low-cost, high-concurrency capability at the top model tier is a cost campaign fought jointly by model architecture, chip bandwidth, compilers, fused operators, the inference framework, and cloud services. The takeaway for developers and enterprises is clear: move evaluation granularity from “does it run” to the instruction and path level, and drive optimization with observable metrics. That is how you actually gain cost control in long-context, high-concurrency scenarios. Teams that want to validate a similar path on Baidu AI Cloud can start with general-purpose capabilities such as the container platform, object storage, logging service, and monitoring and alerting to build a reproducible load-testing and observability loop.