Hybrid Attention LLMs: The Correctness Boundaries of KV Cache Reuse
Prefix cache hit rate is a performance metric, not a correctness guarantee. In hybrid attention large language models—where layers mix full-history compression, sliding windows, and sparse routing—the assumption that an identical token prefix means a KV block can be safely reused breaks down. This article breaks down the five heterogeneous cache objects involved (compressed KV, uncompressed tail, SWA window, indexer state, and on-disk prefix), explains why the allocator must evolve from a simple free-block finder into a shape-aware state machine, and lays out the four verification layers and four consistency rules that every cache hit must pass before generation can safely continue from it.
Introduction: Hit Rate Is Not Correctness
When people discuss the latest generation of long-context large language models, the first thing on their mind is often the prefix cache hit rate—how high it is, how much GPU memory it saves. But one point needs to be stated up front: prefix cache hit rate has never been a correctness metric.
Paged KV cache management splits token history into fixed-size pages, then uses a page table to map these logical pages onto physical KV blocks. For multiple requests that share the same prefix, this mechanism reuses existing blocks directly and skips redundant prefill computation—and it has run reliably in mainstream inference frameworks for two years. It rests on a simple assumption:
As long as the token sequence (or its hash) of a request’s prefix is identical, the corresponding KV block can be taken directly and computation can continue from there.
The problem is that hybrid attention architecture pushes this assumption to its boundary for the first time. When different layers of a model start to mix full-history compression, sliding windows, and sparse routing, the rule “same prefix → cache can be reused directly” quietly stops holding.
Why the Old Reuse Rules Break Down
Consider a library analogy.
In a traditional model, a cache hit on a block is like finding a shelf number in a library—once the number matches, you go straight to the shelf and pick up the book, with no additional verification in between.
In a hybrid attention model, even after you locate the block, you must confirm five things item by item before you take the book:
- Whether the book is still on the shelf (whether the compressed KV is usable, i.e., compressed KV);
- Whether the latest pages have been bound (whether the uncompressed tail is intact, i.e., uncompressed tail);
- Whether the borrowing card has expired (whether the sliding window’s valid boundary still covers this position, i.e., SWA window);
- Whether the index catalog has been synchronized (whether the sparse routing’s index state is consistent, i.e., indexer state);
- Whether a book has been sent to a suburban warehouse and not yet returned (a prefix sunk to low-speed storage that has not been backfilled, i.e., on-disk prefix).
Only when all five conditions are met and can be correctly restored can you truly “continue reading from here.” If any single one is not satisfied, then even with a hash hit, reusing directly will produce incorrect generation results.
This is precisely the core contradiction: once the cache object becomes heterogeneous, the original “allocate + match” two-action model is no longer enough.
Breaking Down the Five Heterogeneous Cache Objects
Traditional inference frameworks have two parallel actions: alloc, which picks a free block for a new token and writes it in, and prefix match, which uses the hash to determine whether history can be reused. Both take the “homogeneous KV block” as an implicit assumption.
Once hybrid attention is introduced, the five objects’ lifecycle, recovery conditions, and hit determination all differ, and must be modeled explicitly:
| Cache object | Meaning | Typical lifecycle | Recovery / verification focus |
|---|---|---|---|
| compressed KV | The representation after full-history compression | Continuously updated as the window advances | Whether the compression ratio and quantization error stay within threshold |
| uncompressed tail | Original KV of recent tokens not yet compressed | Short-lived, reclaimed by the compression action | Whether the tail length aligns with the sliding window |
| SWA window | The valid interval covered by the sliding window | Rollingly invalidated as the position slides | Whether the current position still falls within the window |
| indexer state | The routing/index state of sparse routing | Tightly bound to the prefix | Whether the routing decision matches the current prefix |
| on-disk prefix | Prefix blocks sunk to the storage layer | Long-resident, backfilled on demand | Whether backfilling is complete, whether bytes are aligned |
The key point is that these five kinds of objects cannot use the same rules for hit determination. A hit on compressed KV may correspond to an uncompressed tail that is not yet ready; a hit on an SWA window may mean the index catalog is already out of sync. Hash equality is only a necessary condition, never a sufficient one.
The Allocator: From “Finding an Empty Block” to “Recording State”
Once cache objects become heterogeneous, the responsibility of alloc is significantly enlarged. It is no longer just “find an empty GPU block”; it must also record, for each segment of tokens, which shape it is currently in. Otherwise you get the typical error chain:
prefix match reports a hit by hash↓on actual read: missing tail / missing SWA window / missing indexer routing↓generation stage reads an inconsistent context↓garbled or semantically wrong output (with no exception thrown)
This kind of bug is dangerous precisely because it does not throw an error—the framework believes the hit succeeded and the cache was reused, the program keeps running normally, only the result is wrong. Below is an illustrative snippet of stateful matching logic:
def can_reuse(cached_seg, request_prefix, cur_pos):# A matching hash is only an entry ticket, not a passif cached_seg.hash != request_prefix.hash:return False# Validate each object: any one failing means no direct reusechecks = {"compressed_kv": cached_seg.compressed is not None,"uncompressed_tail": cached_seg.tail_ready,"swa_window": cached_seg.swa_covers(cur_pos),"indexer_state": cached_seg.indexer_matches(request_prefix),"on_disk_prefix": cached_seg.disk_backfilled(),}# Only allow a hit if all passreturn all(checks.values())
What the allocator must maintain is no longer a single free list, but a state machine tagged by shape: each block records whether it is in compressed form or raw form, inside or outside the sliding window, whether it has been sunk, and whether the index is synchronized. Both allocation and reclamation must follow the state-transition graph, rather than a simple “allocate/free.”
Four-Layer Verification: Can a Hit Be Used to Continue Directly?
Even after confirming that a cache is reusable, it must pass four gates before you can conclude that this prefix hit can truly be used to continue computation directly:
- Alignment granularity check (lcm whole block): The length/position of the cache block must be an integer multiple of the least common multiple (lcm) granularity, to avoid misalignment when stitching across blocks. Half-block hits and misaligned hits are both hazards.
- Operator ABI compatibility check: The layout of the reused KV must match the ABI (application binary interface convention) of the downstream operator—dtype, layout, stride, and alignment requirements. An upstream hit does not mean the downstream operator can accept this layout.
- Multi-cache-group state intersection check: A model often has multiple cache groups (different layers, different attention types). Only when all cache groups are in a reusable state can the whole be considered a hit—take the intersection, not the union.
- Byte-level hardware alignment check: A GPU block must be aligned at the byte level with the hardware access granularity; otherwise reuse triggers out-of-bounds reads or unaligned access.
The four layers are in an “AND” relationship: if any single layer fails, this hit cannot be used to continue directly and must fall back to full recomputation or partial recomputation.
Four Consistency Checks: Iron Rules the State Machine Must Never Violate
Finally, the allocator’s state machine must hold four consistency bottom lines throughout its entire lifecycle:
- Admission cap: Before accepting a new request, first evaluate whether all five states can be correctly restored. Requests that cannot be restored should be rejected at admission, rather than accepted and then quietly computed wrong.
- Five-state dispatch: After a request enters, it is dispatched by object shape, and a single path is forbidden from covering all cases. Dispatch is the key gate that prevents “one-size-fits-all reuse.”
- TOCTOU protection: There is a time window between “checking the state” (time-of-check) and “actually using it” (time-of-use). If asynchronous backfilling, compression reclamation, or eviction happens in between, it leads to a check that passes but a use that fails. State pointers (such as state descriptor structures) must be protected with version numbers or reference counting, to prevent reading stale state.
- Static compute graph topology: In scenarios that use static compute graph capture (fixing the operator sequence into a graph that is replayed repeatedly), the cache’s addresses and shapes are fixed at capture time. Dynamic reuse must guarantee that the new block is fully consistent with the topology at capture time; otherwise a replay reads wrong addresses.
Summary
The real challenge that hybrid attention large language models bring is not “insufficient cache,” but that the correctness determination of the cache is fundamentally rebuilt. Developers need to establish three insights:
- Hit rate optimizes performance, while correctness depends on “whether it can be fully restored”—the two must not be conflated;
- Paged KV cache evolves from a “homogeneous block” into a “heterogeneous state set,” and the allocator must be stateful;
- Every prefix hit must go through multiple layers of verification and consistency checks—computation must never be continued directly just because the hash matches.
Only by building these layers of verification and consistency constraints into the design of the inference service can we hold the line on generation correctness while pursuing long context and high reuse.
