Hierarchical caching for LLM inference keeps the key-value (KV) state a model computed for one request and reuses it for later requests that share the same prompt prefix. That state is stored across GPU memory, CPU RAM and disk rather than being discarded when the request finishes. A cache hit turns part of the prefill computation into a lookup and a transfer, so first-token latency on long, reusable prompts stays almost flat instead of growing with prompt length. It stops helping, and can make things slower, when prefixes are short, reuse is low, the GPU is fast or the working set outgrows the cache.
This article uses the phrase in its LLM serving sense. If you are working to the TTFT budget for real-time GenAI, caching is one of the serving-path levers that improve latency without replacing the model.
How Hierarchical Caching Works in an LLM Serving Stack
When a request arrives, the serving engine splits the prompt into fixed-size blocks, hashes them, and reuses any blocks whose hashes match an entry already in the cache. In vLLM’s automatic prefix caching the default block is 16 tokens and eviction is LRU at block level. When a block is not in GPU memory, a hierarchical system looks in the next tier down. Cake’s authors describe that order as GPU memory, then CPU memory, then disk, with computation from scratch only when no level holds the cache.
In vLLM’s tiered offloading, the CPU tier acts as the gateway: a completed GPU block is copied to CPU memory first and then pushed asynchronously to secondary storage, and a hit in a secondary tier is promoted into a reserved CPU slot before it is copied to the GPU. While that promotion runs, the scheduler defers the request and tries again rather than blocking.
Loading and computing are not mutually exclusive. Cake splits a prompt into chunks, computes KV state forward from the start on the GPU while loading cached state backward from the end, and stops when the two meet. Across its evaluations that overlap gave an average 2.6× reduction in time-to-first-token (TTFT) compared to baselines. The useful mental model is that every request needs a full set of KV state before decoding can begin, and the system’s job is to assemble it from whichever source finishes soonest.
Why Recomputing a Shared Prefix Dominates First-Token Latency
The KV cache holds the attention key and value tensors every input token produces, kept in GPU memory so the model can generate the next tokens without recomputing them. Producing that state is the prefill phase. Prefill processes all input tokens in parallel, is compute-bound, and dominates first-token latency for long prompts; decode reads the whole KV cache at every step and is memory-bandwidth bound.
The scale is easy to underestimate. Generating the KV cache for a 72K-token input with Llama2-70B on an NVIDIA A100 takes roughly 30 seconds, according to the Cake paper (2024). A system that recomputes a shared system prompt or a retrieved document on every request pays redundant prefill, the largest avoidable cost for such workloads.
The state is also large. The vLLM team (2023) measured up to 1.7 GB of KV cache for a single LLaMA-13B sequence, and found that existing systems wasted 60-80% of that memory to fragmentation and over-reservation. PagedAttention addressed the waste by storing each sequence’s KV cache in fixed-size blocks that need not be contiguous, which brought waste below 4%. vLLM’s automatic prefix caching is built on those blocks, and different sequences can share a block by mapping their logical blocks to the same physical block.
Even with efficient paging, long-context caches quickly exceed GPU memory. The Strata authors note that 40 GB of HBM holds only about 0.3M tokens for Llama-8B. The SAECache authors put serving LLaMA-70B on four A100s at room for roughly 36K cached prefix tokens. That shortfall is what forces production systems to adopt hierarchical caching.
Which Prompt Content Is Worth Reusing Across Requests
Repeated prefixes show up in system prompts, templated retrieval-augmented generation (RAG) pipelines, agent frameworks and multi-turn conversations. Not all of that content is equally reusable. Across the traces studied for SAECache, system prompts were reused 92.3% of the time and chain-of-thought tokens only 2.2%. Model responses showed an asymmetry: 36.3% reuse within a conversation, because later turns include earlier answers, but only 1.5% across conversations. Decode blocks had reuse rates below 3.17%, because reuse would need an exact match of generated tokens.
Prefix matching is strict. A later block can be reused only when every preceding token also matches, so blocks near the start of the prompt (system instructions, shared scaffolding) carry more value than request-specific content further on. Content near the start of a prompt is therefore the part a prefix cache is most likely to reuse.
Document question answering is a favourable case. In extractive Q&A one long document receives many different questions, so large KV prefixes are reused across queries. On such workloads PTStore, which distributes and replicates popular prefixes across nodes, reported 5-6× better efficiency than baselines that regenerate the KV cache. How a radix tree indexes shared prefixes inside one node is covered in our piece on radix cache for production LLM serving.
GPU HBM, CPU RAM and Disk in a Hierarchical Cache
Each tier trades bandwidth for capacity. The figures below are the reference configuration the Cake authors give, with hit rates from Tutti’s (2026) long-context evaluation on LEval and LooGLE:
| Tier | Bandwidth (Cake) | Capacity (Cake) | Hit rate on long-context workloads (Tutti) |
|---|---|---|---|
| GPU HBM | ~2 TB/s | ~80 GB | 8% (LEval), 4% (LooGLE) |
| CPU DRAM | ~25 GB/s | ~1.8 TB | 53% (LEval), 24% (LooGLE) |
| Disk / NVMe SSD | 0.5-4 GB/s | ~26 TB | 84% (LEval), 86% (LooGLE) |
| Recompute | GPU compute | n/a | fallback when no tier holds the prefix |
Tutti’s hit rates make the point: on its long-context workloads, the slowest tier captures most of the reusable state. The Tutti authors estimate that about 2 TB of DRAM retains only around five minutes of KV cache, whereas more than 100 TB of NVMe on a commercial server can retain over an hour.
Moving the state back to the GPU is a major performance bottleneck. In Strata’s measurements serving LooGLE with SGLang offloading to CPU memory, 74% of prefill time was blocked on KV transfers, with up to a 4× throughput reduction. The cause is fragmentation: paging spreads a sequence’s KV cache over many small pages, producing transfers of a few kilobytes that fail to saturate PCIe. From SSD the effect is worse, because restoring a long prefix generates huge numbers of tiny random I/Os and CPU interventions, and Tutti’s authors cite 70-80% GPU stalls as a result.
Simply using bigger pages does not fix it. Benchmarking Mistral-24B on ShareGPT, Strata’s authors found that larger KV pages cut the cache hit rate, raising average TTFT by up to 2× and P90 TTFT by up to 2.9× at the largest sizes. TensorRT-LLM’s documentation describes the same trade: smaller blocks allow finer reuse but reduce attention-kernel efficiency.
Timing matters as much as bandwidth. The py-kvcache study concludes that external KV caching is best understood as a critical-path optimisation, not only an extension of the memory hierarchy, because peak bandwidth does not decide when movement starts or whether loading beats recomputation. Preloading improved TTFT by 1.34-1.66× over the same engine without preload.
Eviction Policies Beyond LRU
Every tier is finite, so the eviction policy decides what stays warm. The SAECache authors call it a first-order design choice: a good policy keeps blocks that will be reused, a poor one spends scarce memory on blocks with little future value. vLLM evicts with block-level LRU, and SGLang manages its cache with RadixAttention-style KV-cache reuse.
Recency alone misses what the reuse data shows. A system-prompt block and a chain-of-thought block with matching recency statistics should not get the same priority, and the SAECache paper argues for scoring each block by token type and position. Across all 12 dataset-interval configurations, that semantic-aware policy improved hit ratio by 4.8-5.9 percentage points over the strongest baseline.
Fixed parameters are brittle. Parameters fitted to chat-heavy traffic caused a 2.7× TTFT degradation when applied to single-turn-dominated traffic. A smarter policy also costs something: on Chatbot-Arena, where only 12% of conversations are multi-turn, SAECache had the best hit ratio but trailed the best baseline on mean TTFT by 12-34% because its bookkeeping overhead exceeded the prefill it saved. A cleverer eviction policy’s latency gains show most clearly where cache pressure and reusable prefixes are both present.
In PTStore’s distributed design, the eviction policy works alongside a choice of what to replicate. PTStore keeps an owned cache and a replication cache for hot tensors on the same local hierarchy, and splitting host memory between them is a trade-off: faster hits on local hot tensors against slower retrieval of cold ones. Policies that learn from live traffic rather than fixed thresholds are a natural fit for this kind of control problem, which our tutorial on RL for inference control works through.
Worked Example: How Cache Hit Rate Maps to TTFT, Throughput and Cost
The core relationship is simple. Cache hits reduce the tokens that need prefill in direct proportion: prefill tokens = prompt length × (1 − hit ratio).
Take the PrefixBench-H100 (2026) setting, where both vLLM and TensorRT-LLM cached about 92% of the input at an 8,192-token shared prefix. Working it through: 8,192 × (1 − 0.92) ≈ 655 tokens still need prefill, against 8,192 with reuse off. The measured result in that study was a 5-6.5× TTFT reduction over a reuse-disabled baseline.
In that same setting, where the working set fit in KV capacity, the study measured a 9-10% drop in average power and net energy savings of 24-31% per request, because expensive prefill kernels were replaced by cheap cache lookups.
Cost per token is where load enters. In a 2026 study of self-hosted inference cost on H100s, enabling vLLM’s prefix cache had a negligible effect at low load (10 requests per second or fewer) but cut effective cost per million tokens by 20-22% at saturation, because saved prefill let the scheduler pack more decode tokens into each batch. Prefix caching lowered the cost level at high load without changing the shape of the cost-versus-load curve. For SSD-backed tiering, Tutti reported serving cost 66.2% below LMCache-SSD and about 27% below LMCache-GDS on LooGLE at 0.5 QPS, attributing it to saturating GPU compute.
Two cautions apply when reading those numbers. First, the cache was not what separated the runtimes: PrefixBench-H100 found that cache effectiveness stayed within a couple of points between vLLM and TensorRT-LLM in every regime, including under eviction, and the differences operators saw came from the scheduling layer above the cache. Second, these figures come from the studies’ own models, hardware and traces. Measuring your own traffic, not a published configuration, is the point of benchmarking GPUs against your own workload.
This is also why caching is a serving-path question before a model question. Production AI cost and latency can often be improved without replacing the model, and TechnoLynx’s GPU performance engineering audits the serving path (batching, caching, routing, runtime configuration) to find those gains before recommending a model change; how much a given workload gains depends on its profile.
The Working Set to Capacity Ratio Decides Whether the Cache Holds
The governing quantity is the ratio of the prefix working set to available KV capacity, not the model size or the runtime. PrefixBench-H100 showed a capped 7B pool and a natural 32B pool reaching the same eviction behaviour at comparable ratios.
Past that ratio, the hit rate degrades sharply. Capping KV capacity to 56,320 tokens collapsed the hit rate from 68.2% to 3.6% on both runtimes, with a 4.6-6.1× regression in p50 TTFT. At 13.2× over-subscription the hit rate fell to 5.6% with a 15.7× TTFT regression. The degradation deepens progressively rather than at a single threshold. The study’s authors note that 70B-class models, multi-GPU serving and FP8 KV caches shrink per-device capacity and could bring that pressure on sooner than their results show.
This is the honest case for a hierarchy: when long contexts exhaust GPU memory, non-hierarchical caching produces frequent misses and repeated recomputation, while Strata’s evaluation shows hierarchical systems reaching about 95% hit rate by using CPU memory. A demo with five users and a warm cache sits on the left of that curve; production traffic may not.
Attention Sinks and StreamingLLM Solve a Different Problem
StreamingLLM is a way to keep a bounded KV cache from breaking generation in a long-running stream, not a way to reuse prefixes across requests. Evicting the oldest tokens from a window cache makes generation fail once the text exceeds the cache size. StreamingLLM instead keeps the KV state for four initial tokens, which act as attention sinks that stabilise attention, plus a rolling window of recent tokens, and discards the middle. Against sliding-window recomputation, the authors report up to 22.2× faster per-token decoding at similar memory use.
The limit is explicit in the paper: StreamingLLM does not extend the context window or give the model long-term memory, so tasks that need evicted information, such as long-document QA, fall outside it. The two techniques combine reasonably well, with a bounded window for an endless stream and a tiered prefix cache for the shared content at its start.
When Is Hierarchical Caching Not Worth It?
A cache hit is not the same as a speedup. A hit replaces GPU prefill with a lookup, a disk or host-memory read and a CPU-to-GPU transfer, and for short prompts, low hit rates or fast GPUs those costs can exceed the recomputation they were meant to avoid.
The py-kvcache study quantified the break-even on its setup (Llama 3.2 3B with llm-d): an 8K-token prompt needed 77.8% prefix reuse to break even, while at 80K tokens the threshold fell to 7.8%. Replaying Bailian production traces, it found external caching improved TTFT on a weaker GPU, but on an H100 the average request fell below the break-even point, so there was no gain over GPU prefix caching alone despite cache hits. That frontier belongs to the path measured: a faster path moves the break-even but does not remove it.
| Condition | What to expect | Basis |
|---|---|---|
| Long reusable prefix, working set above GPU capacity, requests queue long enough to overlap transfers | External tiers most likely to pay off | py-kvcache |
| Short prefixes, low reuse, fast GPU or lightly loaded system | External tiers less attractive; recompute may win | py-kvcache |
| No prefix sharing at all | Prefix cache adds overhead; cost ratio 0.79-1.11, up to 11% worse | Self-hosted cost study (H100) |
| Low offered load | Negligible cost effect from prefix caching | Self-hosted cost study (H100) |
| Single-turn-dominated traffic with a heavyweight eviction policy | Policy overhead can exceed savings (12-34% TTFT regression) | SAECache |
| Perfect request locality | No need for a hierarchy; the GPU tier already holds the reuse | Strata |
The design response is a gate, not unconditional loading. py-kvcache calibrates a break-even prefix length per tier offline and declines loads predicted to cost more than recomputation. Its authors recommend treating recomputation as a valid fallback rather than a cache failure. Arrival pattern matters too: PrefixBench-H100 saw the faster runtime flip between burst and fixed-rate arrivals, and advises benchmarking with the arrival pattern seen in production.
Before building any tier below the GPU, a real-time GenAI deployment should measure three things: the prefix overlap in real traffic, the working set against KV cache memory at target concurrency, and the cold-cache TTFT next to the warm one. If those three numbers are not known, no latency budget built on the warm-cache figure can be trusted.
FAQ
Is Prompt Caching the Same as KV Caching?
Not quite. A KV cache stores the attention keys and values for a single request so decoding does not recompute them. Prompt or prefix caching applies the same idea across requests, reusing the KV vectors of the longest common prefix to skip redundant prefill.
How Much Memory Does the KV Cache Use?
It depends on sequence length, which is highly variable. The vLLM team measured up to 1.7 GB for a single LLaMA-13B sequence. Strata’s authors note that 40 GB of GPU memory holds roughly 0.3M tokens for Llama-8B.
What Is a Cache Hierarchy?
A cache hierarchy stacks storage tiers from small and fast to large and slow, checking the fastest first. In LLM serving those tiers are GPU HBM, CPU DRAM and disk, with recomputation when none holds the data.