LLM Inference Efficiency on Domestic Compute: Building a Token-Efficient Infrastructure
This article examines why LLM inference is becoming the primary workload for AI infrastructure and how token throughput, KV cache management, dynamic scheduling, quantization, communication-compute overlap, and unified evaluation affect real service efficiency. It also outlines a practical optimization path from baseline measurement to production validation for teams seeking to improve inference efficiency on domestic compute.
At the early stage of the large-model industry, attention focused on parameter scale, training data volume, and peak cluster compute. As models begin to support long-running online workloads such as search question answering, intelligent customer service, code generation, content moderation, and enterprise knowledge bases, the criteria for evaluating infrastructure are changing. A system must not only be able to compute; it must continuously produce tokens under complex requests, bursty traffic, and long-context scenarios.
This is also an important turning point for domestic compute as it moves from resource buildout to efficiency operations. More chips do not mean effective inference capacity grows proportionally. Business experience is often determined by how many tokens can be generated stably per unit time, how many requests can be served concurrently, how much memory and energy each request consumes, and whether the system can maintain predictable latency as load changes.
1. Inference Is Becoming the Primary Workload for AI Infrastructure
Model training usually has concentrated tasks, clear cycles, and relatively controllable resource scheduling. Online inference, by contrast, is characterized by long-running operation, significant request fluctuation, large differences in input length, and complex service levels. In long-context applications in particular, the inference stage needs to repeatedly access historical state, so memory capacity and bandwidth become increasingly important.
From a cost-structure perspective, inference spending continues to grow not only because request volume increases, but also because of the following factors:
Context length continues to expand
The longer the input, the more computation the prefill stage must process, and the more historical key-value state must be stored. For multi-turn dialogue, document analysis, and code understanding tasks, KV cache can become the main source of memory usage.Concurrent requests become more complex
In online services, requests differ in input length, output length, and generation speed. If scheduling follows only request arrival order, short requests may wait behind long requests, compute units may sit idle, and memory fragmentation may increase.Communication overhead becomes visible
When a model is split across multiple accelerators or even multiple compute nodes, tensor parallelism, pipeline parallelism, and expert routing all introduce communication. If communication cannot overlap effectively with computation, peak hardware compute is difficult to convert into actual throughput.
Therefore, inference optimization should not be understood as single-operator acceleration. It should be treated as a system engineering problem involving compute, storage, communication, scheduling, and energy.
2. KV Cache Is a Critical Resource for Long-Context Inference
During autoregressive generation, the model saves keys and values for tokens that have already been processed to avoid recomputing historical content each time a new token is generated. This cache is usually called KV cache. It can significantly reduce repeated computation, but it also introduces high memory usage.
The actual size of KV cache depends on the number of model layers, the number of attention heads, cache precision, context length, and the number of concurrent requests. Simply increasing cache capacity does not solve all problems, because larger capacity also raises management cost, movement cost, and fragmentation risk.
More effective optimization usually includes the following directions:
1. Use tiered caching
Cache can be divided by access热度 and latency requirements into high-speed device memory, host memory, and larger external storage. Recently active requests remain in the high-speed area, while temporarily inactive requests that may resume are migrated to lower-cost storage. This improves concurrency capacity and avoids keeping all cache permanently in the most expensive memory resources.
2. Adopt block-based management
Changing continuous cache into fixed-size logical blocks helps reduce memory fragmentation and supports cache block reuse, migration, and reclamation. For requests with the same prefix, part of the historical state can be reused under consistency requirements to reduce repeated prefill.
3. Introduce sparsity strategies
Not all historical tokens are equally important. For specific attention structures, windowing, blocking, or importance filtering can reduce the range of cache that must be continuously accessed. However, sparsity must be validated for accuracy; cache compression ratio should not be the only goal.
4. Let cache management participate in scheduling
Cache should not be only a passive resource inside the inference engine; it should become part of scheduling decisions. The system needs to consider the remaining request length, occupied cache, expected generation volume, and migration cost when selecting request combinations that are more suitable for batching.
3. Move from Static Configuration to Dynamic Scheduling
Traditional inference systems often use fixed batch size, fixed parallelism, and fixed memory allocation. Such configurations are simple in benchmarks but cannot fully adapt to real business traffic. Online requests are inherently uncertain, and static plans tend to create two problems: first, reserving large amounts of resources for peak traffic leads to low utilization during off-peak periods; second, compressing resources to improve average throughput can cause queuing and latency jitter during traffic bursts.
Dynamic scheduling can be developed at three levels.
The first is request-level scheduling. The system can group requests by input length, priority, and expected output length, and use continuous batching so that newly arrived requests can join the current batch without affecting tasks already in execution.
The second is resource-level scheduling. The scheduler needs to observe compute utilization, memory watermark, communication bandwidth, and cache hit conditions, and dynamically adjust parallelism. Compute-intensive requests should be given priority for compute resources. For long-context requests, cache pressure should be assessed in advance to avoid frequent migration caused by insufficient memory.
The third is service-level scheduling. Different businesses have different requirements for first-token latency, overall generation speed, and throughput. Interactive requests care more about whether responses are fast, while offline tasks care more about completed volume per unit time. The system should support multi-objective scheduling rather than pursuing a single throughput metric.
4. Quantization and Operator Optimization Must Work Together
Low-bit quantization can reduce memory usage and data movement, but quantization is not simply replacing floating-point numbers with lower-bit data types. Different layers and tensors have different sensitivity to precision. An unreasonable quantization strategy can degrade output quality and even offset the benefits of hardware acceleration.
In engineering practice, three points need attention at the same time:
- Precision calibration: Use representative business data to evaluate perplexity, task accuracy, and generation stability.
- Operator adaptation: Confirm that key operators such as matrix multiplication, normalization, activation functions, and sampling can use efficient implementations.
- Data layout optimization: Reduce frequent conversion of quantized data between different formats, so that operator acceleration is not slowed down by format conversion.
With suitable model structures and hardware support, quantization can improve memory capacity, memory bandwidth, and concurrency at the same time. However, the final result must be judged by end-to-end token throughput and business accuracy, not by the theoretical performance of a single operator.
5. Communication and Computation Must Form a Pipeline
The performance bottleneck of multi-card inference often comes from communication. After a model is partitioned, each layer of computation may need to exchange intermediate results. If communication happens before computation and blocks completely, it creates a serial process of compute, wait for communication, and compute again.
Optimization can consider:
- Overlapping communication operations with the next stage of computation;
- Reducing unnecessary data copies and format conversions;
- Choosing a suitable parallelism method based on model structure;
- Using a more reasonable placement strategy for frequently accessed data;
- Monitoring link bandwidth and communication wait time, rather than observing compute utilization only.
It is important to note that communication optimization cannot be separated from model structure. Higher parallelism can provide stronger theoretical compute capability, but it may also increase communication volume. The best configuration is usually not the one with the most cards, but the one that balances compute gains against communication cost.
6. Performance Improvements Need a Unified Evaluation System
Inference systems cannot be measured only by single-run peak throughput. A more reliable evaluation should include at least the following metrics:
- First-token latency: Measures how quickly a user receives the first response.
- Per-request generation speed: Reflects the continuous output experience.
- Total token throughput: Measures the overall processing capacity of the system.
- Concurrency capacity: Observes stable service capability under different loads.
- Memory utilization and cache hit rate: Indicates resource management efficiency.
- Tail latency: Focuses on high-percentile latency to avoid averaging hiding anomalies.
- Energy per token: Measures long-term operating cost.
- Accuracy and business success rate: Confirms that optimization does not harm model quality.
In one test, a long-context, low-bit inference configuration used shared cache and scheduling optimization to increase concurrency from a lower level to several times the original level, while raising peak decoding throughput by about 60%. Such results show that system software optimization can indeed release a large amount of unused hardware potential. In production environments, however, stability must also be verified under different input lengths, concurrency scales, and sustained operating conditions.
7. A Complete Optimization Path for Domestic Compute
For teams seeking to improve inference efficiency, a practical approach is baseline establishment, bottleneck identification, local optimization, and end-to-end validation.
The first step is to establish a unified baseline. Fix the model version, input and output lengths, quantization method, and concurrency pattern, and record latency, throughput, memory, communication, and energy data.
The second step is to identify the main bottleneck. Monitoring should determine whether the problem comes from insufficient compute, insufficient memory, inefficient cache management, communication blocking, or an unreasonable scheduling strategy.
The third step is to implement combined optimization. Do not modify only a single operator; evaluate cache, batching, quantization, parallelism, and memory management within the same framework.
The fourth step is to conduct stress testing. Simulate burst traffic, mixed long and short requests, request cancellation, and multi-tenant contention in real business scenarios, and observe whether the system shows significant tail-latency growth.
The fifth step is continuous operations. Inference optimization is not a one-time project. Model versions, business traffic, and context lengths will change, so continuous maintenance is needed through monitoring and alerting, automatic parameter tuning, and capacity forecasting.
Conclusion
As model training gradually shifts from one-time engineering to long-term online service, the way compute value is measured must also change. Truly competitive infrastructure is not just about having more chips. It is about organizing compute, cache, communication, and energy in a unified way to stably generate more effective tokens at a lower unit cost.
For domestic compute, inference optimization provides an important path to amplify value: hardware provides the basic capability, system software removes resource waste, and the scheduling system adapts to real workloads, together forming sustainable model service capability. In the future, competition around supernodes or large-scale accelerator clusters will increasingly focus on output per unit of compute, long-context capacity, service stability, and lifecycle energy efficiency.
