Skip to content

spec, qwen4exp, delta-net : faster prompt processing with an MTP draft loaded - #255

Merged
dzannotti merged 4 commits into
masterfrom
hb/mtp-prefill
Nov 26, 2026
Merged

dzannotti merged 4 commits into
masterfrom
hb/mtp-prefill

Conversation

@Nathanw1014

@Nathanw1014 Nathanw1014 commented Nov 5, 2026 •

Copy link
Copy Markdown

With an MTP draft loaded, prompt processing on qwen4exp is 16 to 18% faster on Vulkan (Strix Halo, Qwen3.8-Flash-Next UD-Q4_K_XL + shared Q4_K_M MTP).

  • spec : MTP keeps only the carry row of a prompt batch on the host path (no row copy for rows that are never accepted against)
  • qwen4exp : MTP eh_proj as one 2D GEMM over all streams and tokens
  • delta-net : a ubatch wider than n_rs_seq + 1 tokens per sequence runs the plain scan and stores only the final state. The memory refuses a partial rollback after such a ubatch (rs_max), so the other snapshot slots are never read. Suggested by @dzannotti.

No change without a draft (n_rs_seq = 0): same logits and token ids as master.

Tested: ctest -L main on Vulkan and ROCm, test-backend-ops CONCAT_SSM_CONV_SILU / SSM_CONV / CONCAT / GATED_DELTA_NET on Vulkan. Not tested: -np > 1, other delta-net models with a draft, GPUs other than gfx1151.

AI usage: ASSISTED. Written with Claude, tested by me.

🤖 Generated with Claude Code

@rcfa

rcfa commented Nov 7, 2026

Copy link
Copy Markdown

This PR with 4 slots (-np 4 -kvu) on gfx1150

The PR lists more than one sequence and GPUs other than gfx1151 as not verified, so we ran it at our production
shape. The machine is a Radeon 890M (Strix Point, gfx1150), not Strix Halo.

Device:     Ryzen AI 9 HX PRO 370 / Radeon 890M (gfx1150) / Minisforum N5 PRO, 96 GB DDR5-5600, UMA 48 GB
Kernel:     7.2.15+kali-amd64, amdgpu.gttsize=73728 ttm.pages_limit=8650752; Vulkan RADV, Mesa 26.1.6
Build:      -DGGML_VULKAN=ON -DLLAMA_CURL=OFF -DCMAKE_BUILD_TYPE=Release (gcc 16.2)
Baseline:   master 62a3f4144 (M)
Change:     62a3f4144 + this PR (d20804564), merged locally without conflicts (N); same worktree, separate bin dirs
Model:      ISTA-DASLab/Qwen3.8-Flash-Next-GSQ-RCO-GGUF IQ3_XXS + mtp-Qwen3.8-Flash-Next-shared-Q4_K_M (Unsloth)

GGML_VK_MMV_NO_SPLIT=1 llama-server -m IQ3_XXS -ngl 99 --load-mode none --lazy-mode on-direct -c 524288 -np 4 -kvu --cache-ram 0 -ub 2048 -ctk f16 -ctv f16 --mmproj mmproj-F16 --spec-type draft-mtp -md mtp-shared-Q4_K_M -ngld 99 --spec-draft-n-max 2

Method:

  • One fresh server per cell, in the order N, M, N.
  • Each server got a warm-up, then one cold prompt of 16384 tokens and one of 32768. The prompts were fixed token
    sequences of English text, sent to /completion with cache_prompt false and n_predict 1. The figure is
    timings.prompt_per_second.
prompt master this PR (1st / 2nd server) change
16384 268.4 280.8 / 279.4 +4.4%
32768 266.4 272.3 / 275.6 +2.8%

Without the draft (--no-mtp), this PR gave 328.3 t/s at 16384 and 303.7 at 32768. Master gave 329.0 at 16384
earlier the same day, so AR is unchanged, as you said. With the draft, the 64 greedy tokens after the 16k prompt
differ from the no-draft stream from the first token on, on master and on this PR alike.

One observation, not chased down. Earlier the same day, on the same machine and shape, we had measured two local
changes of our own that each do one of your parts:

At 16384 tokens:

build with MTP, t/s MTP's cost of prefill
master 269.6 18.1%
our split alone 293.5 10.8%
our eh_proj change alone 282.2 14.6%
this PR 280.1 (mean of the two) 14.5%

So at -np 4 -kvu this PR gains about what the eh_proj change alone gives here, and our split alone gained more. We
did not check with GGML_VK_PERF_LOGGER whether your scan split engages at -np 4. With one prompt in flight,
n_seqs should be 1, so we may be missing something. The first three rows are single runs. We are not proposing
our versions; this is only a pointer in case the split is skipped here.

Written by Claude Code (an AI agent), run on rcfa's Strix Point machine; rcfa owns it.

@dzannotti dzannotti mentioned this pull request Nov 10, 2026
@dzannotti dzannotti added in-review We are reviewing. verifying Building and running the PR to verify its claims. and removed in-review We are reviewing. labels Nov 11, 2026

@dzannotti dzannotti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict

Changes requested. Target correctness holds on both backends, but with the PR merged into current master the delta-net part gives about +5% prompt speed on ROCm and nothing on Vulkan. On Vulkan the conv split also makes the backend reject its direct conv fold.

Direction

Accept after work. We want the prompt-speed win with an MTP draft. The eh_proj GEMM is small and self-contained. The scan and conv split should live in qwen4exp.cpp, not in the shared delta-net base, and it needs numbers on current master for both backends.

Asks

  1. Blocking. src/models/qwen4exp.cpp:2844 (build_conv_state_split). The first part's conv input is a prefix view of qkv_mixed, so the Vulkan direct conv matcher rejects it ("x layout": 576 rejections in one 2048-token llama-bench run on head, none on master). The HIP gdn_conv matcher has the same nelements(x) == C*T*S check. Make part 0 a whole tensor that the matchers accept, or drop commit 4, and show a Vulkan prefill gain on current master. Please also say which commit gives the +4.6% in the description: without a draft, the two delta-net commits do not speed up Vulkan prefill on either base (table below).
  2. Blocking. src/models/delta-net-base.cpp:526-632, src/models/models.h:93-114. The split adds 73 lines, a std::pair out-param and a std::function callback to an upstream method, for one model. llama_model_qwen4exp::graph already derives from llm_build_delta_net_base, so build the split in qwen4exp.cpp as straight-line code and leave the upstream file and struct as they are. This also removes the unreachable !part1_qkv branches and the SCALE(RMS_NORM) re-application in slice_tokens (only qwen4exp calls the split, and it always passes part1_qkv).
  3. Should fix. common/speculative.cpp:1838 and qwen4exp.cpp:2094. Width (n_all <= n_max + 1, n_seq_tokens > K) is not a prompt test. With --spec-type draft-mtp,ngram-mod an ngram verify batch is wider than n_max + 1, and MTP's accept(is_other = true) then takes the last row instead of row n_accepted. With --spec-n-rs-seq below the draft n_max, verify batches also take the graph split. Use the per-row output flags (a prompt batch outputs only its last row). One draft-mtp,ngram-mod run on Qwen3.8-27B per backend gave the same acceptance on base and head, so this is from reading the code.
  4. Should fix. qwen4exp.cpp:1079-1118. build_norm_gated_parts copies the fast-path condition and the static pad of build_norm_gated. Use one shared helper so that the two paths cannot drift.
  5. Should fix. No test reaches the split. case_rollback in tests/llama-context/cases-rs.cpp decodes n_rs_seq + 1 tokens, which is never wider than K. Decode n_rs_seq + 1 + 16 tokens in one ubatch there and compare the replay against an unsplit run.

Nits: the (size_t) 0 - c1->view_offs view is legal but hard to read; the split path drops the cb() names of the other paths; the comments with ms and MB figures belong in the commit messages.

Correctness

PASS for target output. AR (no slots) final logits and token ids are byte-identical base vs head on qwen4exp and qwen35, both backends. With rollback slots forced (n_rs_seq 3), qwen4exp KLD head vs master is 0.0019 (Vulkan) and 0.0024 (ROCm), below the A/A floor of 0.0021 and 0.0026, and head is as close to the AR run as master (0.0017 vs 0.0020 Vulkan, 0.0025 vs 0.0024 ROCm). qwen35 (Qwen3.8-27B with its MTP head) gives byte-identical logits with slots and identical greedy streams and acceptance with --spec-type draft-mtp, both backends. On a small random qwen4exp, a prompt reused after dropping 1-3 tokens (restored from the rollback slots) gives the same tokens and top-5 log-probs as a fresh run, base and head. ROCm results are the same with HIP_LAUNCH_BLOCKING=1. Not run: a qwen4exp target with its MTP draft (see Not tested), so the eh_proj change and the draft acceptance are not verified.

Performance

Qwen3.8-Flash-Next (qwen4exp) TQ2_0, no draft loaded, rollback slots forced to n_rs_seq 3 (the target side of --spec-draft-n-max 3), llama-bench -ub 2048, 2 rounds x 3 reps, base and head alternated:

backend prompt master t/s head t/s change
Vulkan 512 825.9 +- 6 826.3 +- 7 +0.0%
Vulkan 2048 1089.1 +- 25 1084.3 +- 26 -0.4%
Vulkan 8192 1037.2 +- 2 1033.8 +- 3 -0.3%
ROCm 512 807.7 +- 6 820.7 +- 3 +1.6%
ROCm 2048 986.0 +- 13 1037.1 +- 9 +5.2%
ROCm 8192 944.4 +- 1 992.2 +- 1 +5.1%

AR without slots is unchanged (2048: Vulkan 1158 vs 1150, ROCm 1123 vs 1126, within stddev). On Vulkan, slots still cost about 6% at 2048 on head, so the split does not recover what it targets there. On the PR's own base (ea5285d vs d208045), Vulkan with slots goes from 1048 to 1029 t/s at 2048 (-1.9%) and from 979 to 965 t/s at 8192 (-1.4%, stddev about 1.5). There, slots cost master almost nothing (AR 1052 t/s), so the +4.6% in the description probably comes from the draft side (eh_proj and the carry row), which we could not test.

Verification

Strix Halo (gfx1151), Vulkan (RADV) and ROCm. We compared the PR merged into master 50c2c8c (the PR was 78 commits behind) against master.

Not tested

The qwen4exp target with the MTP draft: target, draft, KV and compute buffers do not fit our memory budget, so the eh_proj GEMM, the carry-row change on qwen4exp, draft acceptance and end-to-end decode t/s are untested. Also not tested: -np 4, contexts above 8192 on qwen4exp, the server pytest suite (not installed).

Thanks for the detailed write-up and the split commits.

Review made with AI on behalf of the strix-llama.cpp maintainers.

Full verification (for reproduction and agents)

Environment

  • Ubuntu 26.04.1, kernel 7.0.0-43-generic, Strix Halo (gfx1151, Radeon 8060S), 128 GB unified memory.
  • ROCm 10.1 (hipconfig 7.16.26385), AMD clang 24.0.0git d6f6cb69.
  • Mesa RADV 26.0.8.
  • cmake 4.2.3, gcc 15.2.0, Ninja.

Compared

  • master tip: 50c2c8c (50c2c8cb522e6c5e0532939db52785a2977a9440). Master later moved to 093c552 (CI workflow files only).
  • PR head: d208045 (d208045642003bbe35088f52eb9aae7e6fa77865).
  • merged (PR merged into master, local only, clean merge): c9b7b3a41.
  • merge base: ea5285d. The PR was 78 commits behind master.
  • Extra Vulkan check on the PR's own base: ea5285d vs d208045.

