Repository navigation
gpu, gpu-gates: Qwen3.8's MTP draft store reads only final hidden rows - #691
Conversation
The head's mix applies the last layer's combine, and a prompt call runs the head on its last pass or ubatch alone, over a split walk's last unit alone. The draft's warmup reads every row of every unit, so the rows of a split walk's first unit and of each pass or ubatch before the last were read before the combine. A prompt call with a tap now applies the combine alone to every row the head's mix leaves: Gemm38::finals over each unit but the last (every unit when no head runs), at the unit's own combine weights, and Pass38::finals over a pass with no head. A call without a tap runs no such combine, and the target's bits do not move either way. gate_qwen4exp_mtp (fr): one call walked as one unit is the reference; the same call under BLOOMERY_SPLIT_WALK=every and as several ubatches on a load of the same plan leaves the draft's store and next id bit for bit, and the call by passes leaves the call by steps'.
There was a problem hiding this comment.
Verdict: CLEAN: No must-fix finding remains in the changed code.
Non-blocking
⚠ Complete GPU evidence for the current head: wide38.rs:2532.
Tapped prefill adds one combine launch per uncovered unit, including two per headless split ubatch. This launch-count change requires its owning gates. The reported gate runs and A/B predate the rebase; the tested base hash and exact model file are missing. Attach both tested hashes, the model file, and gate/A/B commands with output attributable to this head.
Optimization headroom
- G. Per-launch and per-sync fixed cost: wide38.rs:2531. The units' residuals, outputs and per-row weights occupy contiguous spans. Use the existing wide combine once over the parent buffers for a headless split ubatch: one fewer launch per such m-row ubatch, or 1/m fewer launches per prompt token [derived].
Checked
Duplicates: 9 new items checked; none duplicated. The extracted combine reuses the PLE operation. Dryer reported 0 pairs in gpu; gpu-gates was excluded and checked by Grep.
Complexity: final_rows_ubatches is new at 18, mostly error propagation and conjunctions in assertions; load and comparison stages remain short. run rises 95→99 through linear gate stages. Neither needs another owner.
Silent failure: the new final-row paths propagate launch errors; a missing ubatch walk returns a named error. Non-GEMM zero counters describe steps/passes.
Tests: static mutation review—dropping the combine calls at body38.rs:3411 or body38.rs:3561 makes the corresponding (fr) store comparisons false; run propagates them to failure. The PR reports FAIL-first with production reverted. No GPU tests were run during this review.
Gates: no existing pin, tolerance or clause was removed or relaxed.
Adversarial checks: unit weights remain separate, the head's unit is excluded from the standalone combine, and the sink reads each pass or ubatch before the next walk reuses its arena.
Escape catalog: C1–C4 have no matches. No ledger lessons are in force.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen4exp_mtp.rs, crates/gpu/src/arch/qwen3moe/body38.rs, crates/gpu/src/arch/qwen3moe/mtp38.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. |
Qwen3.8의 MTP draft가 마지막 층의 combine이 빠진 hidden row로 key와 value store를 채우던 결함을 고칩니다.
Part of #565. Fixes the Medium item in #637.
What and why
With the MTP draft on, a Qwen3.8 prompt call hands the draft the target's hidden row for every prompt position. Only rows that the head's mix covered are final, because the head's mix applies the last layer's combine. Three kinds of rows never get it: the earlier units of a split walk, the earlier ubatches of a call that runs more than one ubatch, and the earlier passes of a call that runs pass by pass. The draft read those rows as if they were final, so the same prompt left a different draft store than it does when the rows run as one unit with the head. The target is not affected: next ids, logits and states stay bit identical, and only the draft's key and value store differ at the positions that read an uncovered row.
The change applies the last layer's combine to the rows the head's mix does not cover, before the draft reads them:
Gemm38::finalsinwide38.rsruns the standalone combine on every unit the head will not cover (all units when the ubatch runs without the head, all but the last otherwise). The combine call is now onecombinefunction that the PLE front shares, so the copy that lived inline there is gone.Pass38::finalsinprogram38.rsdoes the same for a pass that runs without the head.walk_passandwalk_gemminbody38.rscall them only when the call feeds the draft. A call with the draft off launches nothing extra, and the head path and the buffers the target reads are untouched: the next pass or ubatch rewritesresin its embedding step, so the added combine never reaches the target's next computation.Wide38keeps its walked units in oneVecthat each walk reuses, in place of the last-unit field and the unit counter, which also drops one allocation per walk.The alternative I rejected is running the head site's mix over every column. The mix is three launches plus two Q8_0 projections and a
mixedwrite, and it would have to run per unit with that unit's combine weights, so it moves more bytes and launches more than the single combine.A new gate clause,
(fr), compares the draft store after a prompt call walked as several units, ubatches or passes against the same call walked as one unit, bit for bit.Release notes: Fixed: With the MTP draft on, a Qwen3.8 prompt call no longer fills the draft's key and value store from hidden rows that lack the last layer's combine.
Code shape
combinereplaces the inline combine in the PLE front and servesGemm38::finalstoo. The kernel call itself has one owner.Vec; nothing is left behind.Gemm38::finalscalled before a walk returns a named error.TargetRowsdoc now names the rows the head's mix covers and the rows the prompt call combines itself.cargo fmt --checkis clean on the five changed files.cargo clippywas not run on this head here.Duplication found or removed (
path:line): the inline combine in the PLE front ofcrates/gpu/src/arch/qwen3moe/wide38.rs, nowcombine.What I ran
Hardware: one RTX 5090 32 GB machine (x86_64 Linux), host mode, with the fixture model and its Q8_0 MTP draft.
The checks below ran on the head just before the last rebase onto main. That rebase left the commit patch-identical in
git range-diff(1: 92093fe35 = 1: f25b44cae). Upstream's seven new commits touched three of my files, but only the draft's load path, and left the prompt walk,feed,walk_pass,walk_gemm,final_streams,TargetRowsand the MTP policy as they were. I did not rerun the gates or the A/B on the rebased head, and I did not compile it on the GPU machine.Gates, on the fixture tier:
(fr)comparison passes:clauses: 28 ran, 4 left to the real tierandgate_qwen4exp_mtp ran 47 s (exit 0).gpufiles restored to main fails, and the differing store positions equal the number of uncovered rows. The split walk gives32 of 64 positions other from 1, the pass walk56 of 64, the call cut into ubatches44 of 64, and ubatches combined with the split walk54 of 64. The unit and ubatch counts and the next id still pass there, which confirms the target is unaffected.clauses: 26 ran, 8 left to the real tierandgate_qwen4exp_e2e ran 52 s (exit 0). Its split-walk bit pins pass, as do the eager and graph step paths, whose logits are bit identical.just contrib-check --tier t0passed:DONE tier=t0 total=107 red=0.Speed, 4,096-id prompt with the draft on (
BLOOMERY_DRAFT=mtp), Qwen3.8-Flash-Next UD-Q3_K_XL, default placement, one process per row, two sittings with main and head alternating:The head is within the spread inside one arm (up to 2.5%). In this load the 4,096-row ubatch runs as two units of 2,048 rows, so the added combine runs on one unit. A kernel trace of one prompt shows 21,454 kernels on main and 21,455 on head, and the added launch takes 113,439 ns. That is 0.004% of the 2.6 s prefill. The first sitting's head arm was 1.33% below main on its mean, from one row whose host expert time was 60 ms longer; the second sitting had head 0.15% faster.
What I ran into
This does not block review. I did not measure draft acceptance or decode speed. The speed rows cover the one prompt length above on one machine.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.