← All guides

Lowest KV Cache Local LLM (2026): gpt-oss 20B Wins

Model cards publish parameter counts and benchmark scores. None of them publish the number that decides whether a long context fits your card: the KV cache cost per token. It is not proportional to model size. A 21B model can cost six times less cache than an 8B one, and a 235B mixture-of-experts can cost less than a 32B dense model. This page ranks nine current local models by cache per 128K context, computed from fields in their own config files.

Bottom Line

  • KV cache cost does not track model size. It tracks three config fields: layers, key-value heads and head dimension.
  • gpt-oss 20B is the cheapest here at 3.0 GiB per 131,072-token window. Llama 3.3 70B is the most expensive at 40.0 GiB — a 13x spread.
  • A 21B model costs six times less cache than an 8B one. gpt-oss 20B is 3.0 GiB; Qwen3-8B is 18.0 GiB.
  • A 235B model costs less than a 32B one. Qwen3-235B-A22B is 23.5 GiB; Qwen3-32B is 32.0 GiB.
  • num_key_value_heads is the field that decides it, and it appears on no model card headline, no benchmark chart and no product page.
  • Halving key-value heads halves the cache exactly. There is no approximation in that.
  • These are calculations, not measurements. Your runtime will report something else. Rank with this table; size with your loader.

The Table

Every field comes from each model’s published config.json on Hugging Face, read on 6 September 2026. The cache figures are fp16, unquantised.

ModelLayers that growKV headshead_dimKiB / tokenGiB @ 32,768GiB @ 131,072
gpt-oss 20B12 of 24864240.753.0
gpt-oss 120B18 of 36864361.14.5
Qwen3-30B-A3B48 of 484128963.012.0
Qwen3-8B36 of 3681281444.518.0
Qwen3-14B40 of 4081281605.020.0
Mistral Small 3.2 24B40 of 4081281605.020.0
Qwen3-235B-A22B94 of 9441281885.923.5
Qwen3-32B64 of 6481282568.032.0
Llama 3.3 70B80 of 80812832010.040.0

Sort that table by parameter count and it scrambles. The ordering by cache and the ordering by size are close to unrelated.

The Formula

The cache holds one key and one value for each key-value head, in every layer, for every token. At fp16 that is two bytes per value:

bytes per token = 2 (K and V) x layers x kv_heads x head_dim x 2 bytes

Worked for Qwen3-32B:

2 x 64 x 8 x 128 x 2 = 262,144 bytes = 256 KiB per token
256 KiB x 131,072 tokens = 32 GiB

Worked for gpt-oss 20B, where only the 12 full-attention layers count:

2 x 12 x 8 x 64 x 2 = 24,576 bytes = 24 KiB per token
24 KiB x 131,072 tokens = 3.0 GiB

Notice what is absent from that formula. Total parameters. Expert count. Quantisation of the weights. Benchmark scores. None of them touch the cache. This is why a page that tells you “a 70B needs 40GB at Q4” has told you about half the problem — the other 40 GiB is context, and it is a different calculation entirely. Our 128K context VRAM page works the general version.

The Two Design Choices That Matter

Key-value heads

This is the strongest lever and the least visible one. Grouped-query attention lets a model use fewer key-value heads than query heads, and the cache scales directly with that count.

Qwen3-32B and Qwen3-30B-A3B are instructive because they are close in name and far apart in cache. The dense 32B uses 8 key-value heads across 64 layers. The MoE 30B uses 4 across 48 layers. The result is 32.0 GiB against 12.0 GiB — a 2.7x difference between two models a buyer would treat as interchangeable.

Sliding-window attention

The gpt-oss pair go further and simply stop half their layers from growing. Both alternate sliding_attention and full_attention, with sliding_window set to 128. Twelve of the 20B’s layers, and eighteen of the 120B’s, hold 128 tokens each forever. That is about 3.0 MiB in total for the 20B — a rounding error against the 3.0 GiB the other half costs.

