Repository navigation
qwen38: launch a verify before its PLE rows arrive - #877
Merged
juliankang4 merged 2 commits intoOct 27, 2026
Merged
Conversation
… on the step thread Prefetcher::read_now is submit and wait in one call for a caller with nothing to do until the rows are in. A token the helper would read alone (one too small to split, every token of a pinned helper) is advised, filled and copied on the calling thread, so neither the helper nor the caller has to wake for it; a token that splits still goes to the helper and its part threads. Qwen3.8's PLE fills that wait at once (a verify's draft rows, a pass, a slot's rows, a step with nothing read ahead) take this path. A batch read ahead (a prompt call's next ubatch, a step's read ahead) is still taken from the helper, and a walk that takes its rows at its PLE site still starts the read on the helper.
A verify read its PLE rows, decoded them and copied them to the card before its graph's launch, so the card sat idle for the read and the launch. The verify's graph now holds the rows' arrival at its PLE site: a wait on a host flag, then a copy from a page-locked staging. The host lowers the flag, launches the graph, then reads and decodes the rows on its own thread, stages them and raises the flag, while the card runs the embedding and the layers before the site. The flag is raised on every path, a failed read included. The staging, the flag and the arrival's wait and copy are the gpu crate's StagedRows, which DeepSeek V4.1's engram rows' arrival (RowsArrival) now uses too: one owner of the clear, deliver, wait and copy and of the staging's lifetime, the row count, row width and copy offset given by each caller. RowsArrival keeps its image layout and byte packing; its raise, which nothing called, is gone. An eager verify delivers its rows before its walk. A pass of several slots keeps its rows in the arena before its launch and has no arrival. The verify's graph holds two nodes more (one batch memory operation and one copy); the e2e gate's verify pins move from 1187 to 1189 and from 1427 to 1429 under the card plan.
Contributor
There was a problem hiding this comment.
Verdict: CLEAN: I built no failure path that the code does not block, and the new items have no duplicate.
Checked
- Duplicates: 9 new items checked (
StagedRows,read_now,read_job,take_back,take_in,read_named,name_rows,deliver_ple,ARRIVAL_NODES), none duplicated.RowsArrival's copy moved intoStagedRows, which leaves fewer elements. dryer: 0 pairs. - Complexity:
plan_verify14 to 16 (one added call and one branch, harmless);load_placed76 to 77 (one field, even growth). - Failure path built: the verify graph waits on a flag that nobody raises. Blocked:
launch_served(model.rs:1891) callsserve_capturedright aftergraph.launchforBody38,serve_chainrunsdeliver_plefirst, andStagedRows::deliverraises the flag on every path. The eager walk delivers before it enqueues. The PLE site is a single layer, soverify_launchesandShape::arrivalsagree. - Silent failure: 6 sites followed (
deliverwrite error, row past staging, copy past buffer,take_indrain,read_nowrefusals,finishwithout start). Each ends as a named error. - Tests: the
read_nowtest fails if the caller reads a splitting token, if the helper reads a lone token, or if the pinned case is dropped, because it asserts the copying thread's name. TheStagedRowshardware test fails if the wait or the write is dropped (stale values after a 20 ms sleep). The e2e gate compares verify rows bit for bit. The PR body lists the mutants that turned each red. - Performance: the hot path is the verify step. No allocation, lock or launch is added per token; the added terms are one flag wait and one H2D copy per verify, in place of the host-side upload before the launch. The staging copy is fixed at
VERIFY_ROWS * 2560f32 at every row count, which is small. The class is a node-count change, and the PR body has the gate (pinned counts) and a timed A/B on a GB10. - Gates:
REAL_NODES_VERIFY1187 to 1189 andREAL_NODES_VERIFY_CARD1427 to 1429, each with a dated PIN and the derivation. The unsafe ratchet moves gpu +1 and gpu-deepseek41 -1, with PINs; the new block has its SAFETY line. - Escape catalog: no match.
Notes
just gate-gpu-ds41-step,-engramand-chain-gluedid not run (no model).RowsArrivalkeeps the same wait and copy, so I accept the build check as the PR body states.- The gates ran before the final rebase; the PR body names the range-diff result.
Card check: gpu-evidence. This pull request changes crates/gpu-deepseek41/src/chain/glue.rs, crates/gpu-gates/src/bin/gate_qwen4exp_e2e.rs, crates/gpu-gates/src/q38_fixture.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)
Collaborator
Author
|
The review is done and the contribution check passed, so I'm merging this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Qwen3.8 FP4-Local MTP의 verify step이 PLE 행을 기다리지 않고 graph를 먼저 실행하게 해, DGX Spark의 MTP 디코드 속도를 높이는 속도 PR입니다.
What and why
A verify step used to read its PLE rows, decode them and copy them to the card before it launched the verify graph. The card sat idle for that read and copy. Now the graph is launched first. At the layer with the PLE site the graph waits on a host flag and copies the rows from page-locked staging, and the engine thread reads and delivers the rows after the launch.
A PLE fill that needs its rows at once (draft rows, a pass, slot rows, a step with no read ahead) now reads on the calling thread when the reader would have read the token alone. Neither the reader's helper thread nor the caller has to wake up for it.
StagedRowsincrates/gpu/src/graph.rsowns a row that the host writes after the launch of the graph that reads it. It holds the page-locked staging and the flag.clearlowers the flag before the launch,deliverwrites the row and raises the flag on every path (a failed write included), andenqueuecaptures the flag wait and one copy of the row into the graph. It has the one newunsafeblock, with its SAFETY line.RowsArrivalincrates/gpu-deepseek41/src/chain/glue.rscarried the same wait-and-copy code for the engram rows. It now usesStagedRowsand keeps only its image layout and 4 byte packing. The wait and the copy are the same. Itsraise, which nothing called, is removed.Verify38takes an optional arrival and enqueues it before the front of the PLE site layer.Body38::plan_verifynames the rows (a rejected row hash still fails before the launch), clears the flag, stages and launches.Body38::deliver_plereads and delivers the rows after the launch. The eager verify delivers before its walk, so eager and graph verifies receive the same rows in the same order. A multi-slot pass still places its rows before the launch.Prefetcher::read_nowincrates/engram/src/prefetch.rsreads on the calling thread a token that the helper would read alone. A token that splits into parts goes to the helper and part threads as before. The helper loop andread_nowshare one read body,read_job.PleHost::fill_spannedreads throughPleRead::read_now, andPleRead::take_inis the one rule for taking in a read-ahead batch. The prompt ubatch read ahead is unchanged.gate_qwen4exp_e2e,REAL_NODES_VERIFYgoes from 1187 to 1189 andREAL_NODES_VERIFY_CARDfrom 1427 to 1429, each with aPIN(2026-10-27)line. The verify structure check now requires one more batch memop and one copy node per PLE site. Intools/unsafe-ratchet.txtthe gpu crate goes from 2748 to 2749 blocks andgpu-deepseek41from 397 to 396, each with aPINline.Greedy output is identical on every request, and the e2e gate compares each verify row's token and logits bit for bit with the single-step path.
Release notes: Changed: Qwen3.8 verify steps launch their graph before the PLE rows arrive, which raises MTP decode speed on a DGX Spark.
Code shape
RowsArrivalcarried now lives inStagedRows, which both the Qwen3.8 verify and the engram rows use. The helper andread_nowshareread_job.StagedRowsis in the shared graph code and has no model branch.Verify38holds the one arrival the Qwen3.8 PLE layers need.RowsArrival::raisehad no caller and is removed, along with the imports it needed.PIN(2026-10-27)and the reason.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-gpuandbloomery-gpu-deepseek41needs CUDA and did not run on the machine I used for it. Both crates build on the DGX Spark.Duplication found or removed (
path:line): the arrival code incrates/gpu-deepseek41/src/chain/glue.rs(RowsArrival) moved intocrates/gpu/src/graph.rs(StagedRows).What I ran
The engram and PLE decode tests ran on an RTX 5090 machine. The graph, e2e and deepseek41 tests ran on a DGX Spark. The gates below ran on the head before its final rebase onto upstream main
f0077054b5f9c3e3aca2e62ad9fb33348e490ec6;git range-diffshows both commits unchanged by that rebase (=), and the upstream commits between touch none of the files this PR changes.read_nowtest: test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 25 filtered outStagedRowshardware test passes: test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 435 filtered out. It captures the arrival for row 1 of two, launches, writes and delivers the row after a 20 ms host sleep, and checks that the buffer holds the late value from the arrival's offset and zero around it, twice. It also checks that a failedwritestill lets the replay end, that a row or copy past the buffer is refused before it is enqueued, and that the arrival adds two graph nodes.just gate-gpu-qwen4exp-e2eexits 0 with 26 clauses run and 8 left to the real tier: clauses: 26 ran, 8 left to the real tierjust gate-gpu-qwen4exp-mtpexits 0 with 28 clauses run and 4 left to the real tier: clauses: 28 ran, 4 left to the real tierEach new or changed test was made to fail first by breaking the code it covers, and succeeds again after the file was restored (the tree is clean at the end of each run):
read_nowhanding every token to the helper fails theread_nowtest: RESULT 101 expected nonzeroread_nowreading a token that splits on the caller fails theread_nowtest: RESULT 101 expected nonzeroread_nowtest: RESULT 101 expected nonzeroStagedRowstest: round 1: 4096 of 4096 values are not what the host delivered after the launchStagedRowstest: round 1: 4096 of 4096 values are not what the host delivered after the launchNot run:
just gate-gpu-ds41-step,just gate-gpu-ds41-engramandjust gate-gpu-ds41-chain-glue. They need the DeepSeek V4.1 model, which none of the machines I used hold.RowsArrivalmakes the same wait and the same copy as before, and I built thegate_deepseek41_stepbinary on the DGX Spark instead: DS41-STEP-BUILD rc=0.just affectedselects more gates than the ones above, so a maintainer runs the rest on the workstation.Speed
The timed model is
nvidia/Qwen3.8-Flash-Next-FP4-Localat revisionb9ce18a6887e18c089fdea8509a33e63429a3300, with the Q8_0 MTP draft filemtp-Qwen3.8-Flash-Next-shared-Q8_0.gguf(SHA-2565ff54097406a905cf3a724c709124ceb0e3e10235ee862298969e91c96fa96e6) 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 mainc21e3b81eb7f3ede965e5ac68f325b8a59cb2e05. The head timed is2d593cc3ff7894dd974916ffcea33075d89bf418. Base and head are built from their own trees and run alternately. Each cell is the median of three rounds.Ranges are "separate" when the three head rounds and the three main rounds do not overlap.
draft-on decode +1.992% (code-fn) and +2.880% (prose-en), above the 1.272% and 1.711% the run can resolve; the other rows are inside the spread of repeated runs of the same tree
Only the two draft-on decode changes are 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.
The head timed is not this PR's head. After the timing the row-arrival code moved into
StagedRowsand the branch was rebased onto current main; both changes are host code. The compiled GPU code of this head is the same as main's for every entry (BLOOMERY_ARCH=sm_86 just canon-check 12dee757e1bf9ecd9eae3fe115baca5d3df2fe0a): canon-check: 4 bins, 1668 entries: 1668 identical, 0 reordered-only, 0 differs, 0 only-on-one-sideReproduction
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-off arm set
BLOOMERY_DRAFT=offand leave outBLOOMERY_MTP_DRAFTandBLOOMERY_MTP_WIDTH.Hardware
One DGX Spark for the timed runs, the graph, e2e and deepseek41 tests, and an RTX 5090 machine for the engram and PLE decode tests. This section lists only the card and driver lines saved with the runs.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.