FlashStates: Why Your Agent Recomputes 66K Tokens While the KV Cache Still Holds Them — aniketkarneai.com | aniketkarneai.com
Wednesday, November 11, 2026 Field notes on autonomous systems ● Amsterdam, NL
daily

FlashStates: Why Your Agent Recomputes 66K Tokens While the KV Cache Still Holds Them

Together AI and UIUC shipped FlashStates, a vLLM fork that checkpoints recurrent hybrid state at any token position instead of KV block boundaries. The interesting part is not the 3x throughput number but the miss taxonomy behind it: placement, dependency, and capacity misses, and the fact that SGLang fixed one and made another worse.

The number that made me stop reading was not a throughput number. It was this: at 32 concurrent sessions, SGLang recomputes a median of 66K to 68K prompt tokens per affected request — nearly the whole prefix — while that prefix’s KV cache is still sitting in GPU memory. Nothing ran out of memory. The bytes were resident. The engine just could not use them.

That is the kind of bug I would not believe if someone described it to me, and it turns out to be structural rather than a mistake in anybody’s code. The project is FlashStates, from Chenxi Li and Weili Xu at Together AI and UIUC with Chenfeng Xu at UT Austin, published as a release paper on November 9, 2026. It is a fork of vLLM v0.33.0 plus a fork of Mooncake 0.3.13.post1, Apache-2.0, and at the time I looked it had 144 stars, 6 forks, and two commits in its history.

The workload that breaks prefix caching

Start with why hybrid models are different, because everything downstream depends on it.

A transformer layer caches key-value pairs per token and can resume a prefix from any point where the KV is present. A hybrid model mixes those attention layers with linear-attention or state-space layers. For the latter, the layer does not have a per-token cache. It has one recurrent state, and it is overwritten every step. St = F(St-1, xt) — that is the whole recurrence, and the state at position 10,000 is only reachable by replaying tokens 1 through 10,000.

So to reuse a cached prefix on a hybrid model you need two things, not one. You need the attention KV for that prefix, and you need the recurrent checkpoint that exactly matches the end of that prefix. Have one without the other and you recompute.

Coding agents resend a growing context on every turn. The next prompt is the previous prompt plus the previous output plus the new user message. That makes every turn a prefix extension, which makes it exactly the workload where the two-cache problem shows up. FlashStates frames the whole thing this way: a cached prefix on a hybrid model is reusable only with its hybrid state.

Three ways to miss, and they are not the same bug

Here is where I think the paper earns its keep. Rather than reporting “cache hit rate went down,” it decomposes every computed prompt token into one root cause, by comparing each request’s cached prefix against its ideal resume position.

New content past the ideal resume position must be computed under any caching scheme. That is not a miss, that is work. Everything else falls into three buckets.

A placement miss is recomputed because the engine never saved a recurrent checkpoint at the right place. A dependency miss is recomputed because a checkpoint was evicted while the attention KV it depends on stayed cached. A capacity miss is recomputed because both the checkpoint and part of its KV were evicted under memory pressure.

The distinction matters because the fixes are incompatible with each other, and each engine has a different one.

vLLM has placement misses. For GLM-5.3-Flash it saves a recurrent checkpoint only at 4,352-token KV-cache block boundaries inside the prompt — Qwen3.8-Flash-Next uses 3,136 and Nemotron 3 Super uses 8,320 — and never during decoding or at the end of a request. So a follow-up turn can resume only from the last block boundary of the previous prompt, and everything after it gets recomputed. At low concurrency, 8 to 16 sessions, vLLM evicts almost nothing, so placement is its only avoidable miss, accounting for up to 43% of its uncached prompt tokens.

SGLang has dependency misses. It aligns checkpoints to a 256-token grid, so placement misses drop to about 0.2K tokens per request and its cache hit rate beats vLLM’s by up to 3.1% at low concurrency. Then it gets worse under load. It keeps about 430 recurrent checkpoints in a separate pool beside 5.9M tokens of KV, and evicts each pool in its own LRU order. At 32 sessions its finer grid saves 4.2× as many checkpoints per request as vLLM, so the state pool fills and starts evicting checkpoints whose KV is still cached. Those dependency misses cause 33 to 43% of SGLang’s uncached prompt tokens at 24 to 32 sessions.

Capacity misses stay below 0.4K tokens per request at those loads. That control is the load-bearing part. If capacity were the problem, adding memory would help. It is not the problem, which means the fix has to be in the eviction policy rather than in the memory budget.

There is a footnote in the paper that I liked: they observe no misses in the reverse direction, where a recurrent checkpoint survives but its KV does not. So the dependency only ever points one way.

vLLM falls into the same trap with a different shape. Its dependency misses grow from 40 sessions and reach 8.5K tokens per request at 64 sessions, where its hit rate drops to 62.4%. A request’s prompt-end checkpoint returns to the evictable queue at its first decoding step, while the request is still running, and is later evicted by recency. From 40 sessions on, both engines are in what the paper calls hybrid state thrashing.

The fix, and the part I found most interesting

FlashStates decouples three decisions that vLLM and SGLang bundle together: where a checkpoint goes, what stays cached, and what leaves under pressure.

The first is Arbitrary State Checkpointing. The kernel contract is:

PrefillExport(X, S0, c) -> (O, Sfinal, Rc)

Rc is the canonical recurrent checkpoint the same backend would have produced if the call were truncated at c. O and Sfinal are identical to the no-export call. So you get a checkpoint at an arbitrary interior position, and the answer is bit-identical to the answer you would have gotten by truncating the prefill there. No new matmul, no approximation, no numerical drift.

That is implemented in both the KDA and GDN kernels, and the two implementations are not the same underneath. KDA’s export grid aligns with its compute tiles, so the kernel can serialize the live state it already has at a tile boundary. GDN uses larger tiles where interior states are not directly materialized, so the kernel uses operands already computed for that tile to do one bounded prefix update, gets Rc, and then continues the original full-tile computation. The difference in internals is exactly the kind of thing that usually gets hand-waved in a paper, and here it is stated plainly.

The second part is the eviction policy, and this is where I would point an agent-serving engineer. FlashStates uses GreedyDual-Size, adapted from Cao and Irani’s 1997 storage paper, to price hybrid states by the prefill they save per block of cache they occupy. One priority function for both admission and eviction, so the thing that gets admitted is the thing that survives. No per-workload tuning knob, which matters because nobody tunes per-workload knobs in production.

The relevant related work is instructive by contrast. HiState assumes a prefix hit is equally likely to end at any position inside a segment, and adds recency to expected recomputation with a time scale τ. FlashStates instead derives each request’s ideal resume position from the prefixes actually processed before it — which, in an agent trajectory, is usually the exact end of the previous request — and uses the GreedyDual-Size watermark as its recency term, so recency and restore cost share units and need no weighting parameter.

Everything is off by default. The flags are --mamba-frontier-checkpoint, --mamba-prefill-export, --prefix-cache-eviction gds, --prefix-cache-leaf-last, --prefix-cache-leaf-idle-seconds 60. The prefill cost coefficients are fitted once per model and passed as --prefill-cost-coefficients 1.862e-5 3.33e-6 for GLM-5.3-Flash. The cost model is C(a,b) = d(b-a) + e(b²-a²)/(2·10⁵) seconds, with the second term growing with attention context. Fitted values are (1.862, 0.333)×10⁻⁵ for GLM-5.3-Flash, (2.230, 0.434)×10⁻⁵ for Qwen3.8-Flash-Next, and (1.322, 0.419)×10⁻⁵ for Nemotron 3 Super.

The numbers, read off the figures JSON

The repo publishes the raw readings behind the paper’s figures in docs/figures/gpu-only.json, so I did not have to take the screenshots on faith. Two B200 GPUs per server, closed-loop replay of 393 public coding-agent sessions from SemiAnalysis’s traces, with model revisions pinned.

GLM-5.3-Flash NVFP4 at 48 sessions:

MetricvLLMFlashStatesDelta
Output tok/min/GPU10,27731,0453.02×
Prompt tok/min/GPU1,484,0004,658,0003.14×
Uncached prompt tokens p5024,6711,025−96%
TTFT p9020.405 s2.357 s−88%

Nemotron 3 Super at 48 sessions: uncached p50 goes 57,313 to 1,582 and p90 TTFT goes 23.404 s to 5.361 s. Qwen3.8-Flash-Next FP8 at 48 sessions: output goes 24,635 to 37,950 and p90 TTFT goes 7.483 s to 1.573 s.

The pattern worth noting is that the win is not uniform across session counts. At 24 sessions on GLM-5.3-Flash, official vLLM does 26,042 output tok/min/GPU and FlashStates does 25,995 — slightly worse. At 32 sessions it is 28,236 against 29,009. The gains only open up at 40 and 48 sessions, where vLLM’s uncached p50 goes from 4,347 to 24,671 while FlashStates stays flat at 1,025. Whatever FlashStates fixes, it only becomes a problem when there are enough concurrent agents for the eviction policy to matter.

The Mooncake sweep in docs/figures/mooncake-sweep.json shows the same shape with a host-side store, and it is where the story gets sharper. At 80 sessions on GLM-5.3-Flash with 512 GiB of host cache per engine, output throughput per GPU is 86,422 for FlashStates, 61,111 for vLLM, and 63,444 for SGLang. But p90 TTFT at that point is 7.18 s for FlashStates, 21.88 s for vLLM, and 22.97 s for SGLang. The engines that keep the GPU busy are the ones that make the agent wait. The demo in the README makes the same point visually — 48 agent sessions replayed, each circle one agent, green slices cached and red recomputed — and reports 20 agents finished at 61.7K output tok/min with an 87% cache hit rate for FlashStates, against 7 agents at 22.0K and 30% for vLLM, and 8 agents at 15.4K and 6% for SGLang.

On Kimi-K3.1-Pro the setup is different enough to be worth a note: one engine on two GB300 trays, eight GPUs, decode context parallelism 8, DSpark speculative decoding, 640 GiB Mooncake store. FlashStates reaches 8,683 output tok/min/GPU against vLLM’s 6,377, with p90 TTFT of 2.0 s against 9.1 s.

What I could not check

Several things, and I would rather list them than round them off.

The repo is two commits old with 144 stars. I did not run any of these benchmarks; I am reading the published readings and checking them against the paper’s own text and the figures JSON. The numbers in the tables above are the authors’ measurements, not mine.

The arXiv identifier is 2611.flashstate, which does not resolve on arxiv.org — I got a 404. The alphaXiv page exists and carries the same authors, but under a slightly different title, “FlashState: Unlocking Flexible Hybrid State Management for Agentic LLM Serving” rather than the repo’s “FlashStates … for Agentic LLM Inference”. The authoritative artifact is the release PDF versioned in the repository, and I linked that.

The evaluation gap between FlashStates and HiState is also larger than it looks. HiState evaluates Qwen3.5-9B on one H100 with at most 24 live sessions and reports p95 and p99 TTFT. FlashStates serves three hybrid models with contexts up to 1M tokens on two B200s at 24 to 48 sessions, up to 80 with a CPU store, and reports throughput alongside TTFT. Different models, different hardware, different session counts, different percentiles. A 12B model on an H100 at 24 sessions is not a regime where 1M-token context and hybrid state thrashing at 48 sessions even apply.

And one thing I want to flag for anyone planning to reproduce this. The dependency-miss mechanism I described is not a bug in vLLM’s eviction code that a patch fixes. It is what happens when you cache two things with different lifetimes — KV blocks and recurrent checkpoints — and evict them with one LRU over one of them. Any stack that stores recurrent state for a linear-attention model has this shape. The two caches need to be admitted and evicted together, and the priority has to be priced in the units that matter, which for a hybrid model is prefill seconds saved, not bytes.

I have not worked out whether the dependency-miss numbers hold on a stack where the agent is doing something other than replaying recorded traces. The whole evaluation is a replay harness with fixed sessions, warm-up phases, and seeded start points. Real agent traffic is messier. What I do not know is whether a real agent’s context growth pattern produces the same dependency-miss rate, or whether the 66K-token recompute is partly an artifact of the replay being turn-aligned in a way that real traffic is not.

Where to dig

Aniket Karne
DevOps & AI Engineer · Amsterdam
Back to all posts
Reader correspondence

Comments

Powered by GitHub Discussions via Giscus. Sign in with GitHub to leave a comment.