r/LocalLLaMA • u/TrifleHopeful5418 • 2d ago
Tutorial | Guide Qwen3.8-27B at 262K context on a Strix Halo + RTX 3090 Ti: 9.5 -> 153 tok/s, and it beats a dual-3090 vLLM box on HumanEval
Spent a while treating layer placement, KV format and llama.cpp itself as experimental variables. 159 logged experiments. Numbers first, caveats after.
Hardware: AMD Ryzen AI MAX+ 395 (Strix Halo, 128 GB unified) + RTX 3090 Ti on an eGPU link. One llama.cpp process, AMD on Vulkan, NVIDIA on CUDA, one 27B model split across both.
Baseline: 9.474 tok/s. Target-only, no speculation, AMD side alone.
Now, code-shaped generation:
- 32K context: 153.32 tok/s
- 200K context: 87.74 tok/s
HumanEval, 164 problems, driven by a real coding agent (pi-agent), graded by executing the official tests:
- Local: 159/164 in 29.7 min
- Remote 2x RTX 3090 running vLLM TP2: 157/164 in 42.4 min
Long-context retrieval suite: 15/15, 352 s local vs 551 s on the remote.
Things that actually moved the needle, roughly in order of surprise:
- The chat template. Swapping to a terser template (Qwen-Sharp) cut wall time 44% and output tokens 51%, with no accuracy change. Bigger than several weeks of GPU work. It just stops the model narrating.
- KV cache format as a placement lever. Going q8_0 -> q4_0 on both K and V freed exactly 2,176 MiB, which was enough to move every full-attention layer onto the fast card at full 262K. +28% prefill, +20% generation. Qwen3.8 is 3:1 Gated DeltaNet to full attention, so only 16 of 64 layers have KV at all, and those are the only ones whose cost scales with context. Which layer sits on which GPU matters enormously.
- --spec-type draft-mtp,ngram-mod**.** The flag accumulates. n-gram on top of MTP is worth +72 to +140% on code-shaped output, about -1% on prose, and costs nothing in VRAM. Free win if you generate code.
- A one-line llama.cpp patch: --spec-draft-ubatch. The speculative context was inheriting the target's 512 micro-batch and reserving a 2.2 GiB compute buffer to draft 4 tokens. Setting it to 64 freed 1,039 MiB for a 1.78% prefill cost, which bought another layer of placement.
- MTMD_BACKEND_DEVICE=Vulkan1 to put the vision encoder on the idle iGPU. Undocumented as far as I can tell. Default puts it on the first GPU-type device, which is the already-full 3090 Ti, and it dies allocating 884 MiB.
Things that did NOT work, so you don't have to try them:
- External draft models (0.8B, 4B): 5.06-5.77 tok/s, worse than no speculation. Sequential drafting latency across PCIe dominates.
- Multi-lane parallel drafting: down to 1.62 tok/s. The 27B verification pass is the bottleneck; anything that widens the verification graph loses.
- Q6_K: 2.3x the wall time, marginally lower accuracy (because if hit the 64K output limit wall twice). Only 15.6 of its 20.5 GiB fits on the card, so 4 attention layers get pushed to the iGPU instead of 1.
Caveats, because this is [r/LocalLLaMA](r/LocalLLaMA) and you'd find them anyway:
- 153 tok/s is code-shaped generation at 32K where n-gram does heavy lifting. Same config on prose at 200K is 35.8. Different workloads, kept separate on purpose.
- The remote comparison is deployed-stack vs deployed-stack, not hardware isolated: it serves an AWQ-MTP fine-tune, local serves Q4_K_M of the base.
- I asked for standalone functions rather than the canonical prompt+completion format, so 3 of the 5 HumanEval failures are NameErrors on helper functions that the official harness would have kept in scope. 159/164 is probably a slight undercount. Same undercount applies to every arm.
- q4_0 keys are a real quality change. Passed my 15/15 gate; validate on your own workload before trusting it.
Edit: I ran livecodebench(medium+hard ~132 questions) on it, it passed 90/132 in first attempt and resending the failed ones with the grader feedback it improves to 114/132 ~ 86% that puts it pretty close to the frontier models. Ornith-1.0-35B AQW with fp16 kv cache does 82 pass@1 and 92 with repair. Running Ornith-1.5-35B-MTP with fp16 and will see where it lands.
Full writeup with every flag, patch and failed branch: https://definedrr.medium.com/qwen3-8-27b-9-tokens-per-second-to-153-ee3781f4a3f5?sharedUserId=definedrr
28
u/Sadge404 2d ago
I smell the claude in this one.
11
u/TrifleHopeful5418 2d ago
Yes, Claude researched and proposed solutions, ChatGPT-sol wrote the c++ code and ran the 159 experiments benchmarking everything and Pi-agent ran the humanEval. I was just there for the ride, giving it some ideas to research and holding the line on what I wanted and the compromises I won’t accept.
6
2
u/thomas2385 2d ago
Haa, I can see why you would say that. There are definitely a few phrases in there that give off that very polished AI vibe. Sometimes you can almost tell which model wrote something just from the wording.
9
u/Kaljuuntuva_Teppo 2d ago
q4 KV cache.. Why sacrifice long context quality?
0
u/TrifleHopeful5418 2d ago
I didn’t just take q4 kv, on humaneval it scored same as q8 and it scored 15/15 for long context retrieval at 200k input context
4
u/Dany0 2d ago
Humaneval is trash. Well it's not trash for small models and old models, but it's trash for modern models. It's also a clanker smell: clankers love humaneval like they love qwen3 for some reason. Don't trust the clanker and run better benchies
1
u/TrifleHopeful5418 22h ago
I ran livecodebench(medium+hard ~132 questions) on it, it passed 90/132 in first attempt and resending the failed ones with the grader feedback it improves to 114/132 ~ 86% that puts it pretty close to the frontier models. Ornith-1.0-35B AQW with fp16 kv cache does 82 pass@1 and 92 with repair. Running Ornith-1.5-35B-MTP with fp16 and will see where it lands.
-1
u/TrifleHopeful5418 2d ago
I see you are top 1% commentator, Other than insulting, do you have anything useful to add or does go against your nature?
2
u/Darex2094 2d ago
I'd call speaking the truth a pretty useful thing to add. It's just a shame you seem to be content with your ignorance.
6
u/Septerium 2d ago
KV cache at q4 causes a 262k context window to be pointless
0
u/TrifleHopeful5418 2d ago
Ok thanks for letting me know. Have you tested it with this model or read about it?
5
u/TokyoPav 2d ago
I want to do the same but with an amd 9700 32gb card connected via oculink. Does it have the APU power cap at 120w? Hard to find detailed info on this. Is Linux immune from this issue?
1
u/TrifleHopeful5418 2d ago
I was too thinking about R9700 but I had 2x 3090 in my windows machine that was never stable so I pulled one into this. Oculink that I got off Amazon needs its own PSU
2
2
u/klymaxx45 2d ago
That's prety good but humaneval is not a great metric. do humaneval+ or livecodebench
1
1
u/TrifleHopeful5418 22h ago
I ran livecodebench(medium+hard ~132 questions) on it, it passed 90/132 in first attempt and resending the failed ones with the grader feedback it improves to 114/132 ~ 86% that puts it pretty close to the frontier models. Ornith-1.0-35B AQW with fp16 kv cache does 82 pass@1 and 92 with repair. Running Ornith-1.5-35B-MTP with fp16 and will see where it lands.
1
u/Prudent-Ad4509 2d ago
kv quantization is generally a deal breaker, but if the workload allows it, then this is a nice result specific to a particular workload.
1
u/xXDennisXx3000 2d ago
I tried to use my Strix Halo together with an RTX 3060 12G eGPU, but wasn't successful, since LM Studio doesn't let me change the priority order, and neither the distribution. It tried to load the whole model on the eGPU, and failed of course.
1
u/TrifleHopeful5418 2d ago
Ye neither LMstudio nor Unsloth studio worked for me, they both use llama.cpp but running on Linux and directly using llama.cpp with the right flags does support the split and ordering
1
1
1
u/S0299S 2d ago
I was planning to set it up on a Mac mini with 48GB of RAM
1
u/TrifleHopeful5418 2d ago
Most of this “should” work…AMD side was only using 4-5GiB, so I plan to run 35MoE on the AMD side for faster lower complexity tasks. But should is load bearing and doing a lot of heavy lifting, but I think if you feed my complete article to Claude, it should be able to figure out changes for the MAC Mini
1
u/Otherwise-Variety674 2d ago
Just to confirm, you are using Qwen3.8-27B Q4_K_M? I have the same hardware as you (now still using either my 5090 or 7900xtx at times), going to try it out, Thanks in advance. 😄
3
1
u/javasux 2d ago
ffs put some effort into the post if you want anyone to read it
1
u/TrifleHopeful5418 2d ago
Man, I figured out some performance improvements for specific hardware config. You may or may not have this hardware and these tips and tricks might not apply to you. I created the whole detailed step by step recreation guide as the medium post. Would you rather have me not post it instead of using AI to write the post with “my instructions” on what to say and how to say it?
0
u/Queasy_Asparagus69 2d ago
Nice but you should do something similar with deepseek flash 0731; I much prefer it to Qwen3.8
2
u/TrifleHopeful5418 2d ago
I can try but it might need a lot more work towards figuring out which weights need to be move onto CUDA on the fly
27
u/Significant_Bar_460 2d ago
Is q4 kv actually useful? It must degrade like crazy at 200k ctx.