Instruction-Level Analysis: How Domestic AI Chips Are Reshaping LLM Inference Costs
This article explains how instruction-level tracing reveals where large language model inference costs actually come from, going beyond peak compute and memory capacity. It covers co-designed model and hardware paths, attention mechanism changes, stage-specific chip specialization, and layer-by-layer optimizations such as parallel scheduling, operator fusion, low-precision quantization, and MoE communication. Readers will find a reusable, trace-driven methodology for attributing bottlenecks and reducing cost per token while maintaining P99 latency.
1. Why Instruction-Level Analysis Is a New Lens on Inference Cost
AI chips have traditionally been evaluated on two dimensions: peak compute and memory capacity. In real-world LLM inference serving, however, neither metric explains the bill. The actual cost per token is driven by memory access efficiency, operator fusion, scheduling gaps, and the share of collective communication. Instruction-level tracing makes end-to-end speed attributable: it records the execution trace, timing relationships, and performance counters inside the chip, mapping every millisecond to a specific operator, memory transaction, or communication primitive.
A recent public analysis from a semiconductor research organization noted that a new generation of high-end domestic AI chips runs a flagship open-source LLM inference pipeline in which parts of the model structure were co-designed for domestic inference hardware, rather than passively adapted after the model was released. This matters far beyond a compatibility check: the inference path, execution strategy, and software stack were refined together at an earlier stage.
2. How Model-Side Changes Force Hardware-Side Restructuring
Two moves in the latest flagship model iteration stand out.
First, the attention mechanism was restructured. Traditional multi-head latent attention reduces KV cache footprint through low-rank compression, but the decode phase still reads the cache repeatedly, creating a memory wall. The new approach combines compressed sparse attention with highly compressed attention: the former restricts attention computation to positions judged critical, while the latter stores historical states at an extremely low bit budget.
The following illustrative code shows the difference in execution semantics:
# Traditional path: full KV read + dense scoringscores = softmax(Q @ K_all.T / sqrt(d))out = scores @ V_all# Sparse compressed path: select blocks first, then compute; memory traffic drops with sparsityidx = topk_block_score(Q, K_compressed, budget=1024)out = sparse_attn(Q, K_compressed[idx], V_compressed[idx])
Second, product lines are being split by stage. The industry has seen chip designs divided by phase: one type targets Prefill and recommendation workloads, emphasizing dense compute and batch throughput; another targets Decode and training, emphasizing memory bandwidth, low-precision compute, and inter-card interconnect. This division is rational because Prefill is compute-intensive while Decode is memory-intensive. Their bottlenecks are entirely different, and a single configuration serving both phases inevitably wastes resources.
3. Layer-by-Layer Breakdown: Where the Cost Is Squeezed Out
3.1 Parallel Scheduling: Removing the Bubbles
A single Decode step involves little computation, so kernel launch overhead and synchronization waits are amplified. Common techniques include graph-mode capture, automatic operator batching, and merging multiple small operators into a single dispatch submission. To check whether the optimization works, look at whether the gaps between kernels in the trace converge, not at the duration of any individual kernel.
3.2 Operator Fusion: Fewer Intermediate Tensor Writes
Fusing attention with normalization, residual connections, and activations can compress multiple memory round trips into one. The key constraint is register and on-chip buffer capacity, so fusion strategies must be selected dynamically based on head dimension and sequence length rather than a fixed template.
3.3 Low Precision and Quantization: Trading Bandwidth for a Precision Budget
Quantizing weights and the KV cache directly reduces memory access bytes. The more robust engineering route is mixed precision: matrix multiplications run at low precision, accumulation and normalization keep higher precision, and outlier channels are handled separately.
3.4 MoE Communication: Making All-to-All a Predictable Cost
In mixture-of-experts structures, only a few experts are activated per token during decoding, and routing introduces dynamic All-to-All traffic. There are three optimization priorities: caching routing results locally to improve hit rates, overlapping communication with computation, and reordering by expert popularity to reduce cross-node traffic. If the communication share cannot be squeezed into an acceptable range, even the highest per-card compute will be held back by the interconnect.
4. A Reusable Engineering Methodology
- Establish a baseline trace first, clarify the shares of memory access, compute, and communication, then decide the optimization order;
- Use a fixed input distribution for regression testing to avoid “individual requests get faster while overall P99 gets worse”;
- Treat batch size, context length, and sparsity budget as joint tuning dimensions rather than independent variables;
- On the serving side, combine prefix caching, continuous batching, and tiered storage to amortize repeated Prefill cost;
- Build dual dashboards for cost per token and P99 latency on top of container platforms and monitoring and alerting systems.
5. Conclusion
Inference cost reduction is never a single breakthrough. It is a systemic cost campaign involving model structure, chip bandwidth, compilers, fused operators, inference frameworks, and cloud services. Once models and hardware enter a co-design phase, migration gains strong inertia. For developers, the practical approach is to master trace-driven analysis and base optimization on correct attribution of bottlenecks. On platforms such as Baidu AI Cloud, general capabilities like containerized inference services, object storage, and log monitoring can be combined to build a high-concurrency inference system that is continuously observable and continuously cheaper.
