Optimizing State Caching in Hybrid Architectures: Up to 3x Higher Prefill Throughput

    This article examines the caching challenges introduced by hybrid LLM architectures that combine full attention layers with linear state layers. It breaks down three structural issues—inconsistent state semantics, conflicting eviction policies, and cross-layer transfer overhead—and explains a reconstruction-based design built on unified addressing, state snapshotting, tiered placement, and coordinated transfer. A public technical validation reports up to 3x higher prefill throughput and nearly 90% lower p90 time-to-first-token, along with practical guidance for auditing cache hit quality and building a GPU–memory–storage tiered caching system.

    1. Background: New Caching Challenges from Hybrid Architectures

    Mainstream large model architectures are shifting from “pure attention” to a hybrid form of full attention layers plus linear state layers. These models require less computation during decoding and occupy less GPU memory, which is why they are widely adopted for long-context scenarios. However, as workloads move from single-turn question answering to multi-turn, ultra-long-context tasks with frequently reused prefixes—such as coding agents—cache management complexity rises sharply.

    The core conflict is this: a pure attention model has only one cache form, a key-value cache that grows per token. A hybrid architecture holds two kinds of state at once—an attention cache that grows linearly with the context, and a recurrent state maintained by the linear layers that has a fixed size but must be recomputed whenever the prefix changes. The two state types have completely different lifecycles, eviction policies, and transfer granularities. If the traditional prefix caching mechanism is reused as-is, you get cache hits that do not actually skip computation.

    2. Three Structural Difficulties of Hybrid State Caching

    1. Inconsistent state semantics. The attention cache is “concatenable”: a cache for any prefix can be extended directly. The linear state is “compressed”: it encodes the entire prefix into a fixed-length representation, so once a prefix forks, it cannot be reused simply and must fall back to recomputation from the fork point.

    2. Conflicting eviction and promotion policies. The attention cache can be evicted block by block, while the linear state is a single, global point with no fine-grained reclamation space, which easily causes GPU memory fragmentation and invalidates hit detection.

    3. High cross-layer and cross-node transfer overhead. Hybrid state requires transferring both large attention caches and fixed-length state snapshots. An imbalance between the two makes bandwidth the new bottleneck, especially once a large-capacity memory cache is introduced.

    3. Optimization Approach: A Reconstruction-Style Design for Hybrid State

    A representative class of solutions in the industry—collectively describable as hybrid state cache reconstruction schemes—centers on upgrading “cache” from passive data storage into an execution element that is decidable, reorganizable, and migratable. The key designs reduce to four points:

    • Unified addressing: establish one prefix identifier scheme for both attention blocks and linear state, so hit detection completes in a single pass and “partial hits” that trigger fallback recomputation are avoided.
    • State snapshotting: snapshot the linear state at fork points, allowing recovery from the nearest common prefix instead of starting from zero.
    • Tiered placement: keep hot data in GPU memory, move warm data down to a large-capacity memory cache, and push cold data to distributed storage, migrating dynamically by access frequency.
    • Coordinated transfer: package attention blocks and state snapshots together for transfer, reducing round trips and improving cross-node reuse efficiency.

    The hit detection logic can be understood schematically as follows:

    1. def lookup(prefix_id):
    2. attn_blocks = attn_cache.get_blocks(prefix_id) # concatenable block cache
    3. state_snap = state_cache.get_snapshot(prefix_id) # fixed-length state snapshot
    4. if attn_blocks and state_snap:
    5. return Reuse(attn_blocks, state_snap) # genuinely skip prefix computation
    6. return RecomputeFrom(common_ancestor(prefix_id)) # fall back to the nearest common prefix

    4. Measured Gains and Engineering Implications

    In a public technical validation, replaying real operation traces from an AI coding tool on a single high-end accelerator, the reconstruction-style hybrid state cache delivered up to roughly 3x higher prefill throughput than a general-purpose inference framework, and p90 time-to-first-token dropped by nearly 90% at best. The gains held after attaching a memory cache on the order of hundreds of gigabytes, and the setup already supports distributed storage and cross-node state reuse.

    The implications for engineering teams are clear. First, adopting a hybrid architecture cannot be a model swap alone; the cache layer must be reconstructed in step. Second, cache hit rate is no longer the only metric—whether a hit can genuinely skip computation is what matters. Third, tiered caching and cross-node reuse should be built into capacity planning as default capabilities.

    5. Implementation Recommendations

    To practice this in your own inference service, a three-step path is suggested: first, audit the hit quality of the existing prefix cache and separate “true hits” from “false hits”; then introduce state snapshotting and unified addressing so fork scenarios remain recoverable; finally, scale the memory cache and distributed storage as needed to form a three-tier GPU–memory–storage system. Combined with the general-purpose container platform, object storage, and monitoring and alerting capabilities available on Baidu AI Cloud, this caching system can be deployed and observed relatively smoothly.