This is not free. In those layers a token can attend no further back than 127 positions. Long-range recall is removed by construction, and the model compensates through its full-attention layers. If your work depends on precise recall of something far back in the window, test that specifically. We cover the tradeoff on the gpt-oss 120B sizing page.

The Caveat On Window Length

The right column compares every model at 131,072 tokens so the arithmetic is comparable. Not every model here has a 131,072-token native window.

Native max_position_embeddingsModels
131,072gpt-oss 20B, gpt-oss 120B, Mistral Small 3.2 24B, Llama 3.3 70B
40,960Qwen3-8B, Qwen3-14B, Qwen3-32B, Qwen3-30B-A3B, Qwen3-235B-A22B

The Qwen3 models reach 128K through RoPE scaling, not natively. Enabling it changes quality as well as memory, so the 32,768-token column is the fairer comparison if you are choosing between a Qwen3 model and a gpt-oss one — every model in the table runs that window without scaling.

How To Use This

The practical move is the one people skip: change the model before you buy the card.

If you have 16GB and a 24GB cache requirement, a second card costs more than every model in this table combined. Switching from Qwen3-32B to Qwen3-30B-A3B saves 20 GiB of cache at 128K for no money. Switching to gpt-oss 20B saves 29 GiB.

If you have 24GB, the whole gpt-oss 20B job — weights plus a full 128K cache — fits with headroom, while Qwen3-32B’s cache alone overflows the card before its weights are loaded. That is the decision the 24GB tier page is really about.

If you have 96GB or more, the cache stops being the constraint and the weights take over. See is 96GB of VRAM enough.

And if none of that is enough, KV cache quantisation halves every figure in the table at 8-bit. Do that after you have picked the cheapest model that does your work, not before. Quantising a bad choice is more expensive in quality than choosing well was in memory.

See Also

Sources

Read 2026-09-06. Each link is the raw config.json for the named model.

These are calculations, not measurements. No benchmark was run for this page and none is implied. Runtimes add buffers, pad allocations, and in the gpt-oss case may ignore the sliding window and reserve double. Check what your loader reports against the row above before you conclude a model does or does not fit.

Need OpenClaw fixed live?

Remote rescue sessions for gateway, auth, tunnel, VPS, and model access problems.

See Rescue Session

Read next

gpt-oss 120B vs 20B (2026): Which One Should You Run?
gpt-oss 20B fits a 16GB card at short context and does not fit one at its full 128K window — the KV cache is 3.0 GiB and the weights leave about that much room. The 120B needs 96GB or a 128GB unified box. Both figures come from the models' own config.json.
How Much VRAM Does gpt-oss 120B Need at Full 128K Context? About 4.5 GiB of Cache, Not 9
gpt-oss 120B holds its entire 131,072-token window in roughly 4.5 GiB of KV cache, because half its layers only ever attend to 128 tokens. Here is the arithmetic from the model's own config.json, and the machines that fit the ~70GB total.
Dense 70B or MoE 120B: Which Is the Better Local Model in 2026?
Same disk footprint, very different memory shape. A dense 70B costs 327,680 bytes of KV cache per token; Laguna S 2.1 at 118B costs 49,152. On a 48GB card that is under 20K tokens of context against more than 100K. The layer math, the speed ceiling, the one thing sliding-window attention takes away, and which to run at 48GB and 96GB.
Best 20B to 35B Local LLMs: The Band That Fits One GPU
The best local LLMs between 20B and 35B parameters in 2026. Qwen 3.6 27B and Gemma 4 31B on a 24GB card, gpt-oss 20B on 16GB, Qwen 3.6 35B-A3B and Nemotron 3 Nano 30B-A3B for speed, Laguna XS 2.1 33B for agentic coding. Quant-by-quant memory fit for 16/24/32GB VRAM and 32/48GB Macs.