LLM Inference Price Cuts and KV Cache: How to Calculate the Real Cost Savings
When an LLM inference provider cuts a unit price to a quarter of its original rate, many people assume their total bill will also drop to a quarter. In reality, a single API call can be billed across uncached input tokens, cache-hit input tokens, and output tokens, each with its own rate. This article explains how KV caching and prefix caching work, why cross-request cache hit rates can be surprisingly high, how to estimate KV cache memory usage, and how to model the actual savings from a price cut. It also covers practical steps for making cache benefits stable in production: structuring prompts so stable content comes first, measuring hits by traffic type, and factoring in isolation and cold-start costs. The goal is to help you optimize the real cost of completing a business task, not the cache hit rate itself.
When a unit price for LLM inference drops to a quarter of its previous rate, the most common misconception is that your total bill for the same application will also fall to a quarter. In practice, a single call may incur several charges at once—uncached input, cache-hit input, and output—and how these are separated depends on the provider’s billing rules. Which item the price cut covers, and what your traffic actually consists of, determine how much you really save.
Caching makes this calculation worth doing carefully. For applications where fixed rules and reference materials recur across requests, reusing input prefixes may be more effective than trimming a few sentences from your prompts. For applications with long outputs and highly personalized inputs, even a high cache hit rate may yield limited savings.
1. What Does Within-Request KV Caching Save?
Autoregressive models generate output token by token. Given the input “the weather today,” the model first predicts the next token based on the input, then adds that prediction to the context and continues generating. Token boundaries depend on tokenization and do not necessarily align with words or characters.
In models using causal attention, each layer typically constructs queries, keys, and values—Q, K, and V—for every position. The query at the current position computes attention weights against the keys of all visible positions, then uses those weights to aggregate the values. The key insight is that historical positions cannot see tokens appended later, so as long as the model and existing context are unchanged, their keys and values do not need to be recomputed as the sequence grows.
Inference therefore splits into two phases:
- The prefill phase processes the input sequence, builds the KV cache for each layer, and produces what is needed to generate the first output token.
- The decode phase processes new tokens one at a time, appending their keys and values to the cache, while using the new positions’ queries to read the existing cache and predict subsequent tokens.
The KV cache avoids re-running forward computation for historical tokens at every step, but that does not mean each step’s cost is independent of context length. In full-attention architectures, a new position still has to read the keys and values of all visible history and compute attention over them. The longer the context, the more data must be read, and both memory capacity and memory bandwidth can become bottlenecks.
2. Why Can Cross-Request Cache Hit Rates Be So High?
Within-request KV caching solves the problem of “don’t reprocess history within a single generation.” Cross-request prefix caching goes further, solving “don’t reprocess the same beginning across multiple calls.” If an inference service supports prefix reuse and a cached prefix is still available, a new request can continue processing from the end of the matched prefix instead of running full prefill from scratch.
Consider a document Q&A application: every request includes the same long document and a fixed set of answering rules, with only the final question differing. Once the first request establishes the cache, subsequent requests can reuse the shared portion. Although questions vary widely, they happen to sit at the end; as long as the shared prefix is long enough, the hit rate measured by input tokens can be very high.
Conversely, if you put a changing timestamp, request ID, or user information at the beginning of every prompt, then even if the following thousands of tokens are identical, standard prefix matching cannot reuse them. The reason is not just failed text comparison: in causal attention, a position’s representation depends on its preceding context, so the same text appearing after a different beginning cannot be treated as having the same key-value state.
Cache benefits therefore come from the interaction between input structure and the service’s implementation, not from some inherent property of the model’s generated content. Actual hit rates are also affected by cache capacity, eviction policy, request intervals, instance routing, and cache isolation scope. Results measured by repeatedly sending requests for the same prefix in quick succession do not represent long-term behavior in production.
3. How Much GPU Memory Does the KV Cache Need?
For the common implementation with uniform layers and explicit storage of keys and values, you can estimate the cache size for a single sequence with this formula:
Cache bytes ≈ 2 × number of layers × number of KV heads × head dimension × cached tokens × bytes per element
The factor of 2 accounts for storing both keys and values. Note that this uses the number of KV heads, not the number of query heads; the two differ in some attention architectures.
Take a hypothetical configuration: a model with 32 layers, 32 KV heads, a head dimension of 128, a cached sequence length of 4096 tokens, and 2 bytes per element. Each layer needs 16,384 bytes per token, and the full sequence’s cache amounts to 2 GiB. If you keep ten sequences of the same length with no shared cache between them, the KV data alone occupies about 20 GiB.
This is not the total memory requirement of the device, nor the actual allocation. Inference also needs room for model weights, temporary computation buffers, memory allocation, and scheduling; and request lengths change as generation proceeds. Implementations using shared caches, paged or chunked management, lower precision, or compressed representations need to be computed according to their specific structure. When planning deployment, do not just verify “can the single longest request run”—also watch whether cache growth, eviction, and request queuing occur simultaneously under high concurrency.
4. If the Unit Price Drops to a Quarter, How Much Does the Bill Fall?
If a service bills uncached input, cache-hit input, and output separately with no other charges, you can simplify the cost of a single call as:
Call cost = uncached input volume × uncached input price + cache-hit input volume × cache-hit input price + output volume × output price.
This is only an estimation framework; not all services bill this way. If the actual rules include cache write fees, storage fees, or other charges, factor them in separately. Also make sure to use consistent pricing units—do not mix per-thousand-token and per-million-token quotes.
Suppose that before a price cut, the affected item accounts for 40% of an application’s spend, with the rest unchanged. If that item’s unit price drops to a quarter of the original, and call volume, input/output lengths, and hit patterns all stay the same, then every 100 units of original spend becomes 40 × 0.25 + 60 = 70. The unit price fell 75%, but total cost fell only 30%.
Likewise, a high token-level hit rate does not mean total cost drops by the same proportion. Suppose 990,000 out of 1 million input tokens hit the cache—a 99% hit rate by tokens. Yet cache-hit input may still be billed, output still has to be generated, and if the few uncached inputs come from especially long requests, they can also concentrate their impact on tail latency. When evaluating benefits, look at both the bill composition and the request distribution, not just a single percentage.
5. How to Make Cache Benefits Reliable in Production
Structure your inputs before tuning scheduling. Without changing instruction priority, data permissions, or business semantics, place stable system rules, fixed examples, and reference materials at the front, and current questions and dynamic information at the end. Also inspect what is actually sent to the model, not just the visible text in application logs: message wrappers, field ordering, whitespace changes, and tokenization differences can all shorten the actually reusable prefix. After a template upgrade, the shared prefix may change, and capacity planning should account for this cold-start period.
Measure by traffic type; do not substitute a single warm run for load testing. Split requests into first-time access, short-interval repeat access, long-interval repeat access, and mixed-prefix access, and record results for each. Request-level hit rate answers “how many calls achieved reuse”; token-level hit rate answers “how much input volume was reused”—the two are not interchangeable. For performance, record time-to-first-token, end-to-end latency, and cache eviction together. Prefix reuse mainly reduces prefill work, so it is more likely to improve time-to-first-token; end-to-end latency also depends on queuing and output length.
Factor isolation and cold-request costs into launch decisions. In multi-tenant scenarios, cache reuse must not cross tenant, session, or data-permission boundaries. For self-hosted inference services, also compare two costs: how much memory retained caches occupy, versus how much redundant computation cache eviction causes. Keeping more cache is not automatically cheaper; if it squeezes out concurrency capacity, hit rates may rise while queueing time grows.
The most reliable way to evaluate an inference price cut is to take the same representative business traffic, compute costs under both the old and new prices, and check real-world cache hits and latency variation. If your workload is dominated by long shared prefixes, short outputs, and frequent repeated calls, prefix reuse is usually worth validating first; if your bill is mainly driven by long outputs, start by evaluating output length and call count. What you should ultimately optimize is not the hit rate itself, but the actual cost of completing a business task while meeting quality, latency, and isolation requirements.
