Redesigning State Caching for Hybrid Architectures: The Critical Path to Faster Prefill

    This article explains why caching is the bottleneck in hybrid LLM architectures that combine full attention and linear layers. It covers the two-part state model (attention KV plus recurrent checkpoints), the capacity, placement, and lifecycle conflicts it creates, and general optimization paths such as unified addressing, multi-level checkpoints, placement alignment, prefill scheduling, and cross-node reuse. Readers will learn the performance boundaries and how to quantify reuse rate, continuation placement, and checkpoint memory before deployment.

    1. Background: Hybrid Architectures Are Mainstream, but Caching Falls Behind

    Over the past year, open-source LLM architecture design has shifted noticeably. Linear attention and state space layers—such as various gated delta rules and selective state update mechanisms—are no longer just research prototypes. They are now widely used in the layer stacks of production models. A typical pattern alternates full attention layers with linear layers: a small number of high-precision attention layers preserve long-range retrieval, while a large number of linear layers reduce decoding to constant-time cost and a smaller cache footprint.

    The benefits are clear. During decoding, per-step computation and memory access no longer grow linearly with context length, and the cache is significantly smaller than in a pure attention design. However, problems surface under coding agent workloads. These workloads are characterized by multi-turn interactions, large amounts of code context appended each turn, frequent branch retries, and repeated reuse of the same prefix. Cache hit rate directly determines end-to-end experience, and cache management in hybrid architectures is far more difficult than in pure attention architectures.

    2. The Nature of Hybrid State: Two Inseparable Components

    A pure attention cache stores entries token by token. A prefix can be truncated at any position and reused, giving fine granularity and flexible reclamation. Linear layers work differently: they summarize the entire prefix with a fixed-size recurrent state. The advantage is that state size is independent of input length. The cost comes in two parts.

    First, a single state block consumes a large amount of memory. It must cover information from the entire prefix, and its size is determined by the state dimension, making it much larger than a single token’s attention cache entry.

    Second, the state cannot be rolled back. This is the most underestimated constraint. Recurrent updates are one-directional: holding the state at token 10000 does not let you derive the state at token 9000.

    This yields a hard constraint: to continue computation from position p, you need two things at the same time—the full prefix’s attention KV and a recurrent checkpoint that lands exactly at p. Missing either one forces a full recompute from the beginning. Schematically, the dependency looks like this:

    1. reusable(p) = KV[0:p] exists AND Checkpoint(p) exists

    This AND relationship means cache management in hybrid architectures cannot rely on the “truncate by token” intuition. Hit rate is no longer determined by prefix length, but by where checkpoints land.

    3. Three Engineering Conflicts That Follow

    1. Capacity conflict. Checkpoints are fixed-size and relatively large. Keeping more of them consumes more GPU memory; keeping fewer lowers the hit probability.
    2. Placement conflict. The actual continuation position of a request is determined by user behavior, while checkpoints can only be decided in advance at write time. The two are naturally misaligned.
    3. Lifecycle conflict. Attention KV can be evicted segment by segment on demand. Once a checkpoint is evicted, all reuse capability before that position is lost. Reclamation must be decided jointly rather than independently.

    4. General Optimization Paths

    4.1 Unified Addressing and Joint Eviction

    Bring KV and checkpoints into the same prefix addressing system, and use the “set of reusable positions” rather than “cached bytes” as the scheduling input. This prevents one-sided eviction from turning the other side into dead occupancy.

    4.2 Multi-Level Checkpoints

    Keep a small number of near-end checkpoints in GPU memory for low-latency hits, and offload far-end checkpoints to host memory or an external cache pool. Combined with an external cache on the order of 512 GiB, this can significantly improve cross-turn hit rate while controlling GPU memory pressure.

    4.3 Placement Alignment

    Use historical traces to measure the distribution of continuation positions, and place checkpoints densely near high-frequency positions instead of splitting them evenly. This trades the same memory for a higher hit rate.

    4.4 Prefill Scheduling Optimization

    Overlap loading, validation, and concatenation of reusable prefixes with computation for new tokens to reduce time to first token. For requests that cannot reuse anything, batch them together to improve compute utilization.

    4.5 Distributed and Cross-Node Reuse

    Store checkpoints and KV separately so different nodes can share the same prefix state. This requires consistency checks and version identifiers to avoid mismatches that skew results.

    5. Performance Boundaries and Deployment Advice

    In real agent trace replay scenarios, the gains from this kind of redesign show up mainly in two metrics: prefill throughput and p90 time to first token. Long-context, high-reuse workloads benefit most; short sessions with low reuse see limited gains. For deployment, quantify three things first: prefix reuse rate, continuation placement distribution, and checkpoint memory budget. Then decide the tiering scheme and eviction thresholds. If you use general capabilities such as cloud container platforms, object storage, or distributed caches to host the external state pool, factor network round-trip latency into the budget so that hit gains are not canceled out by transfer overhead.