Skip to content

serve: a sampled request drafts beside other busy slots, its window a row of the round's one pass with its sampler and history; Qwen3.8's unset MTP draft drafts on any slot count - #964

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fp4l-mtp-sampled-slots
Oct 29, 2026

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

여러 요청이 함께 도는 라운드에서도 sampled 요청이 MTP draft를 계속 쓰도록 하고, Qwen3.8의 기본 draft를 slot 수와 상관없이 켜는 변경입니다.

What and why

Beside another busy slot, a sampled request (or one that bans token ids) did not draft: the worker turned the request's round into a plain step, and an unset MTP draft on Qwen3.8 stayed off under --parallel above 1. At two and four concurrent sampled requests the server decoded one token per slot per round.

This PR makes a sampled request's window one row of the round's single verify call. The row carries the request's history and sampler, and each kept id is drawn from that row's verified logits with the same rule the single-request path uses (keep up to the first id that differs from the proposal's next id). A request with a given seed therefore takes the same ids alone and beside others. With sampled rows in place, the unset draft no longer needs the slot-count rule, so draft_for_slots and Draft38Off::Slots are removed and the unset draft drafts on any slot count.

Release notes: Changed: a Qwen3.8 server with the MTP draft drafts sampled and id-banning requests while other requests run, which raises their decode throughput at two and four concurrent requests on a DGX Spark; an unset draft is no longer turned off by --parallel above 1.

Code shape

The review reads these first. A box left unticked needs one line of why.

  • No second copy. Logic two models (or two call sites) share has one common owner; I lifted it there instead of
    copying it (AGENTS.md "Common code first", docs/rust-quality.md R14). Where I found an existing copy, I
    named it below.
  • Model code holds only architecture facts. A model's own files carry only what its architecture forces
    (tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
  • Dead code is gone. Nothing I made unused is left behind (functions, flags, gate clauses, docs).
  • No silent failure. Undefined input is a named error or panic, never a defined-looking output.
  • Comments state what is true now. No dates, issue numbers or how a bug was found (tools/check-comments.sh).
  • No relaxed gate. No band, tolerance or lint moved to make a check pass; a re-pin carries PIN(YYYY-MM-DD):
    and its reason.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": crates/app/src/lib.rs:692 Session::slots_row repeated the NaN check of row_logits (:949); both now call Session::read_row (:444).

What I ran

Throughput, base and head

One DGX Spark (GB10, sm_121a) in a CUDA 13.3.1 container, model nvidia/Qwen3.8-Flash-Next-FP4-Local at revision b9ce18a6887e18c089fdea8509a33e63429a3300. Base is 5e743ada8; the head measured is 547ef405, this change on that base. Each arm starts bloomery-serve -m <folder> --parallel N with BLOOMERY_DRAFT unset (N is 2 or 4 and equals the number of concurrent requests), then sends N concurrent sampled requests of a 4096-token prompt and 128 generated ids (temperature 0.7, seed 42 plus the request number), 8 windows with a warm-up first. Each cell is the median of 3 rounds, alternated between base and head. A difference counts only when it exceeds the same-revision repeat spread (never below 0.5%) and the ranges do not overlap.

Metric Base Head Difference Ranges overlap
2 requests, code, decode tok/s 21.44 29.94 +39.6% no
2 requests, code, total tok/s 36.20 45.91 +26.8% no
2 requests, prose, decode tok/s 21.54 24.91 +15.6% no
2 requests, prose, total tok/s 36.68 40.67 +10.9% no
4 requests, code, decode tok/s 12.96 15.18 +17.1% no
4 requests, code, total tok/s 40.18 42.54 +5.9% no
4 requests, prose, decode tok/s 13.33 13.56 +1.7% yes
4 requests, prose, total tok/s 41.43 41.18 -0.6% yes

Prefill tok/s and TTFT p95 are inside that spread with overlapping ranges in every arm (for example 2 requests, code, prefill: 2338.8 to 2344.8 tok/s). The 4-request prose cells are inside the spread too, so I read them as no change.

Real binary on the card

bloomery-serve built with the shipped features, --parallel 2 --ctx-size 16896, BLOOMERY_DRAFT unset, BLOOMERY_RESIDENCY=off BLOOMERY_STEP_STATS=1 BLOOMERY_HOST_ROOM=96G, on the same model. Two sampled requests of 128 ids each run alone and then together; then one greedy and one sampled request run together.

setup draft=mtp draft_from=folder slots=2 ctx=8448
check a_default_load_drafts: PASS
sampled A: alone 128 ids draft 117/80 54.1 tok/s; together 128 ids draft 111/70 31.1 tok/s
sampled B: alone 128 ids draft 129/69 44.3 tok/s; together 128 ids draft 122/65 27.6 tok/s
check b_sampled_together_ids_are_alone: PASS
check b_sampled_together_drafts: PASS [111, 122]
check d_sampled_rounds_pass_both: PASS 57 pass rows=2, 0 step rows=2 of 57 records
mixed: greedy 128 ids draft 112/77; sampled 128 ids draft 88/52; 51 pass rows=2 of 51 records
check c_mixed_ids_are_alone: PASS
check d_mixed_rounds_pass_both: PASS
CARDRUN PASS

Unit tests on the card machine

bash tools/gate.sh --oxide -p bloomery-gpu-gates --release --features deepseek41,hf --lib -- bind::
test result: ok. 36 passed; 0 failed
cargo test --release --bin bloomery-serve-qwen38
test result: ok. 26 passed; 0 failed
cargo test -p bloomery-app --lib -- mtp
test result: ok. 20 passed; 0 failed

cargo check of gate_glm5next_serve, gate_qwen38_serve and bloomery-serve finished without errors.

Hardware (if the change is for a machine)

The change is for the GB10 serve path. Measured on one DGX Spark: NVIDIA GB10, 595.84 (driver 595.84, CUDA 13.3), sm_121a, CUDA 13.3.1 container.

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

… row of the round's one pass with its sampler and history; Qwen3.8's unset MTP draft drafts on any slot count
@github-actions github-actions Bot added dgx-spark The DGX Spark (aarch64, GB10) port documentation Improvements or additions to documentation 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 serve The HTTP server: crates/serve labels Oct 29, 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 merge-blocking behavior or quality defect was found.

Non-blocking

⚠ Measure the added greedy-round allocations: crates/gpu-gates/src/bin/shared/serve_seats/rounds.rs:336.
The new draws, given and drawing vectors add three allocations per nonempty drafted round, including all-greedy rounds [derived].
The supplied A/B covers sampled requests. Add a greedy A/B to measure this host cost; retaining round scratch would remove these allocations.

Optimization headroom

  • G. Per-launch and per-sync fixed cost: crates/gpu-gates/src/bind.rs:2171, reuse the existing per-request Gen::lent history storage for shared passes. This removes one fresh history allocation per sampled slot per round [derived], as the single-request path already does.

Checked

Duplicates: 32 new definitions checked, including test adapters and the local error tag; no actionable duplicates. Dryer reported zero pairs; GPU code was checked manually.
Complexity: crapper's Link::pass_slots (5→12), app::mtp::pass_slots (22→26), and rounds::pass_rows_one_pass (20→24) gained sampler dispatch and restoration branches; draft_slot_share (41→42) and slots_drafted_sampled (17→18) gained clause checks/calls.
Silent failure: three default/skip sites followed. A missing returned draw leaves a missing sampler and fails; the absent-draw history length is unused; defaulted test error text fails its assertion.
Tests, static mutation analysis: worker.rs:918 Sampled→Step fails concurrent-draft assertions; worker.rs:966 using advance_slots for one row fails the mixed-call test; bind.rs:2170 dropping the draw fails row-output/sampler-state assertions; bind.rs:2200 and engine.rs:687 dropping history checks fails refusal tests; genloop.rs:614 dropping the sampler check fails the named-error test; genloop.rs:404 allowing probability requests to draft fails the new step-record clause; mtp.rs:883 reading another window's row fails alone-id comparisons; restoring draft_for_slots fails the unset-load clause. These mutants were not executed.
Gates: no numeric band changed; dated reasons cover the retired slot restriction and step-only expectations.
Escape catalog: C1–C4 do not match this diff. Context limits, zero-width windows, mixed rounds, and nonzero first row offsets were traced.

Notes

Static review only; no build or hardware gate was run here. The PR lacks the owning just gate-gpu-qwen38-serve and just gate-gpu-glm5next-serve command output and FAIL-first output for the new clauses. Its measured hashes differ from this review's base/head, and the throughput runner commands/output are absent. GPU evidence is false under the requested evidence rule.

Card check: needs-gpu. This pull request changes crates/app/src/lib.rs, crates/app/src/mtp.rs, crates/gpu-gates/src/bin/bloomery_serve_qwen38.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 4c549a4 into midagedev:main Oct 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dgx-spark The DGX Spark (aarch64, GB10) port documentation Improvements or additions to documentation 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 serve The HTTP server: crates/serve

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant