Skip to content

serve readers: read SSE frames whole in every gate and check the soak's paired chat answer - #1114

Merged
juliankang4 merged 6 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-silent-readers
Nov 2, 2026
Merged

juliankang4 merged 6 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-silent-readers

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

서빙 gate와 soak의 응답 reader가 읽지 못한 응답을 건너뛰지 않고 이름을 밝혀 거부하게 고칩니다.

What and why

The serve gates, the DeepSeek V4.1 soak and the decide seat gate read a served reply with defaults that hide a malformed one: a missing stop_type became an empty string, an SSE frame without the exact data: prefix was skipped, a 200 body that was not JSON counted as no answer, and a set D grid entry that was not an unsigned integer was dropped. A gate could succeed on less than the server sent.

Fixes #1091. Fixes #1094. Each reader now refuses what it cannot read, by name, before the ids are compared or the answer is stored. serve_client::stop_of is the one reader of a completion's stop_type and accepts only the stops the server emits. serve_client::sse_events and sse_event are the one reader of an SSE body, used by the soak and by the Qwen3, Qwen3.8 and DeepSeek V4.1 serve gates. The soak also reads the paired chat answer and every fresh completion through the same readers. gate_clef_serve reads set D's image_grid_thw and image_spans as exactly the unsigned integers they hold. No server, model or kernel code changed, and no speed is claimed.

Release notes: Fixed: the serve gates and the DeepSeek V4.1 soak refuse a reply, SSE frame or set D entry they cannot read instead of skipping it.

Code shape

  • 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): the soak's own SSE event splitter, its copy of the chat answer read and LookupCompletion's own stop_type reader are gone; they use crates/gpu-gates/src/serve_client.rs:253 (sse_events), :270 (sse_event) and :324 (stop_of). The one remaining strip_prefix("data: ") is at crates/gpu-gates/src/serve_client.rs:258.

What I ran

Base d748b6e0d5d12a32bffbe4d25a096e280f4cd5be, PR head 5c35d35baabc6fa1b9e405ab9e83b70f43cf8036.

Before and after, the reader tests run against the upstream/main reader bodies and against this branch's readers (a scratch crate that holds both bodies, run on a Mac; the full bloomery-gpu-gates crate with deepseek41 needs a CUDA toolkit):

upstream/main reader bodies:
test tests::a_served_answer_the_soak_cannot_read_is_refused ... FAILED
test tests::set_d_numbers_refuse_what_they_cannot_read ... FAILED
test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

this branch's readers:
test clef_tests::set_d_numbers_refuse_what_they_cannot_read ... ok
test tests::sse_readers_refuse_what_they_cannot_read ... ok
test tests::a_served_answer_the_soak_cannot_read_is_refused ... ok
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.17s

For #1094, a completion whose ids equal the reference with stop_type removed, null, 1, true, {}, "", "EOS" or "stop", read by the old as_str().unwrap_or("") and agree against stop_of:

old: valid passes=true mutants passing agree=8/8
new: valid passes=true mutants passing agree=0/8

Unit tests of the changed readers, built and run with cargo oxide on a DGX Spark:

$ BLOOMERY_BOX_LOCAL=1 ./tools/box.sh "bash tools/gate.sh --oxide -p bloomery-gpu-gates --release --features deepseek41,gemma-embedding2,hf --lib -- serve_client::"
test serve_client::tests::stop_of_refuses_a_stop_it_cannot_read ... ok
test serve_client::tests::sse_readers_refuse_what_they_cannot_read ... ok
test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 314 filtered out; finished in 0.11s
$ BLOOMERY_BOX_LOCAL=1 ./tools/box.sh "bash tools/gate.sh --oxide -p bloomery-gpu-gates --release --features deepseek41 --bin soak_ds41_serve"
test soak::tests::a_served_answer_the_soak_cannot_read_is_refused ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.08s
$ BLOOMERY_BOX_LOCAL=1 ./tools/box.sh "bash tools/gate.sh --oxide -p bloomery-gpu-gates --release --features glm5next,clef,mimo2,solar2,minimaxm3,flint,vision,gemma-embedding2,hf,checkpoint --bin gate_clef_serve"
test gate::tests::set_d_numbers_refuse_what_they_cannot_read ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

gate_qwen38_serve (--features deepseek41,gemma-embedding2,hf), gate_ds41_serve (--features deepseek41,vision,gemma-embedding2,hf) and gate_qwen3_serve (the gate_clef_serve feature list) build with the same command shape and their test harness passes (test result: ok. 0 passed; 0 failed, no unit tests in those binaries).

Card and driver of that run:

$ nvidia-smi
Sun Nov  1 19:36:45 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   51C    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                                                             |
+-----------------------------------------------------------------------------------------+
$ nvidia-smi --query-gpu=name,driver_version --format=csv,noheader
NVIDIA GB10, 595.84

Clippy ratchet on the PR head, on an RTX 5090 machine:

$ bash tools/mac-check.sh lint
mac-check: lint ^warning: 0 = the ratchet 0 in tools/lint-ratchet.txt; 39 bloomery crates checked or compiled

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 tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo 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: No blocking defect remains in the changed readers.

Non-blocking

⚠ Pin the paired chat consumer: crates/gpu-gates/src/bin/soak_ds41_serve.rs:757.
The new test calls chat_answer directly at line 1538 and never calls Mix::pair. Deleting chat_answer(st, body)? here restores the reported bug without failing those assertions.
Add a mock HTTP 200 response with malformed chat content through Mix::pair to protect this call before further soak changes.

Checked

Duplicates: 23 new definitions checked, excluding the stream rename; no duplicate owner found. No dryer pairs were available.
Complexity: CompletionStream::read (16) renames the existing reader and adds HTTP/body framing. sse_errors (1→9), Mix::pair (13→20), Mix::chat (12→17), cut_of (13→16) and DS41 run (90→95) add reply validation. DS41 tiered/drafted, GLM draft_only/drafted/slots_flow_together/slots_skipping/plain/width_cost and MiniMax greedy_probs grow by one or two checks.
Silent failure: 7 added production sites followed. Optional delta content is validated before omission; an absent deferral remains reported; malformed paired HTTP status increments transport failures; ignored Drop cleanup results do not become response data.
Tests: static mutation review covers all four new tests and the changed lookup test. Skipping malformed frames or grid entries, accepting missing stop types, dropping the EOF completion check, or accepting a lookup reasoning-loop stop fails an assertion. The paired consumer gap is above.
Gates: no existing band, threshold, clause or case was relaxed or removed. FAIL-first evidence is supplied for the reader fixes.
Escape catalog: C1–C4 do not match. No inference hot path changed.

Notes

Dryer did not run; diagnostics reports no eligible changed Rust files despite the crate changes.
Tests were not executed during this review. The PR supplies host reader test output, but no just gate-* card run.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/gate_clef_serve.rs, crates/gpu-gates/src/bin/gate_ds41_serve.rs, crates/gpu-gates/src/bin/gate_glm5next_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 ea7eb3c 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 tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

serve gates: missing stop_type still passes completion agreement gate_clef_serve: reference provenance silently discards invalid grid dimensions

1 participant