Skip to content

docs(serve): identify the continuation reference source - #1074

Merged
juliankang4 merged 6 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-drafted-ref-steps
Nov 1, 2026
Merged

juliankang4 merged 6 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-drafted-ref-steps

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

Qwen3.8 serve gate가 drafted 서버의 기준 토큰을 얻는 방식이 확률 요청의 draft를 잘못 가정해서 고쳤습니다.

What and why

gate_qwen38_serve took the drafted server's reference ids from one /completion request with n_probs, assuming that a request asking for probabilities never drafts. The server drafts those requests too, so the "reference" ran speculative passes and drafted_reference_steps_draft_nothing could not hold.

This adds serve_client::stepped_completion: it asks for one token per request and reuses the previous prefix, so no speculative pass can start. The drafted arm and the width chooser clause use it in place of the local steps_of. The drafted arm runs the reference after its cache and continuation clauses, because the one-token requests leave prefix snapshots in the prompt cache. Three gate expectations change with the server's behavior: the slots_drafted_probs rounds are cmd=pass instead of cmd=step, and in the lookup arm a logprobs request is checked like any other lookup request (lookup_7_verifies_proposals, file-bound) instead of lookup_logprobs_step_without_a_draft. Both re-pins carry PIN(2026-11-01). Header comments that said probability requests step now say they draft.

Release notes: internal: the Qwen3.8 serve gate takes its drafted reference from one-token requests, which never draft.

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": removed the local steps_of and tokenized in crates/gpu-gates/src/bin/gate_qwen38_serve.rs; both call sites use serve_client::stepped_completion and the shared serve_client::tokenized.

What I ran

On a DGX Spark (GB10), Qwen3.8 fixture (BLOOMERY_MODEL=qwen4exp, 4 layers, 512 experts, Q4_K) with the MTP Q8_0 draft, prompt The capital of France is, 16 tokens.

Before, a unit test puts the old multi-token n_probs request in place of the helper, on a mock server that drafts (base 28bc0af4):

bash tools/gate.sh --oxide -p bloomery-gpu-gates --release --features deepseek41,gemma-embedding2,hf --lib -- serve_client::tests::stepped_completion_never_drafts_on_a_drafting_load --exact --nocapture
assertion `left == right` failed: the reference drafted 15 ids
test serve_client::tests::stepped_completion_never_drafts_on_a_drafting_load ... FAILED
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 317 filtered out

After, with stepped_completion, the serve_client:: tests:

bash tools/gate.sh --oxide -p bloomery-gpu-gates --release --features deepseek41,gemma-embedding2,hf --lib -- serve_client:: --nocapture
test serve_client::tests::stepped_completion_never_drafts_on_a_drafting_load ... ok
test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 311 filtered out

The real server, on the drafted and lookup arms (run on db2eb82a):

cargo oxide build --arch "$arch" -- -p bloomery-gpu-gates --features deepseek41,gemma-embedding2,hf --release --bin bloomery-serve-qwen38 --bin gate_qwen38_serve
cargo oxide build --arch "$arch" -- -p bloomery-gpu-gates --features gpu --release --bin generate_qwen3moe
bash tools/gpu-gate.sh generate_qwen3moe --place gate --tokens "$REF_TOKENS" -n 16 > gen.log
bash tools/gpu-gate.sh gate_qwen38_serve --arm drafted --gen gen.log --prompt "The capital of France is" --ids "$REF_TOKENS" --dir drafted
bash tools/gpu-gate.sh gate_qwen38_serve --arm lookup --gen gen.log --prompt "The capital of France is" --ids "$REF_TOKENS" --dir lookup
steps on the drafted server: tokens [34727, 18849, 63985, 196451, 244610, 182444, 36336, 47237, 173187, 128437, 11061, 59985, 141187, 239582, 114443, 131474] draft_n=0
check drafted_reference_steps_draft_nothing: PASS
check drafted_ids_are_its_steps: PASS
check continued_after_windows_keeps_them_and_joins_at_their_end: PASS
check continued_after_windows_drafts_the_plain_ids: PASS
gate-gpu-qwen38-serve: PASS
gpu-gate.sh: gate_qwen38_serve ran 41 s (exit 0)
check lookup_7_ids_are_draft_off: PASS
gate-gpu-qwen38-serve: PASS
gpu-gate.sh: gate_qwen38_serve ran 35 s (exit 0)

The plain arm, with the same helper and the two-slot probability pair on the drafted load (run on 1d170649):

check slots_drafted_probs_rounds_run_one_pass: PASS
check slots_drafted_probs_together_alone: PASS
gpu-gate.sh: gate_qwen38_serve ran 242 s (exit 0)

Hardware (if the change is for a machine)

Card Driver
NVIDIA GB10 595.84

AI help

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

@github-actions github-actions Bot added gpu The card engine: crates/gpu*, crates/app needs-gpu Changes code a card must check, and carries no gate run on a card labels Nov 1, 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: One-token reference requests avoid speculative passes, and the updated expectations match the server's drafting paths.

Checked

  • Duplicates: 2 new items searched; no new duplicate. No dryer pairs were available.
  • Complexity: width_cost rises 24 → 25 from the fallible tokenization call in its existing reference stage; harmless growth.
  • Silent failure: the new helper strictly reads token IDs and checks subsequent prefix-cache counts, draft counts and stop types.
  • Tests: static mutation review at crates/gpu-gates/src/serve_client.rs:941: changing the request limit from 1 to 2 makes the test fail on the rejected response. The PR supplies FAIL-first output for restoring the old multi-token probability reference. Plain-step probability requests fail the changed round-command and real-file proposal checks.
  • Gates: both changed probability expectations carry PIN(2026-11-01) and reasons. The reference equality and zero-draft checks remain.
  • Escape catalog: no C1–C4 pattern appears in this Rust-only diff.

Notes

Dryer did not run, as reported by diagnostics. Tests and hardware gates were not executed during this validation. The PR reports GB10 runs but lacks the full hardware-evidence list in CONTRIBUTING.md.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_qwen38_serve.rs, crates/gpu-gates/src/serve_client.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)

Filed outside this PR: #1075, #1076

@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 8499acd into midagedev:main Nov 1, 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 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