In this series / On this page· 11 of 11

Hybrid Models and the Memory Split: Why Fixed Pools Strand Your KV Cache

Why a hybrid model's full-attention cache, window cache and recurrent state compete for one GPU's memory, what fixed pools waste, and how vLLM and SGLang share it instead.

12 min readUpdated
A blueprint drawing of one long memory slab: large recurrent-state blocks fill it from one end, small KV-cache pages from the other, and a gold sliding-window band floats in the free space between them.
One arena for every kind of state: recurrent state grows from one end, full-attention KV from the other, and the free middle belongs to whoever needs it.

A hybrid model keeps three kinds of state per request, and the serving engine has to divide the GPU's memory between them before the first request arrives. SGLang's default split gives recurrent state 47% of a Qwen3.5-4B server's KV memory whatever the traffic is, and about 40% of that memory ends up idle both for long requests and for short ones, while new requests wait. SGLang's experimental --enable-unified-memory drops the split; vLLM avoided it differently from the start.

Three kinds of state, three growth laws

A hybrid model mixes layer types (the mechanisms are in When Most Layers Stop Caching), and each type keeps a different kind of memory for a running request:

State What a request keeps What makes it grow Qwen3.5-4B gpt-oss-20b
Full-attention KV every past token the request's length 8 layers: 32 KiB per token 12 layers: 24 KiB per token
Sliding-window KV the last W tokens length, until W none 12 layers, W = 128: 24 KiB per token, 3 MiB at most
Recurrent state one fixed-size state one per running request 24 linear layers: 49.1 MiB per request none

Sizes are BF16 KV from each model's config.json (the state is FP32, as the model's config asks). Two numbers in the table do most of the work. A Qwen3.5-4B request costs 49.1 MiB of state the moment it starts, the same as 1,572 tokens of its full-attention cache; and a gpt-oss-20b request never needs more than 3 MiB of window cache, however long it runs.

So the right division of memory depends on the traffic. Long requests want full-attention KV and almost no state or window memory. Many short requests want state slots or window memory, and little full-attention KV each. The same request even changes its mix as it runs: its state slot is taken at once, while its full-attention cache keeps growing.

The fixed split: one guess at startup

By default SGLang gives each kind of state its own pool and sizes the pools once, at startup, with two ratios:

  • --mamba-full-memory-ratio (default 0.9): recurrent state gets ratio / (1 + ratio) of the memory left after the weights, 47.4% at the default (kv_cache_configurator.py).
  • --swa-full-tokens-ratio (default 0.8): the window pool holds 0.8 times as many tokens as the full-attention pool (pool_configurator.py). For gpt-oss-20b, whose window layers store as much per token as its full layers, that is 44.4% of the memory.

The defaults are in schedule.py (0.8) and at L225 (0.9) as of v0.5.23. Once set, a pool's bytes belong to it: when the full-attention pool is full, a new request waits, even if the state pool is half empty. A third rule caps concurrency: with the prefix cache on (the default), SGLang prices each running request at 3 state slots, so the number of running requests is capped at a third of the slots (kv_cache_configurator.py, ratio at L227). SGLang says so in its startup log; on our own Qwen3.8-27B server, When Most Layers Stop Caching shows it capping a long-context server at 8 running requests.

Here is what that costs on 40 GiB of KV memory, for two workloads per model. The script is memory_split.py: it applies SGLang's rules, then counts how many requests fit if every request takes what it uses from one budget, keeping the same 3 state slots per request.

Model, workload Fixed pools: requests that fit What runs out first Memory idle One budget: requests that fit
Qwen3.5-4B, 16K in + 4K out 33 full-attention KV (394 state slots, enough for 131 requests) 14.6 GiB (37%) 52 (1.58x)
Qwen3.5-4B, 1K in + 256 out 131 state slots: 394 / 3 (KV for 538) 16.0 GiB (40%) 218 (1.66x)
gpt-oss-20b, 512 in + 1,536 out 474 full-attention KV (window pool for 4,045) 15.7 GiB (39%) 780 (1.65x)
gpt-oss-20b, 32K in + 1K out 28 full-attention KV 18.2 GiB (46%) 51 (1.82x)

Fixed pools for Qwen3.5-4B: with long requests the state pool sits mostly empty while the KV pool is full; with short requests the state pool is full while KV memory is left overFixed pools for Qwen3.5-4B: with long requests the state pool sits mostly empty while the KV pool is full; with short requests the state pool is full while KV memory is left over

These are upper bounds: the script ignores page rounding and the scheduler's headroom for tokens still to come. The ratios between the columns are the point, and the two Qwen3.5-4B rows show the split failing in both directions. Long requests run out of full-attention KV while 295 state slots sit idle. Short requests run out of state slots, three per request, while KV for 400 more requests sits idle. Either way about 40% of the memory does nothing, and one budget fits about 1.6x more requests. gpt-oss-20b only fails one way: its window pool is far larger than 128-token windows ever need.

You can tune the ratios to your traffic. The trouble is that you tune them for the traffic you measured: when the mix of request lengths shifts during the day, the memory is again stranded behind yesterday's guess, and the LMSYS measurements below show a ratio set too low costing more than the default.

Two ways to share one budget

The fix is to let every kind of state draw from the same bytes. The difficulty is that the units differ wildly in size. For one layer of Qwen3.5-4B, a recurrent state is 2 MiB and 64 tokens of full-attention KV are 256 KiB; for a whole request, the state is 49.1 MiB and a 64-token page of all 8 full-attention layers is 2 MiB. vLLM and SGLang solve that in opposite ways.

vLLM makes every page the same size, so one layer's state fits one page and a KV page holds about 550 tokens; SGLang keeps each unit's own size and packs both into one arena, from opposite endsvLLM makes every page the same size, so one layer's state fits one page and a KV page holds about 550 tokens; SGLang keeps each unit's own size and packs both into one arena, from opposite ends

vLLM: make the units equal. vLLM v0.33.0 runs every layer type off one block pool (kv_cache_coordinator.py), and a sliding-window layer gives back its blocks as they fall out of the window. For a model with recurrent state, it raises the attention block size until one block of KV takes at least as many bytes as one state, then pads the state to match (interface.py). For Qwen3.5-4B, one layer's state is 2,146,304 bytes and one token of one layer's KV is 4,096, so a block needs at least 524 tokens: 528 once rounded to 16-token kernel blocks, and 576 when prefix caching (on by default) also rounds blocks to the 64-token grid of the linear-attention checkpoints. A plain model uses 16. Any free block can then hold either kind of state, so nothing is stranded between pools. The price is coarse pages: a request wastes on average half a block of KV per layer, and prefix caching shares prompts only in whole blocks of several hundred tokens (Paged Attention explains why the block is the sharing unit).

SGLang: keep the units, share the bytes. With --enable-unified-memory, each kind of state keeps its own unit: KV pages of whatever --page-size you choose, state in single slots. All of them live in one region of memory, the arena. The flag has been in SGLang, marked experimental, since v0.5.15 (July 2026); the LMSYS post of 11 November explains the design, and we read the code of v0.5.23.

How the arena stays usable

Putting two pools in one buffer is easy. Keeping free space usable is the hard part. As requests finish, they leave holes: a freed state slot is 49 MiB, a freed KV page 2 MiB, and neither hole fits the other's unit. SGLang's arena handles that with three rules.

Each kind of state grows from its own end. Full-attention KV takes the high end of the arena and grows down. The bounded kind (recurrent state, or window KV for a model like gpt-oss) takes the low end and grows up. A model with both puts the window between them, as a band that can move. The free bytes collect in the middle and belong to nobody until one side needs them.

The arena: state grows up from the low end, full-attention KV down from the high end, a window band floats between them; a demand is served by reusing holes, then compacting the ends, then moving the floating bandThe arena: state grows up from the low end, full-attention KV down from the high end, a window band floats between them; a demand is served by reusing holes, then compacting the ends, then moving the floating band

Make room with as little movement as possible. When a request needs pages, the allocator tries three things in order: reuse free holes inside a band and extend it; compact the two end bands to merge their holes into the free middle; and only then move the floating band. It stops at the first step that serves the demand.

