Redesigning State Caching for Hybrid Architectures: 3x Higher Prefill Throughput
This article explains why hybrid architectures that combine full attention with linear or state space layers create new caching challenges for long-context AI Agent workloads. It breaks down the semantic differences between key-value caches and recurrent states, then presents four design principles for a unified state cache: composite state units, state-aligned splitting, copy-on-write for forked states, and state-type-aware tiered scheduling. A single-GPU replay of real Agent traces shows up to 3.14x prefill throughput and an 88.4% reduction in p90 time-to-first-token, along with practical guidance on measuring prefix reuse, capacity planning, observability, cache affinity, and correctness checks.
1. Why Hybrid Architectures Are Now the Default for Long-Context Workloads
Over the past year, a clear trend has emerged in mainstream LLM architectures: linear attention or state space layers are interleaved between standard full attention layers, forming a hybrid “full attention + linear layers” structure. The motivation is straightforward. The compute and memory cost of full attention layers grows quadratically with context length, while the inference cost of linear layers grows roughly linearly. Combining the two makes decoding lighter, reduces cache footprint, and significantly lowers the cost per token for long-context scenarios.
However, architectural benefits do not automatically translate into serving performance. When the workload shifts from single-turn question answering to forms such as coding Agents, the bottleneck moves.
Typical coding Agent behavior includes multi-turn tool calls, very long system prompts, repeated reads of the same repository context, and frequent incremental modifications to the same prefix. This leads to two consequences. First, prefixes are highly repetitive, so cache hit rates should be high. Second, every request turn must reprocess a long prefix, making the prefill stage the primary source of latency.
In a pure Transformer serving stack, prefix caching semantics are relatively simple: the cached objects are homogeneous key-value tensors, split into blocks, indexed by hash, and reused via reference counting. Under a hybrid architecture, however, the cache holds two types of state with completely different semantics: the key-value cache on the attention side and the recurrent state on the linear layer side. Their lifecycles, splitting methods, and migration costs are all inconsistent. Reusing the original cache abstraction leads to substantial invalid reuse and repeated computation.
2. Why Hybrid State Caching Is Harder to Manage
2.1 Semantic Differences Between the Two State Types
The key-value cache is addressable: any historical position can be queried directly by subsequent tokens, making it naturally suited to block-based splitting and random reuse. The recurrent state of linear layers is not addressable: it compresses history into a fixed-size state tensor and can only evolve by continuing to advance. You cannot directly read out “the contribution of the k-th token” from an intermediate point.
This creates a key contradiction: block-based reuse assumes each block can be independently skipped or loaded, but once recurrent states are split into blocks, strong dependencies exist between blocks and they cannot be freely concatenated.
2.2 State Fragmentation from Prefix Forking
In Agent workloads, the same prefix often spawns multiple branches: the same code context used for generation, review, and testing subtasks. A pure attention model only needs to copy pointers, at almost zero cost. A hybrid model must maintain an independent recurrent state copy for each branch, with memory and bandwidth costs scaling linearly with the number of branches.
2.3 Cache Granularity Mismatch
If a fixed block size is retained, the attention cache may suffer excessive indexing overhead because blocks are too small, while the recurrent state may fail to align with the attention side because blocks are too large. The result is “half-hit” requests where one side hits and the other misses. A half hit still requires recomputing part of the prefix, which largely erodes the benefit.
2.4 Asymmetric Migration Costs in Tiered Storage
In a tiered hierarchy of GPU memory, host memory, and remote cache, key-value caches are suited to fine-grained, on-demand fetching. Recurrent states are small but tightly coupled, and arbitrarily splitting or migrating them breaks correctness. If scheduling does not distinguish between them, cross-tier transfer overhead may exceed the cost of recomputation.
3. Core Design Principles
The industry is converging on four design principles for serving hybrid architectures. These can serve as an evaluation checklist for in-house development or technology selection.
Principle 1: Replace the key-value block with a state unit as the caching abstraction. The minimum cache unit is no longer a single tensor block but a composite unit containing an attention shard and its corresponding recurrent state segment. Both share the same naming and lifecycle, ensuring consistent hit determination and eliminating half hits.
Principle 2: State-aligned splitting. At each split point, force the recurrent state to advance to a position aligned with the attention block boundary, and record a state snapshot at that point. This ensures any prefix length can find an aligned reuse point. The cost is a sequential advance during splitting, so the number of split points must be traded off against hit rate.
Principle 3: Copy-on-write and sharing for forked states. Use reference counting for read-only shared recurrent states, and copy only when a branch performs a write (i.e., continues decoding). This reduces branching overhead from “growing with the number of branches” to “growing with the actual amount of modification.”
Principle 4: State-type-aware tiered scheduling. Route attention caches through a fine-grained, randomly accessible channel; route recurrent states through a “bulk migration + local snapshot” channel, and keep them preferentially in lower-latency tiers. Illustrative scheduling pseudocode:
def lookup(prefix_tokens):aligned = align_to_block_boundary(prefix_tokens)kv = kv_store.get(aligned) # fine-grained, partial hits allowedstate = state_store.get(aligned) # bulk read, strongly consistentif kv is None or state is None:return None # reject half hits to avoid recomputationreturn kv, statedef fork(state, branch_id):if state.refcount > 1 and state.dirty:state = state.copy_on_write()return state
4. Where the Performance Gains Come From
In an experiment replaying real Agent traces on a single GPU, the redesigned approach achieved up to 3.14x prefill throughput compared with a conventional serving stack, and p90 time-to-first-token dropped by up to 88.4%. This magnitude of improvement does not come from a single optimization but from three combined factors:
- Eliminating repeated prefill: Aligned reuse means long prefixes are almost never recomputed across turns, and prefill is the main compute cost in long-context scenarios.
- Eliminating half-hit waste: Composite state units guarantee “all hit or no compute,” avoiding partial computation for incomplete caches.
- Reducing tail latency jitter: The p90 improvement far exceeds the mean, indicating that gains mainly come from eliminating large recomputations in long-tail requests, which has the greatest impact on Agent interaction experience.
When hundreds of GiB of host memory caching is introduced, the gains persist, indicating the bottleneck has shifted from compute to cache capacity and scheduling efficiency. Further supporting distributed caching and cross-node state reuse allows multi-replica Agent sessions to share prefixes at the cluster level, with hit rates increasing as cluster size grows.
5. Practical Implementation Recommendations
- Measure prefix reuse rate first: Analyze the distribution of repeated prefix lengths and the branching factor in real traces. If reuse rates are low, the return on investment for cache redesign does not hold.
- Configure tiered capacity proportionally: Reserve the GPU memory tier for hot states, use host memory for warm states, and remote cache for cold states. Monitor per-tier hit rates rather than only the overall hit rate.
- Bring caching into the observability system: Collect metrics such as hit length, state migration time, and copy counts through general logging services and monitoring alerts to locate sources of tail latency.
- Elastic scaling with cache affinity: On container platforms, route the same session back to its original node where possible, using session sticky routing when necessary. Cross-node reuse relies on a shared cache layer.
- Prioritize correctness: State snapshots and advancement logic must have strict consistency checks. Any “approximate reuse” will be amplified into semantic errors in long-context, multi-turn scenarios.
The next phase of competition in hybrid architectures is not about model structure itself, but about whether the serving stack can manage “state” as a first-class citizen. Whoever first gets the abstraction, splitting, and scheduling of state caching right will gain a several-fold prefill throughput advantage in multi-turn, long-context workloads.
