{
  "video_id": "reddit_1txpqru",
  "channel_slug": "LocalLLaMA",
  "channel_handle": "r/LocalLLaMA",
  "title": "Maybe KV cache offload to RAM isn't bad",
  "url": "https://www.reddit.com/r/LocalLLaMA/comments/1txpqru/maybe_kv_cache_offload_to_ram_isnt_bad/",
  "external_url": null,
  "upload_date": "20260605",
  "published_at": "2026-06-05T16:23:19+00:00",
  "transcript": "So, llama.cpp has the `-nkvo` (`--no-kv-offload`) option to offload KV cache to RAM instead of VRAM. Many people avoid this because obviously it hurts performance.\n\nBut every option exists with a trade off. And in my case, I think it's worth it. Hear me out.\n\nI'm running Qwen3.6 27B (IQ4\\_XS) on RTX 5060 Ti 16GB and 32GB DDR5. In order to fit 65k context, I have to quantize the KV cache down to q4\\_0, and keep only 58 layers on the GPU. This gives me **23 tps at peak, down to 16 tps during long generation**.\n\n    llama-server -m Qwen3.6-27B-IQ4_XS.gguf -c 65000 \\\n    \t-ctk q4_0 -ctv q4_0 -fa on -ngl 58 -np 1 \\\n    \t--temp 0.6 --top-p 0.95 --top-k 20 --presence-penalty 1.25 \\\n    \t--min-p 0.0 --chat-template-kwargs '{\"preserve_thinking\":true}' \\\n    \t--spec-type draft-mtp --spec-draft-n-max 2\n\nAdding `-nkvo`, I'm able to fit the whole model in GPU, and have the default f16 for KV cache. The speed plunged to **19 tps at peak, and 14 tps during long generation**. Not a bad trade off.\n\n    llama-server -m Qwen3.6-27B-IQ4_XS.gguf -c 65000 \\\n    \t-fa on -ngl 99 -nkvo -np 1 \\\n    \t--temp 0.6 --top-p 0.95 --top-k 20 --presence-penalty 1.25 \\\n    \t--min-p 0.0 --chat-template-kwargs '{\"preserve_thinking\":true}' \\\n    \t--spec-type draft-mtp --spec-draft-n-max 2\n\nThe interesting part is, I can even double the context window to 128k by keeping 63 out of 65 layers (for the MTP version) on the GPU. The generation speed didn't change much.\n\n    llama-server -m Qwen3.6-27B-IQ4_XS.gguf -c 131072 \\\n    \t-fa on -ngl 63 -nkvo -np 1 \\\n    \t--temp 0.6 --top-p 0.95 --top-k 20 --presence-penalty 1.25 \\\n    \t--min-p 0.0 --chat-template-kwargs '{\"preserve_thinking\":true}' \\\n    \t--spec-type draft-mtp --spec-draft-n-max 2\n\nKV cache quant when offload to RAM didn't seem to give any improvement, so we basically get f16 quality for free. In some cases, I found it hurts the performance as well.\n\nSo the takeaway is, if you found yourself lowering down the KV cache just to make the model fit, or needing more context window, you might better get away by offloading the KV cache to RAM instead.\n\n\n\n--- Top Comments ---\n\n\n[13 upvotes] With qwen 3 4B instruct 2507, all 36 layers in my gtx 1650 mobile and kv on ran(unquantized) at 64000 i get around 16 tokens/s on my lm studio\n\nRam is ddr4 btw\n\n[7 upvotes] Never go below FP8 for kvcache unless it’s turboquant. It’s not worth it - and please mmap when you offload weights to the RAM when using llama.cpp - otherwise you will get lazy OS to VRAM weight calling which will downgrade performance big time \n\n[9 upvotes] Now compare the prompt processing...",
  "transcript_chars": 2603,
  "ingested_at": "2026-06-06T01:30:02.847584+00:00",
  "source": "reddit",
  "yt_meta": {
    "score": 71,
    "upvote_ratio": 0.94,
    "num_comments": 41,
    "author": "bobaburger",
    "is_self": true
  }
}