Repository navigation
qwen38: a drafted load runs a round of several slots' plain steps as one pass - #703
Conversation
…one pass A drafted load stepped a round of sampled or id-banning requests a slot at a time, each step told to its slot's draft. The round now runs as one pass of the busy rows, as a plain load's does, each row told to its slot's draft around the pass: the rows its draft left waiting walked before it, and the row's answer recorded after it as the next refresh, its hidden row the pass's. On a --parallel 4 server of Qwen3.8-Flash-Next-FP4-Local on a GB10 under BLOOMERY_DRAFT=mtp, four sampled 4096-id requests decoded at 55.8 tok/s over their all-active window against 28.3, and two at 41.8 against 28.1, with the same ids; greedy requests are unchanged. The unset draft stays off under --parallel above 1: the drafted round still walks each slot's draft over its row, one slot after another, and the same sampled rounds ran at 62.7 and 45.1 tok/s on the plain load. The reason the rule names is updated. gate_qwen38_serve's slots server holds it: a sampled pair banning the end ids steps in rounds of one pass of both slots with its alone ids, and a sampled request that steps beside a short one then drafts alone from the state its rows left. The plain arm's sampled rounds clause shares the pair's code.
The slots clauses' together runs, the late pair, the off slot's drafted request, run_streamed and run_sampled joined each streamed request's thread and took its answer in their own copies of the same loop; they now take it from answers, and one answer posts no request of its own, so run_streamed and run_sampled are gone.
The drafted sampled tail kept the long request's answer and dropped the short one's, so a short request that failed, or one that never shared a round, left the long request drafting alone, and both tail checks could pass without a row of the long request told to its draft from a pass. The clause now refuses by name unless the short request answered its eight ids and a slots round record of the tail run is one step pass of both rows. ids_as_alone takes the alone answers as an iterator, so the slots clause's ids check and the late pair's go through it with the sampled pair's.
A pass of several slots writes the pass arena the live sequence, slot 0's, reads its hidden rows from, whether the pass holds slot 0 or not; only a parked slot's rows are copied out to its own buffer. A round cut into more than one pass ran the pass that holds slot 0 first, so the passes after it overwrote the rows slot 0's draft walks next: a drafted round of nine sampled slots fed slot 8's hidden row into slot 0's MTP store, and a greedy round of drafted windows past the pass bound fed another slot's rows into slot 0's refresh. round_passes cuts a round between entries at the body's bound and puts the pass that holds slot 0 last. Session::step_slots_rounds runs its passes in that order, each pass's ids and logits rows at its rows of the round. pass_slots now takes the whole round: every window's proposal is made before any pass, so no pass overwrites the rows a draft walks before its own, then the windows run in round_passes' passes, cut by their proposals' rows, and it returns the passes it ran with each window's commit.
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix defect survives the source review.
Non-blocking
⚠ Verify the final dispatch path: crates/gpu-gates/src/bin/shared/serve_seats/qwen38.rs:2830.
The owning gate was refused with exit 64, and the A/B predates the final pass planner and refresh guard.
Run just gate-gpu-qwen38-serve on an RTX 3090 and a base/current-head A/B, including mixed and multi-pass rounds. These runs verify the implementation being merged.
Optimization headroom
- D, More at once: crates/gpu-gates/src/bin/shared/serve_seats/qwen38.rs:2847. Mixed plain and drafted groups still run separate target passes, dispatched separately at crates/serve/src/worker.rs:870. Sharing a pass when their rows fit could remove one target graph replay and token-id readback per mixed round in graph mode.
Checked
Duplicates: 16 new items checked; no duplicated owner found. Dryer reported 0 pairs; gpu-gates was excluded and checked by Grep.
Complexity: pass_slots 19→21 adds a pass loop using the shared planner. slots_drafted_sampled is new at 17: pair exercise, tail prerequisites, assertions; sampled_pair already owns the reusable stage.
Silent failure: 4 error-sensitive branches followed. Request errors turn checks red; absent drafts are intentional; missing round drafts are refused before execution.
Tests, static mutation audit: removing the slot-0 move at crates/app/src/lib.rs:786 fails the planner test. Forcing the guard true at crates/gpu-gates/src/bin/shared/serve_seats/qwen38.rs:2579 fails the mixed-round test.
Sampled clauses: disabling step_pass fails the pass-count assertion; swapping row answers fails together/alone; dropping after_row fails the drafting tail; forcing zero acceptance fails its acceptance assertion. The extracted plain sampled clauses retain their assertions.
Gates: no existing threshold, case, or pin was relaxed or removed. FAIL-first evidence describes the planner, refresh guard, batching, and refresh-record mutants.
Escape catalog: C1–C4 do not match the changed code.
Notes
Source review only; no build or hardware test was run here. The PR supplies no successful owning GPU gate run.
Card check: needs-gpu. This pull request changes crates/app/src/lib.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의 sampled 요청이 같은 round에 있을 때 slot마다 따로 돌던 step을 한 번의 pass로 묶어서 처리량을 높이는 작업입니다.
Part of #565. Fixes the Low item in #699.
What and why
With
BLOOMERY_DRAFT=mtp, a round in which several slots take a plain step (a sampled request, or one that bans token ids) ran one pass per slot. A load without a draft already runs the same round as one pass of all busy rows. This PR gives the drafted load the same pass:step_rows_draftedselects each row's slot, lets that slot's draft walk the rows it left waiting, runs onestep_rows_one_pass, and then tells each slot's draft the row's answer as its next refresh.On one DGX Spark (GB10) with
nvidia/Qwen3.8-Flash-Next-FP4-Local,bloomery-serve --parallel 4andBLOOMERY_DRAFT=mtp, four sampled requests decode at 55.80 tok/s over their all-active window where main decodes 28.29 tok/s (+97.28%), and two sampled requests at 41.77 tok/s where main decodes 28.07 tok/s (+48.84%). Every request returns the same ids as on main in every group. Greedy requests take drafted passes, which this PR changes only in the order of passes in a round of more than eight rows.crates/gpu-gates/src/bin/shared/serve_seats/qwen38.rs:step_passno longer excludes a load that drafts with MTP, and the seat'sstep_slotscallsrounds::step_rows_draftedfor such a load. A lookup load keeps its per-slot fallback.crates/gpu-gates/src/bin/shared/serve_seats/rounds.rs:step_rows_draftedloops over whatever rows the round holds, so the row count stays data.crates/gpu-gates/src/bin/shared/serve_seats/drafted.rs:before_rowis the pre-step half ofstep_reading, which now calls it, so one function owns the order.after_rowgives the draft the row throughpassed_plain.crates/app/src/mtp.rs:MtpDraft::passed_plainis the one owner of "a plain row ran in a pass of several slots". The depth-0 window inpass_slotscalls it too, because a depth-0 window is one row and records the same refresh. The row's hidden state is the pass arena's, whereBody38::plan_slotsalready lays the rows ofstep_slots.crates/app/src/lib.rs:round_passescuts a round's entries into passes of at mostSlotRows::MAX_ROWSrows and runs the pass that holds slot 0 last (see "A defect that was already there" below).Session::step_slots_roundsruns the passes in that order and puts each pass's ids and logits rows at the round's own row positions, so a caller sees its rows in the order it gave them. An entry of no row, an entry of more rows than a pass holds, and a pass that answers another count of ids than its rows are each refused by name.crates/app/src/mtp.rs:pass_slotstakes the whole round, makes every window's proposal before the first pass, and cuts the passes withround_passesfrom the rows the proposals actually hold. It returns the commits and the number of passes, so the signature of thispub fnchanges; the two callers ingate_qwen4exp_mtp.rsandgate_glm5next_mtp.rsignore the count.crates/gpu-gates/src/bin/shared/serve_seats/rounds.rs:pass_rows_one_passcallspass_slotsonce and no longer lays windows out with a loop of its own.crates/levers/src/lib.rs,crates/levers/src/registry.rs,docs/serving.mdand the seat's docs: the reason the unset draft rule gives is updated to what is still true (see "The qwen38: keep the unset MTP draft off under --parallel above 1 #695 rule" below).crates/gpu-gates/src/bin/shared/serve_seats/qwen38.rs:round_keeps_refreshis the one rule for when a step or verify call may take the shared pass (see "A defect that was already there").step_slotsandpass_slotsboth ask it.crates/gpu-gates/src/bin/gate_qwen38_serve.rs: the new gate clauses described under "What I ran".sampled_pairis the one body of the plain arm's sampled rounds clause and the drafted one.ids_as_aloneis the one comparison of a together run's ids with the same requests run alone, used by the slots clauses, the late pair andsampled_pair.A defect that was already there
A pass of several slots writes its rows into the pass arena that slot 0's live sequence also reads its hidden rows from, whether or not the pass holds slot 0. A parked slot's rows are copied out to its own buffer; slot 0's are not. When a round takes more than one pass and slot 0's pass is not the last, the next walk of slot 0's draft reads another slot's hidden row, and nothing reports it.
The new step path meets this with nine slots, where a round of plain rows takes two passes of at most eight rows. The drafted greedy path in
pass_rows_one_passhad the same defect before this PR: it laid windows out in slot order, slot 0's first, so a round whose windows hold more than eight rows (a fixed window width of 3 with three or more slots) ran slot 0's pass first, and a later pass overwrote its rows.round_passesfixes both paths with one order. Moving slot 0's pass last is not enough for the windows, because an earlier pass would then overwrite the waiting rows that slot 0's draft walks when it proposes. Sopass_slotsmakes every proposal before the first pass.The same arena is shared between calls, not only between the passes of one call. A pass that holds no slot 0 overwrites the rows slot 0's draft still has waiting, and nothing moves slot 0's position or its pending refresh. A sampled step of slots 1 and 2 ahead of a greedy verify (or the reverse) would therefore change slot 0's next proposal and its acceptance.
round_keeps_refreshcloses this at both entries,step_slotsandpass_slots: a group takes the batched pass when it holds slot 0, when the load has no MTP draft, or when slot 0's draft is off. Any other group runs each slot in turn, which leaves slot 0's buffers alone. The sampled C@2 and C@4 groups measured below hold slot 0, so they stay on the batched pass; only a partial round that leaves out slot 0 steps per slot.docs/serving.mdsays the same in its concurrent-request paragraph.Rounds of at most eight rows are one pass, so the 2-slot and 4-slot rounds measured below run the same calls as before.
The second commit,
gate_qwen38_serve: one owner joins a streamed request's thread, is a cleanup inside that gate. The slots clauses' together runs, the default server's pair, the late pair, the off slot's drafted request,run_streamedandrun_sampledeach had their own copy of the loop that joins a streamed request's thread, receives its answer and prints it. They now callanswers, andansweris its one-request form, sorun_streamedandrun_sampledare gone. The file loses 98 lines and gains 39. The lookup cost clause keeps its own loop, because a failed request there ends the gate with an error instead of turning a check red.Rounds that mix a drafted slot with a stepping slot still make two target calls, one for the steps and one for the windows. Folding the steps into the verify pass needs
verify_slotsto return each plain row's logits. That is not part of this PR.Release notes: Changed: a Qwen3.8 load with the MTP draft runs a round of sampled or id-banning requests from several slots as one pass, which roughly doubles sampled decode throughput at four concurrent requests on a DGX Spark.
Code shape
passed_plainreplaces the inline refresh record inpass_slots,before_rowis moved out ofstep_readingand called from both paths,sampled_pairserves both sampled rounds clauses, andanswersreplaces the copied join loops in the gate.MtpBodyandSlotRows, so a model supplies no new branch, flag or method for it.run_streamedandrun_sampledare removed in the second commit. Nothing else is left unused.answersis a printed failure and a red check.slots_sampled_rounds_run_one_passandslots_sampled_together_alonekeep their names and checks.cargo fmtandcargo clippyare clean on what I touched.Duplication found or removed: the join loops in
gate_qwen38_serve.rs(second commit), and the sampled pair clause shared between the plain arm and the drafted one.What I ran
Throughput A/B
One GB10 in a CUDA 13.3.1 container. Main (
78c3680d) and the head were built in their own targets withcargo oxide build --arch sm_121 -- -p bloomery-gpu-gates --features glm5next,clef,mimo2,solar2,minimaxm3,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve. Each arm loaded the server once withbloomery-serve -m <folder> --parallel 4 --ctx-size 16896,BLOOMERY_DRAFT=mtpandBLOOMERY_HOST_ROOM=96G, and the arms ran back to back in one sitting with the GPU clock cap lifted for each arm and restored after it. Every request has a 4096-id prompt from a code corpus and generates 128 ids with the prompt cache off. Greedy groups use temperature 0. Sampled groups use temperature 0.7, top-p 0.8, top-k 20 and seed 20261023 plus the request index. All-active decode counts the tokens that all requests emit while all of them decode.Each arm ran each group once, so these are single observations, not a significance test.
C@4 sampled all-active decode under BLOOMERY_DRAFT=mtp rose from 28.29 to 55.80 tok/s (+97.28%) and C@2 from 28.07 to 41.77 tok/s (+48.84%), with the same ids as main; the greedy groups take drafted passes, a path the change leaves as it is.
C@2 sampled with banned ids went from 28.31 to 42.20 tok/s (+49.08%). Each server's own
slots roundrecords show the change: main ran its plain rounds a slot at a time (cmd=step rows=2 passes=2263 times androws=4 passes=4123 times), and the head ran them as one pass (rows=2 passes=1267 times androws=4 passes=1126 times). The drafted rounds are nearly the same on both.The greedy C@4 all-active decode is 4.01% lower on the head, and I have one observation of it. Greedy requests that ban no id take drafted passes, so they never reach
step_rows_drafted. The four-request window is 4.1 to 4.4 s long, the cost chooser's draft counts follow its clock, and the group total moved by -0.30%.The A/B ran on
7122ac48, which is the change on top of main78c3680d; this head differs from it. The head adds comments, docs, the unset rule's message text, the gate changes,round_passesandround_keeps_refresh. The measured sampled rounds hold at most four rows, so they are one pass, andround_passesleaves a one-pass round as it was. Every measured round holds slot 0, soround_keeps_refreshchooses the same batched pass for it. I carried the measurement to this head and did not rerun it.Correctness
The ids are equal on every pair of arms (main with the draft, head with the draft, head without it) in the greedy, sampled and sampled id-banning groups, and in a pair of two sampled requests of 16 and 128 ids. In that pair the long request drafts 95 proposals and keeps 78 on the head, against 97 and 82 on main, with the same ids. A sampled request that steps beside a short one and then drafts alone depends on
after_row, and the gate clause below covers it.With nine slots a round takes more than one pass. On one GB10 I served the same model with
bloomery-serve --parallel 9 --ctx-size 9216,BLOOMERY_DRAFT=mtpand a fixed window, and ran nine greedy requests of 48 ids and nine sampled requests of 48 ids (end ids banned), each set alone and then together. All eighteen requests return the same ids together as alone, and the greedy ones the same proposed and accepted counts (request 0: 51 and 31 both ways). The server'sslots roundrecords show the cuts: the sampled rounds arecmd=step rows=9 passes=2(46 rounds), and the drafted greedy rounds arecmd=pass rows=9 passes=5(17 rounds). A slot 0 draft that walked another slot's row would change its proposals and accepts, so the equal counts cover the order for the drafted path. Slot 0's order on the step path is covered by the host test below, because a sampled request drafts nothing.The change adds no kernel and no graph. A drafted load's round now makes the same
step_slotscall a plain load makes, so thePass38andVerify38launches are the ones that already exist.The #695 rule
The unset draft stays off under
--parallelabove 1. On the same head, a sampled load with the draft is still slower than the same load without it, and a greedy load gains only at C@2.A request without a temperature is sampled, so turning the unset draft on would trade the default request's throughput for greedy's. What is left is the draft's own walk:
before_rowwalks each slot's draft over its waiting row, one slot after another, before the shared pass. The rule is unchanged, and its stated reason in the lever text, the registry anddocs/serving.mdnow says this.Gate clauses
gate_qwen38_serve's slots server (BLOOMERY_DRAFT=mtp, a fixed window,--parallel 2,BLOOMERY_STEP_STATS=1) gains three clauses afterslots_drafted_beside:slots_drafted_sampled_rounds_run_one_pass: a sampled pair banning the end ids, run alone and together, where everyslots roundrecord of the together run iscmd=step,rows=2,passes=1,slots=2. It protectsstep_passandstep_rows_drafted.slots_drafted_sampled_together_alone: the pair's ids together equal its ids alone, so each row's answer goes back to its own request.slots_drafted_sampled_tail_drafts: a sampled request of 96 ids beside one of 8 drafts alone after the short one ends, and its proposals per id past the short one's 8 are at least half of its alone run's. It protectsafter_row. The clause is refused by name unless the short request answered all 8 ids and aslots roundrecord of that run iscmd=step,rows=2,passes=1, because the tail checks hold only for a long request whose rows rode a pass beside the short one.I could not run this gate.
just gate-gpu-qwen38-serveon an RTX 5090 machine built its binaries and was refused bytools/gpu-gate.sh, because the gate runs on the RTX 3090 only and its paged clause needs that card's plan. The new clauses compile, and the compile is part of thecargo checkrun below. A maintainer runs the gate on the 3090.To show that the clauses can fail, I checked the same predicates on the real server. Main's server keeps
step_passfalse under the draft, and the same pair's rounds printpasses=2where the clause assertspasses=1. Withafter_rowtold nothing on the head, the pair of 16 and 128 sampled ids steps beside the short request as one pass and then the long request's first drafted pass is refused:On the unmodified head the same pair completes, drafting 95 and keeping 78.
Host checks
On an RTX 5090 machine at this head: the
checkrecipe'scargo check --workspace --all-targetscommand exits 0,bash tools/gate.sh --oxide -p bloomery-app --release --libreports 27 passed, thegate-q38-serve-rulesrecipe reports 3 and 20 passed, and thegate-serve-draft-rulesrecipe reports 6 and 5 passed.The new test
round_passes_keep_each_drafts_hidden_rowsmodels the pass arena (every pass writes its rows from row 0 of the live arena, and parked slots' rows are copied to their own buffers) and checks that each slot's draft walks its own slot's rows after nine sampled slots' plain rows at eight rows a pass, three drafted windows of four rows, a round without slot 0 and a round of one pass. It also checks the named refusals of an entry of no row and of nine rows. To show the test can fail, I turned off the move of slot 0's pass to the end, and the test fails:The test
mixed_rounds_keep_slot_zeros_proposals_and_acceptancemodels the live pass arena, the parked slots' own buffers and the row-count metadata. It runs three pairs of a sampled step and a greedy verify over three and four slots, and compares each slot's proposal rows and acceptance with the same calls run alone. It also checks that groups holding slot 0, a load without MTP and a load with slot 0's draft off keep the batched pass. With the guard turned off (every group batched), the test fails: slot 0's proposals become[1,1,1,1,3,3]where alone they are[1,1,1,1,1,1], and its acceptance is 4 where alone it is 6. With the guard restored, the seat's host rules report 21 passed, 0 failed. This commit touches only the seat, this test anddocs/serving.md, so the app and draft-rule results below are from the commit before it.The commands of the
gate-q38-serve-rulesandgate-serve-draft-rulesrecipes, run directly, print:Hardware
One DGX Spark (GB10, compute capability 12.1) in the CUDA 13.3.1 container used for the A/B. The card was idle before each arm and the CPU load was under 1 for 30 seconds. The nine-slot run used a second GB10 of the same driver and CUDA version.
What I ran into
None of this blocks the PR. The greedy figures in the A/B were measured before
pass_slotsbegan cutting its passes by the rows the proposals hold, which can only lower a drafted round's pass count, and I did not remeasure them. The new gate clauses did not run on the RTX 3090, as described above. The greedy C@4 difference of -4.01% is a single observation on a path whose measured rounds the PR does not change.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.