Hybrid-Architecture LLMs for Agents: State Cache Redesign Boosts Prefill Throughput Up to 3x

    Hybrid attention architectures combine full attention layers with linear attention layers, but their heterogeneous cache structures make prefix reuse difficult in Agent workloads. This article explains why traditional KV caching breaks down in hybrid models, how FlashStates treats linear states as first-class cacheable objects with checkpointing, and what results it achieves—up to 3.14x prefill throughput improvement and up to 88.4% lower p90 TTFT—plus practical lessons for building multi-tier cache systems for long-context Agents.

    Why Hybrid Architectures Struggle with Caching in Agent Workloads

    Recent years have seen a clear architectural trend in LLM inference: stacking “full attention layers” and “linear attention layers” in alternation to form a hybrid architecture. Full attention layers preserve precise long-range dependency capability, while linear attention layers compress historical information into a fixed-size state, trading that for faster decoding and a smaller cache footprint. This design performs well on general conversational tasks and has been adopted by several leading model teams.

    However, when such models support workloads like coding Agents, the problems surface. Coding Agents typically exhibit:

    • Multi-turn interaction: A single task often involves dozens or even hundreds of tool calls, with each turn generating from the full context of the previous turn;
    • Long context: Code repositories, file contents, and terminal output keep accumulating, with context lengths often reaching hundreds of thousands of tokens;
    • Highly reusable prefixes: Between adjacent requests, the vast majority of the input prefix is identical—only new tool results are appended at the end.

    For pure Transformer models, prefix caching simply means caching each layer’s Key/Value tensors, which have a regular structure that can be split by layer and position. But in a hybrid architecture, different layers need entirely different cached content: full attention layers cache KV tensors that grow linearly with sequence length, while linear attention layers cache a fixed-size recurrent state that can only be computed via a sequential scan from beginning to end. These two cache types differ in how they are generated, how they can be partitioned, and where their reuse boundaries lie. Traditional inference frameworks’ prefix caching mechanisms cannot be directly applied, causing large amounts of reusable computation to be redundantly executed in Agent scenarios—making the prefill phase the latency bottleneck.

    FlashStates’ Core Idea: Treating “State” as a First-Class Citizen

    FlashStates, proposed by a research team, is built on a key insight: in hybrid architectures, the cache management object should not be KV alone, but a unified state system of “KV + linear states.” Its key designs include:

    1. Unified Abstraction and Partitioning of Hybrid States

    FlashStates brings the recurrent states of linear attention layers and the KV of full attention layers under a single cache management framework, with clearly defined state boundaries. Since linear states accumulate sequentially, they naturally lend themselves to “checkpoints”: a snapshot of the intermediate state is saved at specific positions in the sequence, and subsequent requests can continue scanning from the nearest checkpoint instead of recomputing the entire context from scratch.

    2. Coordinating State Checkpoints with Parallel Prefill

    The recurrent nature of linear attention seemingly conflicts with parallel computation: the state must be generated in order. FlashStates solves this with a chunking strategy—the long sequence is split into chunks, computed in parallel within each chunk, and chained across chunks by passing states. Once these intermediate chunk states are cached, any request sharing the same prefix can directly reuse the chunk-level states, compressing prefill computation to only the incremental portion.

    3. Reuse Optimization for Agent Workloads

    Coding Agent request sequences show extremely strong prefix correlation. FlashStates optimizes the cache hit path for this pattern: when a new request arrives, the system first matches the state snapshot corresponding to the longest reusable prefix, then performs prefill only on the incremental tokens. For full attention layers, the incremental portion generates new KV; for linear layers, the recurrent state is updated starting from the cached state. The entire process is fully transparent to upper layers.

    Benchmark Results and Engineering Validation

    Tested on the latest generation of data center GPUs using replayed trajectories from real coding Agent interactions, the results are impressive:

    • Prefill throughput: Up to about 3.14x higher than mainstream open-source inference frameworks;
    • Time to first token (TTFT): p90 latency reduced by up to 88.4%.

    For Agent applications, TTFT improvements translate directly into user experience: the wait after each tool call drops noticeably from seconds, and overall completion time for multi-turn tasks falls accordingly.

    Combining with a CPU Cache Pool

    Going further, the team validated how the approach works with large-scale CPU memory cache pools (similar in capability to distributed KV cache middleware): even with hundreds of GiB of CPU-side caching attached, the gains remain significant. This means state caches can be pushed down to the memory tier and reused across multiple instances and nodes—even if GPU-side caches are evicted, long-prefix states can be quickly restored from CPU memory. The solution also supports distributed storage and cross-node hybrid state reuse, providing a scalable cache hierarchy for large-scale Agent cluster deployments.

    Lessons for Engineering Practice

    1. Optimize hybrid architectures layer by layer: Linear layers cannot be treated like ordinary layers; making their states checkpointable is the key to unlocking prefix reuse.
    2. For Agent scenarios, prioritize prefill over decoding: With multi-turn tool calls, TTFT often affects the experience more than throughput, and cache hit rate is the primary metric.
    3. Build a multi-tier cache system: Hot data in GPU memory, warm data in CPU memory, and cold data in distributed storage—combined with a unified state abstraction—are what make long-context Agent services scalable.

    For teams building hybrid-architecture inference services or Agent platforms, FlashStates’ design approach—treating hybrid states as first-class cache objects and using checkpointing to bridge parallel computation and prefix reuse—offers a highly valuable reference paradigm.