Hybrid Architecture State Cache Optimization: Tripling Prefill Throughput
This article examines why cache management becomes a bottleneck in hybrid LLM architectures that combine full attention layers with linear or state layers. It explains why prefill is especially sensitive to cache behavior in multi-turn, long-context workloads such as coding agents, and outlines core design ideas including state tiering, unified addressing, differentiated eviction, and prefill coordination. It also covers engineering practices for tiered caching and distributed reuse, along with the reported throughput and latency gains and the workload conditions under which those gains hold.
1. Background: Cache Management Becomes the New Bottleneck
Over the past year, mainstream LLM architectures have visibly diverged. Beyond dense models built purely from stacked attention, a growing number of models adopt a hybrid structure of full attention layers plus linear or state layers. The motivation is straightforward: linear layers offer constant state overhead on long sequences, significantly shrinking cache size and speeding up decoding, while retaining a few full attention layers preserves precise retrieval and long-range dependency modeling.
Problems surface when the workload shifts from single-turn question answering to multi-turn, ultra-long-context scenarios with frequent prefix rewrites, such as coding agents. In hybrid models, the prefix cache is no longer a homogeneous key-value tensor. It is composed of states with different shapes, lifecycles, and eviction costs. Cache systems designed for pure attention models, if applied directly, suffer from lower hit rates, transfer amplification, and scheduling jitter. Prefill is where these issues are most visible.
2. Why Prefill Becomes the Bottleneck
Prefill must process the entire prompt at once. It is compute-intensive and extremely sensitive to cache hits. In a coding agent, a single task often includes a system prompt, repository context, multiple rounds of tool call results, code snippets, and prior reasoning. Prefixes can easily reach tens of thousands to hundreds of thousands of tokens, and adjacent requests share large amounts of identical prefix.
When cache granularity and state shape do not match, three typical losses appear: recomputing the same prefix, repeatedly moving large state blocks between storage tiers, and requests competing for cache space so that the hit rate drops sharply. Together, these push up tail latency for time to first token.
3. Core Design Ideas for Hybrid State Caching
The key is to break “cache” down from a single object into state families that can be managed by category, with independent indexing, migration, and reuse strategies for each.
- State tiering: distinguish attention key-value states from recurrent or convolutional states. The former can be chunked and shared; the latter is tightly bound to sequence position and must be reused cautiously.
- Unified addressing: assign consistent block-level identifiers and reference counts across state types, giving cross-request and cross-node reuse a common semantic basis.
- Differentiated eviction: set retention priority by reconstruction cost, keeping expensive-to-rebuild states on faster media.
- Prefill coordination: when assembling batches, the scheduler prioritizes merging shared prefixes to reduce redundant computation and transfer.
Illustrative pseudocode:
def schedule_prefill(requests, cache):groups = group_by_shared_prefix(requests) # group by shared prefixfor g in groups:hit = cache.lookup_prefix(g.prefix_id) # unified block-level addressingreuse_state(g, hit) # reuse attention and state cachesbatch = pack(g.miss_tokens) # compute only the missed portionengine.prefill(batch)
4. Engineering Practice: Tiered Caching and Distributed Reuse
Adding large-capacity memory or a remote cache beyond single-machine GPU memory can substantially raise hit rates for long prefixes, but consistency and bandwidth must be addressed. Key practices: keep block granularity from being too large to avoid write amplification; set more conservative migration thresholds for state caches; use content addressing as primary and position information as secondary for cross-node reuse; and continuously monitor hit rate, transfer volume, and tail latency with alerting.
On general-purpose cloud environments, this capability is typically delivered by running inference services on a container platform, persisting state in object storage or a distributed cache, and relying on logging and monitoring services for observability. No proprietary interfaces are required.
5. Benefits and Boundaries
In replay tests on real coding agent traces, this design raised prefill throughput to roughly three times that of the prior approach, and reduced p90 time to first token by nearly 90% at best. Gains held after attaching memory caches on the order of hundreds of gigabytes. The boundaries are equally clear: if the workload has low prefix sharing, short contexts, and few interaction rounds, the gains shrink noticeably. Evaluations of such optimizations should therefore be based on the sharing structure of real traces, not on model architecture labels alone.
