Hybrid Architecture Agent Inference Optimization: State Cache Redesign Delivers 3× Higher Prefill Throughput
Hybrid models combine full attention with linear attention or state space model layers to reduce decoding costs, but their heterogeneous cache structures make prefix reuse difficult in multi-turn Agent workloads. A redesigned state caching system serializes and restores prefix states, combines GPU and CPU cache tiers, and schedules KV and state blocks at fine granularity. In reported data center GPU tests, the approach increased prefill throughput by more than 3× and reduced p90 time to first token (TTFT) by nearly 90%.
1. Background: Hybrid Architectures Are Becoming Standard in Open-Source LLMs
In recent years, architectures that combine linear attention and state space model (SSM) components have become increasingly common in open-source large language models. These models typically alternate between full attention layers and linear attention or SSM layers:
- Full attention layers provide precise long-range retrieval, helping the model reliably recall critical information.
- Linear or SSM layers use a fixed-size state instead of a KV cache that grows linearly with sequence length. This enables faster decoding and lower GPU memory consumption.
The advantages of this design are particularly clear during decoding. Because the KV cache is significantly smaller, memory pressure is reduced and the cost of long-context inference decreases. As a result, a growing number of next-generation models are adopting hybrid architectures.
2. The Challenge: Cache Management Is More Complex Under Agent Workloads
The limitations become apparent in workloads such as coding Agents. Typical programming Agent interactions have three characteristics:
- Multi-turn interaction: Each tool call or file edit can trigger a new inference request.
- Highly overlapping prefixes: A later request often contains the previous system prompt, code repository, and conversation history, plus additional context.
- High sensitivity to first-token latency: User experience is directly affected by TTFT, or time to first token.
For a pure Transformer, prefix caching is relatively straightforward. If the prefix token sequence is identical, the corresponding KV cache blocks can be reused directly. Hybrid architectures introduce two additional challenges:
- States cannot be independently partitioned: A linear layer’s state is a compressed representation of the entire sequence. It has dependencies across chunk boundaries and cannot be cached and reused in independent blocks like a KV cache.
- The cache is heterogeneous: Within the same model, some layers store KV data while others store states. These two cache types differ in granularity, lifetime, and invalidation conditions, making them difficult to support with existing prefix-caching mechanisms.
As a result, during multi-turn Agent replays, a substantial amount of prefill computation that could theoretically be reused is recomputed because the cache management layer lacks the necessary support. TTFT can therefore become worse rather than better.
3. The Approach: A Redesigned Hybrid State Cache
To address these issues, research teams have proposed a system-level redesign of cache management. The main ideas can be summarized in four areas.
1. Serialize and Reuse Prefix States
The compressed state produced by each linear layer at a prefix boundary is explicitly exported, serialized, and added to a unified cache index. When a new request matches an existing cached prefix, the system can restore the corresponding state and skip the repeated prefill computation.
The conceptual flow is:
# Pseudocode: selectively prefill after prefix matchingcached_len, state = state_cache.match_prefix(token_ids)if cached_len > 0:model.load_states(state) # Restore linear-layer statesmodel.recompute_kv(from=cached_len) # Compute only incremental KV dataelse:model.full_prefill(token_ids)
2. Use a Two-Tier Cache Architecture
A tiered design can combine GPU memory with CPU memory and, where necessary, distributed object storage. Frequently accessed prefix states remain in GPU memory for low-latency reuse, while colder prefixes are moved to a larger CPU-side cache pool and transferred back on demand over high-bandwidth links.
With several hundred GiB of CPU-side cache capacity, long-context Agent workloads can still achieve substantial benefits. The design also supports cross-node state reuse, making it suitable for multi-machine inference clusters.
3. Combine Chunked Prefill with Fine-Grained Scheduling
Long prefixes are divided into fixed-length chunks, with each chunk serving as the smallest unit for reuse and scheduling. The scheduler can manage KV blocks and state blocks together.
When multiple Agent sessions are replayed concurrently, the GPU can pipeline prefill work across requests more effectively. On data center GPUs, reported prefill throughput reached more than 3× that of traditional inference frameworks, while p90 TTFT decreased by nearly 90% in the best cases.
4. Define Consistency and Invalidation Rules
A state cache must correctly handle cases where a prefix appears to match but the cached state also depends on information outside that prefix. The proposed approach records dependency fingerprints for each cache entry, such as sampling parameters, random seeds, and sliding-window offsets for extremely long contexts.
When these dependencies do not match, the system conservatively falls back to full recomputation. This preserves strict consistency with the uncached execution path.
4. Engineering Recommendations
Teams deploying hybrid architecture models in self-managed inference services can consider the following practices:
- Measure cache hit rates: First calculate the average prefix overlap across Agent sessions. State caching becomes particularly beneficial when overlap exceeds 50%.
- Plan cache capacity: The size of a linear-layer state depends on the number of model layers and the state dimension. It is generally much smaller than a KV cache for the same sequence length, so several hundred GiB of CPU memory can cover thousands of long-context sessions.
- Monitor TTFT percentiles: Use p90 and p99 rather than the average as primary optimization targets. Tail latency is more representative of user experience in Agent workloads.
- Preserve numerical consistency: Every cache reuse path should be validated offline against full recomputation to ensure identical outputs and prevent subtle regressions in generation quality.
5. Conclusion
Hybrid architectures address the cost of long-context decoding, but their full potential in real-world multi-turn workloads such as coding Agents can only be realized when prefill cache management is redesigned as well.
The combination of prefix state reuse, tiered caching, and fine-grained scheduling provides a practical engineering pattern for next-generation inference engines. As hybrid architectures become more widespread, state cache management is likely to evolve from an optional optimization into a fundamental inference-framework capability.
