Attention Architecture and KV Cache Design in Next-Generation LLM Inference Systems

    New-generation large language models mix full attention, sliding-window attention, and compressed sparse attention within a single model, breaking the assumption of uniform per-layer KV tensors. This article examines how inference systems must adapt, covering multi-level KV pool design, unified prefix trees with shadow identifiers, coordinated eviction, pipelined compression and TopK selection, CUDA Graph adaptation, prefill/decode separation, context parallelism, and MoE weight-side optimizations for trillion-parameter serving.

    1. Background: Model Architecture Evolution Is Reshaping Inference Systems

    Open-source large language models have been iterating rapidly, with parameter counts climbing from tens of billions into the trillions. Architecturally, models have evolved from standard dense attention plus MoE into complex hybrids that mix multiple attention mechanisms. New-generation models share several common traits:

    1. Diverse attention mechanisms: A single model may simultaneously use full attention, sliding-window attention (SWA), and token-compression-based sparse attention. KV state shapes differ entirely across layers, so it is no longer valid to assume “one equal-length raw KV tensor per layer.”
    2. MoE at scale: Expert counts and parameter sizes grow together, making weight loading and expert routing new bottlenecks.
    3. Training–inference convergence: Reinforcement learning training requires inference engines with high-throughput rollout capability, adding more constraints to deployment.

    These shifts mean the focus of inference frameworks has moved from “getting a model class to run” to “building deployable, tunable, and reusable serving paths for new attention structures.” This article takes a general technical perspective and walks through the key design points for bringing such models into production inference systems.

    2. Core Challenge: State Space Explosion in the Attention Runtime

    Traditional inference systems treat the KV cache as a set of per-layer contiguous tensors, allocated, indexed, and evicted uniformly. Under hybrid attention architectures, the problem becomes far more complex:

    • Sliding-window layers (SWA): Only KV within the most recent window needs to be maintained. Anything beyond can physically be discarded, but logically it must still align with sequence coordinates.
    • Compressed attention layers: Historical tokens are represented in compressed form at different compression granularities (e.g., a fine-grained tier and a coarse-grained tier), each requiring an independent compression pool to store compressed KV states.
    • Indexer state: Sparse attention typically relies on a lightweight selector/indexer to decide “which historical tokens the current query attends to,” and this indexer has its own cacheable state.
    • Compression intermediate state: Compression happens in a streaming fashion, so a state pool must track “which tokens have been compressed, and how far compression has progressed.”

    In aggregate, a single request carries multiple coordinate systems and multiple physical stores at once: full token-sequence coordinates, pools for each compression granularity, a window pool, an index pool, and a state pool. The inference framework must answer three questions:

    1. How should these pools be addressed uniformly so that attention kernels can route to the correct storage per layer?
    2. How does prefix cache hit detection work across a multi-pool structure, so that requests can reuse each other’s state?
    3. How do CUDA Graphs, prefill/decode (PD) disaggregation, and tiered offloading coordinate with these pools?

    3. Multi-Level KV Pool Design and Implementation

    3.1 Unified Prefix Tree with “Shadow” Identifiers

    Classic prefix caching uses a radix tree to manage token prefixes shared across requests. In a multi-pool architecture, the naive approach breaks down: SWA window states keep “sliding out of validity” as the sequence advances, and compression-layer state depends on compression boundaries. Binding all pools to the same set of tree nodes makes hit detection overly conservative.

    An effective engineering solution is a “shadow node” mechanism: maintain independent logical views for different pool types on the unified prefix tree. Physical pages hang only off the full-coordinate tree, while the window pool and compression pools connect via offset mapping. This yields:

    • A full-coordinate tree handling request routing and hit detection;
    • An SWA pool where the tail can expire while the head is reused, without discarding entire segments;
    • A compression pool aligned to compression boundaries, with hit granularity matching compression blocks to avoid recomputation from half-compressed state.

    3.2 Per-Pool Allocation and Coordinated Eviction

    A multi-pool system needs independent lifecycle policies for each pool type:

    1. Pool Type | Allocation Granule | Eviction Policy
    2. ---------------------|--------------------|--------------------------------------
    3. Full token pool | page | LRU + reference counting
    4. SWA window pool | page | Reclaimed immediately as window slides
    5. Fine-grained pool | compression block | LRU after boundary alignment
    6. Coarse-grained pool | compression block | Same as above
    7. Indexer state pool | page | Invalidated in sync with main pool

    The key is coordinated invalidation: when a segment of the full pool is evicted, all compression blocks and indexer states depending on that token range must be released simultaneously, or dangling references appear. Implementations typically use reference counting plus epoch validation, with kernels checking state validity before execution.

    3.3 Pipelining the Compressor and TopK

    The compute cost of compressed attention comes from two places: the compression transform itself, and TopK retrieval during sparse selection. An efficient implementation pipelines the two:

    • Compression completes synchronously with token writes during prefill, avoiding compression backfill during decode;
    • TopK selection leverages the indexer’s small KV (typically low-dimensional vectors), performed on GPU with blocked parallel retrieval so that selection overhead overlaps the main attention computation;
    • For historical state beyond GPU memory capacity, the coarse-grained compression pool can be offloaded to host memory and retrieved on demand via sparse lookup (the “tiered offloading” approach), trading coarse-grained recall loss for capacity expansion.

    4. System-Level Coordination: CUDA Graphs, PD Disaggregation, and Parallelism

    4.1 Adapting CUDA Graphs to Multi-Pool Architectures

    CUDA Graphs require fixed tensor addresses and shapes at capture time. With multiple pools, in-pool offsets differ per request, so a common approach is “fixed virtual address + page-table indirection”: capture the graph once, then switch to each request’s physical pages by updating page-table entries at inference time, avoiding repeated capture for every pool combination.

    4.2 Prefill/Decode Disaggregated Deployment

    Hybrid attention raises new requirements for PD disaggregation: compressed state is generated in a streaming fashion, so when migrating from a prefill instance to a decode instance, you cannot transfer raw KV alone—you must also transfer the compression pool, index pool, and compression progress state. In practice, migration uses a “state snapshot + sequence coordinate alignment” approach, so the decode side can seamlessly resume from any compression boundary.

    4.3 Parallelism Dimensions

    Attention-level parallelism can combine data parallelism (DP), tensor parallelism (TP), and context parallelism (CP). In a multi-pool structure, CP splits must align with compression boundaries; otherwise cross-shard compression requires heavy communication. In practice, compression blocks serve as the minimum CP unit, combined with contiguous splits of the full pool, balancing communication volume and load balancing.

    5. MoE and Weight-Side Optimizations

    Beyond attention, serving trillion-parameter MoE models requires:

    • Tiered expert weight placement: Hot experts stay resident in GPU memory, cold experts are offloaded to host memory, with routing prediction used for proactive prefetching;
    • Fused MoE kernels: Gating, dispatch, expert computation, and combine are fused into a small number of kernels to reduce memory traffic and launch overhead;
    • Multi-token prediction (MTP): A draft model or shared head predicts multiple tokens at once, with a verification mechanism to boost decode throughput—especially beneficial when prefix cache hit rates are high.

    6. Summary

    The hybrid attention architectures of new-generation models push inference-system complexity from the “operator layer” up to the “state management layer.” A mature serving stack must get all of the following right: unified addressing and coordinated eviction across multi-level KV pools, prefix reuse aligned to compression boundaries, indirect addressing for graph capture, state migration under PD disaggregation, and tiered weights plus throughput optimizations on the MoE side. These design points are deeply coupled—only by wiring them into one coherent runtime system can the performance benefits of the new architectures actually materialize. For engineering teams, understanding this “state-space-first” design philosophy is more valuable in the long run than memorizing any single technique.