Why LLM Inference Costs Can Drop to One-Quarter
This article explains why a "permanent price cut to one-quarter" for LLM inference usually comes from cost structure rather than cheaper hardware. It breaks inference cost into memory footprint, compute per request, and scheduling efficiency, then walks through KV Cache, a memory capacity estimation formula, and prefix reuse as the main levers. Readers will learn how to estimate monthly cost, which metrics to monitor, and how to judge whether a price cut reflects sustainable engineering gains or a short-term subsidy.
1. The Real Issue Behind the Price Cut: Cost Structure, Not Unit Price
When a cloud provider announces that a class of LLM inference service is “permanently reduced to one-quarter of the price,” developers most often misread it as “compute has become cheaper.” The real reason is usually not the hardware purchase price, but a large reduction in the effective resources consumed per request. Inference cost can be roughly split into three parts: memory footprint determines the concurrency ceiling, compute usage determines per-request latency, and scheduling efficiency determines actual utilization. Optimizing any one of these lets the same bill buy several times the throughput.
The “cache hit rate close to 100%” experience circulating in the community essentially shows one thing: a large share of requests share repeated or highly similar input prefixes, and those repeated parts could be computed only once. Whoever eliminates that repeated computation can push marginal cost extremely low.
2. KV Cache: Where the Repeated Computation in Autoregressive Generation Comes From
Text generation is an autoregressive process: it produces one token at a time, then appends it back to the sequence to continue. Without caching, the second step has to recompute the Key and Value of the first three words, even though they were already computed in the first step and are exactly the same. That is pure waste.
KV Cache works like this: after each token is computed, its K and V are written to GPU memory; later steps only compute the Q of the newest token, then run attention scoring against all cached K and take a weighted sum over the cached V. So the work per step drops from “processing the whole sequence” to “processing one token.”
Illustrative pseudocode:
# No cache: recompute the full sequence at every stepfor _ in range(max_new_tokens):logits = model(input_ids) # complexity grows linearly with sequence length# With cache: reuse historical K/Vpast = Nonefor _ in range(max_new_tokens):logits, past = model(new_token, past_key_values=past)new_token = sample(logits)
3. Do the Memory Math: A Capacity Estimation Formula
Cache size can be estimated with the following formula:
KV_bytes = 2 × layers × kv_heads × head_dim × seq_len × bytes_per_value
Take 32 layers, 32 heads, 128 dimensions per head, a sequence length of 4096, and FP16 as an example: per layer and per token it is 2×32×128×2 = 16384 bytes, or 16KB; the total cache is about 16KB×32×4096 ≈ 2GB; 10 concurrent streams come to roughly 20GB. For long-text and high-concurrency scenarios, the cache can easily exceed the model weights themselves and become the real bottleneck. Common engineering mitigations include multi-query or grouped-query attention to reduce the number of KV heads, KV quantization, paged memory management, and prefix sharing.
4. Prefix Reuse: Why the Hit Rate Can Approach Saturation
When system prompts, knowledge base snippets, and code context stay highly consistent across requests, the K/V of that prefix only needs to be computed once and shared by multiple requests. The higher hit rate comes from three design choices: a stable prefix order (put variable content at the tail), a cache key that includes the model and parameter version, and an eviction policy that prioritizes keeping high-frequency prefixes. The higher the hit rate, the lower the average computation per request, and the lower the bill.
5. Applying the Optimizations to Cost Estimation
Teams are advised to build a simple model of their own: monthly cost ≈ requests × (missed-token unit price × miss ratio + hit-token unit price × hit ratio) + memory scaling cost. Then use monitoring alerts and logging services to collect hit rate, time to first token, and peak concurrency, and keep tuning the prefix structure and batching strategy. If the inference service is hosted on general capabilities such as Baidu AI Cloud’s container platform, object storage, and monitoring and alerting, elastic scaling and capacity planning can be handled more smoothly.
6. Conclusion
The essence of a price cut to one-quarter is turning “repeated computation” into “compute once, reuse many times.” Once developers understand the KV Cache capacity formula and the prefix hit mechanism, they can judge whether a given price cut is a sustainable engineering dividend or a short-term subsidy.
