Repository navigation
qwen38: a prompt call runs one cut across its checkpoints and reads its PLE rows under the layers - #724
Conversation
…nd the exposed PLE read once A prompt call with cache checkpoints inside it (a serve prompt past 4,096 ids) ran each run between two marks as a call of its own: the vocabulary head and its blocking argmax readback at the end of every run, and a new PLE read-ahead for each run, so the first ubatch after each mark read its own rows from the NVMe tier with the card idle. The call now cuts its units once (call_units: each run between its marks cut as the ubatch cut cuts it) and walks them in one loop. The PLE reader reads every later unit ahead across the marks, and the head runs on the call's last unit only. A marked unit before it still runs the last layer's combine when the MTP draft reads the point row or a tap reads the rows, and reads the fault word before its checkpoint is taken. The units, their order and the last unit's head are the ones the runs walked, so every store, checkpoint and logit keeps its bits.
…ayers before the PLE site A ubatch walk's PLE rows were read, decoded and copied to the card before its first launch, so the card sat idle for the whole fill: on a 4K FP4-Local prompt on GB10, 313 ms of host-only time before the first kernel, then the 41.9 MB upload. On a walk with no expert tier whose every layer serves no host leg, the plan now names the rows and starts their read; the walk decodes and copies them when it reaches the first PLE site, after the layers before it are enqueued, so the fill runs while the card computes them. A walk with a host leg keeps the fill before the walk, since its step thread serves the host between launches. The rows' copy goes through a safe window of the arena buffer, which removes three unsafe views.
There was a problem hiding this comment.
Verdict: CLEAN: No behavior defect or blocking quality defect was found.
Non-blocking
⚠ Cover the production read-ahead boundary: crates/gpu/src/arch/qwen3moe/body38.rs:6183.
The NVMe test calls prompt_start directly and never calls feed38. Restoring per-mark read-ahead in the production caller leaves this test green.
Extend an existing prompt gate to observe prefetch across an internal checkpoint. This closes the caller's regression coverage while its scheduling changes.
⚠ Verify draft recovery at an internal checkpoint: crates/gpu/src/arch/qwen3moe/body38.rs:4169.
The timed run disables the draft, and the owning checkpoint/MTP gates were not run. Neither changed unit test exercises this final-combine decision.
Run a prompt across an internal mark, restore that checkpoint, and compare its hidden row and draft logits with a fresh prefix. Force finals = false to verify that the assertion fails.
Optimization headroom
- E. Less work: crates/gpu/src/arch/qwen3moe/body38.rs:4169. With a draft and no sink, a checkpoint reads only the last hidden row, but
finalscombines every row. Restrict that combine to the last row using existing windows: save81,920 × (m − 1)B of residual reads/writes per marked unit [derived: four streams, 2,560 f32 values, one read and write].
Checked
Duplicates: 10 new functions/types checked; no proven duplicate. Common call_batches balances batches; this cut retains full-width units. Dryer reported 0 pairs.
Complexity: stage_gemm 11→16 adds deferred-fill branches; feed38 27→30 merges pass/GEMM orchestration; front 30→32 adds optional callback dispatch. These are existing host functions.
Silent failure: 6 optional/fallback sites followed; read, decode, copy and intermediate device-fault errors propagate.
Tests: by inspection, marking every unit or dropping the next prefetch submission fails the new assertions. The production restart mutant remains uncovered.
Gates: no tolerance relaxed; unsafe-block pin tightens 2266→2263.
Adversarial checks: empty/context-boundary prompts are refused; marks come from the sorted common owner; hostless guards prevent a deferred-copy host wait; standalone and head combines use the same FMA.
Performance: Qwen3.8 prefill; the launch-count class needs its owning gate, requested above.
Escape catalog: no matching patterns.
Notes
Static review only; no build or GPU gate run here. The PR lacks the exact timed-head hash and a completed owning GPU gate with output, so GPU evidence is false.
Card check: needs-gpu. This pull request changes crates/gpu/src/arch/qwen3moe/body38.rs, crates/gpu/src/arch/qwen3moe/wide38.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 프롬프트 처리에서 아무도 읽지 않는 일(체크포인트마다 반복되는 head 계산, 카드가 쉬는 동안 하던 PLE 행 디코드)을 없애 첫 토큰까지의 시간(TTFT)을 줄이는 속도 PR입니다.
Part of #565.
What and why
The Qwen3.8 prompt call did two kinds of work that no later step reads, and one read that stalled the card.
feed_markedcut a prompt call into runs between the checkpoint marks and ran each run as its own call. Every run started its own PLE read-ahead, so the first ubatch after a mark read its own rows with the card idle on a load whose PLE table lives on the NVMe tier (the FP4-Local folder). Every run also ended with the final combine, the head and the argmax readback, although only the call's last unit has a reader for them.This PR changes both, in
crates/gpu/src/arch/qwen3moe/body38.rsandwide38.rs:call_units(from, n, width, marks)is the one cut of a prompt call: each run up to the next mark is cut the wayubatch_cutcuts it, and the unit before each mark is marked.feed_markedcomputes marks only when checkpoints are on and callsfeed38once for the whole call.feed38starts onePleHost::prompt_startfor the call's units (now given the cut instead of a row width), runs the head on the last unit only, and on a marked unit before it still runs the last layer's combine when the MTP draft or a tap reads the rows, and reads the fault word beforemark_heretakes the checkpoint.PleRead::readis split intostartandfinish, andPleHost::fill_spannedintoname_spanned(names the rows, makes every refusal, starts the NVMe read) anddecode.PleHost::uploadcopies the decoded rows into the arena'sethroughWindowMut::of_mut, which replaces threeunsafef32_viewcopies (the prompt, ubatch and verify plans).Body38::ple_lateis set bystage_gemmon a walk with no expert tier where every layer isCard38::hostless(FP4-Local on GB10 loads this way).walk_gemmthen hands the walk arows_inclosure (decode and upload),WideParts::ple_rowscarries it, and the front's PLE-site branch calls it beforecombine. A walk that reaches its PLE site without the rows copied in is refused by name. A walk with a host leg keeps the early fill, because there the step thread serves the host between launches.tools/unsafe-ratchet.txt: the gpu block count goes from 2268 to 2265.The change is in Body38's own prompt path, above any rank split, so the rank count is not involved.
Release notes: Changed: long Qwen3.8 prompts reach their first token sooner on GB10.
Code shape
call_unitsis the one cut that the walk and the read-ahead both use, and it replaces the per-run cut.PleHost::uploadreplaces three copies of the same copy. Searches forcall_units,PleRowsIn,name_spanned,upload,mark_here,feed_stepsandple_latefind no second definition.Resultis propagated.tools/check-comments.shis ok.cargo fmtandcargo clippyare clean on what I touched; the lint count did not go up.cargo fmt --checkandcargo checkare clean on this head. Clippy has not been run on this head.Duplication found or removed (
path:line), or "none": none.What I ran
Hardware: one DGX Spark (GB10) for the timed run and the unit tests.
The build container reports CUDA 13.3 for the toolchain; the host line above is the driver's.
Speed
Measured on one DGX Spark (
NVIDIA GB10, driver 595.84), the head against mainc681eb07d, each built from its own tree, FP4-Local foldernvidia__Qwen3.8-Flash-Next-FP4-Local/b9ce18a6887e18c089fdea8509a33e63429a3300.--parallel 1 --ctx-size 16896,BLOOMERY_DRAFT=off, checkpoints on,/completiongreedy withn_predict32, one request at a time. The arms ran in the order main1, head1, main2, head2 in one lease, with one server load per arm and three requests per prompt length, each on its own window of the corpus; a cell is the arm's median. Load time is reported apart. The GPU clock cap was lifted from each arm's ready to its done and restored after it.4096 ids: TTFT -51.8 ms (-1.46%), prefill +1.50%, decode +0.54%; 8192 ids: TTFT -134.1 ms (-1.83%), prefill +1.88%, decode +0.87%
The deltas compare the two head arms with main2, the warm main arm. Main1 is the first server after the builds, so its page cache was cold and it paid for the PLE rows its later arms found already read; it is in the table and left out of the deltas. That leaves one warm main arm, so this is one alternating pair and not a significance claim. At 8K every head request (7,160 to 7,220 ms) is below every main2 request (7,278 to 7,320 ms). At 4K the head requests (3,478 to 3,523 ms) and main2's (3,521 to 3,577 ms) overlap slightly, and the 4K gain is small enough that I would not call it separated from the run-to-run spread. The decode difference is not something this change aims at, and I do not claim it.
Which change acts where: a 4K request prefills 4,095 ids (
prompt_wholesteps the last id), which is one unit whose only mark is the call's end, so at 4K only the late PLE fill acts. An 8K request prefills 8,191 ids as two units with a checkpoint after the first, so the late PLE fill acts on both units, and the one-cut call also drops the first unit's head and reads the second unit's PLE rows ahead. At 4,095 rows, the head and readback that an intermediate checkpoint unit no longer runs cost 10.96 ms by the profile, and six launches and one blocking readback are gone per such unit.The same lease measured the machine's read ceiling at 206.6 GB/s (
read_probe).The timed head has the same
crates/code as the head of this PR. The rebase onto current main changes onlytools/unsafe-ratchet.txt(the recounted gpu block count: 2268 to 2265 on this base, 2256 to 2253 on the measured base), and upstream between the measured base and this PR's base changed neitherbody38.rsnorwide38.rs.Output parity
Greedy ids (32 a request) are equal across all four arms in all six windows, both prompt lengths, with checkpoints on.
Tests and FAIL-first
bash tools/gate.sh --oxide -p bloomery-gpu --release --lib -- arch::qwen3moe::body38:: arch::qwen3moe::wide38::on the head, then on two planted mutants of the code, restoring the file after each:prompt_startfor each run between marks). The NVMe PLE test stops at its read-ahead assertion.a_call_cuts_its_units_at_its_marksstops at its marks assertion.The ignored test,
hw_a_unit_window_gives_back_its_context_handle, needs a CUDA device and runs underjust gate-gpu-lib.a_call_cuts_its_units_at_its_marksis new, and the NVMe PLE test now reads ahead across a mark.just gate-gpu-qwen38-servenot run: the gate needs the maintainers' workstation.just gate-gpu-qwen4exp-e2eandjust gate-gpu-qwen4exp-mtpnot run: they load the plan of the maintainers' workstation.Reproduction
Send greedy
/completionrequests withn_predict32 and prompts of 4,096 and 8,192 ids on fresh corpus windows, and compare TTFT against main after one warm-up load on each tree.What I ran into
This does not block the PR.
t0, clippy and the other static checks.AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.