Skip to content

serve: skip unused Qwen3.8 prompt heads and read PLE rows in parts - #817

Merged
juliankang4 merged 2 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-lead-host-gap
Oct 25, 2026
Merged

juliankang4 merged 2 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-lead-host-gap

Conversation

@juliankang4

@juliankang4 juliankang4 commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

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_only feeds such a run without the head, defaulting to the seat's prefill; the Qwen3.8 seat runs the batched prompt and the draft's prompt walk through new prefill38_with, MtpBody::prefill_with, Session::prefill and MtpDraft::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::workers lets a floating prefetch helper cut a token's rows into ordered runs once its largest site holds at least PART_ROWS rows 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.

  • No second copy. The head-free prompt call shares prompt38_read with the token-producing one, and prompt_joined serves both draft entries.
  • Model code holds only architecture facts. The common owners (Seat, MtpBody, Prefetcher) gained a defaulted method and a worker count, not a per-model branch.
  • Dead code is gone. Nothing this change made unused is left behind.
  • No silent failure. A helper of no workers and a buffer too small for a part are named errors.
  • Comments state what is true now.
  • No relaxed gate. No band, tolerance or lint moved.
  • cargo fmt is clean on what I touched. cargo clippy was 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:59 forwards to prefill38_with, crates/app/src/mtp.rs:533 and crates/app/src/mtp.rs:1015 share prompt_joined, and crates/gpu/src/arch/qwen3moe/body38.rs:3957 and crates/gpu/src/arch/qwen3moe/body38.rs:3947 are entries over prompt38_read with the head on or off.

What I ran

Format and build, on this head:

cargo fmt --all -- --check
BLOOMERY_BOX_LOCAL=1 just check

cargo fmt --all -- --check passed on a Mac with no output. The all-targets just check build 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:

NVIDIA GB10, 595.84
| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |

just gate-gpu-qwen4exp-nvfp4 not 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:

Part and metric Main Head Change
FP4-Local TTFT p95 (ms) 2292.14 2232.52 -2.601%
FP4-Local prefill (tok/s) 1791.44 1839.76 +2.697%
FP4-Local decode (tok/s) 30.1957 30.2768 +0.268%
NVFP4 TTFT p95 (ms) 2396.43 2358.23 -1.594%
NVFP4 prefill (tok/s) 1714.07 1742.33 +1.649%
NVFP4 decode (tok/s) 22.7755 22.4924 -1.243%

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 초안 리뷰는 제가 직접 했습니다.

…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.
@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card labels Oct 25, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_read and prompt_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)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit 7f3efbf into midagedev:main Oct 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant