Hybrid Attention Architectures and KV Cache Management in Next-Generation LLM Inference Systems

    How hybrid attention architectures are reshaping LLM inference systems, and a practical guide to multi-tier KV cache pooling, streaming compression, unified coordinate management, CUDA Graph capture, and PD-disaggregated deployment.

    1. Background: Hybrid Attention Changes the Design Assumptions of Inference Systems

    For years, most LLM inference systems were built on a relatively simple assumption: every attention layer uses homogeneous full attention. Under that assumption, the KV cache can be modeled as a single set of raw KV tensors organized by layer, managed by one unified paged allocator. In this world, prefix caching, CUDA Graphs, KV offload, and prefill-decode (PD) disaggregation all share the same coordinate system and lifecycle management.

    Newer open-source models are breaking that assumption. The latest generation of models commonly introduces hybrid attention structures:

    • Sliding window attention (SWA): attention is computed only within a recent window; KV outside the window can theoretically be discarded or stored at reduced fidelity.
    • Compressed attention: historical KV is compressed into a small number of token-level summary representations—for example, a coarse-grained and a fine-grained tier (think of C4 compression aggregating 4 tokens per unit, and C128 aggregating 128 tokens per unit). The two compression pools need to be switched dynamically during request processing.
    • Indexer structures: beyond the compression pools, an independent indexer state must be maintained for top-k retrieval in sparse attention.
    • Compression intermediate state: streaming compression requires caching “partial” intermediate state that has not yet filled one compression unit, which introduces yet another state pool.

    This means the inference runtime no longer faces a single state space of “one raw KV set per layer.” Instead, it must maintain five or six distinct cache pools—each with different granularity, lifecycle, and eviction policies—and keep them consistently mapped across prefix reuse, graph capture, PD disaggregation, and KV offload. This is the central engineering challenge in inference systems today.

    2. Multi-Tier KV Cache Pooling

    2.1 Split the Cache into Pools by Physical Form

    The recommended first step is to split the “logically single KV cache” into multiple physical pools, each with its own page size and its own manager:

    1. TokenPool # full-token coordinates + raw KV, page size = 1 token
    2. SWAPool # sliding window physical pool, with window-based eviction
    3. CompressPool4 # coarse-grained compression pool, page size = compression unit
    4. CompressPool128 # fine-grained compression pool
    5. IndexerPool # sparse retrieval index state
    6. CompressState # intermediate state for streaming compression

    The key benefit of this split is that each pool can adopt its own allocation and eviction strategy. The SWA pool only needs physical page contiguity within the window; compression pools can align page size with the compression unit, which significantly reduces fragmentation; the state pool is managed per request lifecycle and does not participate in prefix reuse.

    2.2 Unify the Coordinate System

    Multiple pools immediately create coordinate fragmentation. A request at logical token position 1000 has completely different page numbers in the raw KV pool, the compression pools, and the indexer pool. In practice, the request metadata should carry a unified logical coordinate table, and each pool converts logical positions to physical addresses via a mapping function:

    1. def resolve_page(req, layer_type, logical_pos):
    2. if layer_type == "swa":
    3. return swa_pool.page_of(req, logical_pos) # mapped only within the window
    4. if layer_type == "compressed":
    5. unit = logical_pos // COMPRESS_UNIT
    6. return c_pool.page_of(req, unit)
    7. ...

    On a prefix cache hit, the prefix segments of all pools must be correctly reused. This is why a single traditional radix tree no longer suffices—you need separate prefix indexes for the window structure and the compression structure (for example, by attaching per-pool range descriptors to tree nodes). This is the “shadow prefix tree” idea: the main tree records the token sequence, and each node carries a snapshot of page ranges for every pool.

    3. Sparse Attention and the Compression Pipeline

    3.1 Streaming Compression

    Compressed attention cannot wait until the full sequence is generated before compressing, or decoding would never have access to compressed representations in time. The workable approach is pipelining:

    1. Every few generated tokens, append them to the compression state pool;
    2. Once the state fills one compression unit, trigger a compression kernel that writes the result into the corresponding compression pool;
    3. Update the indexer pool’s retrieval index in sync.

    The engineering crux is overlapping the compression kernel with the decode kernel. Compression is computationally cheap but depends on write barriers, so it is typically scheduled as a small kernel between two decode iterations, or folded into a fixed segment of a CUDA Graph.

    3.2 Speeding Up Sparse Top-K Retrieval

    Because the compression pools exist, each decode step can first run a lightweight “summary-level retrieval” to select a few relevant historical ranges before computing exact attention. This is essentially a GPU-side Top-K problem, with the bottleneck in sorting and index access. Optimization directions include:

    • Lay out the indexer state for vectorized reads to avoid the randomness of gather-based memory access;
    • Replace full sorting with partial selection (e.g., a radix-select style approach);
    • Fold Top-K into the prologue of the attention kernel to eliminate one global synchronization.

    3.3 KV Offload and Sparse Reclamation

    When GPU memory runs short, raw KV outside the SWA window and low-heat compressed ranges can be offloaded to host memory. Sparse retrieval naturally provides heat information: compressed ranges that have not been hit by Top-K for a long time are the first candidates for offload. During reclamation, you must maintain reference consistency between the compression pools and the raw pool—otherwise you can end up with “summary still present, raw tokens already reclaimed,” which breaks prefix reuse.

    4. Deployability: From Structure to the Serving Path

    4.1 Multi-Pool Challenges Under CUDA Graphs

    Graph capture requires that tensor addresses and shapes stay fixed across iterations. With a multi-pool structure, you need to reserve static buffers for each pool type and perform a “copy physical pages into the static region” gather step outside the graph. The dynamic number of compression units must be folded into a fixed upper bound (max compressed units per step); anything beyond that falls back to eager mode.

    4.2 PD Disaggregation and Cache Migration

    When prefill and decode are disaggregated, KV migration no longer moves a single raw KV stream but a complete snapshot of “raw segments + compressed segments + state segments.” Engineering recommendations:

    • Use the logical coordinate table as the source of truth for migration; the transport layer moves only physical pages along with their coordinate descriptions.
    • Compressed segments can be transferred incrementally (only compression units added since the last snapshot), which greatly reduces cross-node bandwidth.
    • Migrate the state pool with the request as a whole to avoid inconsistent intermediate compression state.

    4.3 Adapting Parallelism Strategies

    Under mixed DP/TP/CP parallelism, compression pools are typically sharded along the sequence dimension (CP-friendly, since compression is a local operation), while raw KV is sharded along attention heads. Because the SWA window is small, the window KV can even be replicated within a group in exchange for eliminating communication. The choice should be driven by each pool’s access locality, not a one-size-fits-all policy.

    5. Practical Takeaways

    1. Build the coordinate system first, then split into pools. Without unified logical coordinates, multi-pool management inevitably spirals out of control.
    2. Overlap the compression pipeline with decoding. Compression kernels are small and frequent; scheduling overhead determines the payoff.
    3. Prefix reuse must cover every pool. Schemes that reuse only raw segments simply do not work under hybrid attention.
    4. Layer offload by heat. Sparse retrieval hit rates are a natural heat signal.
    5. Design for CUDA Graph support from day one. Draw the boundary between static buffers and dynamic pools as early as possible.

    Hybrid attention is a clear direction in LLM evolution, and the competitiveness of an inference system will increasingly depend on how cheaply it can fold these new structures into a reusable serving path. Mastering three core designs—multi-tier cache pooling, streaming compression, and unified coordinate management—is the necessary foundation for building the next generation of inference frameworks.