Hybrid LLM State Cache Redesign: Improving Prefill Throughput
Hybrid large language models combine full-attention layers with linear-state layers to reduce decoding costs and cache memory requirements. However, their heterogeneous state creates new challenges for long-context, multi-turn agent workloads. This article explains how unified state addressing, chunked prefill, prefix reuse, tiered storage, and cache-aware scheduling can improve prefill throughput, along with key metrics and practical implementation guidance.
1. Why Hybrid LLM Architectures Are Gaining Adoption
Increasingly, large language models are moving beyond pure full-attention architectures toward hybrid designs that interleave full-attention layers with linear-state layers. Here, “linear-state layers” refers broadly to linear attention, state-space models, gated linear recurrent units, and similar components that maintain a fixed-size recurrent state.
Three factors drive this shift:
- Decoding speed: Full-attention layers must access the accumulated KV cache during decoding, so memory traffic grows linearly with context length. Linear-state layers update a fixed-size hidden state at each step, keeping per-step memory access and computation O(1) with respect to context length.
- Cache size: In pure attention models, the KV cache grows linearly with sequence length and can become a major consumer of GPU memory for long contexts. Linear-state layers retain a compressed state rather than per-token key-value pairs, substantially reducing total cache requirements.
- Model quality: Purely linear architectures are generally weaker than full attention at precise long-range retrieval and in-context learning. Retaining some full-attention layers can preserve much of this capability while capturing the efficiency benefits of linear-state layers.
These decoding benefits introduce new challenges for inference infrastructure. Cache management becomes more complex, particularly for agent workloads with very long contexts and repeated interactions. In these settings, prefill throughput can become a significant bottleneck.
2. The Prefill Bottleneck in Agent Workloads
Agent applications often combine long system prompts, repeated conversation history, and many concurrent sessions. Tool definitions, memory, and retrieved content can easily add tens of thousands of tokens to a prompt.
These characteristics place substantial pressure on prefill:
- Time to first token matters. After a user submits a request, the system must process a long input context before generation can begin.
- Prefixes are highly repetitive. Requests to the same agent often share system instructions and tool descriptions. Recomputing these prefixes for every request wastes substantial compute.
- State is heterogeneous. Full-attention layers store KV tensors, while linear-state layers store recurrent states. Their shapes, lifetimes, and reuse patterns differ, so a cache system designed exclusively for KV tensors cannot directly reuse linear-layer states.
As a result, teams deploying hybrid models may find that the model itself is efficient, but the inference framework’s cache subsystem limits performance. Common symptoms include low prefill throughput, poor prefix-cache hit rates, and GPU memory fragmentation.
3. Redesigning the Hybrid State Cache
The central approach is to treat KV tensors and linear-layer states as a unified hybrid state cache, then redesign prefill around that abstraction.
3.1 Unified State Abstraction and Addressing
Traditional inference engines typically manage KV caches in blocks or chunks—for example, 16 tokens per block. A block table maps logical token positions to physical GPU memory.
For hybrid architectures, this abstraction needs to cover two types of state:
- Attention state: Block-based K/V tensors, addressed at the granularity of layer, block, and token.
- Linear state: Fixed-size recurrent state snapshots for each sequence or block boundary, addressed at the granularity of layer and checkpoint.
The key is to use block boundaries as checkpoints, recording both the KV block references and the linear-layer state snapshots at each boundary.
A cached prefix can then be represented as a combination of KV blocks and state snapshots. A unified hash index supports prefix matching and reuse: compute hashes block by block, reuse matching cached state, and process unmatched input incrementally from the nearest checkpoint.
3.2 Chunked Prefill and Incremental State Computation
A common misconception is that linear-layer prefill cannot be parallelized in chunks because its state evolves sequentially.
In practice, many linear recurrences can be expressed as associative scans. This supports a two-level execution pattern: parallel computation within a chunk, followed by sequential state propagation between chunks.
# Illustration: chunked prefill for a recurrent linear-state layerdef chunked_prefill(chunks, init_state):state = init_stateoutputs = []for chunk in chunks: # Sequential across chunksout, state = scan_chunk(chunk, state) # Parallel computation within a chunkoutputs.append(out)return concat(outputs), state
With prefix caching, the prefill workflow becomes:
- Divide the input into blocks and match their prefix hashes against the cache.
- Skip the matched prefix by reusing its KV blocks and loading the corresponding state snapshots.
- Process the unmatched suffix incrementally from the nearest checkpoint.
- Write newly generated KV blocks and state snapshots back to the cache pool.
For agent workloads with heavily repeated system prefixes, the shared portion only needs to be computed once while it remains cached. Subsequent requests may require an order of magnitude less prefill work.
3.3 Tiered Memory and State Eviction
Hybrid caches have asymmetric memory requirements. KV tensors are large but are needed only by the full-attention layers. Linear states are smaller, but retaining snapshots at many checkpoints still consumes memory.
A practical design combines three mechanisms:
- Tiered storage: Keep hot data—the KV blocks and states used by active sessions—in GPU memory. Offload warm, reusable prefixes to host memory or fast local storage. Evict cold data.
- Differentiated eviction: Manage KV blocks using policies such as least recently used (LRU), together with prefix reference counts. For smaller linear-state snapshots, prioritize checkpoints with high branching factors: shared prefix boundaries from which multiple continuations diverge. These checkpoints offer particularly high reuse value.
- Reference counting and sharing: When sessions share a prefix, manage both KV blocks and state snapshots through reference counts. Use copy-on-write to avoid unnecessary duplication.
3.4 Cache-Aware Scheduling Under Continuous Batching
Cache improvements only translate into system-level gains when scheduling takes advantage of them. Under continuous batching, the scheduler should be cache-aware.
Important strategies include:
- Prefix-affinity scheduling: Route requests with shared prefixes to the same inference instance to improve cache hit rates.
- Prefill–decode disaggregation: Separate prefill and decoding into different resource pools. Prefill instances focus on large-chunk computation and produce the required state; decode instances load that state to begin generation. This prevents long prefill operations from blocking decoding.
- Interleaved chunked prefill and decoding: Split long prefill jobs into chunks and alternate them with decode work, balancing time to first token and overall throughput.
4. Evaluation and Implementation Guidance
The impact of a hybrid state cache redesign should be evaluated across several dimensions.
Prefill Throughput
For typical agent workloads—long system prefixes followed by short user inputs—the prefix-cache hit rate is a decisive metric. With hit rates above 80%, several-fold improvements in end-to-end prefill throughput can be feasible. This is consistent with the optimization direction described in public industry reports, rather than a guaranteed result for every deployment.
GPU Memory Utilization
Hybrid architectures already reduce KV cache requirements. Adding tiered offloading can further increase the number of concurrent sessions supported by a single GPU.
Tail Latency
Chunked prefill and prefix-cache hits can improve time to first token, with P99 latency often benefiting more than the average.
Practical Implementation Recommendations
- Measure before optimizing. Establish observability for prefix-cache hit rate, block reuse rate, state offload latency, and related metrics. General-purpose monitoring and alerting tools can support the required dashboards.
- Ensure hash consistency. Prefix hashes must account for tokenized input and model configuration to prevent incorrect reuse caused by mismatched boundaries or incompatible states. These errors can be difficult to detect, so include sampled validation.
- Adopt the design incrementally. Start with block-level KV prefix caching, then add linear-state snapshots. Introduce tiered offloading and cache-aware scheduling after those foundations are working.
- Plan for elastic capacity. These inference services have substantial and variable compute and GPU memory requirements. Container-based scaling, combined with object storage for cold state data where appropriate, can help balance cost and performance.
5. Conclusion
Hybrid LLM architectures combine full attention and linear-state layers to balance model quality with inference efficiency. They also expand the cache-management problem from storing KV tensors to managing heterogeneous state.
A unified state abstraction, chunked prefill, prefix reuse, tiered memory, and cache-aware scheduling provide a systematic path to improving prefill throughput. Several-fold gains are possible when workload characteristics and cache reuse support them, but the outcome must be validated through measurement.
For teams building agent infrastructure, the state cache is a high-value area for optimization: it determines how effectively the inference system can reuse long contexts and turn the model’s architectural efficiency into serving performance.
