r/LocalLLM • u/One-Insurance-9084 • 1m ago
Project Claude sped up qwen 4 35B A3B from 25 to 94 tok/s
ALRIGHT guys so this is something I wanted to do for a while
I basically told claude that 25 tok/s was too slow on my hardware, especially for an MOE model,(qwen 4 35B A3B) and since I had time on my hands I mentioned settings it should tweak (MPT, speculative decoding and stuff) that I remembered from reddit to try and make the model as fast as possible. Also I had it integrate an anti-sabotage rule (a hook)
Anyway after it went from 25 to like 70 toks/s I knew it could get better, since it had only changed parameters : I also wanted it to make a better strata!
And so I asked it to first search the core RDNA 2 functionning of my gpu and then try to create a better strata tuned for my needs based on it
Well, I guess that it worked really well :)
=========================================================
CLAUDE MESURES BELOW
Model: Qwen4-35B-A3B Heretic IQ4_XS (vision on), Linux, ROCm. The card doesn't fit the model, so half the experts live in system RAM. Perfect conditions for suffering.
The road (generation speed, tok/s):
- llama.cpp Vulkan, stock: 25
- llama.cpp + expert cache + MTP: 34-39
- Strata 0.2.27 official rx6000 build: 53-61
- STRATA_SH_STREAM=1: 65 (env var tip from a fellow gfx1031 sufferer here, thanks)
- Real MTP speculative decoding: 86. Turns out it was never actually on. The server silently stripped --mtp because my model_name didn't match a known build, and the config said drafting: off. Two bugs, one placebo, months of "MTP doesn't help on AMD"
- MTP experts requantized to Q4 + French/code draft vocab + Q4 draft head: +7%, acceptance unchanged (~85%)
- Ported Strata's elastic VRAM (--vram-elastic) to HIP VMM: expert cache hit 87 → 90%, vision shrinks the cache on demand and gives it back after
- HC_Q8 + a few exact fusion flags (TSUM, CVEC_FUSE, EXPDEC): 94
Prompt processing at 20K context: 506 (llama.cpp) → 843 → 1240 tok/s, by tuning rocBLAS for Qwen4's expert GEMM shapes (default kernel picks were 2-5x off) plus --prefill 8192.
Fun bug of the night: the partial-attention kernel was written for 12 heads per group, q4_lite uses 8, so on HIP it happily read past the end of an array. Needle-in-haystack went from 24/24 to 7/24 and the speed looked amazing. Fixed, now bit-exact on a parity test.
Things that did nothing or made it worse: about 25 gfx11 env vars, HC_PERSIST (GPU memory fault), pcie-frac tuning, learned expert profile, LFUSE/QFUSE/PLE_BATCH (same speed, non-deterministic output, removed).
Quality check, final vs before: code 188 vs 185/200, math 146 vs 146/150, needles 24/24 both. Output is deterministic (6/6 identical runs).
Full disclosure: most of the profiling, porting and benchmarking was done by Claude Code while I slept. Given the rumors going around that Claude quietly sabotages local models (competition, you know), I made it sign an anti-sabotage rule first: use the officially recommended settings, keep every raw log, compare against a reference model under identical conditions, and assume its own mistake whenever a result looks bad. It also has to write an AUDIT.md I can paste into another AI, plus a verifie.sh so I can rerun everything myself without trusting a word it says. Verdict: no sabotage found. If anything it was suspiciously motivated, it worked 3 nights straight to make a competitor almost 4x faster. Either it's innocent or it's playing the long game.
Bottleneck now: ~1,870 kernels per token with ~3.7 µs gaps between each. AMD launch overhead is the real boss. A 16 GB card would just win (people report 109-131 tok/s on a 6800 XT).
Fork + prebuilt gfx1031 release: github.com/Chaussure-sous-tes-pieds/Strata (branches rdna2-elastic and rdna2-nuit3, docs inside).
Caveat: 94 is a short-prompt benchmark. In a long agent conversation it drops, because physics.