Build

Vulkan: cmake -S <tree> -B <tree>/build-vk -DGGML_VULKAN=ON -DGGML_HIP=OFF -DCMAKE_BUILD_TYPE=Release -G Ninja
ROCm:   cmake -S <tree> -B <tree>/build-hip -DGGML_HIP=ON -DGGML_VULKAN=OFF -DGPU_TARGETS=gfx1151 \
          -DCMAKE_HIP_COMPILER=$(hipconfig -l)/clang -DCMAKE_PREFIX_PATH=$(hipconfig -R) -DCMAKE_BUILD_TYPE=Release -G Ninja
cmake --build <tree>/build-<be> -j

No HIP source changed, so no -Werror HIP build and no VGPR spill gate.

Models

model arch sha256
Qwen3.8-Flash-Next TQ2_0 (176.9 B params, 85.6 GiB), agentionai/Qwen3.8-Flash-Next-Gyro-GGUF qwen4exp 7aa36d15131d255179ab6c87fa9c9f81a0b541fc9e81e959d4c3e29eb20feb5f
Qwen3.8-27B UD-Q4_K_XL (with its MTP head) qwen35 3f227079003add2511437e5b1e94812e363385225bf6a9b47b0054a72bc8b01e
random tiny qwen4exp MoE from test-llama-archs -a qwen4exp -o <dir> (default seed) qwen4exp 433fb2d994f1005c...

Corpora (tests/corpus, sha256 prefixes): code dec1127ae75ffa56, numeric d9f08d9470e53ef6, prose c90398f2e2885f20, structured c21947b360bea62d.

Rollback slots without a draft: a small LD_PRELOAD shim wraps llama_init_from_model and sets params.n_rs_seq = 3. That is the target context that --spec-type draft-mtp --spec-draft-n-max 3 creates; the log prints n_rs_seq = 3. We used it for llama-debug, llama-perplexity, llama-bench and llama-server (tiny model). We did not load the qwen4exp MTP draft. With the 85.6 GiB target, draft, KV and compute buffers, it does not fit our memory budget.

Commands

# unit, both sides, both backends
ctest --test-dir <build> --output-on-failure -L main -E 'test-opt|test-llama-archs'
ctest --test-dir <build> -R 'spec-mtp-pcum|draft-vocab'
test-llama-archs -b <dev> -a qwen4exp ; test-llama-archs -b <dev> -a qwen35
test-backend-ops test -b <dev> -o GATED_DELTA_NET ; -o SSM_CONV
test-vk-exact                                    # Vulkan only
test-llama-context -m <tiny qwen4exp> ; -m <tiny qwen35> ; -m <Qwen3.8-27B>

# logits + token ids (llama-debug), AR and with slots (shim)
llama-debug -m <model> -f correctness-<t>.txt -c 16384 -b 16384 -ub <512|2048> -ngl <99|0> -fa on -ctk f16 -ctv f16 \
  --save-logits --logits-output-dir <dir>
#   Qwen3.8-27B: -ub 512, AR on code, slots on code + prose. tiny qwen4exp: -ub 512, all 4 corpora, AR + slots, -ngl 99 and 0.

# KLD/PPL, qwen4exp TQ2_0, code corpus
llama-perplexity -m <model> -f correctness-code.txt -c 2048 -b 512 -ub 512 -ngl 99 -fa on -ctk f16 -ctv f16 --kl-divergence-base <side-mode>.kld
llama-perplexity -m <model> -c 2048 -b 512 -ub 512 ... --kl-divergence-base <ref>.kld --kl-divergence
#   floor: base AR scored with -ub 256 against base AR -ub 512

# greedy decode with the draft, Qwen3.8-27B, fresh server per side, base/head/head/base
llama-server -m <27B> --spec-type draft-mtp --spec-draft-n-max 3 -ngl 99 -fa on -ctk f16 -ctv f16 -np 1 -c 16384 -b 2048 -ub 512
#   /completion, token-id prompts = first 2000 tokens of code / prose / structured, n_predict 256, temperature 0, top_k 1,
#   ignore_eos, cache_prompt false, each prompt twice per server
# same with --spec-type draft-mtp,ngram-mod on a repetitive code prompt (1899 tokens), 2 requests

# rollback restore, tiny qwen4exp, server with n_rs_seq 3 (shim) and without
llama-server -m <tiny> -ngl 99 -fa on -ctk f16 -ctv f16 -np 1 -c 256 -b 256 -ub 64
#   P = first 200 tokens of prose; send P (cache_prompt true), then Q = P with token n-d changed (d = 1, 2, 3, 5),
#   n_predict 8, n_probs 5, cache_prompt true (reuse); then Q again with cache_prompt false (fresh); compare

# prefill, qwen4exp TQ2_0, no draft, slots (shim), base/head alternated, 2 rounds
llama-bench -m <model> -p 512,2048,8192 -n 0 -b 2048 -ub 2048 -r 3 -ngl 99 -fa on -ctk f16 -ctv f16 -o jsonl
llama-bench -m <model> -p 2048 -n 0 ... -r 3          # AR, no shim, once per side
GGML_VK_FUSION_DEBUG=1 llama-bench -m <model> -p 2048 -n 0 -r 1 ...   # Vulkan fold check, slots on

ROCm: correctness ran twice, with HIP_LAUNCH_BLOCKING unset and =1 (tiny logits + restore, 27B logits, qwen4exp KLD). Benchmarks with it unset. A memory guard stopped any run above 89 GiB of GPU memory; peak was 37 GiB GTT plus the mapped model, and system MemAvailable stayed above 32 GiB.

Results

Unit tests (both backends, base and head the same): ctest -L main 63/65 on both sides, with the same 2 failures on base and head (test-tokenizers-ggml-vocabs, and test-llama-context, which aborts when ctest runs it without a model). Spec ctest 2/2. test-llama-archs qwen4exp and qwen35 OK on both sides. GATED_DELTA_NET and SSM_CONV OK on both sides. test-vk-exact: the same 11 failing checks on base and head. test-llama-context: tiny qwen4exp and qwen35 pass on both sides; Qwen3.8-27B fails the same rollback case (replay nmse 1.1e-5) on base and head.

llama-debug (final logits + token ids, cmp):

model mode corpora Vulkan base vs head ROCm base vs head ROCm HLB=1
Qwen3.8-27B AR code identical identical identical
Qwen3.8-27B slots code, prose identical identical identical (code)
tiny qwen4exp AR all 4 identical identical identical
tiny qwen4exp slots all 4 max abs diff up to 3e-8 (logits about 0.1), same argmax same same
qwen4exp TQ2_0 AR (.kld) code identical identical identical

On the tiny model, LLAMA_FUSED_GDN_CH=0 and LLAMA_GDN_NORM_PAD=0 with slots run without error on head; the logits are within 1.1e-8 of the default path.

KLD, qwen4exp TQ2_0, code corpus, -c 2048 -b 512 -ub 512:

comparison Vulkan Mean KLD Vulkan same top p ROCm Mean KLD ROCm same top p
head slots vs base slots 0.001913 99.238 % 0.002395 98.749 %
head slots vs base AR 0.001722 99.120 % 0.002460 98.866 %
base slots vs base AR 0.001961 99.101 % 0.002433 98.866 %
A/A floor (base AR -ub 256 vs -ub 512) 0.002142 98.944 % 0.002592 98.807 %

PPL (code, 2048): Vulkan AR 1.8113 on both sides, base slots 1.8122, head slots 1.8108; ROCm AR 1.8131 on both sides, base slots 1.8135, head slots 1.8100 (all +- 0.042). ROCm with HIP_LAUNCH_BLOCKING=1 gave the same KLD values.

Greedy decode with --spec-type draft-mtp --spec-draft-n-max 3, Qwen3.8-27B (sha256 of the generated token ids, accepted / drafted, t/s mean of 8 requests per side):

backend prompt base head
Vulkan code 723c75598b49ed02, 185 / 207, 32.1 same stream, 185 / 207, 32.1
Vulkan prose 102702665186b035, 168 / 261, 25.9 same stream, 168 / 261, 25.9
Vulkan structured f054b3b44df5e774, 175 / 235, 28.2 same stream, 175 / 235, 28.2
ROCm code 723c75598b49ed02, 185 / 207, 28.1 same stream, 185 / 207, 28.1
ROCm prose 29442c48b347f293, 170 / 254, 23.2 same stream, 170 / 254, 23.2
ROCm structured b8b370ba9d646069, 177 / 234, 25.2 same stream, 177 / 234, 25.2

Every stream was the same in both rounds and both requests per server.

--spec-type draft-mtp,ngram-mod, Qwen3.8-27B, repetitive code prompt: both requests give the same stream on base and head, acceptance 194 / 432 and 243 / 390 (mean draft length 31.4 on the second request), on both backends.

Rollback restore, tiny qwen4exp, d = 1, 2, 3 (restored from the slots, 4 prompt tokens processed) and d = 5 (68 tokens reprocessed): reuse and fresh runs give the same 8 tokens and the same top-5 log-probs on base and head, with and without slots, Vulkan and ROCm (both HIP_LAUNCH_BLOCKING settings).

Vulkan fold check (GGML_VK_FUSION_DEBUG=1, one 2048-token run with slots): master logs 8 direct ssm conv not matched: state layout. Head logs the same 8 plus 576 x layout and 504 concat srcs are not (state, transpose(x)).

Performance

Prefill t/s, qwen4exp TQ2_0, no draft, slots n_rs_seq 3, -b 2048 -ub 2048, llama-bench -r 3 (avg +- stddev per round):

backend prompt base r1 base r2 head r1 head r2 change
Vulkan 512 828.1 +- 6.9 823.6 +- 3.0 821.0 +- 6.0 831.5 +- 1.6 +0.0%
Vulkan 2048 1090.0 +- 25.7 1088.2 +- 24.9 1083.8 +- 27.7 1084.8 +- 25.1 -0.4%
Vulkan 8192 1038.9 +- 1.5 1035.4 +- 1.2 1035.5 +- 2.1 1032.0 +- 3.0 -0.3%
ROCm 512 804.8 +- 1.6 810.5 +- 7.8 820.8 +- 2.6 820.5 +- 3.9 +1.6%
ROCm 2048 985.9 +- 12.0 986.1 +- 13.2 1038.4 +- 10.1 1035.7 +- 7.1 +5.2%
ROCm 8192 945.0 +- 0.7 943.8 +- 0.2 992.9 +- 0.4 991.5 +- 0.4 +5.1%

AR (no slots), 2048: Vulkan 1158.4 +- 35.6 (base) vs 1150.1 +- 43.0 (head); ROCm 1123.0 +- 23.0 vs 1125.7 +- 22.7.

PR on its own base, Vulkan, slots: 2048 1051.4 +- 30.1 / 1045.0 +- 28.5 (merge base) vs 1029.7 +- 25.8 / 1027.8 +- 24.4 (PR head), -1.9%; 8192 982.0 +- 1.2 / 975.5 +- 1.1 vs 964.9 +- 1.7 / 964.3 +- 1.3, -1.4%. AR 2048: 1052.1 +- 27.0 vs 1052.5 +- 26.4.

Findings in full

  1. Blocking: the conv split makes the first part's conv input a prefix view of qkv_mixed. The Vulkan matcher ggml_vk_ssm_conv_direct_check resolves x = transpose->view_src and requires ggml_nelements(x) == C*T*S; for part 0, x is the whole qkv_mixed while T = t, so it fails with "x layout". The tail concat fails earlier (view_offs != 0). The HIP matcher in conv-tail.cuh has the same element-count check. The fold check above confirms it on Vulkan. The commit 4 message says part 0 is "the same graph as an unsplit ubatch"; at the matcher level it is not.
  2. Blocking: delta-net-base.cpp is upstream code (3 lines of difference from the last sync before this PR). The PR changes the signature of build_recurrent_attn in the upstream llm_build_delta_net_base, adds slice_tokens, a parts out-param, a std::function callback and a nullptr return. Only qwen4exp.cpp passes parts; the six other callers (qwen35, qwen35moe, qwen3next, kimi-k3, glm5-next, bailingmoe3) build the same graph as before. Upstream changes this function often, so each change becomes a manual conflict. qwen4exp.cpp is also upstream code; the PR moves its conv / q / k / v block into a lambda, which moves upstream lines too.
  3. Should fix: i_beg = n_all <= n_max + 1 ? 0 : n_all - 1 classifies by width. common_speculative_accept also calls the MTP accept(..., is_other = true) after another drafter's verify, and MTP reads verify_h[min(n_accepted, n_rows - 1)]. A verify batch from ngram-mod (its n_max defaults to 64) is wider than MTP's n_max + 1, so only the last row stays and MTP pairs the wrong hidden row. The graph split uses the same kind of width test (n_seq_tokens > n_rs_seq + 1), so with --spec-n-rs-seq below the draft n_max every verify batch takes the split and pays one more GDN dispatch, conv, cont and two-part norm per layer.
  4. Should fix: build_norm_gated_parts repeats the fast-path condition of build_norm_gated and a second static const pad.
  5. Should fix: no test reaches the split (see Asks).
  6. Nits: (size_t) 0 - c1->view_offs (legal: ggml folds the view to buf at offset 0); missing cb() names on the split path; long comments with ms / MB figures. On Vulkan the K=1 chunked scan starts at 64 tokens and on ROCm at 256, so a split with a shorter first part only adds dispatches.
  7. Info: going by the batch-split code, the split should also engage at -np 4 when one prompt is in flight (n_seqs == 1). Not measured.

Claims

claim result
Carry row only after a prompt batch Not tested on qwen4exp. Code-reviewed: the dropped rows are never read in an MTP-only setup; see finding 3 for mixed drafters. Qwen3.8-27B streams and acceptance unchanged.
eh_proj as one GEMM Not tested (no qwen4exp draft run). Code-reviewed: the reshape is legal and the target graph is unchanged.
Rollback-slot scan split speeds up prompt processing ROCm: reproduced, +5.2% at 2048 and +5.1% at 8192 with slots (no draft). Vulkan: not reproduced, -0.4% / -0.3% merged into master, -1.9% / -1.4% on the PR's own base.
Conv split: part 0 is the same graph as an unsplit ubatch, which the backends fold Not reproduced: the Vulkan direct conv fold is rejected on head.
Slots get the same K states Consistent with our results: restore after 1-3 dropped tokens equals a fresh run on the tiny model; KLD with slots within the A/A floor on qwen4exp.
AR serving unchanged Reproduced: AR logits byte-identical and AR prefill unchanged, both backends.
Other delta-net models unchanged Reproduced for qwen35: byte-identical logits with slots and identical draft streams.
+4.0 to +4.6% client prefill with an MTP draft Not tested (no qwen4exp draft run).

Not tested

  • Any run with the qwen4exp MTP draft. With the 85.6 GiB target, draft, KV and compute buffers, it does not fit our memory budget. So the eh_proj change, MTP acceptance on qwen4exp, end-to-end decode t/s and TTFT are untested.
  • qwen4exp contexts above 8192 tokens (memory budget), -np 4, small -ub timing, the long KLD case.
  • The server pytest suite (not installed).
  • GPUs other than gfx1151.

@dzannotti dzannotti added risk:medium Risk: medium waiting-user We asked the author for something. and removed verifying Building and running the PR to verify its claims. labels Nov 12, 2026
@neavra

neavra commented Nov 12, 2026

Copy link
Copy Markdown

I ran into the same problem on a Strix Halo last week, before I had seen this PR: load the MTP draft and prompt
processing drops by about 30 %, with the time going into the gated delta-net op in the target graph rather than
into the draft itself. I traced it to the rollback snapshots forcing the per-token kernel, which is the cause this
PR fixes, and ended up with a different fix for it. The review notes it could not run the PR with the draft
loaded. I can, so here are ROCm prefill numbers with the draft on, this PR rebased onto current master, and after
that a description of the other fix, since it may be relevant to the review's asks.

Setup first.

Device:     Ryzen AI Max+ 395 mini PC, 128 GB LPDDR5X-8000
Power:      firmware default, ~84 W sustained
BIOS:       UMA 2 GB (GTT for the rest)
Kernel:     7.2.13-200.fc44.x86_64, amdgpu.gttsize=126976 ttm.pages_limit=32505856 amd_iommu=off
Backend:    ROCm 7.1.1 (Fedora 44 packages, HIP clang 7.1.52802), HSA_OVERRIDE_GFX_VERSION=11.5.1
Build:      -DGGML_HIP=ON -DGPU_TARGETS=gfx1151 -DGGML_NATIVE=ON -DCMAKE_BUILD_TYPE=Release
Baseline:   master 093c552d7 (merge-base, same session)
Change:     this PR rebased on it (32acfd89d locally, clean rebase)
Model:      unsloth/Qwen3.8-Flash-Next-GGUF UD-IQ4_XS + mtp-Qwen3.8-Flash-Next-shared-Q8_0.gguf
Server:     -ngl 999 -fa on -ctk f16 -ctv f16 --load-mode none --lazy-mode on-direct -np 1 -c 33792
            --spec-type draft-mtp --spec-draft-n-max 3 (-b/-ub per table)

One fresh llama-server per cell, master and PR alternated (base, PR, PR, base), 2 requests per prompt size per
server. The prompt is the first N token ids of tests/corpus/correctness-prose.txt, with the four corpora tiled to
reach 32k, sent to /completion with n_predict 1 and cache_prompt false. tok/s is N over client wall time; the
server's prompt_per_second agrees within 1 %. Mean [min-max], 4 samples per cell.

-b/-ub 2048 master this PR change
2048 1038 [842-1197] 1063 [957-1146] +2 %
8192 977 [971-984] 1131 [1113-1157] +16 %
32768 931 [929-932] 1097 [1094-1099] +18 %
-b/-ub 16384 master this PR change
8192 991 [928-1063] 1199 [1065-1325] +21 %
32768 1056 [1038-1074] 1294 [1259-1326] +23 %

So with the draft loaded the PR is worth +16 % to +23 % here at 8k and above. The 2048 row is dominated by the first
request after load and its ranges overlap, so I would not read anything into it. This is a good deal more than the
+5 % in the review, but the setups differ in several ways (draft actually loaded rather than slots forced, UD-IQ4_XS
rather than TQ2_0, ROCm 7.1 rather than 10.1), so I do not think the two numbers contradict each other. On this box
the prompt tax with a draft loaded is large, around 30 %, and the PR recovers most of it.

Decode, -c 16384 -b 1024 -ub 1024, 256 greedy tokens after a 7.6k-token chat prompt, 3 prompts x 3 reps x 2
servers per arm: master 37.2 to 39.2 tok/s, this PR 36.4 to 41.0, within each other's spread. As you say in the
write-up, the greedy streams with a draft differ from master once the prompt goes through the chunked scan, so I am
not treating decode as a speed result either way.

Now the other approach. The mechanism, for completeness: with a draft loaded the recurrent cache keeps
n_rs_seq + 1 snapshot slots, every GDN op asks for them across its whole ubatch, and the chunked kernel only
handles K = 1, so prompts drop to the per-token path. Instead of splitting the scan inside the graph I split the
batch. Rollback can only ever reach the last n_rs_seq tokens of a sequence, so split_equal()
now hands the last n_rs_seq + 1 tokens of a sequence that ends inside a long ubatch back as their own small
ubatch. A long single-sequence ubatch is then never the tail of anything, and the graph builder gives it the plain
K = 1 path, which is the exact same graph as serving without a draft. Only the small tail ubatch and the verify
ubatches write snapshots. It is 37 lines, 17 of them in src/llama-batch.cpp, the rest a predicate in
llama-graph.h and three one-line conditions in the model code. Not model-specific, and LLAMA_RS_TAIL_CUT=0 turns
it off. Branch halo/pr-rs-tail-cut on nbitslabs/strix-llama.cpp, commit b8bd7e4 on 093c552d7.

Why I think it is worth a look given the review: because the long ubatch builds the unmodified graph, there is no
new view for the Vulkan or HIP conv matchers to reject (ask 1), and nothing moves in the shared delta-net code
beyond two one-line conditions (ask 2), although the 17 lines in split_equal() are of course upstream code too.
On ask 3, the graph side is also a width test, but it is the splitter's own condition (single sequence, at least
n_rs_seq + 257 tokens), so a verify batch from another drafter only reaches it with n_max of 256 or more, and
then the splitter cuts its tail as well. What it does share with the existing code is the assumption that the
snapshots that matter are the ones written by the ubatch that ends the sequence; the TODO in cases-rs.cpp says the
same thing. The test in ask 5 would exercise exactly that, and I would add it. On the same protocol as above it came
out a few percent ahead of this PR on prefill, with the PR's carry-row and eh_proj commits on top of it making no
measurable difference; I can post that table if useful, I left it out here to keep this about the PR.

Not verified: Vulkan at all; -np > 1 (the cut needs one sequence per ubatch, which split_equal gives a single
in-flight prompt, but I have not measured it); other delta-net models.

If the batch-side fix is useful I can open it as its own PR with the test, or as commits on this branch, whichever
you prefer. If the in-graph split is the better fit for a reason I am missing, say so and I will drop it.

AI usage: the branch, the benchmark scripts and this comment were produced by an AI agent (Claude Fable 5.1) under my
direction, on my box.

@Nathanw1014 Nathanw1014 changed the title spec, qwen4exp : faster prompt processing with an MTP draft loaded spec, qwen4exp, vulkan : faster prompt processing with an MTP draft loaded Nov 14, 2026
@Nathanw1014

Copy link
Copy Markdown
Author

Thanks for the review, and to @neavra for the ROCm numbers with the draft loaded.

@neavra, on your question: we keep the in-graph split here. Its first part builds the same conv and plain-scan graph as serving without a draft, and with the Vulkan fold fixed (below) it now gains on both backends. On our rebased tip, your batch-side tail cut showed no prefill change on Vulkan: 1212.5 / 1239.5 / 1245.3 t/s at 2k / 8k / 32k against 1218.1 / 1255.2 / 1243.4 for the same branch without it. We have not checked whether it engaged there, so please treat that number as unexplained. We would gladly test your branch against this one if you open it.

I rebased onto current master (c495f90) and addressed all five asks. With the Vulkan direct conv fold working again, the split now speeds up Vulkan prefill too.

What changed

