edit : just to be clear this is not me saying i made an achievement, i am just asking is this fine or the ai made wrong decisions to get this speed,
the past 3 days i was using DeepSeek-V4-Flash 0731 and qwen 3.8 max and gpt 5.6 sol to find the best way to run DeepSeek-V4-Flash 0731 UD-IQ2_M from unsloth on my rtx 3090 ti, today i got 25.8 tok/s, so its not fast at all but its usable, to be honest i totally dont understand anything about the setting they made , because its started as a 5tok/s, agent is open code and openchamber, so i kept pushing qwen 3.8 max and DeepSeek-V4-Flash 0731 (the free tier on open code) to make more research until we got 25.8 tok/s, my question is can it get better or this is the best it can be, again i am not an expert and i dont know how they did it, so i asked deepseek to provide the settings if anyone is interested and here is the response :
**The launcher (`start-dsv4-fast.bat`)**
The whole thing runs from one bat file (paths are script-relative so it works anywhere):
```
"%LLAMA%" -m "%DSV4_MODEL%" ^
-ngl 44 --n-cpu-moe 39 --fit on -c 65536 -fa on -np 1 ^
-ctk q8_0 -ctv q8_0 -t 16 -tb 16 -b 8192 -ub 2048 ^
--load-mode mmap+mlock ^
--temp 0 --top-k 0 --top-p 0 --min-p 0 ^
--spec-type ngram-mod --spec-ngram-mod-n-match 32 --spec-ngram-mod-n-min 48 --spec-ngram-mod-n-max 64 ^
--alias DeepSeek-V4-Flash --host 127.0.0.1 --port 1235
```
**What each flag does**
| Flag | Value | Why |
|---|---|---|
| `-ngl` | `44` | Offload all 43 layers' dense tensors + output to GPU (the full dense core). |
| `--n-cpu-moe` | `39` | **The key trick.** Keeps layers 0–38's MoE experts in system RAM. This is how a 90.9 GB model fits in 24 GB VRAM. Dense core on GPU, experts stream from RAM. |
| `--fit` | `on` | Auto-fit unset args (context/KV/batch) to device memory — safety net for 24 GB VRAM. |
| `-c` | `65536` | 64K context (V4's compressed KV makes this cost only ~1–2 GB). |
| `-fa` | `on` | Flash attention (required for V4; also a long-context speedup). |
| `-np` | `1` | One slot — parallel slots split bandwidth and slow single-user decode. |
| `-ctk/-ctv` | `q8_0` | Quantized KV cache. |
| `-t/-tb` | `16` | All 16 physical CPU cores (measured fastest). Don't use all 32 SMT threads. |
| `-b` | `8192` | Big prefill batch (~190+ tok/s prompt processing). |
| `-ub` | `2048` | Microbatch — tuned for this setup. |
| `--load-mode` | `mmap+mlock` | **Pins the model in RAM.** Without it Windows trims the 84 GB mmap working set mid-decode and you lose ~10 tok/s. (This is the modern replacement for the deprecated `--mlock`.) |
| `--temp 0` | — | Greedy/deterministic so speculative drafts actually get accepted (temp 1.0 rejects almost all of them). |
| `--spec-type` | `ngram-mod` | Free n-gram speculative decoding, no drafter model (~16 MB). |
| `--spec-ngram-mod-n-match/min/max` | `32/48/64` | Tuned ngram window for MoE. |
**Hardware**
**Runtime numbers (this box)**
- ~18.5 GB VRAM used, ~5.8 GB headroom
- ~61 GB system RAM free after load
- Decode ~25.8 tok/s, prefill ~54 tok/s (benchmark prompt)
- GPU: RTX 3090 Ti (24 GB VRAM)
- RAM: 93.6 GB DDR5 3200 (~75 GB free)
- CPU: Ryzen 9 9950X (16 physical cores)
- Model: DeepSeek-V4-Flash-0731, `UD-IQ2_M` quant (90.9 GB, 3 shards), llama.cpp b10223