Self-Reliant LLM Inference Stack in China: From Open-Source Inference Frameworks to Domestic AI Accelerator Adaptation
This article explains why self-reliance in both models and computing power has become a strategic priority for large-model deployment. It breaks down the role of the inference engine, including computation graph optimization, KV Cache management, continuous batching, and serving capabilities. It also outlines the engineering steps required to adapt open-source inference frameworks to domestic AI accelerators, covering operator alignment, performance tuning, stability and accuracy regression, and end-to-end validation. Finally, it discusses what a viable commercial loop means and offers practical recommendations for developers building more resilient AI infrastructure.
1. Background: Why Both Models and Computing Power Need to Be Self-Reliant
The large-model technology stack can be roughly divided into four layers:
- Chip and computing power layer
- Base software layer, including drivers, compilers, and operator libraries
- Inference engine and serving framework layer
- Model and application layer
Over the past few years, many industry practices have been built on a combination of foreign chips, foreign inference frameworks, and open-source models. However, this combination has two structural risks:
- Supply chain risk: The supply of high-end computing power is uncertain. If procurement is restricted, both training and online inference may be disrupted.
- Ecosystem lock-in risk: Heavy dependence on a specific vendor’s proprietary toolchain leads to high migration costs and weak bargaining power.
As a result, the combination of domestic open-source models and domestic AI accelerators is becoming a strategic choice for many enterprises. To make this path work, the key is not any single point, but whether the inference engine layer can efficiently connect models and hardware.
Recently, a leading domestic open-source model team released the source code of its in-house inference framework. This is a landmark step in completing this layer. It means that the technical loop from model training to deployment and inference can be validated within a self-reliant system.
2. What an Inference Engine Actually Solves
Many developers still understand inference engines as simply “loading a model and running it.” In practice, a mature inference framework requires extensive engineering optimization across three dimensions: performance, cost, and usability. Its core work includes:
1. Computation Graph Optimization and Operator Fusion
Large-model inference involves fine-grained operators and frequent operator calls. An inference engine fuses fine-grained operators in the model computation graph, such as matrix multiplication, layer normalization, and activation functions, into larger hardware-friendly operators. This reduces operator scheduling overhead and the number of memory reads and writes.
On a self-developed hardware stack, this step usually requires deep coordination between the inference engine and the chip operator library. This is also the most valuable part of pairing domestic models with domestic accelerators: the model team understands its own model structure best and can design targeted fusion strategies.
2. Device Memory Management and KV Cache Optimization
For long-context inference, the main bottleneck is often not computing power but memory bandwidth. Common industry optimization methods include:
- PagedAttention-style paging management: Allocate KV Cache in blocks to reduce memory fragmentation.
- Prefix caching: Reuse computed KV states for multi-turn requests that share the same system prompt, significantly reducing first-token latency.
- Quantization compression: Store KV Cache at lower precision, such as INT8, trading acceptable accuracy loss for higher throughput.
3. Continuous Batching
Traditional static batching requires all requests in the same batch to wait until the longest sequence finishes before resources can be released, resulting in low utilization. Continuous batching allows requests to exit immediately after generation is complete and allows new requests to join at any time. It is one of the most important technologies for improving inference service throughput today.
4. Serving Capabilities
Serving capabilities include streaming output, load balancing across multiple replicas, health checks, and metrics exposure. An illustrative service configuration is shown below:
service:model: open-source-llmquantization: int8max_batch_size: 32max_sequence_len: 32768kv_cache: pagedprefix_caching: truereplicas: 4
3. Engineering Practices for Hardware-Software Co-Adaptation
Running an open-source inference framework on a domestic AI accelerator is not as simple as installing a driver. It usually requires several stages:
1. Operator Alignment
Every operator in the framework needs a hardware backend implementation. For missing operators or operators that do not meet performance requirements, additional implementations must be developed using the chip vendor’s operator development toolchain. Numerical accuracy must also be aligned and verified against the CPU reference implementation.
2. Performance Profiling and Tuning
Use the performance analysis tools provided by the hardware platform to determine whether the bottleneck is computation, memory bandwidth, or scheduling overhead. Then adjust operator partitioning strategies, parallelism, and pipeline scheduling accordingly. This stage often accounts for more than half of the total adaptation effort.
3. Stability and Accuracy Regression
Build an automated regression system: a fixed test set + output quality evaluation + long-duration stress testing. This ensures that quantization and graph optimization do not introduce unacceptable accuracy degradation.
4. End-to-End Validation
Finally, conduct end-to-end stress testing with real business workloads, including concurrency, sequence length distribution, and latency SLAs. Generate throughput-latency curves as the basis for capacity planning.
4. What a Closed Commercial Loop Means
A closed loop that actually works means three conditions are met at the same time:
- Technically usable: Inference performance and stability meet production requirements.
- Economically viable: Cost per token is comparable to traditional solutions, or even better.
- Sustainable in supply: Hardware, drivers, frameworks, and models all have stable sources and evolution paths.
For enterprises, the practical significance is that large-model application procurement decisions are no longer limited to a “single optimal solution.” Instead, there is now a complete alternative path. This itself improves supply chain resilience.
5. Practical Recommendations for Developers
- Keep the inference layer abstract: Application code should call inference services through a unified interface as much as possible, avoiding tight coupling with a specific engine API and leaving room for future migration.
- Establish evaluation baselines: Before switching computing power or inference engines, first build performance and quality baselines using your own business data. Any switch should be measured against these baselines.
- Prioritize quantization and caching optimizations: These two approaches usually offer the highest return on investment for cost reduction.
- Follow open-source communities: Domestic open-source inference frameworks are evolving quickly. Early participation in co-building can influence the technical direction and help absorb adaptation costs earlier.
- Run multi-cloud and multi-hardware drills: Complete at least one cross-hardware deployment drill to verify the substitutability of the technical path.
6. Conclusion
A self-reliant technology foundation is not just a slogan. It is a systems engineering effort in which chips, operator libraries, compilers, inference engines, and models interlock layer by layer. Deep adaptation between open-source inference frameworks and domestic computing power marks the transition of this path from “usable” to “well usable.”
For developers and enterprises, now is a good time to review dependencies in their AI infrastructure and plan for a diversified computing-power path in advance. Future competition will largely depend on whose AI foundation is more stable, more cost-efficient, and more sustainable.