The branch is now 5 commits:

  1. spec: carry row only
  2. qwen4exp: eh_proj as one GEMM
  3. vulkan: direct ssm conv takes a token prefix of x
  4. qwen4exp: split the rollback-slot scan and conv of a prompt ubatch
  5. tests: rollback after a wide prompt ubatch
  • Ask 1 (fold): the first part's conv input stays a zero-offset prefix view of qkv_mixed. ggml_vk_ssm_conv_direct_check now accepts a longer contiguous x when there is one sequence: the kernel reads tokens [0, T) at stride C and nothing past them. This is its own commit (3), with new CONCAT_SSM_CONV_SILU cases in test-backend-ops: a prefix of a longer x, with the tail read after the conv, including Flash-Next channels at 2044 + 4 tokens. Part 1 (K tokens) stays below the fold's token minimum, so its concat is not folded either way. The HIP gdn_conv matcher is unchanged here.
  • Ask 2: delta-net-base.cpp and llm_build_delta_net_base are untouched (git diff master -- src/models/delta-net-base.cpp is empty). The split is straight-line code in llama_model_qwen4exp::graph::build_layer_attn_linear. Part 0 calls build_delta_net; part 1 runs ggml_gated_delta_net with K snapshots and writes the slots. slice_tokens, the parts out-param, the std::function and the unreachable branches are gone. The conv / q / k / v block is now one lambda used by both parts.
  • Ask 3: both width tests are gone.
    • The split is taken only when the ubatch has no output row before its last K tokens. A prompt ubatch outputs at most its last row. A verify batch outputs every row (the server adds the sampled token and every draft token as outputs), so verify batches of any width keep the old path. This is tested below with --spec-n-rs-seq 1.
    • The carry row keeps a sequence's rows from its first output row on.
    • Graph reuse does not compare output positions. That is safe here: both graphs give the same slot states for any one-sequence ubatch wider than K.
  • Ask 4: norm_gated_f16_pad() is the one fast-path condition and padding rule, used by build_norm_gated and build_norm_gated_parts. This also fixes a drift you predicted: the parts version had lost the EXL3 ssm_out check.
  • Ask 5: new rollback_wide_prompt case in tests/llama-context/cases-rs.cpp. It decodes n_rs_seq + 1 + 16 tokens per sequence in one ubatch with only the last row as output, which qwen4exp splits for one sequence. A second case does the same with two sequences in the ubatch, which keeps the unsplit path. It rolls back 1, 3 and n_rs_seq tokens and compares the prompt logits and every replayed token against the same prompt decoded with every row as output, which is never split.
  • Nits: the split path has cb() names (conv_input_part0, attn_output_part0 / part1, gdn_out_part1). The wrap-around view offset has a named variable and a comment. ms / MB figures are only in commit messages.

Vulkan, draft loaded

Qwen3.8-Flash-Next UD-Q4_K_XL + mtp-Qwen3.8-Flash-Next-Q8_0.gguf, --spec-type draft-mtp --spec-draft-n-max 3, -np 1 -c 33792 -b 2048 -ub 2048 -fa on -ctk f16 -ctv f16 -lm none -lzm on-direct --cache-ram 0.

Method:

  • One fresh llama-server per cell, in the order master / narrow / PR / PR / narrow / master with the draft and master / PR / PR / master without it, all in one job.
  • A 512-token warm-up per server, then 2 reps of each size.
  • The prompt is the first N tokens of wikitext-2 as token ids, sent to /completion with n_predict 1 and cache_prompt false.
  • The figure is the server's prompt_per_second, mean [min-max] of 4 requests. tg is 128 greedy tokens after the 8192 prompt.
  • "narrow" = commits 1-2 only.
master narrow (1-2) this PR (1-5) PR vs master PR vs narrow
draft, pp 16 71.6 [70-75] 74.0 [71-78] 73.6 [70-77] +2.8% -0.5%
draft, pp 48 162.7 [157-171] 167.3 [158-176] 166.5 [157-178] +2.4% -0.5%
draft, pp 200 438.0 [412-465] 449.2 [428-470] 445.9 [424-470] +1.8% -0.7%
draft, pp 2049 1059.1 [936-1120] 1172.3 [1146-1185] 1209.7 [1193-1222] +14.2% +3.2%
draft, pp 8192 1174.8 [1155-1188] 1254.8 [1252-1258] 1305.0 [1304-1307] +11.1% +4.0%
draft, pp 32768 1183.7 [1170-1189] 1244.3 [1238-1251] 1293.7 [1287-1300] +9.3% +4.0%
draft, tg128 after 8192 35.99 (83/130) 36.21 (83/130), same stream as master 38.31 (85/123), different stream
no draft, pp 16 87.5 [81-94] 86.2 [81-93] -1.6%
no draft, pp 48 195.4 [183-208] 195.8 [184-209] +0.2%
no draft, pp 200 507.7 [480-538] 508.3 [480-541] +0.1%
no draft, pp 2049 1342.7 [1323-1356] 1332.6 [1313-1351] -0.8%
no draft, pp 8192 1437.7 [1427-1452] 1436.7 [1427-1451] -0.1%
no draft, pp 32768 1427.1 [1426-1429] 1424.5 [1414-1430] -0.2%
no draft, tg128 after 8192 25.74 25.83, same stream +0.3%
  • With the draft, the prompt GDN now runs the plain scan, so the stream after the prompt differs from master by design. Its tg follows acceptance on a different continuation and is not a speed result. It is the same stream as the previous revision of this PR (sha ff6948de2ac0), so the Vulkan fold does not change the numerics.
  • Without the draft, all streams are identical to master.
  • Commits 1-2 give most of the gain at 2k and the split adds about 4% from 8k up. In an earlier job, the carry row alone was within noise at -np 1: +0.3 to +1.0% over eh_proj alone.
  • Short prompts (your finding 6): a short first part does not lose. At 16 / 48 / 200 tokens the PR is within -0.7% of narrow, inside overlapping ranges, so there is no minimum length. The 2049 row is a 2048 ubatch plus a 1-token ubatch.

Vulkan direct conv fold

GGML_VK_FUSION_DEBUG=1, one 2048-token prompt with the draft loaded:

x layout concat srcs
master 0 31
previous revision of this PR 1152 1111
this PR 0 247

The remaining concat srcs lines are part 1's K-token concat (non-zero view offset). It is below the fold's 8-token minimum, so it is never folded.

ROCm, draft loaded

Same protocol on ROCm, this PR against commits 1-2 alone (narrow), so the line isolates the split. Master was not run on ROCm in this round.

narrow (1-2) this PR (1-5) change
pp 2048 1220.6 [874-1351] 1174.9 [927-1383] first request after load dominates, not readable
pp 8192 1313.8 [1249-1337] 1400.1 [1337-1442] +6.6%
pp 32768 1322.1 [1310-1334] 1436.7 [1415-1455] +8.7%
tg128 after 8192 42.94 (89/111) 41.61 (88/114), different stream

The HIP gdn_conv matcher still declines the first part's prefix view (the same element-count check). A matching HIP change could add more, but that is left for a follow-up.

More than one sequence (-np 2, -np 4)

Vulkan, same model and draft, -c 32768 -kvu -b 2048 -ub 2048, 2 servers per arm (master / PR / PR / master). Each server runs these phases:

  • pp aggregate: N concurrent distinct ~2k prompts, n_predict 1, run twice.
  • mixed: N concurrent prompts of 40 / 2100 / 300 / 2600 tokens, 96 tokens each.
  • stagger: a 2600-token prompt arrives 2 s into another slot's 256-token decode.
  • tg aggregate: N concurrent 64-token prompts, 128 tokens each.
master this PR change
-np 2, aggregate prompt t/s 1112.4 [1063-1144] 1125.5 [1083-1150] +1.2%
-np 2, aggregate gen t/s 37.3 [37.3-37.4] 38.8 [36.9-40.8] +4.0% (stream-dependent)
-np 4, aggregate prompt t/s 955.6 [929-1002] 1083.4 [1063-1106] +13.4%
-np 4, aggregate gen t/s 46.1 [45.7-46.5] 47.6 [46.8-48.4] +3.3% (stream-dependent)
  • No crash, no device or rollback error in any server log. Every request returned its full token count.
  • Greedy streams with a draft at -np > 1 are not run-to-run stable on master either: the same mixed request gave different streams on master's two servers. So a stream comparison against -np 1 or against master is not meaningful there. The 2600-token prompt of the stagger phase gave the same stream as its -np 1 run on every server, on both arms.
  • Which path runs: a local debug build (one log line per delta-net layer per graph, not part of this PR) shows the split only on one-sequence ubatches. Every ubatch with 2, 3 or 4 sequences took the unsplit path, at -np 2 and -np 4 and in the new two-sequence test. At -np 4, prompts that arrive together and are batched as several sequences keep the K-snapshot scan. The gain there comes from the one-sequence tails and from prompts processed alone.
  • New test case rollback_wide_prompt_2seq: two sequences in one prompt ubatch (unsplit path), rolled back and replayed against the all-outputs run. It passes on the 11 recurrent tiny archs at -ngl 99 and -ngl 0, as does the one-sequence case.

Wide verify batches

--spec-type draft-mtp,ngram-mod --spec-n-rs-seq 1, so every MTP verify batch (4 rows) is wider than K = 2. Same 1500-token repetitive prompt, 256 tokens, 2 reps, -np 1, GGML_VK_FUSION_DEBUG=1. As a positive control, the previous revision of this PR (width test) splits verify batches. Lines below are part-1 concat lines and x layout rejects in the generation phase of each rep:

master previous revision this PR
rep 0 443 / 0 6239 / 5832 659 / 0
rep 1 325 / 0 3376 / 3204 424 / 0
stream, rep 0 6f02684d 168/261 6f02684d 168/261 6f02684d 168/261

This PR's extra lines over master are about one prompt's split, against thousands for the width test, so verify batches keep the unsplit path. Rep 1 streams differ from master on both PR revisions, after a prompt that ran through the split.

Correctness (Vulkan, this PR)

  • test-backend-ops -o CONCAT_SSM_CONV_SILU: 15/15, with no x layout reject under the fusion debug log. A 40-launch hazard run of the same filter: 0 failures.
  • test-backend-ops -o 'SSM_CONV|CONCAT|GATED_DELTA_NET|GDN_CONV_PREFILL|SILU': 491/491.
  • test-llama-context on the random tiny qwen4exp MoE from test-llama-archs -a qwen4exp -o: 16/16, including rollback_wide_prompt. The narrow branch passes the same 15 old cases. Under the fusion debug log, the new case shows part 1's concat, so the split engaged.
  • Full test-backend-ops -b Vulkan0 on the final binary: 44197/44197.
  • test-llama-context --test 'rollback|rollback_wide_prompt' over every tiny arch from test-llama-archs -o, at -ngl 99 and -ngl 0: 11 recurrent archs pass both, the other 119 skip, 0 fail. There is no negative control: no run deliberately broke a slot to show the test failing.
  • ctest -R 'spec-mtp-pcum|draft-vocab|qwen4exp-mtp': 3/3.
  • test-llama-archs -a qwen4exp -b Vulkan0: OK. Without -b, the Meta device row asserts at ggml-backend.cpp:844 on master too.
  • Carry row with --spec-type draft-mtp,ngram-mod and draft-mtp: 3 prompts x 2 reps x 256 tokens. Every request gives the same stream and accepted / drafted counts as eh_proj alone. The wide verify case is covered in the section above.

Overlap: #250 edits the next line of ggml_vk_ssm_conv_direct_check (the token gate). The two merge without conflicts, but I have not built or tested the combination. This PR does not change how the recurrent state rows are laid out, so #247 is unaffected.

Not tested:

  • other delta-net models with a draft (they keep the old path)
  • GPUs other than gfx1151
  • drivers other than RADV 26.2.4

Device: Ryzen AI Max+ 395 / Radeon 8060S (gfx1151), GMKtec EVO-X2, 128 GB, BIOS power mode balanced, UMA 2 GB. Kernel 6.17.0-35-generic, amdgpu.gttsize=118784 ttm.pages_limit=30408704 ttm.page_pool_size=1048576 amd_iommu=off. Mesa 26.2.4 RADV (release tag, unmodified), shaderc glslc. Build: -DCMAKE_BUILD_TYPE=Release -DGGML_VULKAN=ON -DGGML_NATIVE=OFF.

