I put Fable on improving the performance of the new Qwen3.8-125B-A6B model. The results are very good. I wont pretend I understand any of this stuff, which is also why it isn't a PR in the official llama.cpp repo, but a fork. If anyone who can defend the changes want to do the PR, feel free to do so.
It is verified at 70k context with 23 tok/s for prose and around 30 for code.
Model: unsloth UD-Q3_K_XL
The rest of this message is Fables summary for you guys
First, credit where it's due: all of this is built on top of danielhanchen's (Unsloth) PR #27742, which is what added the qwen4exp architecture to llama.cpp in the first place — GDN linear attention, the sparse-attention indexer, the n-gram embeddings, all of it. That PR was merged into llama.cpp mainline yesterday (congrats!) — this branch is its final state plus a week of speculative-decoding fixes, a native MTP implementation, and kernel work on top. None of it exists without that foundation.
TL;DR — The 125B-A6B Flash-Next now runs at 50.4 tok/s decode on code (0.96 draft acceptance), ~24-31 tok/s deep reasoning at 50-73k context, and 338 tok/s prefill at 32k depth on one 128 GB Strix Halo box (Ryzen AI MAX+ 395, Vulkan/RADV). Session start was 23.5 tok/s shallow and 8.8 tok/s at 32k, so that's roughly 2.1x shallow, 2.7x deep, and 1.6x prefill. Everything is reproducible: branch + Dockerfile at https://github.com/apepojken/llama.cpp (default branch qwen4exp-spec-mtp, base = PR #27742), prebuilt MTP sidecar GGUF (4.1 GB Q8_0) at https://huggingface.co/jockevaupptaget/Qwen3.8-Flash-Next-MTP-GGUF
Part 1 — speculative decoding was broken, not useless. The "spec decoding doesn't help this arch" consensus came from seven stacked bugs, root-caused with a greedy identity oracle (at temp 0, speculative output must match plain decode byte-for-byte, so any state corruption shows up as a text diff). Highlights: qwen4exp was never whitelisted for the recurrent rollback ring, so every speculative step serialized the whole 125B recurrent state through host RAM (~750 ms fixed cost per step — that's the 6.5x slowdown people measured); the conv-state and SSM snapshot writes ignored or staled the ring banks so rollbacks fed the GDN layers corrupted state; the n-gram embedding history was rewound lossily; and draft sidecar files never actually loaded (a path bug loaded the main model twice). All fixed, all documented in the commits.
Part 2 — the model's own MTP head, implemented natively. The official checkpoint ships a 4B multi-token-prediction head that public GGUFs simply strip. Re-enabled the converter export (--mtp flag, remaps the mtp.* tensors) and implemented the head in llama.cpp: one full transformer layer with its own hyper-connection combiner reading the backbone's 4-stream hidden state. The combiner variant matters a lot — keeping the streams distinct measures 0.87-0.96 acceptance vs 0.47 for the naive mean, which is why this implementation drafts 6 deep at ~0.9 acceptance on code (n-max 6 is the sweet spot; the Vulkan mat-vec shaders take at most 8 batched columns, so verify batches of n-max+1 must stay ≤8 or every matmul falls off a 2.7x cliff — measured 83→225 ms per eval).
Part 3 — the depth falloff, killed in layers. Plain decode used to fall from 23.5 to 8.8 tok/s by 32k. Fixes, in order: the sparse-attention indexer's top-k ran on the CPU past 1024 columns (first routed through GPU argsort, later replaced by a proper radix-selection kernel — 4-pass 8-bit radix select, one workgroup per row, exact k with tie handling, passes test-backend-ops up to k=9999 over 524k columns); the QSA and PLE graph inputs never implemented can_reuse so every token rebuilt the whole compute graph; the indexer recomputed every block summary key over the whole context every token in all 12 QSA layers — now an incremental pooled-key cache (complete 4-token blocks are immutable, so summaries are write-once with a per-sequence watermark that makes speculative rollback free) worth +17% at 32k alone; and past 32k context, decode attention now gathers exactly the ~2300 selected KV rows instead of running dense attention with a mask (ported from EngramHalo.cpp — credit Aristo94, whose ROCm work independently found several of the same bottlenecks).
Part 4 — kernel fusion and prefill. Decode was launch-gap-bound (~3550 kernel dispatches per token), so the Vulkan mat-vec shaders got fused elementwise epilogs (scale/SiLU/sigmoid/multiply applied at the write-back — the hyper-connection chains collapse from 3-4 dispatches to 1) plus a fused REPEAT+MUL+ADD kernel for the residual scatter: 3550 → ~2800 dispatches per token, all output-identical. Prefill at depth got: `-ub 2048` (+10%), the radix top-k (the old workaround full-sorted 2048 rows × context-width per layer per chunk), a 17x-slower-than-necessary non-contiguous concat in the GDN conv path (463 → 26 ms per chunk), the skinny m=4 inject matmul rerouted off the tiled-MM path (77 → 287 GFLOPS), and a permute-free rewrite of the indexer scoring. Deep prefill went ~215 → 338 tok/s at 32k. Fun finding along the way: llama.cpp's Vulkan flash attention already skips fully-masked tiles via a mask pre-scan, so "sparse prefill attention" was already there — profile before you build.
Real-world evidence, not just benchmarks: a live 73,035-token conversation reloads (full re-prefill) in 291 s at 250 tok/s average, then decodes at 23.3 tok/s at 73k depth on dense thinking prose (draft acceptance 0.65 — the hardest content for any drafter) with spikes to 27+, and 50.4 tok/s at 0.963 acceptance on code. A 19,400-token single response and a 75,226-token session both completed with zero errors, zero truncation, and byte-clean state handling across hundreds of speculative rollbacks. Greedy outputs are verified identical (or within the measured kernel-order noise floor) against the unfused/uncached paths at every step, and every optimization has an env kill-switch for A/B.
Reproduce it: git clone https://github.com/apepojken/llama.cpp && cd llama.cpp && docker build -t qwen4exp-llama . && docker run --device /dev/dri -p 8095:8095 -v /path/to/models:/models qwen4exp-llama
The Dockerfile bakes in the recommended flags (--flash-attn on -ub 2048 -c 262144 --cache-type-k q8_0 --cache-type-v q8_0 --spec-type draft-mtp --spec-draft-n-max 6 --spec-draft-p-min 0.75). Model: unsloth UD-Q3_K_XL shards + the MTP sidecar above. Caveats: n=1 machine, single-slot serving only (--parallel 1), and ROCm measured slower than Vulkan/RADV at every depth on this box. The base PR merged upstream on Aug 27, so a rebase onto mainline (and upstreaming the generic pieces — the radix top-k, the fused kernels, the concat fix) is the natural next step.
Credits: danielhanchen/Unsloth for PR #27742 (the entire qwen4exp architecture this builds on) and the llama.cpp maintainers, the Qwen team (MTP reference implementation), Aristo94/EngramHalo.cpp (gathered-attention idea and the HIP radix top-k this Vulkan kernel is ported from), kyuz0's toolboxes, and the r/StrixHalo thread that kicked all of this off.