Rethinking State Caching for Hybrid-Architecture LLMs: A Practical Path to Several-Fold Prefill Throughput Gains

    Hybrid LLM architectures that combine full attention with linear attention are becoming increasingly common in open-source models, offering faster decoding and smaller caches. However, they complicate prefix caching, a key mechanism for reducing time-to-first-token in multi-turn and agentic workloads. This article explains why hybrid architectures break traditional KV cache reuse, how to treat linear-layer states as first-class citizens in a unified cache design, and the measured results: prefill throughput gains of over 3x and p90 first-token latency reductions of nearly 90%, along with practical deployment recommendations.

    Why Hybrid Architectures Are Becoming the New Trend

    Recently, many mainstream open-source LLMs have adopted a “full attention + linear attention” hybrid architecture: standard full attention is retained in a few key layers, while most remaining layers are replaced with linear attention or state-space-style structures. The benefits are clear:

    1. Faster decoding: A linear layer’s state is a fixed-size matrix, so decoding requires no reads across the full historical KV Cache, dramatically reducing memory bandwidth pressure.
    2. Smaller caches: Full attention layers make up only a small fraction of total layers, shrinking KV Cache size several-fold and allowing more concurrent requests per GPU.
    3. Controllable long-context costs: State size is independent of sequence length, making the architecture naturally suited to ultra-long-context workloads.

    Major open-source inference engines have added support for these architectures, and hybrid models are becoming a mainstream choice for agent-style applications.

    The Problem: Hybrid Architectures Complicate Prefix Caching

    In coding agents and multi-turn conversations, systems typically rely on prefix caching to avoid redundant computation—each user turn shares a long historical prefix with the previous one. If the KV Cache computed in the last turn can be cached and reused, most of the prefill computation can be skipped, significantly lowering first-token latency.

    Hybrid architectures, however, break the assumptions behind this mechanism:

    • Linear layers have no traditional KV: Their “memory” is a fixed state matrix updated recurrently along the sequence. Reusing a prefix requires persisting and managing this state matrix as well.
    • States and KV have mismatched lifecycles: Full attention caches can be paged at token granularity, while linear-layer states are one complete matrix per layer, differing from KV in both granularity and size.
    • Cancellation costs are asymmetric: Linear-layer states are recurrent products and cannot be quickly resumed from existing KV the way attention can. Once a cache entry is invalidated, the entire sequence must be replayed from scratch.
    • Long-prefix scenarios amplify the problem: Multimodal inputs and tool calls produce long prefixes, and agent trajectories can easily reach hundreds of thousands of tokens. Whether the cache hits directly determines service cost and user experience.

    The Core Idea: Treat State Caching as a First-Class Citizen

    Research and practice point to a clear direction: redesign the “KV + linear state” combination in hybrid architectures as a unified cache system, rather than making linear states subordinate to the KV cache. Key design elements include:

    1. A Layered Cache Model

    The paged KV of full attention layers and the per-layer state matrices of linear layers are brought into a single cache manager, uniformly indexed by “sequence prefix version.” On request arrival, prefix matching runs first; on a hit, both parts of the cache are restored:

    1. # Conceptual illustration: unified prefix cache
    2. cache_entry = prefix_cache.lookup(request.tokens)
    3. if cache_entry:
    4. load_kv_pages(cache_entry.kv_blocks) # full attention layers
    5. load_states(cache_entry.linear_states) # linear-layer state matrices
    6. prefill_only(cache_entry.unmatched_suffix)

    2. Asynchronous Offloading and Prefetching

    The total state volume of long agent trajectories can be substantial. Hot prefixes are typically kept in GPU memory, while cold data is asynchronously offloaded to host memory or even a distributed object storage tier. During scheduling, prefetching is overlapped with the prefill computation window, so that restoration latency does not negate the gains.

    3. Coordinating Prefix Reuse with Multi-Request Scheduling

    Because prefill throughput improves substantially, the scheduler can accept concurrent requests more aggressively. When multiple concurrent sessions share the same system-prompt prefix, the state cache only needs to be loaded once, further amortizing costs.

    Measured Results

    In real-world agent coding trajectory replay tests (based on current flagship datacenter accelerators), this redesigned caching approach delivered significant gains:

    • Prefill throughput reached more than 3x that of conventional inference engines;
    • p90 first-token latency dropped by nearly 90% at best—for interactive coding agents, this means users go from “waiting tens of seconds” to “second-level responses”;
    • The benefits hold even with a CPU-side cache tier in the hundreds of GiB range, and the approach supports cross-node state reuse in distributed deployments, making it suitable for production environments where multiple instances share the same large model service.

    Practical Recommendations

    For teams planning to use hybrid-architecture models to power agent applications in self-hosted or cloud inference services, consider these points:

    1. Prefer inference engine versions that support hybrid state caching, or evaluate the cost of extending your own prefix cache manager;
    2. Design a dedicated GPU memory quota for linear states to avoid contention with the KV paging pool;
    3. Use general-purpose storage such as object storage for cold prefixes, tiered by access frequency;
    4. Monitor prefix hit rate and state restoration time—these two key metrics together determine the actual TTFT benefit;
    5. In multi-turn agent scenarios, keep prefix components such as system prompts and tool definitions stable to improve cache hit rates.

    Hybrid architectures reduce decoding costs, and the redesign of state caching fills the gap in long-context, multi-turn workloads. Only by combining the two can hybrid models fully deliver their dual advantages in throughput and latency for agent scenarios.