KV cache quantization for local LLMs: FP8 vs FP4
Weights and KV cache have separate precision settings. Published FP8 and FP4 results show why memory savings, accuracy and speed need to be checked for the model, backend and workload in use.

KV cache quantization stores the keys and values at lower precision to reduce the memory footprint, which leaves room for longer context. This note covers the arithmetic, the mechanism and the budget decisions it forces on a 32 GB card.
How the KV cache grows with context
The KV cache is the model’s working memory of everything already in the context window. Every token you feed it stores keys and values that the attention of every later token will read. The weights take a fixed amount of memory at load, while the cache grows with context length. When a card “can’t hold long context”, the weights almost always fit. The cache is what runs out.
The arithmetic is easy to see on the 27B I serve, because it is a hybrid model. Only 16 layers are full attention (grouped-query, 4 KV heads, head dimension 256), and only those layers pay per token. The price is 32 KiB (32,768 bytes) per token at FP8, 64 KiB at BF16. The remaining layers keep a fixed-size recurrent state (78–154 MB per slot depending on dtype) that never grows with context. That hybrid design is the only reason a 262k window is even conceivable on a 32 GB card. A conventional 27B with full attention on every layer would pay per token on all of them.
The memory budget on a 32 GB card
These numbers come from my live serving config, and each one cross-checks against a figure I have already published:
- The pool and the per-token price agree. My remote RTX 5090 write-up reported a physical KV pool of 114,688 tokens. At 32 KiB per token that is 3.5 GiB to the byte, and the engine’s startup log reports the same reservation: 1.75 GiB of keys plus 1.75 GiB of values. The two figures match once you read SGLang’s “GB” as the binary GiB it means.
- Full native context does not fit alongside the drafter. 262,144 tokens need 8 GiB of KV, again to the byte, which is 4.5 GiB more than the 3.5 GiB reserved today, and only about 2.3 GiB is free. On this card I have to choose between the speculative drafter and the full window.
- Serving a vision model to a text-only harness costs KV room. With the vision tower excluded, the same engine’s measured KV capacity at 32K rose from 91,022 to 135,926 tokens. That is about +49% context for free, on the workload I run.
- The weight build moves the cache budget too. Two published NVFP4 exports of this model differ enough in layout that one leaves roughly twice the KV room of the other on 32 GB.
When the weights alone overflow the card, as with the 180B Qwen3.8-Flash-Next, the budget is spent before the cache gets any of it. Its system requirements show how offload wins the room back.
FP8 KV cache: lower storage, with model and backend checks
FP8 uses about half the storage of BF16 for the same cached values, before implementation overhead. vLLM’s four-model study recommends FP8 for its evaluated configurations. A separate vLLM investigation documents calibration considerations, accuracy fixes and prefill regressions for some large-head-dimension models. SGLang’s documentation also makes backend and fused-kernel support explicit. Memory savings do not guarantee unchanged quality or latency.
My own runs agree as far as they go. Every matched run in my remote RTX 5090 write-up was served on an FP8 KV cache and passed the recall, tool-calling and vision gates, including three-needle recall at 178,014 actual tokens. The rest of my stack is built on that setting.
These results establish that the stated FP8 configurations passed those checks. They do not measure a difference from BF16, because the suite did not include a matched BF16 run.
FP4 KV cache: the reasoning drop in SGLang’s own table
SGLang’s preliminary GPT-OSS-120B evaluation reports AIME-25 scores of 0.7533 with BF16 KV, 0.7667 with FP8 and 0.3533 with FP4. GPQA-Diamond is 0.5081, 0.5434 and 0.3202 respectively. Those are substantial regressions for that FP4 setup, not measurements of my Qwen build or every 4-bit cache format. Read the exact evaluation and backend requirements.
Current SGLang documentation distinguishes its FP4 formats. Its NVFP4 layout includes scales: about 0.5625 bytes per cached value, or roughly 1.78 times FP8 capacity rather than exactly twice. Other 4-bit schemes make different accuracy, latency and capacity tradeoffs. More cache capacity alone does not establish that a full-window request plus output will complete.
I have not tested those KV4 alternatives on this Qwen deployment. The published FP8 configuration remains the one tested here; a different KV setting needs matched quality, peak-memory and latency checks.
Why weights, cache and recurrent state need separate checks
The difference comes from how each one is quantized and how its errors spread:
- Weights are usually converted before inference. Calibration and compensation depend on the conversion method; neither is guaranteed for every checkpoint.
- KV values are produced during inference, but their scales may be calibrated, loaded from a checkpoint or computed dynamically. The selected format and runtime determine the path.
- Cache precision changes the values attention reads. Its effect depends on architecture, context and workload; test long-context behavior rather than assuming a fixed loss that accumulates identically in every model.
The hybrid architecture adds one more precision setting: the recurrent-state dtype on the non-attention layers. The serving cookbook flags it as an accuracy gate to validate for each workload. My own 48-prompt config sweep never tested it, because every config in that sweep ran the same state dtype. Forty-eight byte-identical outputs proved that my prefill knobs preserved the output; they said nothing about state precision. I still owe that test. Higher state precision is not a guaranteed speed gain either: in my engine’s published numbers it won one speculative combination and lost another.
My decision procedure for KV precision
1. WEIGHTS FIRST choose checkpoint, runtime and prompt/output budget
2. SUPPORT check KV format and attention-kernel compatibility
3. BASELINE retain the published FP8 setup as this deployment’s tested baseline
4. COMPARE test another KV format on matched quality, memory and latency checks
5. STATE DTYPE record recurrent-state precision and test changes separately
Point 5 matters most. A needle test only checks that the cache still holds a fact, while a reasoning test checks that the model can still reason across it. In the published table, reasoning collapses while the model still answers, so a needle pass at a big context does not show that the cache precision is safe. Test for the property you need; my 250K tool-calling test applied the same rule to instructions held at depth.
Local model receipt
KV precision receipt · config of record · 26 Aug 2026
- Model
- Qwen3.8-27B · NVFP4 weights · hybrid attention
- Attention layers
- 16 full-attention · GQA 4 · head dim 256
- KV per token
- 32 KiB at FP8 · 64 KiB at BF16
- KV cache
- FP8 · 3.5 GiB pool · 114,688 tokens
- Recurrent state
- Fixed-size slot per sequence · dtype gate still untested
- Not adopted
- 4-bit KV (published reasoning drop) · storage-only 4-bit (latency cost, unavailable)
- Sources
- Own matched runs (remote RTX 5090 write-up) · engine-published KV4 table · vLLM four-model KV study
- Decision
- NVFP4 weights + FP8 KV stands; 262k waits until the memory budget can pay for it
- Corrected
- 2 Oct 2026 · an earlier version multiplied a decimal-KB per-token figure as KiB, overstating both GiB totals by 2.5% · the engine log confirms 3.5 GiB · decision unchanged
Sources
- SGLang: the serving engine whose published 4-bit-KV evaluation this note quotes ↗︎
- vLLM: the four-model KV-precision study behind the FP8 default ↗︎
- Qwen: the official Qwen3.8-27B model card, with the hybrid architecture and context length ↗︎
- Remote RTX 5090 setup: Codex, Qwen3.8-27B and Tailscale: the measured pool, gates, and long-context runs this note builds on
- GitHub: the RTX 5090 serving configs, all running an FP8 KV cache ↗︎
Use this
Check if a model fits →← Previous: LLM quantization: how to choose Q4, Q8 or NVFP4 locally
Want this inside your team’s workflow? The Verified AI Operations Sprint tests one workflow in ten working days. See the sprint →
