Skip to content

serve: the engine's last call prints each slot's last mtp width record before the tier nodes close - #891

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-mtp-width-last-request
Oct 27, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-mtp-width-last-request

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

서버를 멈출 때 각 slot의 마지막 요청에 대한 mtp width 기록이 사라지던 문제를 고칩니다.

What and why

The MTP width chooser's mtp width record is printed at a slot's next prompt call, step, reset or turn-off. When the server stops, none of those happens for a slot's last request, and the engine is left to the process exit without running its Drop, so the record is never printed. Anyone who reads the width chooser's aggregate from a server log loses the last request of every slot.

Engine::close_nodes, the server's last call once the engine thread leaves its loop, is now Engine::close. It prints the records the engine still holds, then ends the load on the tier nodes as before. The record is printed first, so a failure while closing the nodes keeps it. The change reaches every owner of a deferred width record (the MTP and lookup drafts in SlotDrafts, the DSpark and lookup drafts in ServedDraft, and ServedSpark) and every seat that uses one (Qwen3.8, GLM, both Qwen3 seats, DS4.1 and Raon1). Seat::close_nodes and Cmd::CloseNodes in crates/gpu-gates/src/bind.rs are renamed to match.

The change runs after the server loop ends, on counts the chooser has already tallied, so decoding is untouched.

The width_cost clause of gate_qwen38_serve now stops the server with POST /shutdown and reads the record afterwards, instead of sending a one-id request that made the record print. The clause width_cost_flush_ok becomes width_cost_stop_ok. The record clause width_cost_record_is_the_choosers therefore depends on the stop path.

The MTP_WIDTH doc in crates/gpu-gates/src/record.rs and the two checked-in schema files (tools/bloomery/schema/bloomery-serve-qwen38.jsonl and bloomery-serve-ds41.jsonl) carry the same sentence about when the record prints.

Release notes: Fixed: The server prints each slot's last mtp width record when it stops.

Code shape

  • No second copy. print_widths stays the one owner of the record; each new close calls it.
  • Model code holds only architecture facts. The seat files only forward close; no common owner gained a per-model branch or a new trait method (an existing one is renamed).
  • Dead code is gone. The old close_nodes names are gone, and width_cost_flush_ok is replaced.
  • No silent failure. An error while closing the nodes still reaches the server's stderr.
  • Comments state what is true now.
  • No relaxed gate. width_cost_flush_ok is replaced by width_cost_stop_ok; the replacement carries a PIN(2026-10-28): with its reason.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up. I ran cargo clippy -p bloomery-gpu-gates -p bloomery-serve --all-targets -- -D warnings on an earlier revision of this change and it was clean. I did not rerun it on the pushed head.

Duplication found or removed (path:line), or "none": none removed. The three Seat::close impls (crates/gpu-gates/src/bin/shared/serve_seats/ds41.rs:1409, glm.rs:1713 and qwen38.rs:2883) each act on their own draft field and session.

What I ran

The head is e70c5af3bb76ffa173ab99e5f8850b87638ed2e2 on main 2f27e83c17b04ba8f0fdf99d8baba396fb9cf0b6. The runs below measured earlier revisions of the same change, and I did not repeat them on the pushed head. The later revisions only rebased onto newer mains, added the gate binary's Served38::wait_exit helper and changed a comment. The end-to-end run measured 3c91724f2069275a6fd278bdb7d9d2f9d4337b4e against 08047d8b5422432dccb31f9b77f8e00d3892981c. The RTX 5090 gate run is on d615b6e0c473c19e0c76bfd4f8b58054a1eb76cb, which sat on main e009acd4f93e930ae906572acbdcc0c92345d666.

FAIL-first on a DGX Spark, base against head: one server per arm, FP4-Local checkpoint, BLOOMERY_DRAFT=mtp and BLOOMERY_MTP_WIDTH=cost, 16384 context per slot, one n_predict 96 greedy request per slot, then POST /shutdown. The base prints no mtp width record. The head prints one per slot, all after the stop request:

VERIFY base p1 slots=1 requests=1 drafted=[74] records_before_stop=0 records_after_stop=0 exit=0
VERIFY base p2 slots=2 requests=2 drafted=[72, 64] records_before_stop=0 records_after_stop=0 exit=0
VERIFY head p1 slots=1 requests=1 drafted=[74] records_before_stop=0 records_after_stop=1 exit=0
VERIFY head p2 slots=2 requests=2 drafted=[81, 61] records_before_stop=0 records_after_stop=2 exit=0
VERIFY-RESULT PASS []

The one-slot arm drafts 74 ids on both sides. The two-slot draft counts differ because the chooser picks widths from measured wall time in concurrent rounds.

On a Linux CPU machine:

cargo test -p bloomery-serve --lib stop_wait
test result: ok. 11 passed; 0 failed; 0 ignored; 0 measured; 365 filtered out
cargo test -p bloomery-gpu-gates --lib checked_in_schemas_are_current
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 186 filtered out

On an RTX 5090 machine, with the draft rules and the Q38 serve rules gates, which include the new test the_stop_prints_every_slots_last_request:

nvidia-smi; BLOOMERY_BOX_LOCAL=1 just gate-serve-draft-rules && BLOOMERY_BOX_LOCAL=1 just gate-q38-serve-rules
just gate-serve-draft-rules: PASS (rc 0)
just gate-q38-serve-rules: PASS (rc 0)

I did not run just gate-gpu-qwen38-serve, so the changed width_cost clause has not run in full. The DS4.1, GLM and Raon1 seats were not stopped on hardware. They share the ServedDraft::close and SlotDrafts::close owners that the run above exercised, and they compile in a workspace check with every feature (cargo check --workspace --all-targets) on the RTX 5090 machine, which printed no error. I did not run just contrib-check or the repository's tools/check-*.sh scripts.

Hardware

| NVIDIA-SMI 595.99.02              Driver Version: 595.99.02      CUDA Version: 13.2     |
|   0  NVIDIA GeForce RTX 5090        Off |   00000000:01:00.0 Off |                  N/A |

The end-to-end run used one DGX Spark with the nvidia-smi query line below (name, driver, compute capability):

NVIDIA GB10, 595.84, 12.1

The checkpoint is nvidia/Qwen3.8-Flash-Next-FP4-Local at revision b9ce18a6887e18c089fdea8509a33e63429a3300. The device path does not change, so there is no PTX or timing comparison.

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 serve The HTTP server: crates/serve labels Oct 27, 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 stop path prints each slot's last mtp width record on every seat that holds a deferred record, and I found no failure path I could not refute.

Non-blocking

⚠ Only Lookups::close has a unit test: drafted.rs:1352. Mutant: delete l.close() in SlotDrafts::close (drafted.rs:917), or the dspark/lookup arms of ServedDraft::close (served.rs:539). No test in this diff turns red; only the card gates would. This is acceptable for now. Name the card gate that covers each in the PR body.

Checked

  • Duplicates: 8 new items checked (close on Lookups, SlotDrafts, ServedDraft, ServedSpark, Driven, Seat impls, Served38::wait_exit). print_widths stays the one owner. wait_exit removes two copies of the poll loop. No dryer pair (crates/serve: 0 pairs; crates/gpu-gates was not searched by dryer).
  • Complexity: width_cost 21 → 23. This is the added exit check in a gate clause, even growth.
  • Silent failure: 4 sites followed. print_widths is idempotent: take_tally empties the tally and an empty tally prints nothing, so a slot closed at its next call does not print again at the stop. An error from Seat::close still reaches stderr in worker.rs. The record prints before the node close, so a node failure keeps it.
  • Coverage of seats: every seat that holds SlotDrafts, ServedDraft or ServedSpark (Q38, GLM, DS41, Q3, Q35Mtp, Raon1) now overrides close. Hybrid holds no draft. No close_nodes name is left on the Engine or Seat traits.
  • Tests: the new unit test protects Lookups::close. Mutant "drop the for_each" leaves unprinted(true) at [1, 1] and turns the assert red. width_cost_record_is_the_choosers turns red when the stop prints nothing, since the record is absent.
  • Gates: one clause replaced (width_cost_flush_ok → width_cost_stop_ok) and stricter (needs 200 and a clean exit); it has a PIN. A server that does not exit within POLLS is killed by Served38::drop.
  • Hot path: none touched (runs after the engine loop ends, host side only).
  • Escape catalog: no pattern matched.

Notes

  • The PR body says just gate-gpu-qwen38-serve was not run, so the changed width_cost clause has not run in full. The clause is checked by reading only. The DS41, GLM and Raon1 seats were not stopped on hardware.
  • The evidence runs are on earlier revisions, not on head d799fb8, as the body states.

Card check: gpu-evidence. This pull request changes crates/gpu-gates/src/bin/gate_qwen38_serve.rs, crates/gpu-gates/src/bin/shared/serve_seats/drafted.rs, crates/gpu-gates/src/bin/shared/serve_seats/ds41.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)

@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 Oct 27, 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 dc70612 into midagedev:main Oct 27, 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 serve The HTTP server: crates/serve

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant