Repository navigation
width: a chain draft walks only the width the pass plans to verify - #705
Conversation
The MTP draft proposes one id per walk of its own, yet the width chooser handed it its whole width every window and then verified the front k ids: a window cut to 1 or 2 still paid for every walk up to 3. The draft's `Draft::CHAIN` now says a proposal into less room runs only its walks, and the chooser hands such a draft the width it plans to verify (the warm-up's or a probe's width, else the gate's). A window's own profile can still cut that width but not widen it. A shadow still walks the whole width. Each width's cost readings now hold the walks that width needs, so the gate weighs a narrower verify at its own price. A verify cut below the ids the draft walked is no reading of its width (it holds walks past it), and the mean profile learns each position from the proposals that reached it. Block drafts and the lookup draft keep their whole width.
The rows a step or a held pass walks before the target overwrites their arena (the cut step, every plain pass of a closed width chooser, a prompt call that continues the sequence) ran a whole walk with its flash, feed-forward block and head, though nothing reads them: the next chain walks its own refresh, and a later row reads only the rows' keys and values. They now run as store walks, which stop after the append, as the prompt's walks already do. Only a chain's walks read a head. `MtpBody::FITS` now also holds a refresh to one store walk.
There was a problem hiding this comment.
Verdict: CLEAN: The changed draft widths, acceptance bookkeeping and store-only catch-up have no proven merge-blocking defect.
Non-blocking
⚠ Supply the GB10 benchmark commands: crates/runtime/src/width.rs:1371. The throughput table supplies revisions, model and request sizes, but omits the benchmark/client commands and their output. Attach them for both arms, as CONTRIBUTING.md requires, so the speed claim can be reproduced before publication.
Checked
- Duplicates: 7 new function/constant declarations checked; no duplicate owner. Dryer reported zero pairs. The changed GPU gate was checked manually.
- Complexity: land 17→20 adds the Cut timing arm; propose 27→29 adds chain room selection; width_chooser 23→24 strengthens the paying clause. These extend their existing jobs.
- Silent failure: 3 paths followed. The width fallback selects the incumbent; invalid proposal probabilities return WidthError::Probability; nonpositive Cut walls return WidthError::Time. Cut acceptance still updates calibration and tallies.
- Tests: static mutation review maps width.rs:1372 changed to room to the new walked-versus-verified assertion; policy.rs:319/619 changed back to shape.mode to all six edited policy tests. The two other runtime test edits preserve their assertions. The PR reports FAIL-first for the width test, store-mode tests and gate (c).
- Gates: the proposal-length change has PIN(2026-10-23) and a reason; the added short-proposal clause rejects the old full-width behavior.
- Adversarial checks: shortened proposals cannot widen past their room; both verify kinds retain acceptance bookkeeping; store-only catch-up is followed by a fresh chain refresh. Context-end and NaN scenarios are guarded.
- Escape catalog: C1–C4 do not match this diff.
Notes
Runtime checks were not rerun during this static review. The PR reports fixture-tier MTP gates on an RTX 5090 and defers the real-tier Qwen gate.
Card check: gpu-evidence. This pull request changes crates/app/src/mtp.rs, crates/app/src/mtp/policy.rs, crates/gpu-gates/src/bin/gate_qwen4exp_mtp.rs and carries a gate run on the author's card, which counts as verified.
🔨 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. |
Qwen3.8 MTP draft가 폭 선택기가 고른 폭만큼만 draft를 걷게 해서, DGX Spark 한 대에서 MTP decode 속도를 코드 약 2.3%에서 3.6%, 산문 약 6.9%에서 8.1% 높입니다.
Part of #565.
What and why
The Qwen3.8 MTP draft walks its own layer once for every id it proposes. The width chooser decides how many ids a window verifies (0 to 3), but the draft ignored that and always walked three ids, so a window that verified one or two ids still paid for the extra walks. One walk costs about 2.5 to 2.7 ms at a 4096-id context on a GB10, against a window of about 60 ms.
width: a chain draft walks only the width the pass plans to verifyaddsDraft::CHAIN(defaultfalse, set byMtpDraft).Choosing::proposehands a chain draftforced.unwrap_or(self.width).min(room)ids, so the walk count follows the planned width. The chain already took its walk count from the room it was given, so no device code changes. A window's own cut can still go below the planned width but never above it. Block drafts and the lookup draft keepCHAIN = falseand get their whole width as before.seenper position, and "the proposal filled its room" replaces "the proposal held every id".Kind::Cutmarks a verify that cut below the ids the draft walked. Its wall time includes walks beyond its width, so it is not a cost reading of that width, the same ruleKind::Walkedalready follows.Kind::verifieskeeps the accept and step bookkeeping the same forVerifyandCut.gate_qwen4exp_mtpasserted that every proposal held all three ids. It now asserts at least the verified width and at most three ids, and a new condition requires at least one proposal shorter than three ids under the paying walls (the warm-up's forced widths 1 and 2). That condition fails on main.mtp: walk the waiting rows through the store's append alonemakes the catch-up walks that run before a plain step use the store walk.catch_up,before_stepand the zero-row walk of a one-id prompt used to run flash, feed-forward, head and argmax, and nobody reads that head: the next chain walks its own refresh, and later rows read only keys and values. Only the chain still usesShape::mode.MtpBody::FITSnow also checks that a refresh fits one store walk (Qwen'sSTORE_ROWSis 64, GLM's isWALK_ROWS). A Qwen store walk's keys and values match an eager walk's within the q8 activation error, so proposals after a plain step can differ slightly. Kept tokens cannot change, because the target verifies every id.Release notes: Changed: the Qwen3.8 MTP draft walks only the width the chooser plans to verify, which raises MTP decode throughput by about 2% to 8% on one DGX Spark.
Code shape
Choosing::proposeis the one owner of the width rule andpolicy.rschainof the room rule. The catch-up walks reuse the store walk the prompt's warm-up already used.Draft. The common chooser gained no per-model branch.w.ids.len() == 3gate pin was replaced by the range check and the new condition.Cutwall that is not positive is refused by name, like aWalkedwall.cargo fmtis clean on what I touched.Duplication found or removed (
path:line), or "none": none.What I ran
Head
df7686ea1on maina83dd0df9.cargo check --workspace --all-targetswith thecheckrecipe's features,just gate-appand both MTP gates ran on this head, on an RTX 5090 machine.GPU Evidence
On an NVIDIA GeForce RTX 5090 (gates):
On an NVIDIA GB10 (throughput):
cargo check --workspace --all-targetsjust gate-apptest result: ok. 27 passed; 0 failedjust gate-gpu-qwen4exp-mtp(fixture tier)clauses: 28 ran, 4 left to the real tier; gate (c) paying and losing, (i) and (v) PASSjust gate-gpu-glm5next-mtp(fixture tier)clauses: 14 ran, 7 left to the real tierGate (c) paying on the head:
The new tests and gate conditions fail without the change (each check ran on the same patches before the final rebase, which left both patches unchanged):
depth = roominwidth.rs, so a chain draft gets its whole width again,a_chain_draft_walks_the_width_it_verifiesfails (1 failed), and gate (c) fails (the cuts and the gate FAIL, widths[0, 0, 59, 4]).self.shape.mode,gate-appfails 6 of 26 tests (20 passed; 6 failed), the ones that expect the store walk.width.rs,speculative.rsandmtp.rs, gate (c) paying fails (incumbent 0, the cuts and the gate FAIL), because every proposal there holds three ids.Not run:
just gate-gpu-qwen4exp-mtpat the real tier, which needs fixtures this machine does not have, so a maintainer runs it.Throughput
The checkpoint is
nvidia/Qwen3.8-Flash-Next-FP4-Localatb9ce18a6887e18c089fdea8509a33e63429a3300, served from its folder with its own MTP layer and the width chooser at its default,bloomery-serve --parallel 1 --ctx-size 8192. Each arm loads its server once. Every request uses a 4096-id prompt, 128 generated ids, temperature 0 and one concurrent request. Each arm sends one warm request, then 8 code windows and 8 prose windows. Decode tok/s is the generated ids over the server's decode time. The GPU clock cap was lifted for each arm only.C@1 MTP decode rose 3.60% and 2.33% on code-fn and 8.07% and 6.90% on prose-en in two sittings with opposite arm order; every window of both corpora was at least as fast on the head in both sittings.
Sitting b ran main first on main
78c3680d3and head287d5e458. Sitting c ran main last on maina83dd0df9and headdf7686ea1. The rebase between the two left both patches unchanged. The gain keeps its sign and most of its size with the arm order reversed. Greedy ids were equal in all 32 request pairs of each sitting. Every figure is one observation per arm with no confidence interval.For reference, here is the same checkpoint on
NVIDIA/flare-local-inference(5f37bd14with the loader patch from its issue #2, the recipe's default package with adaptive MTP) on a DGX Spark (GB10, driver 595.84), C@1, 4096-id prompts and 128 generated ids. The bloomery columns are sitting c above.This PR is ahead of Flare on both corpora, but the margin may be within the run-to-run spread.
Where the time went, from the width chooser's own cost readings in sitting b: dropping two walks made a width-1 verify cheaper (
48.05to42.12ms in one request), and dropping one made a width-2 verify cheaper (55.51to52.68ms), while a width-3 verify stays near 60 ms. One walk is therefore about 2.5 to 2.7 ms. With these prices the prose gate settles on width 1 most of the time, where it picked width 2 on main.The second commit makes a plain step about 1 ms cheaper (
34.60ms with only the first commit to33.33ms with both, in the same readings), but plain steps are rare at this load, so it shows no throughput change in these runs. It matters where the chooser closes and plain steps are common, which this A/B does not measure.What I ran into
This does not block the PR. Code decode gains less than prose decode here, because code windows mostly verify three ids and keep the full walk cost. Verify rows are most of a code window, and the draft's own walk is the next largest cost the chooser can see.
Hardware
One NVIDIA DGX Spark (GB10), driver 595.84, CUDA 13.3, for the throughput runs, and one RTX 5090 machine, driver 595.99.02, CUDA 13.2, for the checks and gates.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.