Why Prefix Cache Hits Fail in Hybrid-Attention LLMs

    Prefix Cache reuse is a standard way to cut time-to-first-token and redundant compute in LLM inference, but its core assumption breaks once a model mixes attention mechanisms across layers. This article explains why a matching token prefix is only a necessary condition for reuse in hybrid-attention models, breaks down the five heterogeneous cache objects (compressed KV, uncompressed tail, SWA window, indexer state, and on-disk prefix) and their distinct recovery requirements, and shows why allocators must track segment form and readiness rather than just free blocks. It also covers the four post-hit validations, four consistency constraints, and practical guidance on metrics, observability, fallback, capacity planning, and regression testing.

    1. The Starting Point: A High Hit Rate Does Not Mean Correct Results

    In large-model inference serving, Prefix Cache is almost a standard capability for reducing time-to-first-token and repeated compute. Its classic assumption is simple: as long as two requests share an identical token prefix, the KV computation for that prefix can be reused directly, with no recomputation.

    This assumption holds up well on pure full-attention models. The inference framework splits token history into fixed-size pages and maps logical pages to physical KV blocks through a page table. Requests with the same prefix share the same physical blocks, and a hit means direct reuse.

    But the rule starts to crack when a model mixes multiple attention forms across different layers. So-called hybrid attention means three mechanisms coexist inside the model:

    • Full-history compression: compressing long history into a low-rank or low-resolution representation;
    • Sliding window: keeping full KV only for the most recent W tokens;
    • Sparse routing: an indexer selects a small set of relevant history to participate in computation.

    Once these three mechanisms are mixed, “same prefix” becomes only a necessary condition, not a sufficient one. The prefix cache hit rate is essentially a performance metric: it measures how many requests collide with an existing entry at the hash level. Correctness, however, requires that the collided entry can be fully restored and directly used in computation. The two cannot substitute for each other.

    2. Five Heterogeneous Cache Objects: Different Lifecycles and Recovery Conditions

    Under a hybrid-attention architecture, the same span of token history can exist in the cache in five different forms. Their generation timing, eviction policies, and recovery costs are completely different and must be tracked separately.

    1. Compressed KV
      Produced by the full-history compression layer, it is far smaller than raw KV but irreversible. The recovery condition is that the compressed block is either on disk or still in GPU memory, and that the compression ratio and quantization parameters match. If the compressed block is missing, the only option is to fall back to recomputation; it cannot be derived from raw KV.

    2. Uncompressed tail
      The most recent tokens usually keep raw-precision KV to preserve local modeling quality. It has a clear length boundary, and that boundary moves as decoding advances. On a hit, if the tail is too short, the missing portion must be filled in.

    3. SWA window
      The sliding-window layer only cares about the most recent W positions. The hit decision must be aligned with the absolute position of the current request: whether the window covers the target range and whether it has already expired both determine whether reuse is possible.

    4. Indexer state
      Sparse routing depends on the indexer’s intermediate state (such as the candidate set, routing table, and accumulated statistics). This state is often not counted as part of the KV cache, yet it directly determines which history was selected; when it is missing, results shift silently.

    5. On-disk prefix
      When the context exceeds GPU memory capacity, cold prefixes are swapped out to external storage. They “exist” but are “not ready”: an explicit migration back is required, and the migration bandwidth and latency must be factored into scheduling decisions.

    The key difference among these five objects is that the first four may reside in GPU memory at the same time, while the fifth crosses storage tiers. If any one is missing, a “hit” degrades into a “partial hit,” and under hybrid attention a partial hit is not equivalent to a safe skip-compute.

    3. Why the Allocator Must Evolve from “Finding Free Blocks” to “Recording Form”

    The traditional allocator has a single responsibility: pick a free block for new tokens and write into it. In parallel, the prefix match action reports hits by hash. Once cache objects become heterogeneous, this division of labor creates a semantic mismatch: the hash reports a hit, but at read time the tail, window, or index routing is missing, so generation produces wrong results that are hard to locate.

    The allocator therefore needs a second responsibility: record the current form and recoverability of each token span. A schematic data structure can be expressed like this:

    1. @dataclass
    2. class CacheSegment:
    3. token_range: tuple[int, int] # [start, end)
    4. form: str # compressed / tail / swa / indexer / disk
    5. ready: bool # whether it can directly participate in computation
    6. meta: dict # compression ratio, window length, routing version, etc.

    The allocation action and the matching action therefore need to be completed under the same “lock semantics”: first determine form and readiness, then decide whether to reuse, avoiding the time gap where “matching passes but reading fails.”

    4. Four Layers of Validation Required After a Hit

    Even on a hash hit, four layers of validation are needed to confirm that computation can simply continue:

    • Whole-block alignment check: the compressed block, page size, and alignment granularity are consistent, avoiding cross-block concatenation errors;
    • Compute-kernel ABI check: the kernel version and data layout conventions match, preventing layout drift;
    • Multi-cache-group state intersection: the readiness states of multiple layers and multiple cache groups are intersected, and a missing group is treated as a miss;
    • Byte-level hardware alignment: data type, byte order, and hardware memory-access granularity are aligned, avoiding implicit precision loss.

    The common goal of the four layers is to converge a “logical hit” into a “physically recomputable” state.

    5. Four Consistency Constraints That Must Not Be Violated

    In the state machine of scheduling and allocation, four rules should be treated as hard constraints:

    1. Admission cap: limit the total amount of concurrently resident context to prevent swap-in/swap-out thrashing;
    2. Five-state routing: route recovery paths separately for the five object types, and forbid handling them with a single unified rule;
    3. Timing consistency: avoid state drift between check and use (TOCTOU); state pointers must remain valid during the read period;
    4. Static topology constraint: under graph-capture execution modes the topology is fixed, so dynamic form changes must be determined before capture.

    6. Engineering Recommendations

    • Layered metrics: report hit rate and “recomputable hit rate” separately; only the latter is tied to correctness;
    • Observability: instrument each of the five object types separately, recording miss reasons and recovery time;
    • Fallback strategy: on partial hits, first fill low-cost objects (such as the tail), and send high-cost objects (such as on-disk prefixes) to recomputation or a queue;
    • Capacity planning: combine general cloud capabilities such as object storage, caching services, and monitoring/alerting to assess tiered capacity and migration bandwidth;
    • Regression testing: build a test set with identical prefixes but different forms, specifically to validate the boundary where “a hit does not mean correct.”

    7. Conclusion

    Hybrid attention brings not a simple performance problem but a reconstruction of cache semantics. Treating hit rate as a correctness metric amplifies hidden errors in long-context, high-reuse scenarios. The right approach is to explicitly model the five cache object types, upgrade the allocator’s responsibilities, enforce the four validation layers and four consistency constraints, and make “recomputable hit” the core metric. Only then can you gain the benefits of reuse while holding the floor on generation quality.