Skip to content

bloomery-serve: the seat's flags and levers are checked before the driver is asked and the model fetched - #912

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-preflight
Oct 28, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-preflight

Conversation

@juliankang4

@juliankang4 juliankang4 commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

bloomery-serve가 모르는 flag, 잘못된 값, 모델 출처 누락, --help와 --levers를 --hf 다운로드와 GPU 확인보다 먼저 처리하도록 고칩니다.

Supersedes #908.

Part of #565.

What and why

bloomery-serve read a seat's flags and levers only after it had asked the driver and fetched the model with --hf. A typo such as --ctx-size abc, an unknown flag, a bad lever value, or --model qwen38 --help therefore ended after a large download, and without a model file the seat's help never appeared.

Now the launcher checks the arguments as far as that needs no model, card or network. bloomery-serve --model qwen38 --hf o/r --ctx-size abc ends with the argument error before the driver check and the download. With --model or --head, the selected seat's --help, --levers table and refusals of flags, values and levers come first. Without either flag the model file picks the seat, so every seat checks the arguments and the start ends only when all of them refuse; the message lists each refusal once with the seats that give it. The picked seat reads the arguments again after the download, as before.

Each seat's check is one entry into bind::check_seat, which runs the same levers read and parse_args that the seat's run uses and hands the typed result to run, so the early check and the real start share one owner. What needs the model (architecture, a context bound by the file, a draft the file supports) is still checked after the fetch. A generative start with llama-server placement flags resolves its overrides after device discovery, so its levers, --levers included, are read there.

Also in this change:

  • A seat's own refusals that need no model now come first: --ctx-size with --parallel for at least one position per slot, -ub for its range in the Qwen3.8 and decide seats, draft, feed, steps and residency combinations (GLM and the tiered seats share tiered::check_residency_feed), a missing model source, an explicit tier larger than the card, and --parallel above one on the seats whose body holds one sequence (Nemotron, Raon1, Muse Spark).
  • --mmproj with --no-mmproj, image token limits on a build without vision or with no projector to bound, and zero or inverted limits are refused in one place, vision_seat::Flags. Limits with a repository that can supply the projector are accepted.
  • --head and --head-config are checked against the seat word in decide::check_head, which pick also calls.
  • An --alias value that spells a switch (--levers, --list-devices, --version, --cpu_moe) is read as a value. Every launcher scan reads values through llama_launch::serve_option. The qwen3 and decide seats do not take --alias, and docs/serving.md says so.
  • --api-key-file and --chat-template-file are read once per path at start, through serve::flag::file_snapshot, so a pipe such as /dev/stdin serves after the early check has parsed the flags. docs/serving.md says so.

Release notes: Fixed: bloomery-serve refuses a bad flag, value or lever, and answers --help and --levers, before it asks the driver or downloads the model.

Code shape

  • No second copy. Every seat's early check calls the shared bind::check_seat with its own parse_args; there is no second parser. The placement view the launcher builds is llama_launch::seat_view, which Launcher::placed uses too. Source words go through hf::source, head checks through decide::check_head, image limits through vision_seat::Flags. The refusal of a draft width without a draft has one owner, bind::refuse_plain_width, which every seat calls, and so has the refusal of --parallel above one on a body that holds one sequence, SeatFlags::one_sequence.
  • Model code holds only architecture facts. The seats gained a check that calls their existing parser, and their model-specific refusals stay in their own files. No common owner gained a per-model branch.
  • Dead code is gone. The head-conflict refusal that pick carried moved into decide::check_head, the image-flag refusals into vision_seat::Flags, and the GLM and tiered steps and residency refusals into tiered::check_residency_feed. Nothing this change made unused is left.
  • No silent failure. A refused argument is a named error. A key or template file that cannot be read keeps its error for later parses of the same path.
  • Comments state what is true now. They describe current behavior only.
  • No relaxed gate. No band, tolerance, lint level or pin moved.
  • cargo fmt and cargo clippy are clean on what I touched: cargo clippy --workspace --all-targets with the GPU, vision and model features reports no warning in a file this change touches.

Duplication found or removed (path:line), or "none": the head-flag refusal in pick and the image-flag refusals in the seat parsers now live in crates/serve/src/decide.rs (check_head) and crates/gpu-gates/src/vision_seat.rs (Flags). GLM's and the tiered seats' steps and residency refusals are one function, crates/gpu-gates/src/bin/shared/serve_seats/tiered.rs (check_residency_feed). The sixteen candidates the duplicate scan reported are the seats' check entries, which call bind::check_seat with their own parser, or refusals that differ by model.

What I ran

Everything below ran on a DGX Spark (see Hardware). The change touches no device code and no decode or prefill path, and no speed claim is made.

just gate-serve-draft-rules
test result: ok. 44 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out
test result: ok. 46 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out
Verdict: PASS

The recipe runs the bloomery-serve and bloomery-serve-ds41 unit tests and the new tests/serve_preflight.rs on builds without and with the vision feature (the two result lines above). The test file starts the binary with an empty model cache and checks that each refusal comes with the argument error and no driver or download output. I added both serve_preflight runs to that recipe, and added the two hardware cases hw_preflight_normal_inputs_reach_the_fetch and hw_a_device_list_alias_reaches_the_selected_seat (both #[ignore], they need a CUDA 13 driver) to the GLM serve-start recipe. Both pass on the DGX Spark:

cargo test -p bloomery-gpu-gates --release --features glm5next,clef,vision,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf,checkpoint --test serve_preflight -- --ignored --exact hw_a_device_list_alias_reaches_the_selected_seat
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 47 filtered out
cargo test ... -- --ignored --exact hw_preflight_normal_inputs_reach_the_fetch
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 47 filtered out

FAIL-first: with the early(...) call in bloomery_serve.rs disabled, so the start reaches the driver check and the fetch before the arguments are read as before this change, the same test file fails:

test result: FAILED. 2 passed; 42 failed; 2 ignored; 0 measured; 0 filtered out

The refusals are named errors on stderr that say which flag, value or lever was refused, so no separate probe or state record is added. To reproduce the ordering, start a seat with an empty model cache:

bloomery-serve --model qwen38 --hf o/r --ctx-size abc

just contrib-check --tier t0:

DONE tier=t0 total=37 red=0

Not run:

  • A real image encoder, a model load, an actual model download and a timed measurement. The tests check that a start reaches or does not reach the driver and the fetch; they do not show a model loading or generating.

Hardware

DGX Spark, nvidia-smi query: NVIDIA GB10, 595.84, CUDA 13.3 (nvcc release 13.3).

AI help

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

…iver is asked and the model fetched

A start with --model reads the seat's own levers and parser on the
arguments as the seat will see them, so --help, a flag the seat does not
take, a value it refuses and a refused lever end the start before --hf
downloads anything; the qwen38 and decide seats hold the ubatch size to
the engine's there too. A --head selects the decision seat before these
checks. Without --model or --head, every seat checks them and one taking
them is enough, since the model file picks the seat; the refusal of an
argument every seat refuses names each seat's text once. The decision
candidate applies the same embedding restriction as a named decision
seat. Head/seat conflicts are checked by the same owner as the final
head selection. Output-only handlers distinguish option words from
values, including the device list and each seat's record schema. The ds41
seat chooses its placement in run, so its parser reads no card; its
--ctx is held to the fewest slots the start serves, and the qwen3 seat's
--cache-type-k word to its formats. The decide seat, named or picked by
the file, reads the arguments as its own start does, without
llama-server's placement variables, so a split mode the generative seats
refuse does not end a decision start. Checks that need the model stay
after the fetch, the glm seat's image token limit with no --mmproj among
them, since the --hf repo may hold a projector to bound. A key file is
read once per process, so the check and the seat take the same keys,
a pipe's included.
@github-actions github-actions Bot added documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card serve The HTTP server: crates/serve tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 28, 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: I built no failure path that the diff leaves open, and I found no proven duplicate or unneeded element. Three ⚠ items remain.

Non-blocking

⚠ Check, then unreachable! (R37): glm.rs:427 and qwen38.rs:988. draft_of and draft38 call check_draft_word and then match the same word with an unreachable! arm. check calls check_draft_word too, so the word is checked twice per start. Direction: let check_draft_word return the validated word as an enum, and have draft_of and draft38 match on it. The panic arm and the second call then go away.

⚠ Two trait items for one model: tiered.rs:211 and tiered.rs:232. Tiered::UNHOSTED_POOL and Tiered::prefill_steps are overridden only by Mimo (mimo2.rs:485, mimo2.rs:525). The PR text does not name the architecture fact that forces them. Name it in the doc comment (the body's pool support), or keep the check in Mimo's own check.

⚠ CheckedSeat::run can panic: bind.rs:540. expect("the run reads its levers") holds only if the caller passed read_levers = true. Every call today does. The type does not say it. Also minor: residency_pick parses the residency word a second time through check_residency_feed (tiered.rs:393).

Checked

  • Duplicates: about 30 new items checked (check entries, check_draft_word, check_slot_ctx, refuse_plain_width, check_residency_feed, serve_option and the take_* helpers). No proven duplicate. The refuse_plain_width and check_residency_feed owners remove more copies than they add. dryer searched only crates/levers and crates/serve and found 0 pairs; crates/gpu-gates I checked by Grep.
  • Complexity: early (27), qwen38::check (24) and ds41::check (18) are new functions. Each is a flat chain of refusals, one concern per function. The rises in qwen3::parse_args, SeatFlags::parse, glm::parse_args, qwen38::parse_args and Flags::take are one line each, harmless.
  • Silent failure: 12 sites followed (early's reference, seat_view errors, file_snapshot caching a failed read, refuse_unbounded_cache, take_with_env value skipping, one_sequence, parse_one_sequence). None turns a bad input into a default. A cached read failure keeps its error on purpose, and docs/serving.md says so.
  • Failure scenarios built and refuted: a value-less switch before --help (every seat parser takes a value for each flag except --help, --plan and --no-mmproj, which serve_takes_value lists); LLAMA_ARG_MODEL as the only model source (model_from_env runs before early); --levers with placement flags (deferred to the seat, documented); a --ctx split when the draft word raises the slot count (the same slots_given and slots_of owners decide, and run still refuses later).
  • Tests: the FAIL-first run in the PR body shows 42 red with early disabled. Mutants I planted in words: dropping check_head's --head-config branch turns a_start_checks_its_arguments_before_the_fetch red. A flipped from_repo in may_pick turns a_repository_can_supply_limits_only_in_a_vision_build red. Removing the --alias value skip in serve_args turns serve_options_skip_values_and_keep_switches red.
  • Gates: no pin moved and no gate removed. Hot path: none (start-up only), so no performance finding.
  • Escape catalog: no match (no shell script changed).

Notes

  • The PR body has the nvidia-smi query line and the gate output, but not both commit hashes. I set gpu.json evidence to false for that reason.

Card check: needs-gpu. This pull request changes crates/gpu-gates/Cargo.toml, crates/gpu-gates/src/bin/bloomery_serve.rs, crates/gpu-gates/src/bin/bloomery_serve_ds41.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 b1b138e into midagedev:main Oct 28, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation gpu The card engine: crates/gpu*, crates/app host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset needs-gpu Changes code a card must check, and carries no gate run on a card serve The HTTP server: crates/serve tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant