Repository navigation
qwen38: read the next step's PLE rows ahead and keep the command receiver awake between steps - #831
Conversation
The engine thread parked on its command channel after every reply, so each decode step's next command waited for that thread's wake-up after the server sent it. The receiver now polls the channel for up to 1 ms after the call, which covers a step's reply and the server's next call, and then parks as before. Commands sent before the server drops its end are still received before the end is reported. The test fake of the engine thread receives through the same function, and a new test checks that the receiver takes a command sent long after its poll ended, stays parked meanwhile, and takes every queued command before it reports the end.
A plain decode step's PLE rows were submitted to the reader's helper only when the next step's input was built, so the step thread waited for the helper to wake and copy them after the server's next call arrived. The Qwen3.8 seat now starts that read as soon as a plain step has picked its id (Body38::prefetch_input), so it runs while the answer goes to the server and back. The read ahead moves no history and no device buffer. The next fill takes the rows when its position and row ids match and drains them otherwise. It is issued only where the body's next call is the same slot's one-row step: no draft or the slot's draft off, on a load of one slot or one whose rounds run as one pass. The row-id storage and the history walked ahead are kept from call to call (History::clone_from), so the read ahead allocates nothing per step.
There was a problem hiding this comment.
Verdict: CLEAN: Read-ahead mismatches drain before use, and command reception preserves queued work on disconnect.
Non-blocking
⚠ Complete the timing evidence: crates/gpu-gates/src/bind.rs:1647. The shared receiver now polls for up to 1 ms per command before parking. Supply the timed head SHA and the exact benchmark request commands with output for the GB10 A/B. The body names the timed base but leaves the head revision unnamed. Recording them now makes the speed claim reproducible.
Checked
Duplicates: 11 new functions/constants checked; none duplicated. Dryer reported 0 pairs; its excluded gpu-gates paths were searched by hand.
Complexity: crapper flagged no function. The added control flow handles reception and optional read-ahead; no kernel body changed.
Silent failure: 5 sites followed, including receiver loop termination, the test receiver's .ok(), and rejected/overflowing hash hints. Disconnect ends reception; rejected hints leave actual fills subject to named validation errors.
Tests: static mutation checks identify assertions for ngram.rs:182 (fresh clone fails storage identity), body38.rs:611 (accept mismatched ids fails decoded-row comparison), :944 (walk live history fails history equality), :976 (omit submission fails flight assertion), drafted.rs:871 (return speculative rows fails count), and bind.rs:1653/1656 (empty-as-end or prolonged polling fails reception/CPU assertions). The body also checks recycled id storage. The PR reports FAIL-first runs; these were not rerun here.
Gates: no existing pin, tolerance, test clause, or lint level moved.
Escape catalog: C1–C4 matched no changed code.
Adversarial paths: changed token, replaced hint, slot/history switch, reset, invalid token, context boundary, and queued commands at disconnect are blocked by row matching, drains, named guards, or channel semantics.
Notes
The selected serving gate was not run; GPU evidence is incomplete under CONTRIBUTING.md. Runtime tests were not rerun in this static review.
Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/shared/serve_seats/drafted.rs, crates/gpu-gates/src/bin/shared/serve_seats/qwen38.rs, crates/gpu-gates/src/bind.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 FP4-Local에서 draft를 끈 디코드가 다음 명령과 PLE 행을 한 step 앞서 준비하게 해, DGX Spark의 디코드 속도를 높이는 속도 PR입니다.
What and why
In a plain decode step, each token waits for two thread wake-ups. The engine thread parks on its command channel after every reply, so the server's next call waits for that thread to wake. The PLE rows of the next step are handed to the reader's helper only when the next input is built, so the step waits again for the helper.
This PR removes both waits for Qwen3.8 decode without a draft.
receive_commandincrates/gpu-gates/src/bind.rspolls the command channel for up toRECEIVE_SPIN(1 ms) after a call, then parks as before. Commands sent before the server drops its end are still all received before the end is reported. The engine loop and the test fake of the engine thread both receive through it.Body38::prefetch_input(crates/gpu/src/arch/qwen3moe/body38.rs) starts the next step's PLE read as soon as a plain step has picked its id.Q38::read_aheadin the Qwen3.8 seat issues it only when the answer is one id andSeat::pass_rows() == 1(no draft, or the slot's draft off). The read ahead moves no history and no device buffer. The next fill takes the rows when its position and row ids match and drains them otherwise.History::clone_fromincrates/engram/src/hash/ngram.rscopies into the target's storage, so the read ahead allocates nothing per step.tools/spawn-allow.txtallows one more spawn inbind.rs, for the new receiver test.Greedy output is identical on every request. With the draft on, the changed paths are the receiver only, and the measurement below shows no change beyond the run-to-run spread.
Release notes: Changed: Qwen3.8 decode without a draft reads the next step's PLE rows ahead and keeps the command receiver awake between steps, which raises decode speed on a DGX Spark.
Code shape
PleRead, the History storage andSeat::pass_rows.Body38::prefetch_inputis an inherent method of the one body that has a PLE reader, andQ38::read_aheadsits in the Qwen3.8 seat. The sharedSlotDraftsandChainBodygained no method or branch.prefetch_inputandread_aheadreturn their errors with?. A row id the hash rejects clears the hint, and the fill of that id rejects it by name.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.cargo fmt --all -- --checkpasses, and clippy is clean forbloomery-engramandbloomery-gpu-gates. Clippy forbloomery-gpuneeds CUDA and did not run on the machine I used.Duplication found or removed (
path:line), or "none": none.What I ran
The tests below ran on an RTX 5090 machine on revisions of this branch with the same product code as this head (
crates/has no difference; the head differs by the one-linetools/spawn-allow.txtchange).bind::tests::tests pass, including the new receiver test: test result: ok. 36 passed; 0 failed; 0 ignored; 0 measured; 240 filtered outEach new test was made to fail first by breaking the code it covers, and succeeds again after the file was restored (
git diff --exit-codeis clean at the end of each run):clone_fromwith a fresh clone fails the history test: RESULT 101 expected nonzerocargo check --workspace --all-targetswith all features passes on the same machine (BLOOMERY_BOX_LOCAL=1 just check): Finisheddevprofile [unoptimized + debuginfo] target(s) in 43.74sjust gate-gpu-qwen38-servenot run: it needs the maintainers' workstation and the full Qwen3.8 checkpoint set, so a maintainer runs the recipesjust affectedselects.Speed
The timed model is
nvidia/Qwen3.8-Flash-Next-FP4-Localat revisionb9ce18a6887e18c089fdea8509a33e63429a3300, with the Q8_0 MTP draft for the draft-on arms. Each run uses a 4096-id prompt and 128 greedy tokens, on eight corpus windows 50,000 ids apart, with three rounds after a lead-in. Base is upstream main895b32d4a5998bdb53fad6e50d76d64ae0c538e5. Base and head are built from their own trees and run alternately. Each cell is the median of three rounds. The head'scrates/content is identical to the tree that was timed. Greedy output is identical on every request.Ranges are "separate" when the three head rounds and the three main rounds do not overlap.
draft-off code-fn decode +1.263% (resolved above 0.500%); draft-on decode changes -0.131% (code-fn) and -0.519% (prose-en), both inside the 2.937% and 1.076% the run can resolve
Only the draft-off decode change is resolved. The other rows are inside the spread of repeated runs of the same tree, so they are not evidence of an effect or of none.
Reproduction
Build the head the same way. Send 4096-id prompts from eight windows of the same corpus with 128 greedy tokens (temperature 0), alternating the two trees, and compare the median server decode rate. For the draft-on arms set
BLOOMERY_DRAFT=mtp,BLOOMERY_MTP_DRAFTto the MTP draft file andBLOOMERY_MTP_WIDTH=cost.Hardware
One DGX Spark for the timed runs, and an RTX 5090 machine for the tests above. This section lists only the card and driver lines saved with the runs.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.