Repository navigation
serve: skip unused Qwen3.8 prompt heads and read PLE rows in parts - #817
Conversation
…er's threads A Qwen3.8 prompt on a hostless card reads each ubatch's PLE rows through the NVMe tier's prefetcher in the PLE site's host callback, so the read overlaps only the layer before the site. On GB10 a 4,096-id prompt's ubatch names 65,520 rows a plane, and the helper advised, faulted and copied them one after another on its one thread: the engine thread waited for that read, not for the decode after it. HelperOptions::workers lets a floating helper cut a token's rows into ordered runs (threads::chunk_bounds) once its largest site holds at least PART_ROWS rows a part. The helper reads the first run and a scoped thread each other run; every part advises, fills and copies its own rows into its own slots of the token's buffer, laid out as one read lays them, so the buffer, the decoder and the fault contract are unchanged. The token's times are the slowest part's and its faults every part's. A decode step's rows, and every token of a pinned helper, still read on the helper alone; a helper of no workers is refused. The PLE reader reads over twelve.
A Qwen3.8 prompt call that produces no token still read the vocabulary head of its last row and synchronized on its argmax: every prefill the serve loop sends before a step (the run of a prompt's last call ahead of its last id, and the earlier calls a prompt is cut into) paid for a head nothing read. Seat::prefill_only feeds such a run, its default the seat's prefill. The Qwen3.8 seat runs the batched prompt and the draft's prompt walk without the head (Session::prefill, MtpDraft::prefill, MtpBody::prefill_with); a checkpoint at the run's end still combines the final streams, so the checkpoint before the last id stays for a later request. The last id then runs as the captured decode step, as before.
There was a problem hiding this comment.
Verdict: CLEAN: No behavior failure or proven quality defect survived review.
Non-blocking
⚠ Supply evidence from this head: crates/engram/src/prefetch.rs:611. A floating PLE helper using twelve parts starts eleven worker threads per ubatch [derived]; decode-sized reads start none. The timing table predates the rebase and its changed final-layer work. Supply the owning Qwen gate results and a current-head timed A/B on the contributor's card, with both hashes, the model file, commands and output.
Checked
- Duplicates: dryer reported zero pairs; the prompt entries share
prompt38_readandprompt_joined. - Complexity: crapper flagged
feed38, 32 → 36; the existing orchestration gained head selection and a final fault-read branch. - Silent failure: zero workers and insufficient buffer space produce named errors; helper read errors reach
wait(). - Tests: the engram byte assertion detects shortening each run at crates/engram/src/prefetch.rs:599 to
end - 1, by inspection. It also checks zero-worker refusal. The existing serve gate checks cached versus fresh tokens and MTP rejoining after a checkpoint cut at crates/gpu-gates/src/bin/gate_qwen38_serve.rs:1677. - Gates: no thresholds moved and no cases were removed.
- Escape catalog: C1–C4 do not match.
Notes
Source review only; runtime tests were not executed. GPU evidence is incomplete: the PR explicitly reports no gate run on this head.
Card check: needs-gpu. This pull request changes crates/app/src/arch/qwen3moe/mtp.rs, crates/app/src/mtp.rs, crates/gpu-deepseek41/src/chain/glue.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 서버가 프롬프트 앞부분에서 쓰지 않는 vocabulary head 계산을 건너뛰고, 긴 프롬프트의 PLE 행을 여러 스레드로 나눠 읽게 합니다.
What and why
A Qwen3.8 prompt call that produced no token still ran the vocabulary head on its last row and waited for the argmax. Every prefill the serve loop sends before a step paid for a head nothing read: the run of a prompt's last call ahead of its last id, and the earlier calls a long prompt is cut into. On a hostless card the PLE rows of each ubatch were also read by one prefetch helper thread, which advised, faulted and copied up to 65,520 rows a plane one after another while the engine thread waited for them.
This PR does two things.
Seat::prefill_onlyfeeds such a run without the head, defaulting to the seat'sprefill; the Qwen3.8 seat runs the batched prompt and the draft's prompt walk through newprefill38_with,MtpBody::prefill_with,Session::prefillandMtpDraft::prefill. A checkpoint at the end of the run still combines the final streams, so the checkpoint before the last id stays for a later request, and the last id runs as the captured decode step as before. Separately,HelperOptions::workerslets a floating prefetch helper cut a token's rows into ordered runs once its largest site holds at leastPART_ROWSrows per part. The helper reads the first run and a scoped thread reads each other run into its own slots of the token's buffer, so the buffer layout and the fault contract are unchanged. A decode step's rows and every token of a pinned helper still read on the helper alone, and a helper of no workers is refused by name. The PLE reader uses twelve workers. The DeepSeek chain's helper keeps one.Release notes: Changed: Qwen3.8 prompt prefill skips a vocabulary head nothing reads, and a prompt's PLE rows are read on several threads.
Code shape
The review reads these first. A box left unticked needs one line of why.
prompt38_readwith the token-producing one, andprompt_joinedserves both draft entries.Seat,MtpBody,Prefetcher) gained a defaulted method and a worker count, not a per-model branch.cargo fmtis clean on what I touched.cargo clippywas not run on this head.Duplication found or removed (
path:line), or "none": none. The three near-duplicates the scan reports are thin entries over one owner each:crates/app/src/arch/qwen3moe/mtp.rs:59forwards toprefill38_with,crates/app/src/mtp.rs:533andcrates/app/src/mtp.rs:1015shareprompt_joined, andcrates/gpu/src/arch/qwen3moe/body38.rs:3957andcrates/gpu/src/arch/qwen3moe/body38.rs:3947are entries overprompt38_readwith the head on or off.What I ran
Format and build, on this head:
cargo fmt --all -- --checkpassed on a Mac with no output. The all-targetsjust checkbuild passed on an RTX 5090 machine.Boundary check on this head: the last head-free ubatch of a prompt now stops its last layer after the stores when no checkpoint or tap reads its rows. The FP4-Local checkpoint served 4,096-token code windows at four offsets, with and without prompt caching, on main and on this head, 128 greedy tokens each.
All eight requests produced the same 128 tokens on main and on this head, and the top-2 logprobs matched at every generated position.
GPU Evidence
Card conditions of the timed A/B, from
nvidia-smi:just gate-gpu-qwen4exp-nvfp4not run: it was not run on this head, and a maintainer runs it on the workstation.Timed A/B
The A/B ran on a DGX Spark with these two changes on a main from before #812, in two parts, FP4-Local and NVFP4, with the code-function prompt, three rounds per side. Medians:
Greedy output was identical on main and on head in both parts.
On FP4-Local the head's TTFT sat below main in all three rounds, with non-overlapping ranges. The NVFP4 changes are within the run-to-run noise: the ranges of the two sides overlap.
This PR and #812 were developed at the same time, so the main in this table is the main before #812. #812 has since merged and raised the same setup to 2061.01 tok/s FP4-Local prefill and 1959.34 tok/s NVFP4 prefill (its "Speed" table), so #812's head column is the number close to the current main, not the main column here.
Hardware
DGX Spark (GB10), driver 595.84, CUDA 13.3, for the timed A/B and the boundary check. The build check ran on an RTX 5090 machine.
AI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.