Skip to content

qwen38: a pass of several slots runs its MTP chains as one walk a depth over every slot's rows - #1029

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-next-mtp-draft
Oct 30, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-next-mtp-draft

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

DGX Spark에서 Qwen3.8 MTP 서버가 slot 여러 개의 draft chain을 깊이마다 한 번의 walk로 묶어 돌려 C=4 코드 생성 처리량을 높이는 PR입니다.

What and why

When one forward step covers several slots, each slot's MTP draft chain was its own walk. This PR groups the chains whose refresh reads the step or verify arena and walks them together: depth j is one walk over the rows of every slot that reaches that depth. Attention still runs per slot against that slot's own store, and one readback serves the whole round. A single chain keeps its own path, so the one-slot case is unchanged. The gate below compares each slot's proposals and draft store with its alone run.

  • crates/app/src/mtp.rs: pass_slots collects the chain decisions of a window and makes one MtpBody::chain_slots call. The default implementation selects the slots one by one and calls chain.
  • crates/app/src/arch/qwen3moe/mtp.rs: connects chain_slots to Qwen38Model::mtp_chain_slots.
  • crates/gpu/src/model/slots.rs: GpuModel::on_slots binds the named slots' parked sequences.
  • crates/gpu/src/arch/qwen3moe/body38.rs, mtp38.rs: walk is split into walk_in, attend and walk_out, and the round uses them with one readback. The single-chain launch list is unchanged.
  • crates/gpu-gates/src/bin/gate_qwen4exp_mtp.rs: two new (z) clauses run two slots at unequal depths, 1 and 3, in both orders.

Release notes: Changed: a DGX Spark server running Qwen3.8 with MTP and several slots drafts all slots' chains in one walk, which raises throughput at C=4.

Code shape

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

  • No second copy. The chain bound check lives in Mtp38::chain_end, which run_chain and stage_chain both call.
  • Model code holds only architecture facts. The grouping sits in the common pass_slots and GpuModel::on_slots, not in a model file.
  • Dead code is gone. Nothing the change made unused is left behind.
  • No silent failure. A repeated slot and a chain past its store end the call with a named error.
  • Comments state what is true now. No dates, issue numbers or history.
  • No relaxed gate. No band, tolerance or lint moved; the gate gained clauses.
  • 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": none.

What I ran

Base 989d0106b36ca2141adf5d506c3ebdef0c86a1c9, head 268d9730f213bd51a8daa8dac4889a5b7f87063d, model nvidia/Qwen3.8-Flash-Next-FP4-Local at revision b9ce18a6887e18c089fdea8509a33e63429a3300 with its folder MTP draft, served by bloomery-serve on one DGX Spark. Three timed rounds per side, interleaved, P=4096, K=128, temperature 0.7, seed 42, C=2 and C=4.

Each side served the model with 4 slots under bloomery-serve -m <folder>, and a client held C requests in flight. The metric is total tokens per second over the whole request, with the result of the same-window comparison below.

Verdict: GAIN
Metric Base Head Difference Ranges overlap
C=4 code-fn total tok/s 43.369 44.7513 +3.187% no
C=4 prose-en total tok/s 42.3408 42.081 -0.614% yes
C=2 code-fn total tok/s 45.8924 45.2716 -1.353% yes
C=2 prose-en total tok/s 37.9758 39.2211 +3.279% yes

Each cell is the median of three rounds. C=4 code-fn is the one resolved gain: base rounds 42.67, 44.02 and 43.37 against head rounds 44.75, 44.29 and 44.93. The other three cells have overlapping ranges.

The changed multi-slot MTP path, on a GB10 at fixture tier, at head d3f28e0f03ec3b506b773c40f58d8efa9b5bb646:

just gate-gpu-qwen4exp-mtp
(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 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; ... 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; ... PASS
gpu-gate.sh: gate_qwen4exp_mtp ran 368 s (exit 0)

With at: next in chain_rows replaced by at: b.block, the depths 1 and 3 clause reports a difference:

(z) two slots in one pass at depths 1 and 3 (a pass of 6 rows): 8 passes; differs in slot 1 draft windows; ... FAIL
gpu-gate.sh: gate_qwen4exp_mtp ran 350 s (exit 1)

Hardware (if the change is for a machine)

NVIDIA GB10, driver 595.84, CUDA 13.3.1, one DGX Spark, Linux aarch64.

AI help

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

@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 labels Oct 30, 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 defect was identified in the changed paths.

Non-blocking

⚠ Complete the dispatch evidence: crates/gpu/src/arch/qwen3moe/body38.rs:2653.
In graph mode, batching replaces S graph replays per depth with K individual kernel enqueues, where S is active slots and K is the grouped walk's launch count [derived]. Grouping also changes launch geometry.
Provide the launch-count delta, PTX equality for the split, and reproducible gate/A/B commands with output for this head, including the nvidia-smi line. The reported runs name earlier heads and omit the timing commands.

Optimization headroom

  • G. Per-launch and per-sync fixed cost: crates/gpu/src/arch/qwen3moe/mtp38.rs:2188 and mtp38.rs:2205. Use an MTP_ROWS-bounded stack buffer for chain_in's rows and iterate chain_rows directly in chain_out. This removes at least two host heap allocations per executed draft depth [derived].

Checked

Duplicates: dryer reported zero pairs; no duplicate finding retained.
Complexity: walk_out 66 and walk_in 28 split existing dispatch; chain_out 21 schedules copies and the fault tail; mtp_chain_slots 17 validates and packs rounds. pass_slots 26→34 adds common batching branches; slots_windows 59→60 adds a harmless depth loop.
Silent failure: three numeric zero-default sites followed; nonempty rounds and active-depth bounds prevent empty walks. Invalid feeds return named errors; device faults poison the call's slots.
Tests: the new unequal-depth clauses retain comparisons of ids, kept rows, draft windows and stores. The PR reports FAIL-first output for the chain_rows mutant at: next → at: b.block; this run was not independently reproduced.
Gates: no thresholds moved or clauses removed; unequal-depth clauses added.
Escape catalog: C1–C4 do not match the diff.

Notes

Builds and GPU gates were not run during this review.

Card check: needs-gpu. This pull request changes crates/app/src/arch/qwen3moe/mtp.rs, crates/app/src/mtp.rs, crates/gpu-gates/src/bin/gate_qwen4exp_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 d72572f into midagedev:main Oct 30, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant