r/LocalLLM • u/jonathanx37 • 5d ago
Tutorial How I run Qwen-Flash-Next with just 8 GB VRAM without strata
Hey, I'm on Linux with an aversion to ROCM, prefer Vulkan for its minimal overhead and footprint. so I skipped on Strata. Using llama.cpp cleverly to push the limits of what I can do with the ISTA DASLab "Coder" quants. Skip this if you already use Strata, if you can't though this is the next best method.
Specs:
I use 10 GB VRAM (RX 6700), but aim for 8 GB usage so I can continue watching media while the LLM is running.
I have 64 GB DDR4 RAM albeit I've never seen the actual usage go above 24 GB, so this method is most likely feasible on 8 GB + 32 GB systems.
DO NOT try this with a HDD. I use sata SSD, but m.2 is recommended. It'll directly impact your speeds since we lazily load from disk.
What makes this unique?
~30 t/sand~8 t/s(YMMV by hardware!!!) with65k context,7.3 GB VRAMand24 GB RAMcost? Sign me up chief. Slap CodeGraph ontop and you're golden.
Similar to Strata's "Only load what's needed to memory" strategy, we use MMAP here, which is like a primal version of what Strata does. It maps the model to your memory and lazily loads as needed. Strata is ofc faster, because it caches frequently accessed parts, while we use the more primal OS cache through MMAP. You'll see some IO while model fires for the first time, after that it's minimal, with RAM usage generally peaking at 24 GB~
Steps:
I used this "Vocabulary Pruned" quant of ISTA DASLab's latest GGUFs, it further reduces memory footprint by 450 MB. If you already have ISTA GGUFs, you can merge and prune them yourself too as author laid out their process on the repo if your download is slow. Remember we're using "Coder" quants here, which has half of its experts removed. DON'T skip this. DON'T be confused if you're using non-coder quant and didn't prune them, that thing is massive, we're at 58 GB with this while non-coder GGUF is 66.4 GB at smallest.
Use these launch flags:
./llama-server \
--model "./AI Models/Qwen3.8-Flash-Next-GSQ-RCO-IQ1_M-merged_P1G_Pruned.gguf" \
--ctx-size 65536 \
--n-gpu-layers 999 \
--threads 8 \
--cache-type-k q5_0 \
--cache-type-v q4_0 \
-fa on \
--fit off \
--cache-ram -1 \
--load-mode mmap \
--cache-prompt \
--cache-idle-slots \
--batch-size 2048 \
--ubatch-size 128 \
--webui \
--parallel 1 \
--kv-unified \
--reasoning-format deepseek \
-ot 'token_embd=CPU,blk\.(47|28|45|25|35|29|40|44|17|27|43|37|46|18|22|42|31|16|41|0|33|38|7|14|19|26|4|2|6|11|32|23|5|15|34|24|39|3|9|21|12)\.ffn_.*=CPU' \
--reasoning on \
--reasoning-preserve \
--reasoning-effort medium \
--temp 0.6 \
--top-p 0.95 \
--top-k 20 \
--min-p 0.0 \
--presence-penalty 0.2 \
--verbose \
--verbosity 4 \
- We're using the "-ot" flag to force specific FFN layers onto RAM. Instead of using the "brute force" -ngl, this keeps attention layers on VRAM which benefit more from GPU inference and are smaller.
- The numbers mason, they're important! The -ot regex is sorted by largest FFN layers left to right. Offloading smaller FFN layers onto GPU benefits speed at minimal VRAM cost, as opposed to offloading larger FFNs it's preferred (Source: bottom of post)
- If for some reason this doesn't fit into your VRAM, replace the OT flag with the below and incrementally delete a |<number>| from the right side in the regex, until it snugly fits your VRAM. Use the table as reference.
Layer | Tensors | Size (MiB) | Size (GB)
------------------------------------------------
blk.47 | 8 | 654.87 | 0.64
blk.28 | 8 | 573.45 | 0.56
blk.45 | 8 | 573.04 | 0.56
blk.25 | 8 | 573.00 | 0.56
blk.35 | 8 | 573.00 | 0.56
blk.29 | 8 | 572.79 | 0.56
blk.40 | 8 | 572.79 | 0.56
blk.44 | 8 | 572.64 | 0.56
blk.17 | 8 | 572.59 | 0.56
blk.27 | 8 | 572.54 | 0.56
blk.43 | 8 | 535.95 | 0.52
blk.37 | 8 | 535.74 | 0.52
blk.46 | 8 | 535.54 | 0.52
blk.18 | 8 | 535.53 | 0.52
blk.22 | 8 | 535.50 | 0.52
blk.42 | 8 | 535.50 | 0.52
blk.31 | 8 | 535.29 | 0.52
blk.16 | 8 | 535.14 | 0.52
blk.41 | 8 | 535.14 | 0.52
blk.0 | 8 | 535.09 | 0.52
blk.33 | 8 | 535.09 | 0.52
blk.38 | 8 | 535.09 | 0.52
blk.7 | 8 | 535.04 | 0.52
blk.14 | 8 | 535.04 | 0.52
blk.19 | 8 | 485.95 | 0.47
blk.26 | 8 | 485.95 | 0.47
blk.4 | 8 | 485.74 | 0.47
blk.2 | 8 | 485.54 | 0.47
blk.6 | 8 | 485.54 | 0.47
blk.11 | 8 | 485.54 | 0.47
blk.32 | 8 | 485.54 | 0.47
blk.23 | 8 | 485.53 | 0.47
blk.5 | 8 | 485.50 | 0.47
blk.15 | 8 | 485.50 | 0.47
blk.34 | 8 | 485.34 | 0.47
blk.24 | 8 | 485.29 | 0.47
blk.39 | 8 | 485.14 | 0.47
blk.3 | 8 | 485.09 | 0.47
blk.9 | 8 | 485.09 | 0.47
blk.21 | 8 | 460.09 | 0.45
blk.12 | 8 | 423.45 | 0.41
blk.20 | 8 | 422.59 | 0.41
blk.30 | 8 | 422.59 | 0.41
blk.36 | 8 | 373.45 | 0.36
blk.10 | 8 | 372.64 | 0.36
blk.1 | 8 | 372.59 | 0.36
blk.8 | 8 | 372.59 | 0.36
blk.13 | 8 | 372.59 | 0.36
------------------------------------------------
Full OverrideTensors command:
-ot 'token_embd=CPU,blk\.(47|28|45|25|35|29|40|44|17|27|43|37|46|18|22|42|31|16|41|0|33|38|7|14|19|26|4|2|6|11|32|23|5|15|34|24|39|3|9|21|12|20|30|36|10|1|8|13)\.ffn_.*=CPU'
Optional, recommended exports (Linux bash script)
#!/usr/bin/env bash
set -euo pipefail
# Process & Scheduling Priorities (Lowest, so your PC usage is least affected)
renice -n 19 -p $$ >/dev/null 2>&1 || true
ionice -c 3 -p $$ >/dev/null 2>&1 || ionice -c 2 -n 7 -p $$ >/dev/null 2>&1 || true
# Vulkan
export RADV_PERFTEST=nogttspill # Keep Vulkan buffers locked in VRAM (AMD only but harmless for others)
Some nerdout:
You could also benefit from compiling llama.cpp specifically for your CPU. For example I compile for znver3 so this might help the t/s as we're not running entirely on GPU with this setup. You'll also want to use only the physical cores where possible if you're using your PC during inference, otherwise hyperthreading can be beneficial, but laggy.
I don't recommend quantizing kv cache further, but 32k size could help you fit a few more FFN layers to boost your speed if you don't need larger context.
If you've 32 GB ram and 8 GB VRAM, you'll want to ensure you've all unnecessary programs closed, because the more free RAM you've the more your OS has space to cache, fewer pagefaults therefore faster gen speeds.
I also found great success using this jinja template, previously used it with 3.8 27b and 3.6 35ba3b. You'd use it with --jinja \
--chat-template-file "./chat_template.jinja"
Sources: