Why Cached KV Still Gets Recomputed: Production Lessons from SGLang HiCache

How prefetch retries and a prefix recheck before batch admission improved KV cache reuse under high concurrency.

In a multi-turn conversation, a user may add just one question while the model still receives the entire conversation history. Reusing the key–value (KV) cache for an identical prefix avoids processing that content again, reducing computation and the wait for the first token. The KV cache stores intermediate results from processing earlier context so they can be reused later.

Production monitoring showed that subsequent requests with cached KV and a long shared prefix typically achieved cache hit rates above 90%, and the service was stable. A wave of low-hit-rate requests then arrived without reusable cache and required computation from scratch. We refer to these as cold requests. During the same period, hit rates also fell broadly for subsequent requests in ongoing conversations that had previously been able to reuse cached KV. Similar drops were rare at other times.

Cold requests require computation, but why were subsequent requests also recomputing? We saw no L3 cache write failures during that period, so the investigation shifted from whether KV had been written to whether it was available for reuse before execution. Our initial hypothesis was that some KV remained cached but was not being reused in time. To locate the problem, we needed to check whether the L3 copy still existed and trace whether the KV found by a cache lookup could be restored to the GPU before batch admission to form a reusable, contiguous prefix.

#The critical path: making cached KV reusable

In HiCache, reusable KV may reside in three tiers: L1 is GPU memory, L2 is instance-local host memory, and L3 is external shared KV storage. For this issue, the read path matters: can KV be prefetched from L3 to L2, then loaded into L1, in time for request execution?

HiCache's three cache tiers and reuse path: backups move downward; prefetching and loading move upward.

Figure 1. HiCache's three cache tiers and reuse path: backups move downward; prefetching and loading move upward.

Having data in the cache does not by itself save computation. The system must restore the required KV in time, and that KV must match a contiguous prefix from the start of the current input. If there is a gap, cached content beyond it cannot simply be added to the reusable length.

The following explanation uses the “Full KV” path in our test configuration, with both fixes enabled. These behaviors do not represent the defaults in every version. We call the advance read from L3 to L2 prefetching, and the point at which a request enters a GPU computation batch batch admission. Tracing this path revealed two gaps:

  • The request never gets a prefetch opportunity. When the budget is insufficient, the old path may skip L3 recovery without waiting or retrying later.

  • The recovered prefix does not survive until batch admission. The local contiguous prefix may shrink again while the request waits, without prompting another L3 lookup in the old path.

The two fixes preserve opportunities to retry prefetching and recheck L3 before batch admission. In this set of high-concurrency stress-test results, at concurrency 128, actual cache hit rate rose from 79.60% to 99.98%, while median time to first token (P50 TTFT) fell from 68.70 to 41.21 seconds. We examine each fix below.

#Prefetch retries when the remaining budget is insufficient

The first gap occurs before prefetching starts. The old budget check considers current usage but leaves out the incoming request's demand. As long as usage is below the limit when the check runs, prefetching can start for that request. Its demand is added afterward, potentially pushing total usage over the limit.

Consider the normalized example in Figure 2: the limit is 100, current usage is 90, and the new request needs 20. The old check sees 90 < 100 and allows the prefetch to start, bringing registered usage to 110. Until usage falls, later attempts see that the limit has been reached and skip L3 prefetching, without a state for waiting for capacity or retrying. These requests can still use valid local cache, but any KV missing locally that has not been recovered from L3 must be computed.

Budget checks, waiting, and retries before and after the fix

Figure 2. Budget checks, waiting, and retries before and after the fix. Logical budget and physical L2 free space are checked separately; a started prefetch may still fetch a shorter range or be abandoned if space is insufficient. FIFO determines only the order of new prefetch starts; other ready requests can still enter a batch.

With the prefetch retry fix enabled, the check includes current usage + request demand before starting. If that sum exceeds the limit, the request enters a pending state to wait for capacity. As usage falls, waiting requests retry in first-in, first-out (FIFO) order. The logical budget limits the amount of prefetching that has not yet been finalized. This avoids overshooting the budget while preserving L3 prefetch opportunities for later requests.

This step determines whether a request gets a chance to prefetch. How much it actually recovers still depends on physical L2 space, the L3 read result, and cache insertion. We return to these limits later.

#Before batch admission: recheck the prefix after queueing

The first fix lets a prefetch start, but the request still has to wait before batch admission. A successful prefetch does not guarantee that the same prefix length will remain available. If the local contiguous prefix before admission is shorter than the baseline recorded before the previous prefetch attempt, the system rematches the current prefix and rechecks L3 from the point where KV is now missing.

In Figure 3, request A has KV entries a1 through a100. Its initial local contiguous prefix has length 70, so the L3 lookup starts at a71 and fetches a71–a90. After prefetch completion, the local contiguous prefix has length 90. Eviction while the request waits may then shrink it to a1–a60. The diagram shows contiguous prefix lengths; copies in different tiers are not counted twice.

Prefix shrinkage and rechecking after queueing

Figure 3. Prefix shrinkage and rechecking after queueing. The comparison baseline is 70; a drop to 60 starts the lookup at a61. The fixed path illustrates a successful recovery. Bars are schematic; page alignment and prefetch thresholds are omitted.

The old path already rematched the local prefix before batch admission. The fix adds an L3 lookup when that prefix has shrunk below the recorded baseline. It attempts L3 prefetching again and defers admission for the current scheduling pass. In the example, the lookup starts at a61 and fetches a61–a90. If recovery succeeds and the prefix remains intact until admission, the reusable length returns from 60 to 90.

The comparison uses the local prefix length recorded before the previous prefetch attempt—70 in this example—not the recovered length of 90. A drop to 60 triggers the recheck; a drop to 70 or 80 does not. The baseline is updated on every new prefetch attempt.

Recheck attempts before batch admission are limited. Once the limit is reached, admission checks continue using the local contiguous prefix still available.

The two fixes address prefetches that never start and recovered prefixes that subsequently shrink. We look at their combined results next, followed by capacity planning and implementation limits.

#Results: cache reuse and serving performance at high concurrency

The following compares the measured points from this set of stress tests before and after the fixes. The main differences occur at concurrency 128 and 256. At lower concurrency, results are broadly similar, with no consistent improvement.

Test conditions

  • Workload: Fixed-length 128K-token input; one output token; 128 prefix groups

  • Test design: The 128K input and 128 prefix groups enlarge the active cache working set, while high concurrency creates competition for capacity. Limiting output to one token reduces the generation phase's influence on the results.

  • Target and model label: The test is constructed so that every request should hit a reusable prefix, giving a target cache hit rate of 100%. The model label on the test dashboard is GLM-5.3.

  • Concurrency points: 1, 2, 4, 8, 16, 32, 48, 64, 128, 256

  • Metrics: Cache hit rate is shown as reported by the dashboard; its source field and aggregation method have not been further verified from the available material. Total TPS (tokens per second) includes input tokens and does not measure the output token rate. TTFT measures the time from sending a request to receiving the first token. P50 is the latency at or below which half of requests fall; P99 is the latency at or below which 99% fall. Both are converted to seconds.

The retained material includes dashboard results and the workload conditions above. The size of the hardware deployment, build version, L2 capacity, write-back and prefetch policies, warm-up procedure, request count, measurement window, and number of repeated runs were not fully recorded. The results below describe only the observed differences at these test points. They do not isolate either fix's contribution, and the workload does not represent the actual wave of cold requests seen in production.

At low concurrency, both configurations were close to the target cache hit rate. At concurrency 128 and 256, the rate before the fixes fell to 79.60% and 76.37%, respectively. After the fixes, it was 99.98% at both points.

Cache hit rate versus concurrency

Figure 4. Cache hit rate versus concurrency. After the fixes, the rate is 99.97%–99.98% across all tested points.

At concurrency 128, total TPS rose from 225,227.68 to 435,533.81, an increase of 93.37%. At concurrency 256, it rose from 197,520.48 to 390,763.06, an increase of 97.83%.

Total TPS before and after the fixes, as reported by the test dashboard

Figure 5. Total TPS before and after the fixes, as reported by the test dashboard. This metric includes input tokens and does not measure GPU computation throughput.

Time to first token also fell substantially at high concurrency. At concurrency 128, P50 TTFT decreased from 68.70 to 41.21 seconds, a reported reduction of 40.02%. At concurrency 256, it decreased from 88.88 to 68.70 seconds, a reported reduction of 22.71%. P99 TTFT fell from 86.21 to 56.59 seconds and from 172.92 to 133.15 seconds, respectively.

P50 TTFT before and after the fixes, highlighting the high-concurrency region

Figure 6. P50 TTFT before and after the fixes, highlighting the high-concurrency region. Values are in seconds.

#Capacity planning and implementation limits

The tests above show the combined effect of enabling both fixes. The fixes preserve recovery opportunities; they do not guarantee that every recovery succeeds. To explain how capacity affects waiting and recovery, we now map the earlier 90 + 20 > 100 example to the actual host-memory pool.

Implementation details and limits

  • Logical budget: In the host-memory configuration used in this test, where L2 serves as a resident cache, the SGLang code fixes the logical prefetch limit at 50% of the host-memory pool's logical token capacity. It counts candidate tokens registered by prefetch operations that have not yet been finalized. This limit was not introduced by the fixes, and it does not reserve 50% of physical memory.

  • Waiting and retries: Once a request is allowed to start, it leaves the capacity-waiting queue, but the budget counted against its prefetch is not immediately released. Retry entry points cover both the Bootstrap handshake phase and the Waiting phase before batch admission. FIFO determines only the order of new prefetch starts. A request whose demand exceeds the entire limit is not left waiting indefinitely.

  • Actual recovery: After an L3 hit, the system still needs to allocate L2 space. If space is insufficient, it first attempts eviction. If that is not enough, it may fetch a shorter range or abandon the prefetch. Rechecks before batch admission also have a retry limit, and protection during prefetching does not cover the entire queueing period after finalization.

Let G and H be the L1 and L2 token capacities for the same KV pool. The limit of 100 in the earlier example is a normalized representation of this 50% logical budget. The admission check uses the length of the missing prefix that needs to be prefetched. The condition H/2 < G becomes a more direct constraint only when that missing range approaches the size of an L1 working set. A larger host-memory pool gives a larger token budget at the same 50% limit. For the same prefix lengths and concurrency, current usage + request demand is then more likely to remain within the limit.

Conversely, a smaller host-memory pool makes requests more likely to wait at the capacity check, but this does not mean they will be blocked forever. If a single prefetch's demand exceeds the entire limit, the code skips that prefetch instead of leaving it in the pending queue. The missing KV may still need to be recomputed.

The host-memory pool's size affects both logical admission and the physical space available for recovered data. It must accommodate KV backups from L1 and leave room for L3 prefetching. If we want to hold a backup roughly the size of L1 while leaving close to half of L2 available for prefetched data, an idealized estimate gives:

G + H/2 ≤ H  →  H ≥ 2G

H ≥ 2G is only a starting point under these assumptions. It does not guarantee that the cache will avoid eviction or that requests will always maintain high hit rates. Actual configurations also depend on request length, concurrency, storage speed, and evictable space. Track the logical budget, actual host-memory pool allocations, final reuse rate, TTFT, and effective throughput together.

#Debugging: trace where reuse is lost

In production, the final hit rate alone is not enough. The tests above show only the combined behavior with both fixes enabled; they cannot directly identify where an individual request lost its reuse opportunity. To investigate similar issues, trace each stage: prefix matching when the request enters the queue, prefetch admission, actual data fetched from L3, cache insertion, matching at batch admission, and final reuse. Track subsequent requests eligible for reuse separately from cold requests. The table below lists records to compare or add.

Records and checks for locating where cache reuse is lost.

Table 1. Records and checks for locating where cache reuse is lost.

The goal is to keep cache reuse possible under capacity pressure and while requests wait in the queue. A request may still need to recompute KV if L3 has no backup, reads fail, or retry limits are reached. Cached KV saves computation only when it reaches the executing request in time.


TokenPulse builds on SGLang to optimize inference in production. We were a Spark Sponsor of SGLang Summit 2026 and will continue to support the open-source AI ecosystem and its developer communities.