Skip to content

gpu-gates: read the Qwen3.8 greedy draft and cache counts strictly (#1129) - #1130

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-bot-1129
Nov 2, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-bot-1129

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

Qwen3.8 serve gate의 greedy reader가 빠지거나 깨진 draft와 cache 카운터를 0이나 최댓값으로 채우지 않고 이름 있는 오류로 멈추게 고쳤습니다.

What and why

Fixes #1129. The greedy reader in gate_qwen38_serve took a missing or malformed timings.draft_n as 0 and a missing timings.cache_n as u64::MAX. In slot_file_restore_is_the_straight_run, back.draft_n == straight.draft_n therefore passed when both answers carried malformed counters (0 == 0), and a missing cache_n passed back.cache_n == straight.cache_n && back.cache_n > 0 and reused.cache_n >= start. The reader now takes draft_n from serve_client::draft_counts, the parser the GLM gate and the lookup reader already use, so a half-present, non-integer, zero or accepted > proposed pair stops the gate with a named error. A missing cache_n is refused with the same message serve_client uses for /completion. Turn::run in gate_glm5next_serve had the same cache_n default and gets the same error. Only gate readers change; no server, engine or model code is touched.

Release notes: internal: the Qwen3.8 and GLM serve gates no longer pass a response with missing or malformed draft or cache counters.

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": none. The draft count parsing already lives in serve_client::draft_counts; the gate now calls it instead of reading the field itself.

What I ran

Upstream base 22ab72204adc69656f0808b5b1f24ec81d68e7a6, PR head 8ca9ecd47ae9242a609687dc0315507fe6ff5af8.

Card and driver:

$ nvidia-smi
Mon Nov  2 05:37:02 2026       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.84                 Driver Version: 595.84         CUDA Version: 13.3     |
+-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GB10                    On  |   0000000F:01:00.0 Off |                  N/A |
| N/A   45C    P8              4W /  N/A  | Not Supported          |      0%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI              PID   Type   Process name                        GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|  No running processes found                                                             |
+-----------------------------------------------------------------------------------------+
$ nvidia-smi --query-gpu=name,driver_version --format=csv,noheader
NVIDIA GB10, 595.84

Release build of the changed Qwen3.8 gate binary on the card host:

$ cargo oxide build --arch sm_121a -- -p bloomery-gpu-gates --features deepseek41,gemma-embedding2,hf --release --bin bloomery-serve-qwen38 --bin gate_qwen38_serve
    Finished `release` profile [optimized] target(s) in 10m 05s

✓ Cargo build succeeded
$ cargo oxide build --arch sm_121a -- -p bloomery-gpu-gates --features gpu --release --bin generate_qwen3moe
    Finished `release` profile [optimized] target(s) in 9.22s

✓ Cargo build succeeded

Type check of both changed gate binaries (exit status 0, no diagnostics):

$ cargo check -q -p bloomery-gpu-gates --bin gate_glm5next_serve --bin gate_qwen38_serve --features glm5next,deepseek41

Hardware (if the change is for a machine)

NVIDIA GB10, driver 595.84, CUDA 13.3 (nvidia-smi above).

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 2, 2026
@juliankang4
juliankang4 marked this pull request as ready for review November 2, 2026 06:18

@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: MUST_FIX: sibling streaming and media readers still allow malformed draft counters to pass their gates.

Must fix

1. Apply the strict draft reader on the sibling paths (kind B)

crates/gpu-gates/src/bin/gate_qwen38_serve.rs:1996 accepts draft_n=10, draft_n_accepted=11. The slots_alone_draft_counts_stay check at line 2321 passes when alone and concurrent responses carry that same invalid pair: it checks positive proposals and tuple equality only.

crates/gpu-gates/src/bin/gate_glm5next_serve.rs:2886 and crates/gpu-gates/src/bin/gate_glm5next_serve.rs:2915 accept {"draft_n":10} without an accepted count. Both media checks still pass when their other conditions hold; the accepted count is only printed, with a zero default. These are remaining copies of the malformed-counter defect this PR fixes.

Reusing the existing parser now costs three local edits and closes these gate escapes. In Qwen's streamed_with, replace the if let block with:

if v.get("timings").is_some() {
    drafts = draft_counts(&v).map_err(|e| format!("curl {url}: {e}"))?;
}

Replace GLM's image count binding with:

let image_drafted = draft_counts(&reply)?.0;

Replace GLM's text count binding with:

let drafted = draft_counts(&reply)?.0;

Non-blocking

⚠ Reader regression coverage is missing: crates/gpu-gates/src/bin/gate_qwen38_serve.rs:1239.
The existing draft_counts tests call the shared parser, not the changed readers. Restoring the old reader defaults leaves those tests green.
Exercise malformed responses through the changed readers and attach FAIL-first output. This protects the call sites from bypassing the parser again.

Checked

Duplicates: 0 new definitions; the proposed replacements reuse the existing draft-count owner.
Complexity: Qwen greedy adds fallible reads without a new dispatch branch or separate responsibility.
Silent failure: 3 changed reads propagate named errors to failed gate exits; 3 sibling reads retain the escapes above.
Tests: no tests changed; static mutation review found the reader-default mutants unguarded. No runtime tests run in this review.
Gates: no pins, tolerances or clauses removed or relaxed.
Escape catalog: no C1–C4 patterns matched. The change touches gate tooling, with no inference hot path.

Notes

The PR body supplies builds and a type check, but no just gate-* run with output or model path.

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

…idagedev#1129)

The greedy /completion reader defaulted a malformed timings.draft_n to 0
and a missing timings.cache_n to u64::MAX, so a slot-file comparison of
two equally malformed answers passed. Read draft_n through
serve_client::draft_counts and refuse a missing cache_n by name.
@juliankang4
juliankang4 force-pushed the dgx-spark-q38-bot-1129 branch from 93ddf1d to 0dd5cbf Compare November 2, 2026 06:32

@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.

Since the last review:

Verdict: CLEAN: The revision closes the reported malformed-counter escapes and introduces no blocking defect.

Non-blocking

⚠ Reader regression coverage remains missing: crates/gpu-gates/src/bin/gate_qwen38_serve.rs:1997.
The existing tests exercise draft_counts and LookupCompletion::read, not these reader call sites. Restoring the old reader defaults leaves those tests green.
Exercise malformed responses through the readers and attach FAIL-first output. This catches a future bypass of the parser.

Checked

Duplicates: 0 new definitions; the three revised reads reuse the existing parser. No dryer pairs were supplied.
Complexity: crapper flags GLM media 32 → 34 and Qwen greedy 16 → 18; fallible reads grow within existing responsibilities.
Silent failure: 6 changed reads followed. Invalid counters propagate named errors or failed requests; the remaining media display defaults follow strict validation.
Tests: none added or changed. Static mutation check: restoring reader defaults leaves the shared-parser tests green. No runtime tests run.
Gates: no pins moved or clauses removed. Missing count partners and accepted counts above proposals are rejected; omitting both counts remains valid for requests that proposed nothing.
Escape catalog: no C1–C4 pattern matched. Only gate tooling changes; no inference hot path changes.

Notes

Diagnostics reports that dryer did not run.
The PR body supplies builds and a type check, but no just gate-* run with output or model path.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_glm5next_serve.rs, crates/gpu-gates/src/bin/gate_qwen38_serve.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 7805413 into midagedev:main Nov 2, 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.

gpu-gates: Qwen3.8 greedy reader hides malformed draft counters

1 participant