Instruction-Level Breakdown: How Domestic Chips Are Reshaping LLM Inference Costs
This article explains why instruction-level tracing reveals more about inference performance than peak benchmark numbers. It breaks down prefill and decode workloads, examines how attention changes affect memory access, and covers low-precision formats, operator fusion, and communication bottlenecks. Readers will find a practical cost model, an optimization sequence, and a deployment checklist for building a throughput-utilization-cost feedback loop.
1. Why Instruction-Level Breakdown Matters More Than Benchmarks
Traditional chip evaluation relies on peak compute and nominal bandwidth. Real inference workloads, however, are often bottlenecked not by compute but by how the instruction stream is organized: how many instruction blocks a single matrix multiplication is split into, whether operators have to fall back to VRAM, and whether communication instructions can overlap with computation.
Instruction-level tracing uses dedicated software and hardware to record execution paths, timing, and performance counters. It turns an “average latency” figure back into attributable time segments, making it possible to locate the real source of cost.
For LLM serving, cost is not the latency of a single request. It is the resource consumption per token under a given concurrency level. Evaluation therefore has to look at three curves at once: time to first token, per-token decode latency, and the number of tokens each card can stably output per second. Only when the third curve improves does the bill go down.
2. Inference Workload Splits Into Supply and Consumption
LLM inference is usually divided into two stages with nearly opposite resource profiles:
- Prefill: processes a long input in one pass, with large matrix shapes and high parallelism, constrained by compute and interconnect bandwidth.
- Decode: generates one token per step, repeatedly reading weights and the KV cache, constrained by VRAM capacity and memory bandwidth, and extremely sensitive to communication latency.
Putting both workloads on the same hardware causes interference: long prefill instruction blocks drive up decode queueing latency. The industry therefore commonly adopts a “heterogeneous resource division” approach, where one configuration emphasizes prefill and recommendation-style workloads while another emphasizes decode and training, with a scheduling layer routing requests by stage. The logic looks like this:
# Pseudocode: scheduling skeleton with stage-based routingdef route(request, pools):if request.stage == "prefill" or request.is_recommendation:return pools["throughput"].submit(request) # compute/interconnect firstreturn pools["decode"].submit(request) # bandwidth/capacity first
3. How Attention Changes Rewrite the Memory Access Ledger
Recent mainstream designs no longer rely solely on multi-head latent attention. They have shifted toward compression and sparsification: low-rank compression to shrink the KV cache, and sparse selection to reduce the number of token pairs that participate in computation. Mathematically, these designs trade a small amount of precision for a significant drop in memory access. The engineering implications are direct:
- Lower KV cache usage means the same VRAM holds longer contexts and higher concurrency.
- Sparse indexing creates irregular memory access, requiring hardware support for fine-grained gather/scatter and efficient cache line utilization.
- Compression and decompression form a new operator chain; if they cannot be fused, intermediate tensors bouncing to and from VRAM will eat the gains.
Model architecture, chip memory access, and compiler fusion must therefore be co-designed. One metric tells you whether the co-design is working: whether the VRAM bytes required to output each token during decode grows roughly linearly and stays controllable as context length increases.
4. Low Precision and Fused Operators: Where the Gains Come From
The benefit of low precision (such as 8-bit and lower floating-point/integer formats) is not simply “faster math.” It is three effects stacked together: weight read bytes are halved, on-chip cache hit rate improves, and parallel throughput increases. The risk is numerical stability, which requires layer-by-layer sensitivity analysis: keep high precision for sensitive layers, and use safe accumulation strategies for attention scores and normalization.
Operator fusion merges “multiply-add bias-activate-scale” into a single kernel launch, cutting launch overhead and intermediate tensors. An observable way to verify it:
Before fusion: n kernel launches, n-1 intermediate tensors written back to VRAMAfter fusion: 1 kernel launch, intermediate results stay in on-chip registers/shared memory
In decode, a scenario with many small operators and heavy memory access, fusion typically delivers more than a pure compute increase under the same conditions.
5. Communication and Parallelism: The Real Ceiling for Decode
When a model is split across multiple cards and machines, each decode step may need all-reduce or all-to-all to exchange activations and indices. If communication cannot be hidden behind computation, adding cards actually raises per-token latency. An actionable optimization order:
- Use tensor parallelism first to compress per-layer communication volume, then pipeline parallelism to split layers.
- Overlap communication instructions with computation instructions on different streams, avoiding clustered synchronization points.
- Minimize cross-machine traffic and complete high-frequency exchanges within a super node/high-bandwidth domain.
- Use hierarchical reduction to cut the number of small messages and lower the share of fixed latency.
6. Cost Model: Writing the Bill as a Formula
Let single-card decode throughput be T (token/s), the number of cards be N, and effective utilization be U. The cost per token is C = N × unit price / (T × U × duration). Four levers are clear: raise T (fusion and low precision), raise U (fewer bubbles and less queueing), lower N (communication efficiency and parallelism strategy), and use cache reuse to cut repeated prefill. Prefix cache hits are the cheapest optimization: when the same system prompt and long documents are reused, prefill cost can be amortized to near zero.
7. Deployment Checklist
- Are resources split into pools by stage, with independent scaling metrics?
- Are the two base metrics tracked: VRAM bytes per token and communication bytes per token?
- Is precision fallback applied to sensitive layers, with numerical regression cases?
- Are prefix caching and in-batch merging enabled, watching the tradeoff between time to first token and throughput?
- Is continuous tracing used instead of averages to locate long tails? Long tails determine the concurrency ceiling.
8. Conclusion
Top-tier models pushing the price of million-token context extremely low is essentially cross-layer cost engineering: model structures reduce memory access, chips provide high bandwidth and fine-grained memory access, compilers complete operator fusion, and frameworks handle scheduling and cache reuse. The takeaway for developers is that selection should not look only at nominal compute, but should be based on instruction-level observability, building a closed loop of “throughput-utilization-cost per token.” The combination of general capabilities on Baidu AI Cloud, including container platforms, monitoring and alerting, and log services, can support the engineering implementation of such a loop.