AI usage: ASSISTED. Written with Claude, tested by me.

@dzannotti dzannotti added in-review We are reviewing. and removed waiting-user We asked the author for something. labels Nov 15, 2026
@dzannotti dzannotti assigned dzannotti and unassigned Nathanw1014 Nov 15, 2026
@dzannotti dzannotti added verifying Building and running the PR to verify its claims. and removed in-review We are reviewing. labels Nov 15, 2026
@dzannotti
dzannotti dismissed their stale review November 15, 2026 09:28

The rebased branch addresses every blocking ask of this review. A new review on b329e93 replaces it.

@dzannotti dzannotti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review replaces our earlier one on d208045.

Verdict

Changes requested, for one new item. The rebased branch fixes every earlier ask, and with the MTP draft loaded we measured +8.5% to +10.3% prompt speed on Vulkan and +4.8% to +7.7% on ROCm. Output without a draft is unchanged on both backends. One test gate still fails on ROCm, because the context reserve never builds the split graph.

Direction

Accept after work. The split now lives in qwen4exp.cpp, the Vulkan fold works again, and both backends gain. After the reserve fix this is ready for a maintainer decision.

Asks

  1. Blocking. src/llama-context.cpp:2971-2995 with src/models/qwen4exp.cpp:2189-2192. The reserve sets its outputs from row 0 of each sequence, so the split condition (no output before the last K rows) is never true at reserve time. The first prompt ubatch that takes the split then needs a larger compute buffer, and the scheduler grows it at run time. On ROCm, test-llama-context on the tiny qwen4exp with GGML_SCHED_DEBUG_REALLOC=1 (the env that ctest sets for this test) aborts in replay with "unexpected graph reallocation" 3 of 3 times, and master passes 3 of 3. Without the env it prints 13 "compute buffer size ... does not match expectation" warnings, against 0 on master. Reserve the split shape as well when n_rs_seq > 0, for example by putting the reserve's output on the last row of a one-sequence ubatch, and run ctest -L main on ROCm.
  2. Should fix. tests/llama-context/cases-rs.cpp:24-131. rollback_wide_prompt runs a 25-token ubatch, so fused_gdn_norm_f16 is off (it needs 32 tokens), the padded branch of build_norm_gated_parts never runs, and part 0 (16 tokens) never reaches the chunked GDN or the GDN conv fold with a prefix x. Slot 0 is also never checked (rollbacks are 1, 3 and n_rs_seq). Use 64 or more extra tokens, add a step with no rollback, and add one GDN_CONV_PREFILL case with a prefix x.
  3. Should fix. src/models/qwen4exp.cpp:3035-3052 and 2290-2311. build_conv_tail_at adds a third copy of the per-slot conv copy loop, and part 1's scan and slot write repeat the keep branch of build_recurrent_attn line for line. One call to build_recurrent_attn(..., part0.second, il) and one shared slot-store helper would drop about 80 copied lines that the next upstream sync must otherwise update by hand.
  4. Should fix. tests/test-backend-ops.cpp:17576-17579. The x_tail cases have slot copies and no history reader. The real part-0 graph has a CONT(VIEW(concat)) history reader and no slot copies, so the matcher's tail-reader branch is not tested with a prefix x. Add one case with that shape.

Nits: the new struct in cases-rs.cpp:17-23 sits under the doc comment of case_multi_seq_split_replay. Both conv_qkv calls use the same cb() names, so add a _part1 suffix to the second call. The comment at qwen4exp.cpp:2187 says the arithmetic is the same, but the chunked scan rounds differently.

Correctness

PASS for output, FAIL on one ROCm test gate (Ask 1). Without a draft, head and master give byte-identical llama-debug final logits and token ids (code and prose corpora), and the same greedy server stream, on both backends. With rollback slots forced (n_rs_seq 3), the argmax is the same everywhere, and head is closer to the no-slot logits than master in 3 of 4 backend and corpus cells. The 4th cell is inside the noise. With the draft, all 8 servers gave the same 64-token stream with 46 of 50 drafts accepted. SSM_CONV, CONCAT and GATED_DELTA_NET match master on both backends, and CONCAT_SSM_CONV_SILU passes 15/15 on Vulkan with 0 x layout rejects. test-llama-context passes 17/17 on both backends, with HIP_LAUNCH_BLOCKING unset and set to 1, but not under the ctest env on ROCm. Not run: KLD/PPL, the full backend suites, the structured and numeric corpora, -np > 1.

Performance

Qwen3.8-Flash-Next (qwen4exp) TQ2_0 with the shared Q4_K_M MTP sidecar, --spec-type draft-mtp --spec-draft-n-max 3 -np 1 -b 2048 -ub 2048, servers in the order master / head / head / master, 4 requests per size:

backend prompt master t/s [min-max] head t/s [min-max] change
Vulkan 2048 874.1 [860-888] 964.4 [949-980] +10.3%
Vulkan 8192 843.0 [836-850] 920.5 [915-925] +9.2%
Vulkan 32768 853.8 [851-857] 925.9 [925-927] +8.5%
ROCm 2048 809.7 [794-825] 848.9 [835-865] +4.8%
ROCm 8192 801.7 [795-809] 853.7 [850-856] +6.5%
ROCm 32768 814.3 [812-817] 876.6 [875-878] +7.7%

The ranges do not overlap. Without a draft, prompt and decode speed match master within 0.1% on both backends.

Verification

Strix Halo (gfx1151), Vulkan (RADV) and ROCm. The PR is based on the current master c495f90 (0 commits behind). We compared the PR merged into that master against master.

Not tested

KLD/PPL, llama-bench depth sweeps, full backend suites, -np 2 and -np 4, the wide-verify check, and the UD-Q4_K_XL + Q8_0 files from the description.

Thanks for the careful rework.

Review made with AI on behalf of the strix-llama.cpp maintainers.

Full verification (for reproduction and agents)

Environment

  • Ubuntu 26.04.1, kernel 7.0.0-43-generic, Strix Halo (gfx1151, Radeon 8060S), 128 GB unified memory.
  • ROCm 10.1 (hipconfig 7.16.26385), AMD clang 24.0.0git d6f6cb69.
  • Mesa RADV 26.0.8, shaderc glslc 2026.1.
  • cmake 4.2.3, gcc 15.2.0, ninja 1.13.2.

Compared

  • master tip and merge base: c495f90 (c495f90f55e647f9a5b6820b503be6d39c74baa7). The PR was 0 commits behind.
  • PR head: b329e93 (b329e9374d4994f1fc32037770b412b9cebd1ca7).
  • merged (local only, clean, tree equal to the PR head): 010fd19b9.
  • Earlier reviewed head: d208045.

Build

Vulkan: cmake -S <tree> -B <tree>/build-vk  -DGGML_VULKAN=ON -DGGML_HIP=OFF -DCMAKE_BUILD_TYPE=Release -G Ninja
ROCm:   cmake -S <tree> -B <tree>/build-hip -DGGML_HIP=ON -DGGML_VULKAN=OFF -DGPU_TARGETS=gfx1151 \
          -DCMAKE_HIP_COMPILER=$(hipconfig -l)/clang -DCMAKE_PREFIX_PATH=$(hipconfig -R) -DCMAKE_BUILD_TYPE=Release -G Ninja
cmake --build <tree>/build-<be> -j 16 --target llama-server llama-debug test-backend-ops test-llama-context test-llama-archs

No HIP source changed, so we did not run the -Werror HIP build or the VGPR spill gate.

Models

model source sha256
Qwen3.8-Flash-Next-Gyro-M-TQ2_0.gguf (qwen4exp) agentionai/Qwen3.8-Flash-Next-Gyro-GGUF 7aa36d15131d255179ab6c87fa9c9f81a0b541fc9e81e959d4c3e29eb20feb5f
mtp-Qwen3.8-Flash-Next-shared-Q4_K_M.gguf (head-less MTP sidecar) unsloth/Qwen3.8-Flash-Next-GGUF, MTP/ f521868a9e143718bef513772f6e04d9642551e362cf2439636d2abdbd149dfc
random tiny qwen4exp MoE test-llama-archs -a qwen4exp -o <dir> (base build) n/a

Gyro-M always ran with -lm none -lzm on-direct. Peak GPU memory was 41 GiB.

Commands

# op tests, base and head
test-backend-ops test -b <dev> -o SSM_CONV | -o CONCAT | -o GATED_DELTA_NET      # Vulkan0 and ROCm0
test-backend-ops test -b Vulkan0 -o CONCAT_SSM_CONV_SILU                           # also with GGML_VK_FUSION_DEBUG=1

# context tests, tiny qwen4exp, base and head
test-llama-context -m <tiny> -ngl 99                                     # Vulkan; ROCm with HIP_LAUNCH_BLOCKING unset and =1
GGML_SCHED_DEBUG_REALLOC=1 test-llama-context -m <tiny> -ngl 99 [--test replay]   # ROCm, 3 runs each side
GGML_SCHED_DEBUG_REALLOC=1 test-llama-context -m <tiny> -ngl 0                    # CPU only (no GPU visible)
GGML_VK_FUSION_DEBUG=1 test-llama-context -m <tiny> -ngl 99 --test rollback_wide_prompt

# final logits, rollback slots forced with an LD_PRELOAD shim that wraps llama_init_from_model and sets n_rs_seq = 3
llama-debug -m <Gyro-M> -f <corpus> -c 8192 -b 8192 -ub 2048 -ngl 99 -fa on -ctk f16 -ctv f16 -lm none -lzm on-direct \
  --save-logits --logits-output-dir <dir>
#   corpora: the first ~20 KB (cut at a newline) of tests/corpus/correctness-code.txt (5848 tokens) and correctness-prose.txt (4827 tokens)
#   variants: base AR, head AR (cmp against base AR), base slots, head slots

# prefill with the draft, servers master / head / head / master
llama-server -m <Gyro-M> -ngl 99 -fa on -ctk f16 -ctv f16 -lm none -lzm on-direct -np 1 --cache-ram 0 -c 33792 -b 2048 -ub 2048 \
  -md <sidecar> -ngld 99 --spec-type draft-mtp --spec-draft-n-max 3
#   prompt ids: the four corpora joined, tokenized once with /tokenize; first N ids per size; the same id files for every server
#   per server: 512-token warm-up, then 2048 / 8192 / 32768 x 2, /completion n_predict 1 cache_prompt false, timings.prompt_per_second
#   then 2048 prompt + n_predict 64, temperature 0, top_k 1
# fold check: the same server with GGML_VK_FUSION_DEBUG=1, one 2048 prompt, base and head
# no-draft check: the same server without -md / -ngld / --spec-*, 2048 prompt + 64 greedy tokens, base and head

Results

Op tests:

op Vulkan base Vulkan head ROCm base ROCm head
SSM_CONV 45/45 45/45 45/45 45/45
CONCAT 202/202 202/202 not run not run
GATED_DELTA_NET 69/69 69/69 69/69 69/69
CONCAT_SSM_CONV_SILU 12/12 15/15 (3 new prefix cases), 0 x layout n/a n/a

test-llama-context, tiny qwen4exp:

run base head
Vulkan, default env 15/15 17/17
ROCm, HIP_LAUNCH_BLOCKING unset / =1 15/15 / 15/15 17/17 / 17/17
ROCm, GGML_SCHED_DEBUG_REALLOC=1, --test replay, 3 runs 3 passed 3 aborted: ggml-backend.cpp:1958: ggml_backend_sched_alloc_splits: unexpected graph reallocation (graph size = 484, nodes = 484, leafs = 93)
ROCm, compute buffer mismatch warnings 0 13
Vulkan, GGML_SCHED_DEBUG_REALLOC=1 aborts earlier in rf the same abort in rf (exists on master, so replay was not reached)
CPU, GGML_SCHED_DEBUG_REALLOC=1 15/15 17/17

The new cases pass alone under the realloc env on ROCm. The abort comes in the next case, after the first split graph has grown the buffer. On Vulkan, rollback_wide_prompt under the fusion debug log shows 23 part-1 concat srcs lines and 0 x layout, so the split engages.

llama-debug, final logits (AR = no slots):

backend corpus head AR vs base AR head slots vs base slots (cos) head slots vs base AR (cos) base slots vs base AR (cos) argmax
Vulkan code byte-identical 0.998256 0.998587 0.998237 equal in all
Vulkan prose byte-identical 0.995280 0.995693 0.996463 equal in all
ROCm code byte-identical 0.997878 0.998699 0.997778 equal in all
ROCm prose byte-identical 0.987193 0.992028 0.989803 equal in all

For scale, ROCm AR against Vulkan AR on prose is cos 0.99282. The token ids are identical in all variants.

Fold check with the draft (one 2048 prompt, debug log lines):

x layout concat srcs state layout
master 0 18 14
head 0 126 14

The extra concat srcs lines are the part-1 K-token concat. Our earlier review measured 576 x layout lines on d208045.

Greedy streams: with the draft, all 8 servers (both backends, both sides) gave the same 64 tokens, with 46 of 50 drafts accepted. Without the draft, base and head gave the same stream on both backends.

Performance

Prefill t/s with the draft, every request (master: servers 1 and 4; head: servers 2 and 3; 2 requests each):

backend prompt master head
Vulkan 2048 866.8 887.9 860.4 881.2 948.8 980.2 951.5 977.2
Vulkan 8192 839.3 850.0 836.3 846.4 918.2 925.1 915.3 923.5
Vulkan 32768 856.6 855.2 852.1 851.2 926.5 925.6 926.7 924.9
ROCm 2048 815.7 793.7 825.1 804.4 865.0 844.1 851.5 835.1
ROCm 8192 795.3 809.1 798.1 804.4 855.2 853.0 856.1 850.4
ROCm 32768 816.7 815.4 813.2 811.8 876.7 878.3 874.8 876.6

Decode after the 2048 prompt with the draft: Vulkan 49.18 / 49.44 (master) vs 50.32 / 50.21 (head), ROCm 42.66 / 42.71 vs 43.62 / 42.49 t/s. Without the draft: Vulkan pp 1017.8 vs 1018.3, tg 30.26 vs 30.34; ROCm pp 967.3 vs 967.4, tg 25.85 vs 25.85.

Correctness

check method result
op tests for the changed ops test-backend-ops, both backends PASS, same as master; 3 new fusion cases pass
full backend suites, test-vk-exact not run not run (time budget)
context and rollback tests test-llama-context, tiny qwen4exp PASS in the default env; FAIL under the ctest env on ROCm (Ask 1)
no-draft path llama-debug logits + token ids, cmp; server greedy stream byte-identical, both backends
slot path llama-debug logits, slots forced argmax equal, head as close or closer to AR
KLD/PPL short and long not run the split engages only on prompt ubatches with no output before the last K rows, and llama-perplexity outputs every row
greedy decode with the draft server, 64 tokens same stream and acceptance on all servers
ROCm HIP_LAUNCH_BLOCKING unset and =1 test-llama-context same results
HIP -Werror and VGPR gate n/a no HIP source changed
spec unit tests not run the carry-row change was reviewed in the code

Findings in full

  1. Blocking: the reserve (llama-context.cpp:2971-2995) sets outputs from row 0 of each sequence, so ubatch.output[0] is true and qwen4exp builds the unsplit graph at reserve time. The split graph has more nodes (484 on the tiny model) and a larger compute buffer, which is allocated only at the first split ubatch. On real Gyro-M runs the mismatch lines were the same on base and head, so we saw no extra memory there. The repo's own gate (GGML_SCHED_DEBUG_REALLOC=1 in tests/CMakeLists.txt) treats this as a failure.
  2. Should fix: test coverage of the production paths (see Ask 2).
  3. Should fix: about 80 lines copied from build_conv_state_at and build_recurrent_attn (see Ask 3). The conv/q/k/v block in the conv_qkv lambda is still upstream code, now re-indented, so upstream edits there will conflict. We accept that cost, because the split needs the block twice.
  4. Should fix: the test shape (see Ask 4).
  5. Info: the HIP gdn_conv matcher still requires the whole x, so on ROCm part 0 runs the unfused conv. That is correct, and ROCm gains without it.
  6. Info: graph reuse ignores output positions, so in a rare case a prompt ubatch can reuse an unsplit graph, or the reverse. Both graphs write the same slots, so only the numerics differ.
  7. Checked and correct: the Vulkan x_prefix read range (the strides limit it to tokens [0, T), and view_offs must be 0); the history reader of the part-0 concat (taken as a tail reader, written before the cont); the SSM and conv slot offsets and order; the back_to_buf view; LLAMA_GDN_NORM_PAD off, the fused GDN paths off, LoRA, EXL3 and bf16 ssm_out, n = K + 1; the carry row with mixed drafters.

Claims

claim result
Vulkan prefill with the draft +14.2% / +11.1% / +9.3% at 2k / 8k / 32k Reproduced in direction, smaller on our model: +10.3% / +9.2% / +8.5%
ROCm with the draft +6.6% / +8.7% at 8k / 32k against commits 1-2 Not tested as stated. Against master: +6.5% / +7.7% (+4.8% at 2k)
No-draft serving unchanged Reproduced, both backends
The Vulkan fold accepts the part-0 prefix (0 x layout) Reproduced
CONCAT_SSM_CONV_SILU 15/15 Reproduced
test-llama-context passes, including rollback_wide_prompt Reproduced in the default env; fails under the ctest env on ROCm
Verify batches keep the unsplit path Confirmed by reading the code; not measured
-np 2 / -np 4 gains Not tested

Not tested

  • KLD/PPL, the structured and numeric corpora, llama-bench depth sweeps, the full backend suites, test-vk-exact.
  • -np 2 and -np 4, the wide-verify check (--spec-n-rs-seq 1), the spec unit tests.
  • The UD-Q4_K_XL target and the Q8_0 MTP file from the description.
  • The server pytest suite (not installed).
  • GPUs other than gfx1151.

@dzannotti dzannotti added verified The claims were reproduced. waiting-user We asked the author for something. labels Nov 15, 2026
@dzannotti dzannotti removed the verified The claims were reproduced. label Nov 22, 2026
A prompt batch is never accepted against, so its rows past the last one
were copied for nothing (80 MB per 2048 rows on Qwen3.8-Flash-Next).

accept() reads the row of the last accepted draft token, and only the
rows of a verify batch carry outputs. Keep the rows from the first
output row of the sequence on: a verify batch keeps every row, whichever
drafter made the draft and however wide it is, and a prompt batch keeps
its last row, the carry. With shared memory the master rule stays: all
rows when every row is an output, else the last row.

Resolution of the rebase onto the new row selection by dzannotti.

Assisted-by: Claude Opus 5.5
The draft's eh_proj input is [2*n_embd, hc, n_tokens], so ggml ran
n_tokens batched hc-column mat-vecs, each reading the whole weight:
93 ms per 2048-token prompt ubatch on Qwen3.8-Flash-Next (Vulkan perf
logger), 70% of the draft's prompt catch-up. Reshape to 2D around the
matmul.

Assisted-by: Claude Opus 5.5
…r sequence

After such a ubatch the recurrent memory refuses a partial rollback (rs_max = 0), so no snapshot slot but the
final state is ever read. Run the no-draft scan and conv state store for it, and keep the K-slot path for
ubatches that a rollback can end inside.

Suggested by dzannotti in the review of #255.

Assisted-by: Claude Opus 5.5
@Nathanw1014

Copy link
Copy Markdown
Author

