Skip to content

gate_qwen38_serve, gate_ds41_serve: a completion agrees with its reference by serve_client::agree alone - #1092

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-q38-agree-owner
Nov 1, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-q38-agree-owner

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

gate_qwen38_serve와 gate_ds41_serve가 각자 가진 agree 복사본을 지우고 공용 serve_client::agree 하나만 쓰게 하는 수정입니다.

What and why

gate_qwen38_serve and gate_ds41_serve each kept a private copy of agree, the rule that decides whether a served completion matches its reference: every id when the run hit its limit, and a non-empty prefix only when it stopped at the end-of-generation id. gate_ds41_serve also spelled the same rule inline in its completion_ids_are_generate_ds41 clause. serve_client::agree already holds this rule and the other server gates use it. Fixes #1076. Both gates now import it, the copies and the inline match are removed, and serve_client gets one test that pins the rule (the engine runtime is untouched).

Release notes: internal: the two serve gates share one completion-agreement rule, so a change to it cannot leave a gate behind.

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 fn agree from crates/gpu-gates/src/bin/gate_qwen38_serve.rs and crates/gpu-gates/src/bin/gate_ds41_serve.rs, and the inline match stop in the completion_ids_are_generate_ds41 clause of the latter. The one owner is serve_client::agree in crates/gpu-gates/src/serve_client.rs.

What I ran

Base 9f35aa59b2c472382f496cdab681b472f13c1dac, PR head dd016ef5a1063121d2ecfa47d7eacddc7b983257.

$ nvidia-smi
Sun Nov  1 13:42:19 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   46C    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                                                             |
+-----------------------------------------------------------------------------------------+

Model: Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf, sha256 4448186216b3af4cc558bbce2c3213f01608f8f8b2e5267a9767971dd3ec8082.

Both gates build, and the drafted arm of gate_qwen38_serve runs. Its drafted_ids_are_its_steps clause calls agree:

A=$(bash tools/arch.sh)
cargo oxide build --arch $A -- -p bloomery-gpu-gates --features deepseek41,gemma-embedding2,hf --release --bin bloomery-serve-qwen38 --bin gate_qwen38_serve
cargo oxide build --arch $A -- -p bloomery-gpu-gates --features deepseek41,vision,gemma-embedding2,hf --release --bin gate_ds41_serve
cargo oxide build --arch $A -- -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
check drafted_ids_are_its_steps: PASS
gate-gpu-qwen38-serve: PASS

The new test passes on the fix. With the eos arm changed to accept an empty run ("eos" => reference.starts_with(ids)), the same command fails:

cargo oxide test --arch sm_121a -- -p bloomery-gpu-gates --release --features deepseek41,gemma-embedding2,hf --lib serve_client::tests::agree_takes_a_prefix_only_at_eos
test serve_client::tests::agree_takes_a_prefix_only_at_eos ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 321 filtered out; finished in 0.00s
test serve_client::tests::agree_takes_a_prefix_only_at_eos ... FAILED

Hardware (if the change is for a machine)

One NVIDIA GB10, driver 595.84, CUDA 13.3. The gate runs above used it.

AI help

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

…rence by serve_client::agree alone

Both gates carried a private copy of serve_client::agree, the EOS prefix exception included. They import the shared one now, so the rule has one owner, and a unit test holds that rule.
@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: The gates reuse the existing agreement rule without changing its behavior.

Checked

  • Duplicates: 1 new item checked; no duplicate test found. Both removed functions and the inline match equal the existing owner. No dryer pairs were supplied.
  • Complexity: crapper flagged no functions. The inline match is replaced by a call; no decision logic is added.
  • Silent failure: 0 added default or discarded-error sites.
  • Tests: agreement test:1688 protects the predicate at line 536. Allowing empty EOS output, accepting prefixes for every stop, or requiring full equality at EOS each contradicts an assertion. Static inspection only; tests were not executed locally.
  • Gates: no tolerance, pin, or gate clause is removed or relaxed.
  • Escape catalog: no patterns matched. No engine hot path changes.

Notes

dryer did not run, according to diagnostics; source searches covered duplication.
The GPU output names head dd016ef5, not the current head fac355ba; no just gate-* run is shown.

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

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

gpu-gates: Qwen3.8 duplicates the shared completion agreement rule

1 participant