Move pages without rewriting requests. Requests hold virtual page ids, not addresses; each kind of state maps them to physical pages. A move copies the bytes and updates that map, so no request table changes. Because SGLang prepares the next step while the GPU still runs the current one, a freed or moved page may still be read by a running kernel. The rule the post states is short: a free counts toward capacity at once, but the bytes are reused only after every kernel that may still touch them has finished.

The same allocator also answers every capacity question, from admitting a prefill to evicting from the prefix cache, with the whole demand of a request: its full-attention tokens, its window tokens and its state slot, together. A per-pool "free memory" figure still exists, but only for logs and metrics.

What it buys

The SGLang team measured the arena against the default pools on one H200 per server, on the same two models (their numbers, averages of two runs; our arithmetic beside them):

Workload (LMSYS) Default pools Unified memory Our bound
gpt-oss-20b, 512 in / 1,536 out, 1,024 concurrent 618 running about 1,000 running, +14% throughput, TTFT 6 s instead of 43 s 1.65x more requests
Qwen3.5-4B, 16K in / 4,096 out, 64 concurrent 22 running 32 running, 26% faster 1.58x
Qwen3.5-4B, 1K in / 256 out, 64 concurrent 5,880 tok/s 5,830 tok/s, same GSM8K score (0.875) not a capacity test

The measured gains sit below our bounds, as they should: the gpt-oss run was capped by its 1,024 concurrent requests, and a real scheduler keeps headroom for tokens still to come. The short-request run is a regression check rather than a capacity test: at their defaults, the arena kept the same throughput and the same accuracy. They also measured the cost of a wrong guess: --swa-full-tokens-ratio 0.1 lost 12% of throughput on gpt-oss-20b, and --mamba-full-memory-ratio 0.3 capped Qwen3.5-4B at 24 running requests where the default allowed 51, 14% slower.

When to turn it on

Turn it on for a hybrid model whose traffic you don't know in advance or that changes during the day: the default split strands memory for long requests and for short ones alike, and only a mix that happens to match its ratios escapes. The launch is one flag; --mem-fraction-static and --max-total-tokens now size the arena as a whole:

$ python3 -m sglang.launch_server \
    --model-path Qwen/Qwen3.5-4B \
    --enable-unified-memory

Leave it off when the model is full attention only (a plain Llama or Qwen3-8B has one pool already, and SGLang refuses the flag), or when SGLang v0.5.23 refuses your setup at startup. Among others: DeepSeek-V4, Kimi-K3.1, MLA with sliding-window layers, FP4 KV cache, int8 Mamba checkpoints, two-batch overlap, LMCache, and prefill-decode disaggregation with any transfer backend but Mooncake; the usage guide has the full matrix. The feature is marked experimental. If you run vLLM, there is nothing to turn on: its pool is already shared. Check the block size it logs at startup for a hybrid model instead: for prefix-heavy traffic such as agents, blocks of several hundred tokens mean a cached prompt is reused only up to its last full block.

Gotchas

--max-running-requests still reserves request slots. The arena shares KV and state bytes, but the per-request rows are still a fixed count. Set it to the concurrency you expect, not to a large safety value.

Pool metrics become estimates. Per-pool "available" figures share bytes, so they can add up to more than the arena. Alert on the held figures, which stay exact, or on admission waits.

Priority preemption is off. With --enable-priority-scheduling and unified memory, a high-priority request is admitted first but no longer evicts running ones: under load it waits.

The ratio flags still exist, with a new meaning. Under unified memory they only set the arena's starting layout; they no longer cap anything at run time. A launch script tuned for the old pools keeps working.

Those three state slots per request come from prefix caching: a cached prompt on a hybrid model must keep a state checkpoint as well as its KV. Prefix Caching covers the mechanism, and The Scheduler what the engine does when the memory runs out anyway.

Sources

  1. Serving in ProductionContext Parallelism for Long-Context Serving: PCP and DCP in vLLM and SGLang
  2. Serving in ProductionServing Ripple-65B: What a Dense Model with 1M Context Costs, and When It Beats an MoE
  3. Serving in ProductionServing Kimi K3.1 Pro: The State per Request, the Indexer's Cost, and Where 1M Tokens Fit

Inference Notes

Once a week: what changed in serving AI models, and what it means if you build, run or pay for them, in about five minutes.

Read past issues