Thanks @dzannotti, the plain-scan rule was the right call. Rebased onto master 403dfcb and reworked as you suggested:

  • kept the eh_proj GEMM, and the carry row with your resolution (master's shared-memory rule stays)
  • dropped the rollback-slot split, the Vulkan prefix-of-x match and the two rollback_wide_prompt cases
  • added your change in build_recurrent_attn / build_conv_state_store

Strix Halo (gfx1151), Vulkan RADV 26.2.4, Qwen3.8-Flash-Next UD-Q4_K_XL + shared Q4_K_M MTP, --spec-draft-n-max 3 -np 1 -b 2048 -ub 2048, llama-server. Prompt t/s, and decode t/s over 4 prompts x 256 tokens:

pp 2048 pp 8192 tg
master 1097.0 1112.9 44.39
+ carry row + eh_proj GEMM 1198.2 (+9.2%) 1219.3 (+9.6%) 45.21
+ plain scan (this PR) 1271.2 (+15.9%) 1307.3 (+17.5%) 44.22 (-0.4%)

The middle row comes from a local test build with the plain scan switched off; that switch is not in the branch. The carry row alone measured +0.1% / +2.3% on a cut-down model, inside the spread, same as you found. I kept it since it is small, but happy to drop it.

Without a draft: same logits and token ids as master on this model, llama-bench pp/tg within the spread.
ctest -L main passes on Vulkan and ROCm (36/36, master too). test-llama-context --models gives the same 147/147 table as master under GGML_SCHED_DEBUG_REALLOC=1, qwen35 / qwen3next / inkling2 included. On ROCm the tiny qwen4exp prints 0 buffer warnings, same as master (you saw 6 with the split). The four op tests you listed pass.

On the extra compute buffer line: master prints it too on this model (953 vs 946 MiB, plus a Vulkan_Host line even without a draft). Both reallocate once, on a 2048-token prompt ubatch at depth 4096, and with the plain scan that growth is about 20 MiB larger. It looks like a reserve gap on master, so I'd rather look at it separately, unless you want it in here.

Not tested: ROCm speed, -np > 1, qwen35 / qwen3next with a real draft.

@Nathanw1014 Nathanw1014 changed the title spec, qwen4exp, vulkan : faster prompt processing with an MTP draft loaded spec, qwen4exp, delta-net : faster prompt processing with an MTP draft loaded Nov 24, 2026
@rcfa

rcfa commented Nov 26, 2026

Copy link
Copy Markdown

Measured the case the review could not run, on gfx1150 (Radeon 890M, Strix Point; not Strix Halo), Vulkan, Mesa 26.1.6
RADV, Linux 7.2.15: qwen4exp (Qwen3.8-Flash-Next IQ3_XXS) WITH its MTP draft (the shared Q4_K_M head, n-max 2, draft
vocab 4096), -np 4 on a 524288-cell unified pool, f16 K/V, -ub 2048, cold prefills, no prompt cache.

Arms: master 253022c (today's, with #318) and 253022c with this PR's head df2f118 merged (no conflicts).
Separate build directories, same options. Prompt t/s (two samples where two values are given):

prompt master + MTP PR + MTP gain master, no MTP PR, no MTP
2048 273.1 340.1 +24.5 % 365.1 369.9
8192 289.3, 284.8 355.1, 349.6 +22.7 % 377.1 378.3
16384 287.3 350.2 +21.9 % 371.9 371.4
32768 276.8, 278.9 333.3, 333.1 +19.9 % 354.5 354.4
  • What MTP costs prefill: 22.7 % on master at 16k, 5.7 % with the PR. Without MTP the PR changes nothing (within
    1.3 %).
  • All four slots prefilling 8192 tokens at once: 287.7 t/s on master, 349.8 and 340.1 with the PR, +19.9 % (you
    measured +13.4 % on gfx1151).
  • Greedy 64 tokens after a 16k prompt, MTP vs no MTP: the first difference is at token 7 on master and at token 27
    with the PR, so the PR does not introduce that divergence.
  • No crash; peak GTT 20.9 GiB. Every server on both arms logged the teardown compute-buffer warning ("does not match
    expectation", 2-3 per server); that is a pre-existing allocator issue we are looking at separately, not this PR.
  • Because it is merged onto 253022c, this also ran together with memory : keep rollback snapshots when the recurrent gather moves cells #318, which changes the rollback snapshots that
    commit 3 relies on. Nothing went wrong here, but we ran no rollback-specific test.

Not run: ROCm; Strix Halo; a second sample at 2048 and 16384.

Measured and written by Claude Code (an AI agent) for rcfa.

@dzannotti dzannotti added in-review We are reviewing. verifying Building and running the PR to verify its claims. and removed waiting-user We asked the author for something. in-review We are reviewing. labels Nov 26, 2026

@dzannotti dzannotti left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review replaces our review of 2026-11-22.

Verdict

Changes requested, for one small fix. The reworked branch does what we asked for, and the speed and logit results are good on both backends. Merged into current master, the plain scan makes test-llama-context fail on 10 architectures under GGML_SCHED_DEBUG_REALLOC=1 (the ctest setting), on Vulkan and on ROCm. Master passes on them.

Direction

Accept after work. This is the shape we asked for. With an MTP draft loaded, prompt processing is 11 to 15% faster on Qwen3.8-Flash-Next and 2 to 5% faster on Qwen3.8-27B. Without a draft, nothing changes.

Asks

  1. Blocking. src/llama-context.cpp:1086: with n_rs_seq > 0 the reserve no longer covers the K-slot graph of a short multi-token ubatch. The pp reserve is now the plain-scan graph, and the tg reserve has only one token per sequence. Master's rollback_cell_move case (from #318, newer than your base 403dfcb) runs such a ubatch and aborts with "unexpected graph reallocation" on bailingmoe3, clover_moe, glm5-next, kimi-k3, kimi-k31, lfm2, lfm2moe, lfm3, nemotron_h and nemotron_h_moe. qwen35 and qwen4exp pass, because graph_depends_on_n_tokens() already probes the token ranges for them. This one-line change fixes all 10 on both backends (we tested it):
    -    if (!cparams.training && !model.no_alloc() && model.graph_depends_on_n_tokens()) {
    +    if (!cparams.training && !model.no_alloc() && (model.graph_depends_on_n_tokens() || cparams.n_rs_seq > 0)) {
    Then run ctest -L main on both backends against current master. inkling2-moe aborts the same way on master and with the fix, so it is not yours.

Optional: in common/speculative.cpp the nested ternary for h_offset would read better as an if (is_mem_shared) block, and the new comments are hard-wrapped (AGENTS.md asks for no hard wraps).

Correctness

PASS for model output, FAIL for the context test (Ask 1).

  • Without a draft, base and head are byte-identical on both backends. This covers final f32 logits and token ids on all four corpora (27B and Flash-Next), the .kld files, and 256-token greedy decodes.
  • We forced n_rs_seq = 3 on the target without a draft. Head then gives byte-identical logits, a KLD of 0 and the same greedy stream as n_rs_seq = 0. Master's K-slot path is at or near the noise floor (Flash-Next VK 0.00283 vs floor 0.00270; ROCm 0.00259 vs 0.00222).
  • With the draft, the head's first-token log-probs on the 27B on ROCm equal the no-draft ones, and on Flash-Next they are closer to the no-draft ones than master's.
  • test-llama-archs (all), the four op tests and the spec unit tests pass on both sides. -np 2 and -np 4 (unified and not) and DFlash2 ran with no abort.

Performance

Prompt t/s with the draft (--spec-draft-n-max 3 -np 1 -b 2048 -ub 2048), mean of 4 requests from 4 servers in base/head/head/base order (2 requests at 32k on the 27B and at 64k):

backend model 2048 12000 32000 64000
Vulkan Flash-Next + shared MTP 948.9 -> 1073.3 (+13.1%) 887.3 -> 997.3 (+12.4%) 902.7 -> 1001.1 (+10.9%) 879.6 -> 977.3 (+11.1%)
ROCm Flash-Next + shared MTP 801.5 -> 923.8 (+15.3%) 791.3 -> 892.8 (+12.8%) 816.1 -> 924.2 (+13.2%) 800.0 -> 904.3 (+13.0%)
Vulkan 27B + MTP head 498.9 -> 515.3 (+3.3%) 450.6 -> 460.8 (+2.3%) 414.8 -> 424.5 (+2.3%) 372.4 -> 382.1 (+2.6%)
ROCm 27B + MTP head 391.8 -> 411.1 (+4.9%) 372.8 -> 390.0 (+4.6%) 332.9 -> 346.6 (+4.1%) 278.8 -> 288.1 (+3.4%)

Without a draft, every cell is within 1% of master. Decode with the draft, averaged over 6 prompts x 256 tokens, is 0.4 to 2.5% lower, with acceptance 0.3 to 3.6 points lower. The texts differ by prompt, and head wins on some prompts. The prompt gain is larger than this cost from 2048 tokens on. The ranges are in the details block.

Verification

Strix Halo (gfx1151), Vulkan (RADV) and ROCm. We compared your branch merged into master 1da4f8e (7 commits behind, clean merge) against master.

Not tested

Other GDN or KDA models with a real draft (the tiny models of all architectures ran in the context tests), CPU speed, and the server pytest suite (not available).

Thanks for the quick rework.

Review made with AI on behalf of the strix-llama.cpp maintainers.

Full verification (for reproduction and agents)

Environment

  • Ubuntu 26.04.1, kernel 7.0.0-44-generic, Strix Halo (gfx1151, Radeon 8060S), 128 GB unified memory.
  • ROCm 10.1 (hipconfig 7.16.26385), AMD clang 24.0.0git d6f6cb69.
  • Mesa RADV 26.0.8.
  • cmake 4.2.3, gcc 15.2.0, ninja.

Compared

  • master tip: 1da4f8e (1da4f8e50cd679aba69682990a9abe9bacec7f5c)
  • PR head: df2f118 (df2f118d20d952562028dbcd4128182749eb1956), merge base 403dfcb, 7 commits behind
  • merged: f961300ec (local git merge --no-ff of the head into 1da4f8e, never pushed)
  • reserve fix: f961300ec + the Ask 1 line (local only)

Build

ROCm:   cmake -G Ninja -S <tree> -B <tree>/build-hip -DCMAKE_BUILD_TYPE=Release -DGGML_HIP=ON -DGGML_VULKAN=OFF -DGPU_TARGETS=gfx1151 \
          -DCMAKE_HIP_COMPILER=$(hipconfig -l)/clang -DCMAKE_PREFIX_PATH=$(hipconfig -R)
Vulkan: cmake -G Ninja -S <tree> -B <tree>/build-vk -DCMAKE_BUILD_TYPE=Release -DGGML_VULKAN=ON -DGGML_HIP=OFF
cmake --build <tree>/build-<be> -j

Models

model source sha256 (prefix)
Qwen3.8-Flash-Next-Gyro-M-TQ2_0.gguf (qwen4exp) agentionai/Qwen3.8-Flash-Next-Gyro-GGUF 7aa36d15131d2551
mtp-Qwen3.8-Flash-Next-shared-Q4_K_M.gguf unsloth/Qwen3.8-Flash-Next-GGUF, MTP/ f521868a9e143718
Qwen3.8-27B-UD-Q4_K_XL.gguf (qwen35, built-in MTP head) unsloth 3f227079
Qwen3.8-27B-DFlash2-Q4_K_M.gguf DFlash2 draft for the 27B 1a25c568
LFM2-700M-Q4_K_M.gguf LiquidAI 684e8406dc133214
Inkling-2-Mini-IQ4_NL.gguf ggml-org/Inkling-2-Mini-GGUF cbdf3fa9
146 tiny models test-llama-archs -o <dir> (master build) n/a

Flash-Next runs with -lm none -lzm on-direct.

Commands

# tests, both trees, both backends
ctest --test-dir <build> -L main -E 'test-opt|test-llama-archs' --output-on-failure
test-llama-archs -b <dev>
test-llama-context --models <tiny> -ngl 99                                   # plain, and GGML_SCHED_DEBUG_REALLOC=1 x3
HIP_LAUNCH_BLOCKING=1 test-llama-context --models <tiny> -ngl 99             # ROCm, also with the realloc env
GGML_SCHED_DEBUG_REALLOC=1 test-llama-context -m <tiny>/<arch>.gguf -ngl 99  # each of the 146 models alone, base and head
test-backend-ops test -b <dev> -o GATED_DELTA_NET | SSM_CONV | CONCAT | CONCAT_SSM_CONV_SILU

# parity, n_rs_seq forced through llama_context_params (an LD_PRELOAD wrapper of llama_init_from_model) for the "rs3" runs
llama-debug -m <model> -f tests/corpus/correctness-<t>.txt -c 16384 -b 16384 -ub 512 -ngl 99 -fa on -ctk f16 -ctv f16 --save-logits --logits-output-dir <dir>
llama-perplexity -m <model> -f <4 corpora joined> -c 2048 -b 2048 -ub 2048 --chunks 6 -ngl 99 -fa on -ctk f16 -ctv f16 --kl-divergence-base <base.kld> [--kl-divergence]
llama-perplexity ... -c 16384 -b 512 -ub 512 --chunks 2 ...      # long, 27B only (Flash-Next at c16384 does not fit our memory cap)
llama-completion -m <model> -f correctness-prose.txt -n 256 --temp 0 --seed 1 -no-cnv --ignore-eos -ngl 99 -fa on -c 16384

# servers, one at a time
llama-server -m <model> -ngl 99 -fa on -ctk f16 -ctv f16 --cache-ram 0 -b 2048 -ub 2048 -np 1 -c 70000 \
  [-md <sidecar> -ngld 99] --spec-type draft-mtp --spec-draft-n-max 3        # or -md <DFlash2> --spec-type draft-dflash2
# prompt = the four corpora joined twice, tokenized once with /tokenize, first N ids; 512-token warm-up;
# N = 2048, 12000 (x2 each), 32000 (x2, 27B x1), 64000 (x1), n_predict 1, cache_prompt false
# then 2048 prompt + 256 greedy tokens (top_k 1, n_probs 10); a 2048 + 64 + 1500 continuation with cache_prompt true vs false
# decode: 6 prompts of 2048 ids (offsets 0, 5000, 10000, 15000, 20000, 30000) x 256 greedy tokens, 4 servers per side
# -np 2 and -np 4 (kv-unified and not): concurrent prompts of 3000 / 2000 and 200 / 1500 / 5000 / 50 tokens, compared with solo runs

Results

test-llama-context, realloc env, each tiny model alone (146 models):

Vulkan base Vulkan head Vulkan head + fix ROCm base ROCm head ROCm head + fix
models that abort inkling2-moe inkling2-moe + 10 inkling2-moe inkling2-moe inkling2-moe + 10 inkling2-moe

The 10 are bailingmoe3, clover_moe, glm5-next, kimi-k3, kimi-k31, lfm2, lfm2moe, lfm3, nemotron_h, nemotron_h_moe. They abort in rollback_cell_move, after rollback_bound. The --models run and the ctest test-llama-context abort on both sides, because inkling2-moe aborts on master too. Without the realloc env, 146/146 pass on both sides and both backends, also with HIP_LAUNCH_BLOCKING=1. On CPU (-ngl 0), lfm2 and kimi-k3 already abort on master, so CPU says nothing here.

Other tests, the same on base and head and both backends: ctest 34/35 (only test-llama-context, see above); test-llama-archs all pass (155 ROCm, 156 Vulkan); GATED_DELTA_NET 69/69, SSM_CONV 60/60, CONCAT 246/246 (VK), CONCAT_SSM_CONV_SILU 12/12 (VK).

llama-debug, all four corpora, both backends, 27B and Flash-Next (logits and token ids):

comparison result
base rs0 vs head rs0 identical
head rs3 vs base rs0 identical
base rs3 vs base rs0 logits differ, tokens identical
LFM2-700M and Inkling-2-Mini (code, prose): every pair identical

KLD against base rs0 (.kld files of base rs0 and head rs0 have the same sha256 on both backends):

backend model floor (ub 512) base rs3 head rs3 head rs0 (long)
Vulkan Flash-Next short 0.002696 0.002827 0.000000 n/a
Vulkan 27B short / long 0.000004 / n/a 0.000005 / 0.000014 0 / 0 0
ROCm Flash-Next short 0.002223 0.002591 0.000000 n/a
ROCm 27B short / long 0.000552 / n/a 0.000383 / 0.000545 0 / 0 0

Greedy 256 tokens (prose): base A/A identical; head equal to base; head rs3 equal to base rs0 on both models on Vulkan and on the 27B on ROCm. On ROCm Flash-Next, base rs3 and head rs3 both differ from rs0, because single-token decode steps use the K-slot path on both sides.

Prompt t/s, mean [min-max]:

backend model N base head change
VK Flash-Next + MTP 2048 948.9 [931.8-971.8] 1073.3 [1039.3-1111.1] +13.1%
VK Flash-Next + MTP 12000 887.3 [876.6-897.0] 997.3 [991.8-1003.6] +12.4%
VK Flash-Next + MTP 32000 902.7 [902.1-903.2] 1001.1 [998.7-1004.1] +10.9%
VK Flash-Next + MTP 64000 879.6 [878.4-880.8] 977.3 [976.3-978.4] +11.1%
VK Flash-Next, no draft 2048 / 32000 1133.5 / 1080.2 1144.8 / 1082.2 +1.0% / +0.2%
ROCm Flash-Next + MTP 2048 801.5 [749.2-824.7] 923.8 [911.4-935.6] +15.3%
ROCm Flash-Next + MTP 12000 791.3 [782.7-796.1] 892.8 [881.2-899.4] +12.8%
ROCm Flash-Next + MTP 32000 816.1 [815.0-816.9] 924.2 [919.4-926.6] +13.2%
ROCm Flash-Next + MTP 64000 800.0 [799.6-800.4] 904.3 [903.1-905.4] +13.0%
ROCm Flash-Next, no draft 2048 / 32000 959.3 / 964.9 962.0 / 964.4 +0.3% / -0.0%
VK 27B + MTP 2048 498.9 [489.3-509.2] 515.3 [504.7-526.5] +3.3%
VK 27B + MTP 12000 450.6 [447.5-453.8] 460.8 [459.8-461.6] +2.3%
VK 27B + MTP 32000 414.8 [413.9-415.7] 424.5 [424.2-424.8] +2.3%
VK 27B + MTP 64000 372.4 [371.6-373.1] 382.1 [381.9-382.2] +2.6%
VK 27B + DFlash2 2048 509.0 [496.1-521.9] 528.5 [516.9-540.0] +3.8%
VK 27B, no draft 2048 / 32000 537.9 / 441.3 535.5 / 440.4 -0.4% / -0.2%
ROCm 27B + MTP 2048 391.8 [384.8-398.8] 411.1 [403.2-419.7] +4.9%
ROCm 27B + MTP 12000 372.8 [372.2-373.5] 390.0 [390.0-390.1] +4.6%
ROCm 27B + MTP 32000 332.9 [332.6-333.1] 346.6 [346.5-346.7] +4.1%
ROCm 27B + MTP 64000 278.8 [278.5-279.0] 288.1 [287.8-288.5] +3.4%
ROCm 27B + DFlash2 2048 399.6 [391.9-407.3] 421.1 [411.7-430.5] +5.4%
ROCm 27B, no draft 2048 / 32000 421.9 / 359.1 421.1 / 359.1 -0.2% / +0.0%

Decode with the draft, 6 prompts x 256 tokens, 2 servers per side (each server gives the same result):

backend model base tg head tg change acceptance base -> head
VK Flash-Next 47.87 [42.29-56.38] 46.69 [37.18-53.75] -2.5% 0.792 -> 0.756
ROCm Flash-Next 44.57 [41.48-50.62] 43.83 [39.31-51.92] -1.7% 0.812 -> 0.781
VK 27B 30.08 [26.58-33.80] 29.81 [25.59-33.63] -0.9% 0.807 -> 0.787
ROCm 27B 27.06 [23.29-30.35] 26.94 [24.14-30.31] -0.4% 0.809 -> 0.806

Per prompt, head is faster on 2 of 6 Flash-Next prompts and slower on 4. On both sides the greedy streams leave the no-draft stream at about the same token. On the one Vulkan prompt where both sides give the no-draft stream for all 256 tokens, head accepts 184/210 and base 186/206.

Multi-slot: no abort or "failed to remove sequence" on any server. The concurrent vs solo streams differ on some slots both with and without a draft, on base and on head alike (batch shape), so they do not gate the PR.

Compute buffer warnings at shutdown: with the draft, the Vulkan0 line is 953.09 MiB on head and 947.04 MiB on base. 953.09 MiB is also the size of master without a draft, so head grows to the no-draft graph. On ROCm head prints 639.21 MiB where base prints 648.21 MiB.

Correctness

check method result
spec unit tests ctest -L main (spec-mtp-pcum, draft-vocab, rejection sampling) pass both
test-llama-archs all archs, both backends pass both
test-llama-context 146 tiny models, realloc env, each alone FAIL: 10 head-only aborts (Ask 1); pass with the fix
f32 logit parity, no draft llama-debug, 4 corpora, 27B + Flash-Next byte-identical
f32 logit parity, n_rs_seq = 3 llama-debug, head rs3 vs rs0 byte-identical
KLD/PPL short c2048, 6 chunks head 0; base rs3 within floor (VK) or near it (ROCm Flash-Next)
KLD/PPL long c16384, 27B head 0
greedy decode A/A llama-completion 256 base A/A identical, head equal
target output with draft, temp 0 server, 2048 prompt + 256, and 6 prompts not a gate (see Results); first-token log-probs closer to no-draft on head
HIP_LAUNCH_BLOCKING=1 test-llama-context, ROCm same as unset
op tests GDN, SSM_CONV, CONCAT, CONCAT_SSM_CONV_SILU pass both (no ggml change)
-Werror / VGPR gate n/a no HIP files changed
server pytest n/a not available

Findings in full

  1. Blocking: reserve gap (Ask 1). Before this PR the pp reserve built the K-slot graph at full width, so it covered every short K-slot ubatch. Now the pp reserve builds the plain graph. A ubatch of 2 to n_rs_seq+1 tokens per sequence with several sequences builds a K-slot graph that neither reserve covers. reserve_token_ranges probes the node-count change at n_rs_seq+2 and reserves the top of each range, but it runs only for graph_depends_on_n_tokens() models (qwen35, qwen35moe, qwen4exp). Running it whenever n_rs_seq > 0 closes the gap. In production this is a compute-buffer grow at runtime, not wrong output.
  2. Upstream ggml-org ggml-org#31669 ("GDN: use replay instead of rollback") rewrites build_recurrent_attn. Its keep rule has the same upper bound, n_seq_tokens <= n_rs_seq + 1. At the next sync the delta-net-base.cpp hunk resolves to upstream. The build_conv_state_store hunk stays.
  3. common/speculative.cpp: for verify batches and shared memory the result is the same as master. For a prompt batch only the carry row is copied now, which is what accept() reads.

Claims

  • "16 to 18% faster on Vulkan with the MTP draft": reproduced in direction, +10.9 to +13.1% on our Flash-Next file (TQ2_0, not UD-Q4_K_XL), +12.8 to +15.3% on ROCm.
  • "No change without a draft: same logits and token ids": reproduced, byte-identical.
  • "ctest -L main passes on Vulkan and ROCm": not reproduced on current master (Ask 1). Your base 403dfcb does not have rollback_cell_move.
  • "four op tests pass": reproduced.
  • decode "-0.4%": we see -0.4 to -2.5% over 6 prompts.

Not tested

Real GDN/KDA models other than qwen35 and qwen4exp with a draft (only the tiny models), Flash-Next long KLD (memory), CPU speed, server pytest (not installed), GPUs other than gfx1151.

@dzannotti
dzannotti dismissed stale reviews from themself November 26, 2026 16:35

Replaced by the review of 2026-11-26.

@dzannotti dzannotti added waiting-user We asked the author for something. and removed verifying Building and running the PR to verify its claims. Vulkan testing ggml labels Nov 26, 2026
With n_rs_seq > 0 the pp reserve is the plain-scan graph and the tg reserve
has one token per sequence, so a short multi-token ubatch that takes the
K-slot path was not covered and test-llama-context aborted with
"unexpected graph reallocation" under GGML_SCHED_DEBUG_REALLOC=1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dzannotti

Copy link
Copy Markdown
Collaborator

We added the one-line fix from our review as commit 6f02a13 (spec : probe the token ranges when n_rs_seq > 0), so that the reserve covers the K-slot graph of a short multi-token ubatch.

Re-checked on Strix Halo, with the branch merged into current master 730b567 (clean merge) against that master, on Vulkan and on ROCm (with HIP_LAUNCH_BLOCKING unset and =1):

  • test-llama-context with GGML_SCHED_DEBUG_REALLOC=1, each of the 147 tiny models alone: the 10 architectures from the review now pass, including rollback_cell_move. Only inkling2-moe aborts, the same as on master.
  • test-spec-mtp-pcum, test-draft-vocab and test-qwen4exp-mtp-cache-only pass.
  • Without a draft, the final f32 logits and token ids (llama-debug, prose corpus, Qwen3.5-0.8B and LFM2-700M) are byte-identical to master on both backends.

Thanks @Nathanw1014 for the work and the quick rework.

Comment made with AI on behalf of the strix-llama.cpp maintainers.

@dzannotti
dzannotti merged commit 5b3bda8 into master Nov 26, 2026
9 checks passed
@dzannotti
dzannotti deleted the hb/mtp-prefill branch November 26, 2026 17:52
@dzannotti dzannotti added verified The claims were reproduced. and removed waiting-user We asked the author for something. labels Nov 26, 2026
@dzannotti dzannotti self-assigned this Nov 26, 2026
rcfa pushed a commit to rcfa/strix-llama.cpp that referenced this pull request Nov 26, 2026
…r sequence

After such a ubatch the recurrent memory refuses a partial rollback (rs_max = 0), so no snapshot slot but the
final state is ever read. Run the no-draft scan and conv state store for it, and keep the K-slot path for
ubatches that a rollback can end inside.

Suggested by dzannotti in the review of halo-box#255.

Assisted-by: Claude Opus 5.5
(cherry picked from commit df2f118)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

model risk:medium Risk: medium verified The claims were reproduced.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants