Hybrid Architecture Cache Redesign: The Key to Higher Prefill Throughput

    This article explains why hybrid architectures that combine full attention layers with linear or state space layers have become a common choice for long-context workloads, and why their mixed cache formats make prefix caching far more complex than in pure Transformer models. It covers the three core challenges of caching recurrent states alongside KV Cache, a redesign approach based on block-aligned matching and separate management of the two cache types, and the resulting gains in prefill throughput and p90 TTFT. It closes with practical guidance for engineering teams deploying such caches.

    1. Why Hybrid Architectures Have Become the Default for Long-Context Workloads

    In open-source large model designs over the past two years, linear attention and state space layers have shifted from experimental components to standard configuration. Kimi Delta Attention, Gated DeltaNet, and Mamba-2 share a common trait: instead of retaining full key-value pairs for the entire history, they compress history into a fixed-size recurrent state. This yields two direct benefits. Compute and memory access per decoding step no longer grow linearly with context length, and cache memory consumption changes from “grows with length” to “fixed per layer.”

    As a result, many hybrid architectures now alternate full attention layers with linear layers. A few layers preserve precise global retrieval, while most carry long-range information at low cost. For very long contexts, this trade-off is highly economical.

    But a new problem follows: the cache in a hybrid architecture no longer has a single form. Full attention layers need KV Cache; linear layers need recurrent state. The two differ completely in lifecycle, reuse granularity, and serialization cost, which makes prefix cache management much more complex than in a pure Transformer.

    2. Coding Agent Workloads Amplify the Cache Problem

    Coding assistant workloads have three distinct traits, and each one lands squarely on a hybrid architecture pain point:

    • Accumulation across turns: within a single session, system prompts, repository context, tool definitions, and message history keep stacking up, so prefixes overlap heavily.
    • Long contexts: repository-level retrieval results routinely reach tens of thousands to hundreds of thousands of tokens, making the first prefill a heavy job.
    • High concurrency and branching: the same prefix is requested repeatedly and also spawns branches (retries, parallel subtasks, different sampling parameters).

    Under this workload, time to first token (TTFT) is determined almost entirely by the prefill stage, and prefill cost is determined almost entirely by whether the cache hits and whether the cached data can be used directly after a hit.

    3. Three Core Challenges of Caching Mixed State

    3.1 Recurrent State Cannot Be Sliced by Token

    KV Cache is positionally additive: if a prefix hits N tokens, the keys and values for those N positions are reused directly. Recurrent state does not work this way. It compresses the entire history into a matrix, and no intermediate artifact corresponding to “the state after the first N tokens” can be recovered from it. Two consequences follow: reuse granularity must be aligned to blocks, and once a block misses, all subsequent states can only be recomputed by advancing forward.

    3.2 Eviction Policies for the Two Cache Types Conflict

    KV Cache is large and can be matched precisely, which suits global reuse keyed by prefix hash. Recurrent state is small but information-dense, and there is one copy per layer, so there are many of them. Applying one shared eviction and indexing scheme to both either wastes memory or drags down the hit rate.

    3.3 Cross-Node Reuse Is Expensive

    Under distributed inference, a prefix may be routed to any node. KV Cache can be transferred in shards, whereas recurrent state requires “complete within a layer, independent across layers.” Transfer and deserialization costs have entirely different structures and must be designed separately.

    4. Redesign Approach: Split Mixed State into Two Coordinated Mechanisms

    As the industry has discussed this problem, a few consensus design principles have emerged. The scheduling-side core decision can be expressed with the following pseudocode:

    1. def prefill(request, cache):
    2. # 1. Match prefixes in blocks; block size aligns with the state advance granularity of linear layers
    3. hit = cache.match_prefix(request.tokens, block=STATE_BLOCK)
    4. # 2. Full attention part: reuse precisely by position
    5. kv = cache.kv.get(hit.kv_positions)
    6. # 3. Linear part: reuse recurrent state by block; recompute only missed blocks
    7. states = cache.state.get(hit.state_blocks)
    8. for chunk in request.remaining_chunks:
    9. states = linear_layer.advance(states, chunk) # state can only advance sequentially
    10. cache.state.put(chunk.id, states)
    11. return kv, states

    The key points are: align matching granularity, manage the two cache types on separate accounts, and minimize the missed range.

    Tiered Caching and Capacity Planning

    Keep the hottest prefixes in the memory tier, which is small and low-latency; let the host memory tier hold warm data; let a remote cache pool hold cold data and cross-session sharing. Because recurrent state is small, placing it entirely in a faster tier usually offers better value than keeping large KV blocks in a slow tier.

    Hit Determination and Block Alignment

    Blocks that are too small inflate indexing overhead and metadata; blocks that are too large still require recomputing the tail after a hit. In practice, block size must be tuned together with the advance step of the linear layers and the statistical distribution of request lengths, rather than fixed at a constant.

    Distribution and Cross-Node Reuse

    The state cache needs a transfer protocol that shards by layer and aggregates by request. Prefix identifiers and state block identifiers should also be encoded in a unified way, so different nodes reach the same hit conclusion for the same prefix and avoid duplicate computation.

    5. Where the Gains Come From: Prefill Throughput and p90 Latency

    In replay experiments on real coding traces, this kind of redesign typically delivers two kinds of gains. The first is a multiple increase in prefill throughput, coming from “skip on hit”: in multi-turn sessions most tokens belong to repeated prefixes, and skipping them eliminates the most expensive matrix multiplications outright. The second is a significant drop in p90 TTFT, because tail requests are often exactly the requests with very long prefixes, and cache hits flatten the tail most visibly.

    It is worth stressing that the gains depend heavily on workload characteristics. If prefix overlap is low, or if the block alignment strategy does not match the actual length distribution, the improvement shrinks substantially. When evaluating such designs, therefore, benchmarks should use real traces rather than synthetic short requests.

    6. Engineering Recommendations

    1. Quantify prefix overlap first: measure the prefix hit distribution of production sessions to decide whether investing in a cache system is worthwhile.
    2. Load-test the two cache types separately: observe hit rate, transfer time, and deserialization time for KV and for recurrent state independently.
    3. Treat the cache as a first-class citizen for observability: hit length, missed ranges, and eviction reasons all need metrics, combined with logging services and monitoring alerts to locate tail latency.
    4. Scale elastically on general capabilities: a state cache pool can be built on container platforms and object storage, tiered by session热度, avoiding tight coupling to a single hardware form.
    5. Keep correctness first: any reuse must guarantee strict alignment of state and position, and fall back to full recomputation when prefix validation fails, rather than approximate reuse.

    The decoding efficiency dividend from hybrid architectures is already clear; the real engineering barrier has moved to the cache side. Whoever manages the two semantics of full attention KV and linear layer state separately, and hits reliably across multi-turn long contexts, can push down prefill throughput and first-token latency at the same time.