Inference Cost Optimization on Domestic AI Chips: A Practical Guide to LLM Deployment and Unit Economics
This article translates a research-report observation into an engineering playbook for large language model inference. It explains why inference is usually localized before training, then walks through the key optimization layers on domestic accelerators: operator and graph optimization, quantization and sparsity, continuous batching and scheduling, prefix caching, and elastic scaling, along with cluster-level practices such as fault-domain isolation and topology-aware scheduling. It also defines an auditable cost model for gross-margin breakeven, a deployment topology that keeps compute and data in-region under cross-border compliance constraints, and the revenue metrics that make commercial claims verifiable. The closing sections cover implementation on general-purpose cloud product categories, a risk checklist, and a concrete first step for developers: instrument per-request GPU-hours and quality costs.
1. The Starting Point: Three Hard Constraints on LLM Engineering
A research institution recently maintained an overweight rating on a generative AI company. The core rationale was not a single technical lead but three engineering facts holding at the same time: a cluster of more than 100,000 domestic chips already serving large-scale inference; a specific lightweight model reaching positive gross margin on inference over domestic chips; and more than 80% of revenue coming from a single regional market, with overseas compute assets held by a partner.
Abstracted from these three points are the hard constraints any LLM team faces:
- Compute constraint: access to advanced-process chips is uncertain, so inference cost has to come down through engineering rather than simply adding more cards.
- Compliance constraint: cross-border data and compute flows are restricted by rules, so the deployment topology must be fixed at the design stage.
- Commercial constraint: when revenue is highly concentrated in the local market, the growth curve is tightly coupled to local application penetration, and the cost model must move in step with the revenue model.
This article evaluates no specific company. It rewrites the above observations as an actionable technical design.
2. Inference Engineering on Domestic Compute
2.1 Why Inference Comes Before Training in Localization
Training demands extremely high interconnect bandwidth, per-card memory, and numerical stability, which makes migration expensive. Inference is measured by throughput, latency, and cost per request, and its operator patterns are comparatively converged, which makes it a better entry point for domestic chips. The usual engineering order is inference first, training later.
2.2 Key Optimization Layers
- Operator and graph optimization: rewrite hot operators such as attention and normalization for the instruction set of domestic accelerators, and use a graph compiler to fuse operators and reduce memory round trips for intermediate tensors.
- Quantization and sparsity: quantizing weights and activations (for example, low-bit integer representations), compressing the KV cache, and applying structured sparsity directly determine how much concurrency a single card can carry.
- Batching and scheduling: continuous batching groups short and long requests together, with priority queues to keep long requests from blocking others; latency-sensitive traffic gets its own resource pool.
- Cache reuse: prefix caching hits at a very high rate for system prompts and long-document question answering, making it one of the fastest ways to cut cost.
- Elastic scaling: trigger scale-out and scale-in on two signals, queue length and time to first token, instead of statically holding capacity for peak load.
Illustrative server-side pseudocode showing how batching and caching cooperate:
# Illustrates scheduling logic only; not the interface of any specific productdef on_request(req, scheduler, prefix_cache):cached = prefix_cache.lookup(req.prompt_prefix)if cached is None:cached = scheduler.prefill(req) # computed once, then written to cacheprefix_cache.store(req.prompt_prefix, cached)batch = scheduler.form_batch(req, cached) # continuous batchingreturn scheduler.decode(batch) # decode is bound by memory bandwidth
2.3 Cluster-Level Engineering
Availability at the 100,000-card scale depends not on single-card peak performance but on fault-domain isolation, topology-aware scheduling, and checkpoint frequency. Common practices include dividing fault domains by rack, keeping communication-heavy jobs inside one switching domain, and running stateless inference replicas with fast traffic draining, so a single point of failure does not escalate into a regional outage.
3. What “Positive Gross Margin” Actually Means: An Auditable Cost Model
Positive gross margin is not a marketing statement but a metric that finance and engineering can audit together. The recommendation is to break unit cost into attributable layers:
- Direct costs: card-hour depreciation or rental, data center space and power, network;
- Amortized costs: R&D amortization during model iteration, data and labeling;
- Quality costs: retry rate, timeout rate, share of human fallback.
This yields a unit-economics formula:
gross margin per request = revenue per request − (card-hour cost × card-hours per request) − amortization − quality costpositive gross margin ⇔ the expression above stays above 0 across the measurement period
The only variables engineering can move are card-hours per request and quality cost, which is why optimization has to return to the operators, quantization, batching, and caching of Section 2. Put this model on a dashboard segmented by model version, scenario, and customer tier; only then can you tell whether breakeven is sustainable rather than a one-week accident.
4. Deployment Topology Under Compliance Constraints
When rules restrict remotely calling advanced chips through a third-country data center, the workable architecture converges compute and data inside the region and exports model capability across the border rather than compute. The logical layers:
- In-region layer: the inference cluster, vector retrieval, logs, and audit data all stay local;
- Edge layer: request sanitization, rate limiting, and protocol conversion only, with no model weights;
- Overseas layer: compute assets held by a local partner, called through standard interfaces, with no data leaving the region.
Three supporting pieces are required: data classification with an export inventory, separate key and weight domains, and end-to-end call auditing. The value of this topology is turning compliance from an after-the-fact explanation into a property of the architecture itself.
5. Commercial Metrics: Annual Recurring Revenue and Revenue Mix
When annual recurring revenue is the external target, three definitions must be stated or the number cannot be verified: count only renewable subscriptions and usage commitments, annualize on a rolling basis from the current month, and exclude one-off project delivery. Revenue mix matters just as much: a high share from a single region ties growth to local application penetration, and the engineering answer is to push inference cost low enough that long-tail scenarios also reach positive gross margin, expanding the number of billable scenarios.
6. Implementing This on General-Purpose Cloud Capabilities
The capabilities above can be assembled from common cloud product categories without proprietary interfaces: a container platform hosts inference replicas and elastic scaling; object storage holds model weights and datasets; a message queue smooths peaks and decouples prefill from decode; logging and monitoring with alerting provide latency, throughput, failure-rate, and card-hour dashboards; key management handles separate domains for weights and credentials. Baidu AI Cloud offers this class of general-purpose capabilities and can serve as a reference foundation for building a similar architecture.
7. Risk Checklist and Responses
- Export controls and geopolitics: make domestic compute the primary capacity and keep a multi-architecture abstraction layer;
- Intensifying competition: differentiate on unit cost rather than parameter count;
- Execution pressure from heavy R&D spending: fold R&D amortization into the unit-economics dashboard;
- Uncertain customer adoption: validate a narrow scenario first, then replicate horizontally;
- Dependence on external suppliers: build critical operators and scheduling in-house to avoid single-point lock-in.
8. Conclusion
The engineering translation of the research conclusion is one sentence: when inference cost on domestic compute is low enough for sustainable unit economics, the deployment topology is compliant by construction, and the revenue definitions are auditable, the gap between market sentiment and fundamentals gets corrected. For developers, the executable first step is to instrument card-hours per request and quality costs, then move on to operator optimization, quantization, batching, and cache reuse in that order.
