{"slug": "run-deepseek-v4-1-1017-flash-2-bit-on-a-single-80gb-vram-gpu-at-100-tok-s", "title": "Run DeepSeek v4.1 1017 Flash(2-bit) on a single 80GB VRAM GPU at 100 tok/s", "summary": "A published recipe runs DeepSeek-V4.1-Flash-1017, a 748B-parameter model, as a local coding agent on a single H100 80GB GPU with about 230GB of host RAM using a 392.9GB 2-bit GGUF (routed experts in Q2_K) and two llama.cpp patches on Unsloth's fork release b12823-mix-034de92. The patches lifted pooled decode from 107.0 to 114.5 tok/s (+7.0%) on a 60-task coding gate at 64k context, with 59 of 60 tasks faster and all 60 outputs identical, while the 110-task run measured median decode of 102.9 tok/s for coding and 90.3 tok/s for agent turns. The recipe keeps all routed experts in host RAM, caches the most-used experts in free GPU memory (--moe-cache-mib 55000), runs cache misses on CPU 80% of the time, and leaves the 202.8GB n-gram table on disk; setting -t to all 26 vCPUs collapsed decode to under 3 tok/s.", "body_md": "A recipe for running [DeepSeek-V4.1-Flash-1017](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017) (748B parameters) as a local coding-agent model on **one H100 80 GB with about 230 GB of host RAM**, using a 2-bit GGUF and two small llama.cpp patches.\n\n- Model file: [Tensward/DeepSeek-V4.1-Flash-1017-Coding-2bit-GGUF](https://huggingface.co/Tensward/DeepSeek-V4.1-Flash-1017-Coding-2bit-GGUF) (392.9 GB, routed experts in Q2_K)\n- Draft model: `dspark-DeepSeek-V4.1-Flash-1017-Q8_0.gguf` from[Unsloth's repository](https://huggingface.co/unsloth/DeepSeek-V4.1-Flash-1017-GGUF)\n- Engine: Unsloth's llama.cpp fork, release `b12823-mix-034de92` (it adds the MXFP8 type the model's n-gram table uses)\n\n```\nbash scripts/build_llama_h100.sh ./llama_build_h100          # downloads the fork's source (sha256-checked), applies both patches, builds for sm_90\n\nMODEL_PATH=/models/DeepSeek-V4.1-Flash-1017-Tensward-Coding-2bit-00001-of-00009.gguf \\\nDSPARK_PATH=/models/dspark-DeepSeek-V4.1-Flash-1017-Q8_0.gguf \\\nbash scripts/serve_coding_64k.sh                             # Recipe 1: one user, 64k context, OpenAI-compatible API on 127.0.0.1:8080\n```\n\nBefore the first start, once as root: `echo never | sudo tee /sys/kernel/mm/transparent_hugepage/defrag`. Put the model on local NVMe if you have it. `configs/opencode.json` points OpenCode at the server. For non-thinking replies, send `\"chat_template_kwargs\": {\"enable_thinking\": false}`.\n\nAll routed experts stay in host RAM (`-ot ...ffn_.*_exps=CPU`, `-lm none` so they are pinned rather than memory-mapped), and the free GPU memory becomes a cache of the most-used experts (`--moe-cache-mib 55000`). Experts that miss the cache run on the CPU 80% of the time (`--moe-cache-cpu-share 0.80`) instead of being copied over PCIe. The 202.8 GB n-gram table stays on disk and is read lazily. Decode threads are the physical cores (`-t 13`); prefill uses more (`-tb 24`). Do not set `-t` to all vCPUs: on our box `-t 26` (all 26 vCPUs) made decode collapse to under 3 tok/s.\n\nBoth are off unless their environment variable is set; the serve scripts set them.\n\n- **`01_decode_fast.patch` (`LLAMA_DECODE_FAST=1`).** Less CPU work per token in the expert cache's CPU path: rows the GPU cache already served are skipped instead of quantised and zero-filled on one thread, the expert ids are read back through pinned memory, and one scheduler wait is skipped when the cache's own copy step has already synchronised.\n- **`02_spec_max_concurrency.patch` (`LLAMA_SPEC_MAX_CONCURRENCY=2`).** Switches the draft model off while more than N requests are generating and back on when the load drops. With several users, drafting multiplies the batch size and pushes the expert cache out of its fast path.\n\nHardware: GCP `a3-highgpu-1g`, H100 80 GB (host link PCIe Gen4 x16), Xeon Platinum 8481C (13 cores, 26 vCPUs), 230 GiB RAM, 2 x 375 GB local NVMe.\n\n**Answers.** We ran this recipe, built with the scripts in this folder, on 110 tasks we wrote for the test (none from public benchmarks: coding with hidden tests, multi-turn agent repairs with real tool execution, 30k-54k-token long context, tool calls), against the same model on two FP8 API providers. No quality loss was readable at this size (details and limits on the [model card](https://huggingface.co/Tensward/DeepSeek-V4.1-Flash-1017-Coding-2bit-GGUF)). The patched build's 997 responses were byte-identical to the unpatched build's.\n\n**Single user (Recipe 1).** \"Patches off\" is the patched binary with `LLAMA_DECODE_FAST=0` on the gate and 7.2k rows, and an unpatched build in our 110-task run; the 7.2k row is three restarts per arm, the others one run each:\n\n|  | Patches off | Patches on | \n|---|---|---|\n| 60-task coding gate at 64k context, pooled decode | 107.0 tok/s | 114.5 tok/s (+7.0%; 59 of 60 tasks faster, all 60 outputs identical) | \n| Our 110-task run, median decode: coding / agent turns | 98.7 / 90.0 tok/s | 102.9 / 90.3 tok/s | \n| Prefill, 53k-token prompts (our run) | about 680 tok/s | about 650 tok/s | \n| Prefill, 7.2k-token prompt ( `-ub 4096` ) | 662-691 tok/s | 662-691 tok/s (1.3% lower on average) | \n\nDraft acceptance on the gate: 91.4%; expert cache hit rate: 86.8%; GPU memory at the end of the run: 77.2 GiB.\n\n**Prompt cache.** With `--cache-ram 8192`, a follow-up turn after another request had evicted the slot started in 0.30 s instead of 13.4 s at 8k tokens, and 0.39 s instead of 44.0 s at 32k (one trial each, on an earlier experimental build that also carried other patches).\n\n**Several users.** Auto-flip against always-on drafting, same binary and box, one session each, `-np 8 -c 16384 -kvu`, 56,000 MiB expert cache, `--cache-ram 0`:\n\n| Concurrent requests | Always-on drafting | Auto-flip | \n|---|---|---|\n| 4 | 73.7 tok/s | 119.2 tok/s | \n| 8 | 42.4 tok/s | 146.5 tok/s | \n\nNo draft tokens were wasted during bursts, and single-request speed after a burst stayed within the burst-to-burst spread (81.0 vs 86.1 tok/s).\n\n**Recipe 2** (`scripts/serve_team_multistream.sh`: no draft, 63 GiB cache, `-np 8`) reached 165.3 tok/s decode at 8 concurrent requests and 61.3 at 1 (one session). At 4 concurrent requests 2 of 3 bursts collapsed to about 54 tok/s, because idle and busy slots interleave and the server stops reusing its decode graph; `CACHE_RAM_MIB=0` should avoid it at the cost of the RAM prompt cache (not tested on this recipe). We are working on a fix.\n\n**Without the recipe.** The default memory-mapped load with `-ub 512` prefilled a 7.2k-token prompt at 64.3 tok/s; `-lm none` alone made that 170.4 tok/s, and the full recipe reaches 662-691.\n\n- **Model:** DeepSeek,[DeepSeek-V4.1-Flash-1017](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017) , MIT License.\n- **Source GGUF, draft model and the llama.cpp fork with the expert cache:**[Unsloth](https://huggingface.co/unsloth/DeepSeek-V4.1-Flash-1017-GGUF) , MIT License.\n- **llama.cpp:** the[ggml / llama.cpp authors](https://github.com/ggml-org/llama.cpp) , MIT License.", "url": "https://wpnews.pro/news/run-deepseek-v4-1-1017-flash-2-bit-on-a-single-80gb-vram-gpu-at-100-tok-s", "canonical_source": "https://github.com/Tensward/tensward/tree/main/examples/deepseek-v4.1-flash-h100", "published_at": "2026-11-29 22:18:10+00:00", "updated_at": "2026-11-29 22:46:34.368600+00:00", "lang": "en", "topics": ["ai-infrastructure", "large-language-models", "ai-agents", "ai-tools"], "entities": ["DeepSeek", "DeepSeek-V4.1-Flash-1017", "Unsloth", "llama.cpp", "Tensward", "Hugging Face", "Nvidia H100", "OpenCode"], "also_reported_by": [], "takeaway": "On one H100 80GB, keep routed experts in host RAM, cache hot experts in GPU memory with --moe-cache-mib 55000, run cache misses on CPU at --moe-cache-cpu-share 0.80, and set -t to physical cores (13) rather than all 26 vCPUs, which collapsed decode to under 3 tok/s.", "recommendation": {"advice": "Pin MoE experts in host RAM and cache the hottest in free GPU VRAM, but set decode threads to physical cores only; on this box -t 26 fell below 3 tok/s while -t 13 held 114.5 tok/s.", "playbook": "inference-serving", "playbook_url": "https://wpnews.pro/playbooks/inference-serving"}, "alternates": {"html": "https://wpnews.pro/news/run-deepseek-v4-1-1017-flash-2-bit-on-a-single-80gb-vram-gpu-at-100-tok-s", "markdown": "https://wpnews.pro/news/run-deepseek-v4-1-1017-flash-2-bit-on-a-single-80gb-vram-gpu-at-100-tok-s.md", "text": "https://wpnews.pro/news/run-deepseek-v4-1-1017-flash-2-bit-on-a-single-80gb-vram-gpu-at-100-tok-s.txt", "jsonld": "https://wpnews.pro/news/run-deepseek-v4-1-1017-flash-2-bit-on-a-single-80gb-vram-gpu-at-100-tok-s.jsonld"}}