Skip to content

llama : MTP draft context keeps the catch-up graph on a second scheduler - #348

Open
Nathanw1014 wants to merge 1 commit into
masterfrom
hb/mtp-graph-slot
Open

Nathanw1014 wants to merge 1 commit into
masterfrom
hb/mtp-graph-slot

Conversation

@Nathanw1014

Copy link
Copy Markdown

MTP decode on Qwen4 is 6.6% faster on Vulkan (Strix Halo, Qwen4-35B-A3B UD-Q4_K_XL + Q8_0 MTP, --spec-draft-n-max 1, -np 1): 62.62 vs 58.76 t/s, ABBA, same binary with the knob on and off.

Each MTP round runs two draft-context graphs: the K/V-only catch-up over the verified rows (no outputs) and the one-token draft step. One scheduler holds one allocated graph, so the two evicted each other and both were rebuilt and re-allocated every round. That host time grows when the CPU clocks down under load.

  • Batches of <= 64 tokens without outputs on an MTP context run on a second scheduler with their own graph result. The context's own scheduler is back in place after each ubatch.
  • The second scheduler is reset wherever the main one is (sched_reserve, memory_update, graph_reserve, opt_epoch_iter).
  • LLAMA_MTP_GRAPH_SLOT=0 turns it off. LLAMA_GRAPH_TIMING lines gain alt=0|1.
Qwen4 MTP, Vulkan slot on slot off
tg t/s (2 reps each) 62.70 / 62.54 59.01 / 58.51
draft step 3.41 ms 4.46 ms
round 29.36 ms 31.30 ms

Flash-Next (Qwen3.8-Flash-Next UD-Q4_K_XL + Q8_0 MTP, Vulkan, --spec-draft-n-max 3, same binary, knob on vs off, 3 reps each):

prompt slot on slot off
code 52.77 49.86 +5.8%
prose 35.91 34.45 +4.2%
reasoning 51.63 49.85 +3.6%
ja 22.56 21.78 +3.6%

Graph reuse in the draft context goes from about 0 to 991 of 1035 graphs. Cost: one more compute buffer, +16 MiB GTT on Qwen4.

No change without a draft. Greedy text is identical with the slot on and off (Qwen4 56/56 requests, Flash-Next 4/4 prompts, same draft acceptance).

Tested: ctest -L main (CPU build). Not tested: ROCm, -np > 1, GPUs other than gfx1151.

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

🤖 Generated with Claude Code

The K/V-only MTP catch-up over the verified rows (no outputs) and the
one-token draft step evict each other from the context's one scheduler,
so both MTP graphs are rebuilt every round. Batches of <= 64 tokens
without outputs on an MTP context now run on a second scheduler with
their own graph result, and the context's own scheduler is back in place
after each ubatch. LLAMA_MTP_GRAPH_SLOT=0 turns it off.
LLAMA_GRAPH_TIMING lines gain alt=0|1.

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant