Repository navigation
mtp: walk every plain slot's waiting draft rows in one store walk - #735
Conversation
A drafted Qwen3.8 round of several slots' plain steps ran one pass of the target rows, then walked each slot's draft over its waiting rows one slot after another, a whole store walk a slot. Every op of a store walk up to the append is row-local, so the walks now gather: each slot's policy still decides its rows (`MtpDraft::gather`), and `SlotWalks::run` walks every gathered slot's rows as one store walk (`MtpBody::store_slots`) before the target call that may overwrite them. Body38 stages each slot's hidden rows into its window of the draft's arena, embeds each block at its own positions, runs the pack, eh_proj, mix and q/k/v once over all rows, then appends each block to its own slot's store. A body without its own `store_slots` walks the slots in turn, as before. The plain steps of `step_rows_drafted` and the depth-zero windows of `pass_slots` take this path. Drafted chains stay per slot. gate_qwen4exp_mtp's (z) plain rounds pins each slot's ids, kept rows, draft windows and draft store against its window run alone, through rounds whose plain slots share one store walk.
A pass of several slots walked the pass arena's final streams, which are slot 0's own rows while the homes are canonical, even when it held no row of slot 0. A drafted round that left slot 0 out therefore ran one slot at a time (`round_keeps_refresh`) to keep slot 0's waiting hidden rows. Such a pass now walks into its first slot's own final-stream rows (`Body38::enqueue_slots`), where that slot's copy would have put them, and launches no copy for it. Slot 0's rows stay as its last call left them, so the round runs as one pass and `round_keeps_refresh` goes. gate_qwen4exp_mtp's (z) plain rounds adds passes of slot 1 alone while slot 0's draft waits on rows of the pass arena.
There was a problem hiding this comment.
Verdict: CLEAN: The two retained findings are non-blocking; no must-fix finding remains.
Non-blocking
⚠ Observe executed batching: crates/gpu-gates/src/bin/gate_qwen4exp_mtp.rs:5685 counts PLAIN_ROUNDS entries, independent of the executed store walks. Replacing gather with immediate before_step calls preserves the comparisons and this count while restoring serial walks. Assert the executed shared-walk count, or describe the count as rounds scheduled with both slots plain. This prevents a later regression from retaining a false batching witness.
⚠ Identify the measured revisions: crates/gpu/src/arch/qwen3moe/mtp38.rs:2386 combines per-slot projection launches into a shared batch and changes row geometry. The body names base b9dfc4a7 and describes differences from this head, but omits the tested head hashes and exact A/B commands. Attach those hashes and commands with output to make the reported performance evidence attributable.
Checked
Both cited lines are added by this full-review diff. pass_slots gathers depth-zero rows before SlotWalks::run; Qwen3.8 runs shared projections before appending each block with its slot selected.
plain_rounds compares IDs, kept rows, draft windows and draft stores with standalone runs. Its separate graph-node check covers the target pass, not the draft's shared store walk.
The measurement-evidence request follows CONTRIBUTING.md. Neither item meets the kind A or kind B must-fix bar. No active ledger lessons or applicable escape-catalog patterns change their classification.
Notes
Static validation only; no build or GPU gate was run here.
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/bloomery_serve_qwen38.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)
|
The review is done and the contribution check passed, so I'm merging this. |
MTP draft를 켠 Qwen3.8 서버에서 여러 slot이 같은 round에 plain step을 할 때, slot마다 따로 돌던 draft의 store walk를 한 번으로 묶어 sampled 요청의 처리량을 높이는 작업입니다.
Part of #565.
What and why
With
BLOOMERY_DRAFT=mtpon Qwen3.8, a round in which several slots take a plain step (every sampled request that runs beside another slot, and every drafted slot whose window has no proposal) ran one target pass, but the MTP draft walked each slot's waiting rows one slot after another, one store walk per slot. This PR gathers those walks and runs them as one store walk over every slot's rows before the round's pass. Each slot's rows are embedded at their own positions and appended to their own store, so each slot's draft store is the one its own walk would have written. The shared part of a store walk (the ids upload, the input pack,eh_proj, the attention site's mix and the q, k and v projections) now runs once per round and reads its dense weights once.A second commit removes the serial fallback
round_keeps_refreshfor rounds that leave slot 0 out. Such a round used to step slot by slot so that slot 0's waiting draft rows in the pass arena were not overwritten. The pass now walks into the first slot's own row buffer when it holds no row of slot 0, so slot 0's waiting rows stay where its draft reads them and the round runs as one pass.On one DGX Spark (GB10) with
nvidia/Qwen3.8-Flash-Next-FP4-Local,bloomery-serve --parallel 4, 4096-id prompts and 128 generated ids, sampled C@4 all-active decode moved by +4.41 to +7.22 % over main in all four measurements of two sittings, and its group total by +2.09 to +3.06 %. Sampled C@2 moved between -0.45 and +3.38 %, and greedy and time to first token stayed within noise. Every request returned the same ids on main, on the head and on the head with the draft off, in every group of both sittings. The drafted sampled groups remain 0.85 to 5.15 % below the same head with the draft off, so the #695 slot rule stays.Changes
crates/app/src/mtp.rs:MtpDraft::gatherruns the slot's ownPolicy::before_stepagainst aGatherexec that records the store walk of the target's rows instead of walking it. A chain, a host-hidden walk or two heads are refused by name.SlotWalks::runhands every gathered slot's rows toMtpBody::store_slots, in calls of at mostSTORE_ROWSrows, before the target call that may overwrite them.MtpBody::store_slotsdefaults to the per-slot walk, so GLM keeps its behavior with no code of its own.crates/gpu/src/arch/qwen3moe/mtp38.rs:Mtp38::store_rowsandMtp38::append_storereplacestore_walk.Mtp38::stage_storestages each slot's rows into its window of the store arena (with the arena bound checked by name),store_rowsruns the shared part once over every block, andappend_storeappends each block to its own slot's store.Mtp38::checkedholds the refusals thatrun_walkhad, andcopy_hiddenis the one copy of the hidden-row match for the chain path and the store path, now over checkedWindows.crates/gpu/src/arch/qwen3moe/body38.rs:GpuModel::<Body38>::mtp_store_slotsoverrides the default.Body38::enqueue_slotsswaps the first slot'srows_passinto the pass arena's final-stream place when the pass holds no row of slot 0 (stands_in), walks, and swaps back. That slot'sRowsCopyis then not launched, andslots_launchescounts one launch fewer.crates/gpu-gates/src/bin/shared/serve_seats/{drafted,rounds,qwen38}.rs:step_rows_draftedandpass_slots' depth-zero windows gather and run the walk before the pass.before_row_byholds the seat's records around both the walk and the gather.round_keeps_refreshand its arena-model unit test go, with a datedPINline in the test module.crates/gpu-gates/src/bin/gate_qwen4exp_mtp.rs:capped_runtakes a pass list and serves both the depth references and the new plain-rounds references, andslot_roundsruns both slots' rounds for the depth clauses and the plain rounds. The (z) "plain rounds" clause is new (see "What I ran").crates/levers/src/lib.rs,docs/serving.mdand the seat's docs: they now say the drafts are walked in one store walk beside the pass. Theload draft=offmessage stays true and is unchanged.tools/unsafe-ratchet.txt: the gpu pin goes from 2256 to 2253, becausecopy_hiddenover checked windows removes threeunsafeviews. The diff adds nounsafe.Only store walks of the target's rows are gathered. Drafted chains read a head and their own last row, so they stay per slot. The policy still decides each slot's rows (
before_step), so batching moves where the rows run and leaves the choice of rows alone.Release notes: Changed: a Qwen3.8 load with the MTP draft runs the draft's store walks of several slots' plain steps as one walk, which raises sampled decode throughput at four concurrent requests on a DGX Spark.
Code shape
copy_hiddenis the one copy of the hidden-row match for both walk paths,before_row_byserves both the walking and the gathering entry, andcapped_runandslot_roundsabsorbed the gate's separate plain-rounds runner and the repeated depth runs. The one pair the duplicate scan lists is answered below.MtpBody::store_slots, whose default is the old per-slot walk. GLM has no new code.store_walk,round_keeps_refreshand its unit test are removed.capped_run'sNonearm has no caller in the first commit alone and is used by the second.stage_storepast the arena,store_rowswith ids that do not match its blocks,mtp_store_slotswith a slot named twice or a poisoned model, andGatherwith a walk that is not a store walk of the target's rows or has two heads are each refused by name.enqueue_slotsswaps back on a failed walk and returns the walk's error first.PINreason, because the rule it modelled is gone and the (z) "plain rounds" clause pins the behavior on the card.cargo fmtandcargo clippy:cargo fmtis clean on what I touched. I did not runcargo clippyhere.Duplication found or removed:
crates/gpu-gates/src/bin/shared/serve_seats/drafted.rs:720anddrafted.rs:957(before_rowandgather_row) are one-line calls of the sharedbefore_row_by, one walking (before_step) and one gathering (gather, which needsB: Slots).What I ran
GPU evidence
The A/B ran on one DGX Spark. The first gate run and the FAIL-first runs ran on an RTX 5090 machine, and a later gate run ran on the same GB10 as the A/B. The GB10 A/B log prints the card, driver and CUDA version in
nvidia-smi:The RTX 5090 gate runs print the card with
nvidia-smi -L, and the machine'snvidia-smiquery reports its name, driver and compute capability:The GB10 gate run prints its card the same way:
Throughput A/B
One GB10,
nvidia/Qwen3.8-Flash-Next-FP4-Localfrom its folder with its own MTP layer,bloomery-serve --parallel 4 --ctx-size 16896(4224 per slot, prompt cache off), one server load per arm. Every request has a 4096-id prompt from a code corpus and generates 128 ids. Groups: C=2 and C=4 requests sent at once. Sampled requests use temperature 0.7, top-p 0.8, top-k 20 and seed 20261023 plus the request index. "sampled ignore_eos" is the same group withignore_eos. Greedy requests do not useignore_eos, so an early end reruns the wave with shifted windows. All-active decode tok/s is the summed decode rate over the window in which every request of the group decodes. Group total tok/s is the group's ids over its wall time.BLOOMERY_STEP_STATS=1is set on every arm. The arms are main with the MTP draft, the head with the MTP draft, and the head withBLOOMERY_DRAFT=off, in that order in each sitting. The GPU clock cap was lifted for each arm and restored after it.Each sitting ran every arm once, and two sittings ran, so each cell is one observation and there is no significance test. The two sittings' main arms differ from each other by 0.1 % and 0.8 % on the two C@4 sampled group totals, which is the spread to compare the gains against. The gains below are outside that spread.
Sampled C@4 all-active decode +4.41 to +7.22 % and group total +2.09 to +3.06 % over main in all four measurements of the two sittings (sampled and sampled ignore_eos); sampled C@2 -0.45 to +3.38 %; greedy and TTFT within noise. The head with MTP stays 0.85 to 5.15 % below the head with the draft off on sampled groups.
Sampled C@4 gained in every measurement. Sampled C@2 is within noise. The greedy rows and time to first token show no change beyond noise. Greedy C@2 TPOT p95 moved by -7.78 % in the first sitting and +9.35 % in the second, and greedy C@4 all-active decode read -2.97 % and -0.92 % with group totals of -0.39 % and +0.80 %. The greedy windows differ from arm to arm because the width chooser reads wall-clock costs. The change adds no work to a greedy round: its depth-zero windows now share one store walk, and its chains are unchanged.
An uneven C=4 group (one request asks for 16 ids, three ask for 128) shows the second commit. In the first sitting main ran 117 rounds of three rows as three passes, one slot at a time, once the 16-id request finished, and the head ran one. In the second sitting main ran one such round and the head none. The decode rates of that group depend on which slot finishes first, so they are not in the table.
The two sittings ran on the first commit's batched walk alone (first sitting) and on both commits (second sitting), both on main
b9dfc4a7. The PR head differs from the second sitting's head in three ways: the gate code (the dedup of the two runners above), comments and docs, and one product change,copy_hiddenover checked windows, which issues the same device copies as before. I did not re-measure the head after that change. The head here is both patches rebased onto upstream648dd751:git range-diffshows both commits unchanged (=), and the 15 upstream commits betweenb9dfc4a7and648dd751touch none of this PR's files.Gates
just check,just gate-app,just gate-q38-serve-rules,just gate-gpu-qwen4exp-mtp,just gate-gpu-qwen4exp-e2eandjust gate-gpu-glm5next-mtpran in the fixture tier on an RTX 5090 machine, on a head before the gate dedup,copy_hiddenand the final rebase. The output summaries:just checkprinted no warning or error line. The (z) depth 1, depth 3, waiting, step after and plain rounds clauses all pass; the plain-rounds clause reports 3 walks that took both slots' rows and 3 passes of slot 1 alone beside slot 0's waiting rows.After the gate dedup and
copy_hidden, I ranjust check,just gate-gpu-qwen4exp-mtpandjust gate-gpu-qwen4exp-e2eon the GB10, which printed:In that run the pass of slot 1's four rows alone holds 115 nodes against the body's 115. The clauses that need the real model (four of 28 in
gate_qwen4exp_mtp, eight of 26 ingate_qwen4exp_e2e, seven of 14 ingate_glm5next_mtp) did not run here. A maintainer runs them. The server A/B above ran with the real model, and its ids were equal in every group.FAIL first
The new (z) "plain rounds" clause fails on each defect it protects against. I applied one small change to the code at a time:
select_slotfrom the append loop) makes the clause fail: "a walk from position 66: the draft's store holds this sequence's positions below 65".stand_in && false, the old arena behavior without the fallback) makes it fail: "differs in slot 0 draft windows, slot 0 draft store".slots_launchesmakes it fail on the final head (the first two ran on the head before the gate dedup): "the pass of slot 1's 4 rows alone holds 115 nodes against the body's own 116".The three runs were on the RTX 5090 machine, and each change was reverted afterwards.
Hardware
One DGX Spark (GB10) for the A/B and for the second gate run, and an RTX 5090 machine for the first gate run and the FAIL-first runs. The
nvidia-smilines are in "GPU evidence".What I ran into
None of this blocks the PR. A drafted sampled round still costs about 1.4 to 1.7 ms more than a round with the draft off (derived from the all-active rates of the second sitting: C@4 63.8 against 62.4 ms a round, C@2 45.2 against 43.5 ms). A sampled request beside another slot never proposes (it takes a plain step), so on these groups the draft only costs: a cheaper walk can bring drafted sampled close to the draft-off rate but not above it. The #695 rule, which keeps the unset draft off under
--parallelabove 1, therefore stays. Theload draft=offmessage and the lever text are unchanged.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.