Skip to content

gpu::draft: one executor for a draft's walks of several slots, with Qwen3.8's MTP and GLM's NextN as its programs - #1102

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-cmn-draft-exec
Nov 1, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-cmn-draft-exec

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

여러 slot의 draft walk를 공용 executor 하나로 옮겨 Qwen3.8 MTP와 GLM NextN이 함께 쓰게 했고, Qwen3.8의 launch는 그대로이며 측정한 모든 arm에서 손실이 없습니다.

What and why

A draft that walks several sequences in one pass needs the same steps whatever the model: refuse a slot named twice, cut the chains into rounds the program's limits allow, give each chain's attention its own sequence, and read the proposals back. Qwen3.8's MTP kept that assembly in its own files (body38.rs, mtp38.rs), and GLM's NextN had none, so its slots ran one after another with one readback each.

crates/gpu/src/draft.rs now owns it: the SlotDraft trait, GpuModel::draft_store_slots and GpuModel::draft_chain_slots. A program supplies only its steps. Qwen3.8's Body38 and GLM's Body implement the trait, so a new model's MTP has to write only those steps. Qwen3.8 issues the same launches in the same order as before. GLM's NextN round now runs the embedding norm, eh_proj and the joined projection once for every slot's row and reads the proposals back once per round, where it read back once per slot.

Release notes: Under the hood: Qwen3.8 MTP and GLM NextN walk several slots through one shared executor, and GLM's NextN reads its proposals back once per round.

Code shape

The review reads these first. A box left unticked needs one line of why.

  • No second copy. The slot round (slot and store-walk refusals, cutting into rounds, home order, per-chain sequence exchange, one readback, fault propagation) has one owner, crates/gpu/src/draft.rs. ChainBlock, Proposal and the chain type moved there from Qwen3.8's files, and Head::tokens now calls the shared read_tokens, which the GLM round readback reuses.
  • Model code holds only architecture facts. impl SlotDraft<TargetRows> for Body38 and impl SlotDraft<GlmArena> for Body each call their program's own steps. The common owner gained no per-model branch, flag or trait method.
  • Dead code is gone. mtp_store_slots, mtp_chain_slots, mtp_chain_round, SlotChain38, MtpDraft and chain_spans are removed.
  • No silent failure. A slot named twice, a store walk over its row limit, a round past its row or pair limit, a chain with its own walk or in the store walk's mode, and a probability request the readback cannot answer are named errors at the entry.
  • Comments state what is true now.
  • No relaxed gate. No band, tolerance or lint moved. gate_qwen4exp_mtp.rs only follows the renamed functions.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": the slot round in crates/gpu/src/arch/qwen3moe/body38.rs (mtp_store_slots, mtp_chain_slots, mtp_chain_round) and ChainBlock, MtpDraft and chain_spans in crates/gpu/src/arch/qwen3moe/mtp38.rs, removed after the move into crates/gpu/src/draft.rs.

What I ran

Every check below ran on a DGX Spark. The card line is from:

nvidia-smi
Sun Nov  1 18:16:46 2026       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |
| N/A   59C    P8              5W /  N/A  | Not Supported          |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+

The upstream base is 39ed53b875a0811cdaf587dd19963da24a650c48 and the PR head is 4fe6f97960d0999531eb85a3cd35cea616337e45.

Host test and lint on the PR head:

env BLOOMERY_BOX_LOCAL=1 just gate-app
cargo clippy --workspace --all-targets --features gpu,bloomery-metal/pipeline-scan,bloomery-metal/encode-trace,bloomery-gpu-gates/deepseek41,bloomery-gpu-gates/vision,bloomery-gpu-gates/glm5next,bloomery-gpu-gates/mimo2,bloomery-gpu-gates/solar2,bloomery-gpu-gates/minimaxm3,bloomery-gpu-gates/flint,bloomery-gpu-gates/gemma-embedding2,bloomery-gpu-gates/gemma4a,bloomery-gpu-gates/clef,bloomery-gpu-gates/hf,bloomery-gpu-gates/glm5next-hf,bloomery-gpu-glm5next/hf,bloomery-decision/safetensors
test result: ok. 34 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.01s
chain-clippy: lint rc 0 (^warning: 0, the ratchet 0 in tools/lint-ratchet.txt)

Gates on the changed paths, fixture tier on the card (BLOOMERY_BOX_LOCAL=1, BLOOMERY_TIER=fixture):

./tools/box.sh 'bash tools/gate.sh --gpu --oxide -p bloomery-gpu --release --lib -- draft::tests'
just gate-gpu-qwen4exp-mtp
just gate-gpu-glm5next-mtp
test draft::tests::a_round_walks_each_chain_to_its_depth ... ok
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 481 filtered out; finished in 0.00s
(y) two slots in the server's order: 8 drafted passes a slot, a select between every pass; each slot's ids PASS its single-sequence reference's, its proposals and acceptances PASS, its draft store PASS PASS
(z) two slots in one pass at depths 1 and 1 (a pass of 4 rows): 8 passes; each slot's ids, kept rows, draft windows and draft store its window's alone run's; 16 slot passes kept fewer rows than they ran, 0 passes kept different counts on the two slots (printed, not pinned in this tier) PASS
(z) two slots in one pass at depths 3 and 3 (a pass of 8 rows): 8 passes; each slot's ids, kept rows, draft windows and draft store its window's alone run's; 16 slot passes kept fewer rows than they ran, 0 passes kept different counts on the two slots (printed, not pinned in this tier) PASS
(z) two slots in one pass at depths 1 and 3 (a pass of 6 rows): 8 passes; each slot's ids, kept rows, draft windows and draft store its window's alone run's; 16 slot passes kept fewer rows than they ran, 0 passes kept different counts on the two slots (printed, not pinned in this tier) PASS
(z) two slots in one pass at depths 3 and 1 (a pass of 6 rows): 8 passes; each slot's ids, kept rows, draft windows and draft store its window's alone run's; 16 slot passes kept fewer rows than they ran, 0 passes kept different counts on the two slots (printed, not pinned in this tier) PASS
(kp-draft) a drafted run's state of 69 positions, a point at 64 (asked 68): whole resume holds the draft's 69 at 69 PASS
gpu-gate.sh: gate_qwen4exp_mtp ran 365 s (exit 0)
(f) a chain in the store walk's mode -> glm5next NextN: a chain in the store walk's mode: it reads the head PASS
(f) a chain into no place -> glm5next NextN: a proposal of 1 id into 0 places PASS
(z) two slots in one pass: 8 rounds, each window's draft its own and its proposal capped at the seat's depth 1 (a pass of 4 rows), kept slot 0 [1, 1, 1, 1, 1, 1, 1, 1], slot 1 [1, 1, 1, 1, 1, 1, 1, 1]: each window's ids, kept rounds, draft store and position its alone run's; 16 slot rounds kept fewer rows than they ran, 0 rounds kept different counts on the two slots PASS
gpu-gate.sh: gate_glm5next_mtp ran 22 s (exit 0)

The real Qwen3.8 server binary, built with the gate feature set, with MTP at --parallel 2, drafted and plain arms:

export BLOOMERY_BOX_LOCAL=1 BLOOMERY_TIER=fixture BLOOMERY_MODEL=qwen4exp BLOOMERY_GATE_V41_LOAD=1
. tools/ref/ref-paths.sh
cargo oxide build --arch "$(bash tools/arch.sh)" -- -p bloomery-gpu-gates --features deepseek41,gemma-embedding2,hf --release --bin bloomery-serve-qwen38 --bin gate_qwen38_serve
cargo oxide build --arch "$(bash tools/arch.sh)" -- -p bloomery-gpu-gates --features gpu --release --bin generate_qwen3moe
D=target/q38-serve-gate; mkdir -p $D; T="The capital of France is"; I=$REF_TOKENS
bash tools/gpu-gate.sh generate_qwen3moe --place gate --tokens "$I" -n 16 > $D/gen.log
for arm in drafted plain; do
  bash tools/gpu-gate.sh gate_qwen38_serve --arm $arm --gen $D/gen.log --prompt "$T" --ids "$I" --dir $D/$arm
done
gpu-gate.sh: gate_qwen38_serve ran 46 s (exit 0)
gpu-gate.sh: gate_qwen38_serve ran 249 s (exit 0)

Both arms exit 0, no check line fails, and 96 check lines print PASS across the two arms.

Speed, TP=1, P=4096, K=128, three rounds per side on one GB10, base and head built and timed in one run. Each side is built in its own checkout (base or head):

(cd head && cargo oxide build --arch "$(bash tools/arch.sh)" -- -p bloomery-gpu-gates --features glm5next,clef,vision,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve)

The servers, with MODEL_FP4L set to the FP4-Local folder (Hardware below), for the draft-off arm, the MTP C=1 arm and the MTP C=2 arm:

env BLOOMERY_DRAFT=off BLOOMERY_HOST_ROOM=96G ./head/target/release/bloomery-serve -m "${MODEL_FP4L}" --host 127.0.0.1 --port 18731 --parallel 1 --ctx-size 16896
env -u BLOOMERY_MTP_DRAFT BLOOMERY_DRAFT=mtp BLOOMERY_HOST_ROOM=96G BLOOMERY_MTP_WIDTH=cost ./head/target/release/bloomery-serve -m "${MODEL_FP4L}" --host 127.0.0.1 --port 18731 --parallel 1 --ctx-size 16896
env -u BLOOMERY_MTP_DRAFT BLOOMERY_DRAFT=mtp BLOOMERY_HOST_ROOM=96G BLOOMERY_MTP_WIDTH=cost ./head/target/release/bloomery-serve -m "${MODEL_FP4L}" --host 127.0.0.1 --port 18731 --parallel 2 --ctx-size 16896

Each request is a POST /completion whose prompt is 4,096 token ids from a fixed window of a token-id corpus (code-fn, SHA-256 7520b471436fb307e91ee22640ad8100701d48e63e3da7de9160b705b92915d1; prose-en, d10c7044df8884fdd200304604772d81a4b56a228f802d5f05db724b245ef77a), with n_predict 128. The draft-off and MTP C=1 arms send one request at a time at temperature 0 (draft off on code-fn only). The MTP C=2 arm sends two at once at temperature 0.7 with seed 42. Each arm times eight windows 50,000 ids apart after two warm-up windows. Prefill and decode tok/s come from the server's timings, TTFT p95 and total tok/s from the client clock. Each cell is the median of three rounds with their range in parentheses. A positive change is faster. Head and base print the same 128 token ids per request, and draft on and off print the same ids on each side:

metric base head change ranges overlap
draft off code-fn decode tok/s 31.48 (31.44 to 31.81) 31.57 (31.44 to 31.67) +0.28% yes
draft off code-fn prefill tok/s 2902.09 (2844.47 to 2902.30) 2903.77 (2883.07 to 2904.06) +0.06% yes
draft off code-fn TTFT p95 ms 1416.73 (1416.40 to 1445.02) 1416.57 (1415.79 to 1426.19) +0.01% yes
MTP C=1 code-fn decode tok/s 59.82 (58.54 to 59.93) 59.93 (57.62 to 59.96) +0.18% yes
MTP C=1 code-fn prefill tok/s 2716.48 (2715.92 to 2717.01) 2718.55 (2715.04 to 2720.37) +0.08% yes
MTP C=1 code-fn TTFT p95 ms 1513.08 (1513.05 to 1513.62) 1511.97 (1511.05 to 1514.14) +0.07% yes
MTP C=1 prose-en decode tok/s 41.07 (40.64 to 41.19) 41.44 (41.38 to 41.75) +0.90% no
MTP C=1 prose-en prefill tok/s 2774.37 (2766.04 to 2776.15) 2765.21 (2763.39 to 2779.68) -0.33% yes
MTP C=1 prose-en TTFT p95 ms 1481.93 (1480.74 to 1486.02) 1486.83 (1478.96 to 1487.65) -0.33% yes
MTP C=2 code-fn decode tok/s 31.09 (31.08 to 31.94) 32.53 (31.60 to 32.74) +4.61% yes
MTP C=2 code-fn prefill tok/s 2717.05 (2704.89 to 2721.96) 2705.78 (2703.04 to 2711.93) -0.41% yes
MTP C=2 code-fn total tok/s 47.95 (46.93 to 48.67) 48.20 (46.48 to 48.82) +0.53% yes
MTP C=2 code-fn TTFT p95 ms 3071.20 (3069.23 to 3074.23) 3061.01 (3058.28 to 3072.95) +0.33% yes
MTP C=2 prose-en decode tok/s 25.84 (25.54 to 26.20) 25.76 (24.80 to 26.26) -0.34% yes
MTP C=2 prose-en prefill tok/s 2754.72 (2750.56 to 2762.31) 2748.55 (2737.52 to 2753.72) -0.22% yes
MTP C=2 prose-en total tok/s 42.18 (39.65 to 42.90) 40.35 (40.00 to 41.79) -4.35% yes
MTP C=2 prose-en TTFT p95 ms 3019.28 (3005.26 to 3019.72) 3008.80 (3005.35 to 3011.47) +0.35% yes

The change claims no speed gain. Qwen3.8 issues the same launches as before, and the base and head ranges overlap in every row except MTP C=1 prose-en decode (+0.90%).

Hardware (if the change is for a machine)

NVIDIA GB10 (DGX Spark), driver 595.84, CUDA 13.3. Model:

repository revision file
nvidia/Qwen3.8-Flash-Next-FP4-Local b9ce18a6887e18c089fdea8509a33e63429a3300 the folder (SHA-256 of model.safetensors.index.json 5fa166bbb1cf25adda455117563efa72a2072272001f459eedece131ffc913e1)

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

…wen3.8's MTP and GLM's NextN as its programs

A store walk of several resident sequences' rows and a round of several
slots' window chains were Qwen3.8's own code (Body38's mtp_store_slots,
mtp_chain_slots and mtp_chain_round), and GLM's NextN walked its slots in
turn, one readback a slot. The rounds now have one owner in gpu::draft:
GpuModel::draft_store_slots and GpuModel::draft_chain_slots refuse a slot
named twice, cut the chains into rounds at the program's row and readback
bounds, make the homes canonical (on_slots), walk each depth over every
chain that reaches it with each chain's append and attention on its own
sequence, read the round back once and poison every slot of a call a
fault met. A program implements SlotDraft: its staging, its row-wise
launches, its per-sequence append and attention, its head and readback.

Body38 implements it with Mtp38's existing phases, so Qwen3.8's walks and
proposals are the same launches as before. GLM's Body implements it by
splitting the NextN walk into the same phases (stage, front, append, full
part): a round stages each slot's refresh at its own arena rows, runs the
embedding norms, eh_proj and the joined projection once over every slot's
rows, then each slot's append and full part over its own store, and reads
every slot's proposal back once (head::read_tokens over a buffer laid out
as the head's argmax words). The one-sequence walk runs the same four
phases.

app::mtp's chains_at_once and write_proposal serve both adapters'
chain_slots; Proposal (the readback's ids and probabilities) moved from
qwen3moe to gpu::draft.
@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Nov 1, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: CLEAN: No must-fix finding remains; the evidence requests are non-blocking.

Non-blocking

⚠ Supply the PTX comparison: crates/gpu/src/draft.rs:638 moves Qwen3.8's executor. The body reports gates and timing but no PTX comparison. Attach just canon-check 1dfd2c2b86d21f1a117cff8bd94d381864d95fed output for the move/split class.

⚠ Measure GLM's changed geometry: crates/gpu-glm5next/src/nextn.rs:1516 combines the slots' refresh rows into one projection width and reduces proposal readbacks from one per slot to one per round. The timing table covers Qwen3.8. Attach a GLM two-slot base/head A/B on the contributor's card for the geometry class.

Optimization headroom

  • D, More at once: crates/gpu-glm5next/src/nextn.rs:1372 opens the existing BatchLeg with one column per slot. For S slots, batching these rows through that port would reduce route-download groups, host union calls and sum uploads from S to one each per draft round.

Checked

Ownership: the shared executor replaces Qwen3.8's slot orchestration; both model implementations use it.
Complexity: NextN's existing walk is split into staging, projection, store append and full-row phases.
Silent failure: empty chain lists do not enter a round; GLM refuses probability requests before dispatch.
Tests: static mutation inspection at crates/app/src/mtp.rs:442 and crates/gpu/src/draft.rs:392: dropping the token copy or changing the depth filter from >= to > would fail the new assertions.
Gates: the changed Qwen gate follows API renames without changing assertions. The bounded-wait selector follows read_tokens with a dated PIN and reason.
Escape catalog: none of its four shell patterns appears in the changed script lines.

Notes

Review was static; tests and card gates were not rerun. Posted runs identify 39ed53b→4fe6f97, while this review covers 1dfd2c2→54f76b0. Current-head GPU evidence is absent.

Card check: needs-gpu. This pull request changes crates/app/src/arch/glm5next/mtp.rs, crates/app/src/arch/qwen3moe/mtp.rs, crates/app/src/mtp.rs … and carries no gate run on a card (CONTRIBUTING's evidence list); a maintainer adds gpu-verified after one.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit c297d06 into midagedev:main Nov 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant