The 8-Layer Offload Cliff on 16 GB VRAM & Multi-Turn KV-Cache Drift in llama.cpp¶
Published: 2026-11-30 · Hardware: NVIDIA GeForce RTX 5080 Laptop GPU (16,302 MiB VRAM, sm_120, Windows 11) · Engine: llama.cpp 0.9.0-dev (build 12167, commit 240d68fcf) · Raw CSVs: rtx5080_27b_offload_sweep.csv · llama_cpp_11970_kv_audit.csv
Claim¶
On a consumer 16 GB GPU, fitting a 27B model "almost" in VRAM is nearly useless for interactive decode: spilling just 8 of 64 layers (-ngl 56) into host DDR5 slashes decode speed by -62.0% (33.67 → 12.78 tok/s), whereas shaving 857 MB off the GGUF (15.57 → 14.71 GB) keeps the full model + KV cache above the cliff. In live multi-turn serving, reinjecting <think> reasoning blocks (open-webui#23339) forces 6.7× more tokens to be re-evaluated every turn (33 → 220 tok/turn) and adds +26% prompt latency by Turn 5.
Part 1: 16 GB VRAM Offload Sweep (Qwen3.8-27B)¶
Method¶
Ran llama-bench.exe (-fa 1, -p 512,2048, -n 128, -r 3 repeats) comparing two real local quantizations of Qwen3.8-27B:
- IQ4_XS-16GB-Turbo (14.711 GB on disk) across -ngl 99, 56, 48, 40, 32, 0
- IQ4_XS-Std (15.568 GB on disk) across -ngl 99, 56, 48, 32

Measured Results (llama-bench b12167, mean ± stddev across 3 runs)¶
| Quantization | Size | -ngl |
pp512 (tok/s) |
pp2048 (tok/s) |
tg128 Decode (tok/s) |
Decode vs Full GPU |
|---|---|---|---|---|---|---|
IQ4_XS-16GB-Turbo |
14.71 GB |
99 (All GPU) | 1384.41 ± 70.89 |
1362.10 ± 2.65 |
33.67 ± 0.37 |
1.00× (baseline) |
IQ4_XS-16GB-Turbo |
14.71 GB |
56 (8 CPU) | 876.19 ± 64.44 |
896.40 ± 20.70 |
12.78 ± 0.10 |
-62.0% (0.38×) |
IQ4_XS-16GB-Turbo |
14.71 GB |
48 | 703.33 ± 32.64 |
703.95 ± 9.06 |
8.69 ± 0.01 |
-74.2% |
IQ4_XS-16GB-Turbo |
14.71 GB |
40 | 583.25 ± 27.09 |
575.41 ± 8.06 |
6.34 ± 0.65 |
-81.2% |
IQ4_XS-16GB-Turbo |
14.71 GB |
32 | 480.27 ± 24.87 |
467.25 ± 8.29 |
4.82 ± 0.55 |
-85.7% |
IQ4_XS-16GB-Turbo |
14.71 GB |
0 (All CPU) | 298.04 ± 21.82 |
318.89 ± 7.92 |
2.91 ± 0.07 |
-91.4% (11.6× slower) |
IQ4_XS-Std |
15.57 GB |
99 (All GPU) | 1366.36 ± 83.06 |
1350.70 ± 3.60 |
31.77 ± 0.11 |
-5.6% vs Turbo |
IQ4_XS-Std |
15.57 GB |
56 (8 CPU) | 880.78 ± 44.89 |
896.50 ± 8.59 |
12.10 ± 0.29 |
-61.9% vs Std 99 |
IQ4_XS-Std |
15.57 GB |
48 | 689.26 ± 34.65 |
697.01 ± 3.18 |
8.26 ± 0.42 |
-74.0% |
IQ4_XS-Std |
15.57 GB |
32 | 480.06 ± 21.37 |
485.91 ± 8.84 |
4.95 ± 0.11 |
-84.4% |
Why decode falls off a cliff while prefill degrades gracefully: Prefill (pp2048) amortizes each offloaded weight read across 2,048 tokens (-34.2% at -ngl 56). Autoregressive decode (tg128, batch=1) is strictly memory-bandwidth bound: streaming even ~1.8 GB of CPU layers over host DDR5 (~60 GB/s) adds ~30 ms of serial wait per single token, immediately dominating the ~29 ms it took the RTX 5080 to run all 64 layers!
(You can model this exact cliff for any model and GPU in the interactive KV-Cache & VRAM-Fit Calculator.)
Part 2: Live Multi-Turn KV-Cache Audit (llama.cpp#11970 & open-webui#23339)¶
Method¶
Started live llama-server.exe (--ctx-size 8192 -ngl 99 -fa on --parallel 1, tested both default and --cache-reuse 256) with Qwen3.8-27B IQ4_XS-16GB-Turbo and executed 3 five-turn conversations at temperature=0.0, logging timings.cache_n, timings.prompt_n, timings.prompt_ms, and nvidia-smi VRAM:
1. clean_assistant_replay: unmodified prior assistant responses
2. strip_vs_keep_newline_mismatch: trailing \n\n mutated on prior assistant turns (testing a common #11970 client normalization hypothesis)
3. reinjected_think_tag_bloat: ~185-token <think>...</think> blocks reinjected into prior assistant turns (open-webui#23339)

Turn-5 Summary (Live llama-server b12167)¶
| Server Config | Scenario | Turn-5 cache_n |
Re-Evaluated prompt_n |
KV Hit % | Turn-5 prompt_ms |
VRAM Used |
|---|---|---|---|---|---|---|
| Default | clean_assistant_replay |
1,216 |
33 |
97.36% |
438.76 ms |
14,162 MiB |
| Default | strip_vs_keep_newline_mismatch |
1,216 |
33 |
97.36% |
409.36 ms |
14,162 MiB |
| Default | reinjected_think_tag_bloat |
1,777 |
220 (6.7×) |
88.98% |
533.28 ms (+21.5%) |
14,162 MiB |
--cache-reuse 256 |
clean_assistant_replay |
1,216 |
33 |
97.36% |
395.50 ms (-9.9%) |
14,435 MiB (+273 MiB) |
--cache-reuse 256 |
reinjected_think_tag_bloat |
1,777 |
220 |
88.98% |
498.87 ms (+26.1%) |
14,435 MiB |
One Result That Contradicted Expectation¶
I expected appending trailing \n\n to prior assistant turns to break KV prefix matching on llama-server (reproducing ggml-org/llama.cpp#11970). It did not (97.36% KV hit rate, identical to clean replay). On b12167, the Qwen chat template normalizes trailing whitespace before the <|im_end|> token boundary.
Follow-up isolation on llama.cpp HEAD (808d1fed) confirmed the true trigger behind #11970: non-canonical BPE re-tokenization across turns. Using ServerPreset.tinyllama2() and dynamically banning merged token 're' (276) on Turn 1 so the model emits split ('r', 'e') for "Here,", Turn 2 re-tokenizes "Here," canonically and silently truncates the KV cache (72 vs 99 expected cached tokens — 28 cached tokens discarded, f_keep = 0.720). That minimal deterministic regression test (+97 lines) is packaged for upstream submission on #11970.
One-Command Reproduction¶
git clone https://github.com/cuhawk/p2InferRoute
cd p2InferRoute
python benchmarks/run_rtx5080_experiments.py
And to strip <think> history automatically at the gateway before requests hit llama-server, vLLM, or SGLang:
What I'd Distrust in This Experiment¶
- Warm Turn-1 carryover across scenarios 2 & 3: In
llama_cpp_11970_kv_audit.csv, scenarios 2 and 3 ran sequentially on the samellama-serverprocess without flushing the KV slot, so Turn 1 of scenarios 2 and 3 hit1,122/1,126(99.64%) cached system prompt from Scenario 1. Compare Turns 2–5 across scenarios, not Turn 1. - Short context window (
8K) vs.32K–128K: At8Kcontext,IQ4_XS-Std(15.57 GB) still squeezed into16,302 MiBVRAM underllama-bench(ngl=99). Pushing to32K+context withIQ4_XS-Stdforces OS WDDM shared-memory paging, which is much slower than explicit-ngloffloading. - Single-model architecture (
Qwen3.8-27Bhybrid SSM/Attention): Pure dense GQA models (e.g.Llama-3.3-70B,Gemma-4-12B) allocate larger per-token KV caches than hybrid SSM models; verify your exact model's KV bytes/token before choosing a quant.