Hybrid Architecture State Caching Optimization: 3x Prefill Throughput Improvement

    This article examines why hybrid architectures—which alternate full attention layers with linear or state layers—struggle under AI agent workloads, where the bottleneck shifts from decoding to prefill. It explains the fundamental differences between KV caches and state layer caches, then presents a design that treats hybrid state as a first-class citizen through unified addressing, tiered storage, adaptive snapshot granularity, and cross-node reuse. Readers will find the engineering rationale behind prefill throughput gains, lower p90 time-to-first-token, sustained benefits with large host memory pools, and practical deployment recommendations.

    1. Background: Why Hybrid Architectures Struggle with Agent Workloads

    mainstream large model architectures have gradually shifted from a single full-attention structure to hybrid architectures that alternate full attention layers with linear or state layers. The core benefit of this design is clear: linear layers do not grow the cache as context length increases, which significantly reduces memory footprint and improves decoding speed.

    However, problems surface when the workload shifts from single-turn question answering to scenarios like coding agents. Agents are characterized by multi-turn interaction, extremely long contexts, frequent reuse of the same system prompt and code repository context, and appending new tool call results every turn. In this case, the performance bottleneck is often not decoding but prefill: every turn requires reading the massive historical prefix back in and computing it again.

    Pure attention models have a simple cache structure, and prefix caching can be reused at token granularity. Hybrid architectures, however, maintain two types of state simultaneously: the KV cache on the attention side and the recurrent state on the linear or state layer side. The two differ completely in granularity, lifecycle, and portability, causing traditional prefix caching strategies to fail outright.

    2. The Essential Differences Between Hybrid States

    To understand the optimization space, first look at the differences between the two types of state:

    • KV cache: corresponds one-to-one with the token sequence, naturally supports reuse truncated to a given prefix length, with fine granularity and the ability to be concatenated.
    • State layer cache: essentially a “compressed summary” that is continuously overwritten and updated as the sequence advances. It has no per-token rollback structure, and once advanced it cannot be easily rolled back to a historical point.

    This leads to a key conclusion: prefix reuse in hybrid architectures cannot align only on token boundaries; it must also align on the state layer’s “snapshot points.” If only the KV is reused while the state is recomputed, the benefit is largely consumed; if the state snapshot granularity is too coarse, cache space is wasted.

    3. Core Idea: Manage “Hybrid State” as a First-Class Citizen

    The central claim of this line of work is to unify the KV and state caches into an abstraction called “hybrid state,” and to restructure the cache’s allocation, eviction, reuse, and migration paths around it. This can be broken down into four layers:

    1. Unified addressing: establish a stable state identifier for each reusable prefix, binding the KV segment to its corresponding state snapshot to avoid recomputation caused by “partial reuse.”
    2. Tiered storage: keep the hottest state in GPU memory, with host memory and remote storage handling warm and cold data, forming a tiered cache pool across GPU memory, memory, and remote storage.
    3. Adaptive snapshot granularity: build periodic snapshots for the state layer by block, balancing storage overhead against rollback precision.
    4. Cross-node reuse: serialize the hybrid state into a distributed cache so that different nodes and different sessions can share the same prefix state.

    A schematic abstract interface can be understood as follows (not a real interface, only expressing design semantics):

    1. class HybridStateCache:
    2. def lookup(self, prefix_id: str) -> StateHandle | None: ...
    3. def append(self, handle: StateHandle, new_tokens: Tensor) -> StateHandle: ...
    4. def snapshot(self, handle: StateHandle, block_size: int) -> BlockId: ...
    5. def promote(self, block_id: BlockId, tier: str) -> None: ...

    4. Where the Engineering Benefits Come From

    In real agent trajectory replays, this design typically delivers three types of benefits:

    • Significant prefill throughput improvement: because the state layer does not need to be recomputed, the repeated computation of long prefixes is eliminated, and the prefill phase shifts from “compute-intensive” to “transfer-intensive,” yielding several-fold throughput improvement.
    • Substantial reduction in p90 time-to-first-token: long-tail latency mainly comes from the cold start of extremely long prefixes; tiered caching means cold data does not need to be recomputed every time.
    • Benefits persist after attaching a large host memory cache: even when GPU memory is insufficient and state must be offloaded to a host memory pool on the order of hundreds of GiB, the benefits remain stable as long as the addressing and snapshot mechanisms are correct.

    5. Deployment Recommendations

    1. First quantify the “prefix reuse rate”; if it is below a threshold, the cache optimization benefit is limited.
    2. Prioritize ensuring consistent binding between state snapshots and KV segments to avoid partial reuse.
    3. Adopt tiered caching with reasonable eviction and prefetch policies.
    4. Enable distributed state reuse in multi-node scenarios to reduce repeated prefill.
    5. Stress test with real multi-turn trajectories, focusing on p90/p99 time-to-first-token rather than averages.

    6. Conclusion

    State caching in hybrid architectures is not a simple extension of the KV cache; it needs to be redesigned as a first-class citizen. Unified addressing of hybrid state, tiered storage, block-level snapshots, and cross-node reuse constitute the key path to unlocking prefill performance under long-context agent workloads.