Skip to content

serve_client, serve gates: ids_of refuses a response whose token ids are not all u32 ids - #1090

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-ids-of-strict
Nov 1, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-ids-of-strict

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

서버 게이트가 토큰 id가 아닌 값이 섞인 응답을 조용히 넘기지 않고 이름 붙은 오류로 거부하도록 고쳤습니다.

What and why

Fixes #1075. serve_client::ids_of dropped every entry that was not a u32 id and read a value that was no array as "no ids". A server answer such as [expected..., null] therefore reached a reference comparison as the expected vector and passed. ids_of now returns Result<Vec<u32>, GateError> and refuses both cases by name: token ids: <v> is no array and token ids: entry <i> (<x>) is no u32 id in <v>.

Every caller passes the error on with ?. LookupCompletion::read and the step reference read their ids through ids_of instead of their own deserializers. Clauses that read a failed request as "no ids" to print a FAIL check keep that for a non-200 answer and read a 200 answer strictly. A streamed event with a tokens field must hold ids.

Release notes: Fixed: server gates refuse a response whose token ids are not all valid ids instead of comparing a shortened list.

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": LookupCompletion::read and stepped_completion in crates/gpu-gates/src/serve_client.rs each had their own serde_json::from_value::<Vec<u32>> id reader; both now call ids_of.

What I ran

Base 0dbe02c685491bfb3bd5297ccc1541a0e1112454, PR head d6c68c43623810541c9060356fef34442a45ba46.

$ nvidia-smi
Sun Nov  1 13:46:27 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   48C    P8              5W /  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                                                             |
+-----------------------------------------------------------------------------------------+

Every gate binary that reads ids_of compiles, with the unit tests:

$ cargo check -p bloomery-gpu-gates --features deepseek41,glm5next,minimaxm3,gemma-embedding2,vision,hf --lib --tests --bin gate_qwen38_serve --bin gate_qwen3_serve --bin gate_ds41_serve --bin soak_ds41_serve --bin gate_llama_serve --bin gate_glm5next_serve --bin gate_minimaxm3_serve --bin gate_qwen3_dspark --bin gate_gemma_embedding2_serve
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 37.25s

The unit tests, including the new ids_of_refuses_what_is_no_id (a null entry in [7, null, 8] and a non-array value are refused):

$ bash tools/gate.sh --gpu --oxide -p bloomery-gpu-gates --features deepseek41 --release --lib -- serve_client::tests
test serve_client::tests::ids_of_refuses_what_is_no_id ... ok
test serve_client::tests::lookup_completion_requires_evidence ... ok
test serve_client::tests::stepped_completion_never_drafts_on_a_drafting_load ... ok
test result: ok. 8 passed; 0 failed; 0 ignored; 0 measured; 304 filtered out; finished in 0.12s

The Qwen3.8 serve gate, which drives bloomery-serve-qwen38 and holds the drafted clauses the issue names, on the fixture tier (draft model mtp-Qwen3.8-Flash-Next-shared-Q8_0.gguf):

$ BLOOMERY_TIER=fixture just gate-gpu-qwen38-serve
check drafted_serves_a_sampled_request: PASS
check drafted_top1_sample_is_the_greedy_ids: PASS
check drafted_ids_are_its_steps: PASS
gate-gpu-qwen38-serve: PASS
gate-gpu-qwen38-serve: PASS
gate-gpu-qwen38-serve: PASS

The three PASS lines are the plain, drafted and lookup arms; 136 checks passed and none failed.

AI help

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

…are not all u32 ids

ids_of left out every entry that was no integer in u32's range and read a
value that was no array as no ids, so an answer holding the expected ids
plus a null reached a gate's reference comparison as the expected vector
and passed. It now returns the ids or an error naming the entry (or the
value that is no array), and every caller passes the error on:

- the gates' `?` on each read; the clauses that read a non-200 answer as
  no ids read a 200 answer strictly; the streamed requests refuse an event
  whose tokens field holds no ids;
- LookupCompletion::read and the step reference read their ids through it
  instead of their own deserializers;
- the soak's drift probe and its chat-turn count refuse a malformed answer
  instead of reading it as no ids.
@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: Token ID validation has one owner, and malformed IDs can no longer pass comparisons as shortened vectors.

Non-blocking

⚠ Show the regression failing first: crates/gpu-gates/src/serve_client.rs:1588. The PR shows only passing output. Restore the old filtering inside the new Result signature and attach the failing test output. This confirms the regression catches the original defect before future changes rely on it.

Checked

Duplicates: 1 new item checked, none duplicated. The JSON reader replaces two deserializers; the text ID parsers have a different contract. No dryer pairs were available.

Complexity: crapper flagged DS41 run, slots_together, tiered, converse, drafted; GLM slots_skipping, slots_sampled, drafted, draft_only, slots_one_pass; Qwen38 paged, churn_unhosted, plain; Qwen3 schema_jump_is_the_step_arms, placed_answers_a_prompt_past_the_gemm_walk. Growth is error propagation and explicit HTTP-status arms in existing functions.

Silent failure: 11 conversion, default and optional-field sites followed. Invalid IDs return errors or fail checks. Non-200 defaults remain guarded by status or nonempty-result checks.

Tests: static mutation review. At serve_client.rs:255, restoring invalid-entry filtering makes ids_of_refuses_what_is_no_id fail at expect_err. At serve_client.rs:946, changing the step reference to request two tokens makes stepped_completion_never_drafts_on_a_drafting_load fail. Empty arrays and u32 boundaries were checked.

Gates: no thresholds, pins, clauses or cases removed or relaxed. No inference hot path or unsafe block changed.

Escape catalog: no C1–C4 patterns matched.

Notes

Dryer did not run, according to diagnostics.md. Its stated reason conflicts with files.txt, which lists changed Rust files under crates/; manual duplicate searches were used. Builds and card gates were not rerun here. The PR includes unit-test and GPU gate output from NVIDIA GB10.

Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/gate_ds41_serve.rs, crates/gpu-gates/src/bin/gate_gemma_embedding2_serve.rs, crates/gpu-gates/src/bin/gate_glm5next_serve.rs … and carries a gate run on the author's card, which counts as verified.

🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)

Filed outside this PR: #1091

@github-actions github-actions Bot added gpu-evidence Verified on the author's card: the pull request carries the gate run and its output and removed needs-gpu Changes code a card must check, and carries no gate run on a card labels Nov 1, 2026
@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 9f35aa5 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 gpu-evidence Verified on the author's card: the pull request carries the gate run and its output

Projects

None yet

Development

Successfully merging this pull request may close these issues.

serve_client: invalid response token IDs are silently discarded

1 participant