Redesigning Hybrid Architecture Caching for Higher Prefill Throughput
This article explains why hybrid architectures that interleave full-attention and linear or state layers have become a common choice for large language model inference, and why a unified KV Cache abstraction breaks down in this setting. It identifies three mismatches in state semantics, lifecycle, and memory access patterns, then presents a four-layer cache redesign: a unified state object abstraction, tiered storage with type-specific eviction, prefix state reuse with incremental prefill, and heterogeneous batching and scheduling. The article also covers engineering practices such as correctness checks, observability, gradual rollout, and capacity planning, along with a layered evaluation methodology and common pitfalls. Readers will learn how to reduce repeated computation and data movement during prefill to achieve sustainable throughput gains.
1. Background: Why Hybrid Architectures Have Become the Default for LLM Inference
Over the past year or two, more and more large language models have adopted hybrid architectures that interleave full-attention layers with linear or state-space layers. A common industry pattern is to use state-space or linear attention structures with linear-complexity inference in most layers, while keeping full attention in a subset of layers to preserve long-range precise retrieval and complex context modeling.
The motivation is straightforward:
- Cheaper decoding: The inference state of linear layers is typically independent of, or only weakly related to, sequence length, avoiding the linear growth of the KV Cache seen in full attention.
- More controllable memory usage: In very long context scenarios, the cache no longer grows without bound as tokens accumulate, so a single device can host significantly more concurrent requests.
- Better long-text support: Context windows can be very long while memory and bandwidth pressure grow relatively slowly.
The benefits come at a cost, however. Hybrid architectures turn what was a homogeneous cache space into a heterogeneous collection of states, creating entirely new engineering problems for cache management, batch scheduling, and prefill optimization in inference engines. The core topic of this article is how to redesign the hybrid state cache to multiply prefill throughput.
2. Problem Analysis: Three Mismatches of the Unified Cache Paradigm in Hybrid Architectures
Traditional inference engines were designed around full-attention models, with a very simple cache abstraction: one KV Cache per layer, laid out contiguously along the token dimension and managed through paging or contiguous blocks. Carrying this abstraction over to hybrid architectures produces three kinds of mismatch.
2.1 State Semantics Mismatch
The full-attention cache is positionally addressable: the key-value pair for token i lives at position i, so prefix reuse, exact truncation, and per-token eviction all work. The state of a linear layer is recursively accumulated instead: it is a fixed-size tensor that evolves over time, cannot be split precisely at a token boundary, and cannot easily be rolled back to “the state as of token i.”
A single token-paged cache management scheme therefore cannot correctly describe both kinds of state at once.
2.2 Lifecycle Mismatch
The lifetime of a full-attention cache is strictly bound to the request context, and the whole block can be reclaimed when the request ends. Linear states, in contrast, have potential for cross-request reuse: the same prefix recurs across multiple conversation turns, the same system prompt, or the same long-document Q&A session, and its accumulated state can theoretically be cached and reused. Traditional engines provide no index or invalidation mechanism for this kind of shareable state, so reuse rates stay very low.
2.3 Memory Access Mismatch
The full-attention cache is bandwidth-intensive and dominated by random access; linear states are compute-intensive and updated sequentially. Putting both in the same memory pool under one scheduling policy causes interference: large contiguous allocations worsen fragmentation, and a uniform swap-out policy evicts hot states by mistake.
3. Design Goals: Rebuilding the Cache Around Prefill Throughput
The prefill stage determines time to first token and sets the ceiling on overall throughput. Its bottleneck is usually not compute but wasted repeated computation and cache movement overhead. The redesign therefore has four goals:
- Eliminate repeated prefill: Compute an identical prefix only once and reuse its state.
- Tier state storage: Grade states by access frequency and lifetime to reduce data movement.
- Co-schedule heterogeneous states: Use batching strategies suited to full-attention and linear layers respectively.
- Make it observable and reversible: Every optimization must be measurable, releasable behind a gradual rollout, and switchable off.
4. Core Design: A Four-Layer Rebuild of the Hybrid State Cache
4.1 Unified State Abstraction Layer
Rather than equating the cache with the KV Cache, model it as a “state object” with metadata and payload:
StateObject {state_type: ATTENTION | LINEARlayer_id: intprefix_hash: bytes // exact only for ATTENTIONpayload: tensor // shape depends on typeref_count: intlifecycle: REQUEST | SESSION | GLOBALlast_access: timestamp}
The key point: prefix_hash provides exact token-level indexing only for full-attention layers; linear layers use an approximate index based on a prefix fingerprint plus an accumulated digest, with validation attached to avoid incorrect reuse.
4.2 Tiered Storage and Graded Eviction
States live in three tiers: an on-device fast cache, the main device memory pool, and host memory or a remote cache pool. Eviction policies diverge by type:
- Full-attention cache: block-level eviction driven by reference count and last access time, with exact eviction down to token granularity.
- Linear states: swap in and out at session granularity as a whole, avoiding correctness problems from partially updated states.
Illustrative logic:
def evict(state_pool, pressure):if pressure < HIGH_WATER:return# Evict globally reconstructible attention blocks firstfor blk in state_pool.attn_cold_blocks():blk.drop()# Then swap out linear states of low-activity sessions as a wholefor sess in state_pool.idle_sessions():sess.swap_out()
4.3 Prefill Reuse and Incremental Computation
Extend prefix reuse from full attention to the hybrid architecture:
- On a long-prefix hit, load the corresponding attention blocks and linear state directly, skipping that segment of repeated computation.
- On a miss, prefill incrementally block by block, persisting each completed block as reusable state for later requests.
- For linear layers, introduce a state snapshot mechanism that saves a fixed-size snapshot at block boundaries, enabling approximate rollback.
Request prefix P = [B1][B2][B3]Hit on B1 attention blocks + linear snapshot -> compute only B2, B3
This step is usually the main source of prefill throughput gains: in system prompts, long documents, and multi-turn conversations, repeated prefixes often make up a large share of the input.
4.4 Heterogeneous Batching and Scheduling Coordination
The scheduler must distinguish two task classes:
- Attention-heavy batches: cap the batch size so bandwidth saturation does not cause tail-latency jitter.
- Linear-state batches: moderately larger batches amortize update cost through compute parallelism.
Also add a prefill priority queue that schedules requests with high hit rates and ready states first, reducing cache movement and waiting.
5. Engineering Implementation Notes
- Correctness first: Reuse of linear states must be validated; fall back to recomputation rather than allow silent errors.
- Observability: Instrument prefix hit rate, state swap-in/swap-out volume, prefill queue time, and cache fragmentation rate.
- Gradual rollout and switches: Control every optimization through configuration, with rollout by model and by business line.
- Capacity planning: Estimate memory from peak concurrency × average context × state growth factor, and leave headroom for fragmentation.
- Combine with general cloud capabilities: Use a container platform for elastic scaling, object storage for cold states, and monitoring, alerting, and logging services for long-tail analysis.
6. Performance Evaluation Methodology
Build a layered evaluation rather than looking at a single throughput number:
- Micro benchmarks: Fix prefix length and hit rate, then measure prefill tokens/s.
- Scenario benchmarks: Three real traffic types: system prompt reuse, long-document Q&A, and multi-turn sessions.
- Stability metrics: P99 time to first token, cache jitter, and error fallback rate.
- Cost metrics: Memory per unit throughput and host memory swap-out volume.
Throughput gains are sustainable only when hit rate, latency, and correctness all meet their targets. In industry practice, combining prefix state reuse with tiered caching commonly yields several-fold prefill throughput improvements, but the exact multiple depends heavily on traffic structure and context length distribution, so it must be validated with your own load tests.
7. Common Pitfalls
- Pitfall 1: Treating all layer states as the same kind of cache. Under a heterogeneous architecture, states must be managed by category.
- Pitfall 2: Optimizing memory only and ignoring movement. The prefill bottleneck often comes from data movement rather than compute.
- Pitfall 3: Chasing an extremely high hit rate while ignoring validation cost. Approximate indexes must be paired with validation and fallback.
- Pitfall 4: A single full-scale launch. Cache strategies are sensitive to traffic and must be validated through gradual rollout.
8. Summary
Hybrid architectures trade smaller state footprints and faster decoding for a shift from homogeneous to heterogeneous caching. The key to redesigning the hybrid state cache is a unified state abstraction, tiered storage with graded eviction, cross-request prefix state reuse, and scheduling coordination for heterogeneous workloads. Get these four things right and repeated computation and data movement in prefill drop sharply; a several-fold throughput gain is then not luck but the expected result of sound system design.
