Skip to content

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

Closed
juliankang4 wants to merge 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-preflight
Closed

juliankang4 wants to merge 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-preflight

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

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

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 2 on Nemotron.
  • --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.
  • 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 -p bloomery-gpu-gates -p bloomery-serve --all-targets -- -D warnings exit 0.

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

The gate 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. 43 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, which 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 --test serve_preflight 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. To reproduce the ordering, start a seat with an empty model cache:

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

Not run on this head:

  • just contrib-check --tier t0 and tools/check-recipes.sh.
  • cargo check --workspace and python3 tools/model_tax.py check.
  • The two #[ignore] hardware cases, the test file built with the vision feature, and a build on a DGX Spark.
  • 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 GB10, driver 595.84.

AI help

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

@github-actions github-actions Bot added documentation Improvements or additions to documentation 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 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: MUST_FIX: one rule ("may the --hf repo's projector be picked") is now written twice in vision_seat::Flags, with two different sources for the repo fact.

Must fix

1. One owner for "the repo may supply the projector"

crates/gpu-gates/src/vision_seat.rs:157 check_source spells !cfg!(vision) || !from_repo || self.no_mmproj (with no --mmproj). may_pick, line 169 spells the same rule as vision && mmproj none && !no_mmproj && hf_repo(). They are equal today. When one changes (a new way to disable the projector, a non---hf source), the early check and encoder disagree: the start passes the check and then picks no projector, or the reverse.
Cost: the duplicate is new in this diff. Folding it now removes lines.
Fix: pass the repo fact in, and use the one rule in both places.

    fn check_source(&self, from_repo: bool) -> Result<(), GateError> {
        match self.mmproj()? {
            None if self.sets_limits() && !self.may_pick(from_repo) => Err(
                "--image-min-tokens/--image-max-tokens without --mmproj: no image input to bound"
                    .into(),
            ),
            _ => Ok(()),
        }
    }

    fn may_pick(&self, from_repo: bool) -> bool {
        cfg!(feature = "vision") && self.mmproj.is_none() && !self.no_mmproj && from_repo
    }

In encoder (line 188) call self.may_pick(crate::model_file::hf_repo().is_some()).

Non-blocking

⚠ A lever the seat does not read is reported twice: crates/gpu-gates/src/bind.rs:505. check_seat calls at_main_with_flags, which prints each "X is not applied" line (levers/src/lib.rs:3093). The start now calls it in early and again in run. With no --model, it is called once per seat tried. A set Direct lever (read elsewhere) therefore prints two or more times. Direction: have the early call suppress the notes, or read the levers once and hand them to run.

Checked

  • Duplicates: about 30 new items checked. One hit (finding 1). check_seat, refuse_plain_width, check_residency_feed and check_head each remove copies. dryer searched crates/serve only and found no pair. The ResidencyAt block appears in both ds41::check and ds41::run; the two short copies cost less than an owner, so not raised.
  • Complexity: early (new, 27) and qwen38::check (new, 24), ds41::check (new, 18): new functions, complex on their own; early has four jobs (source, head, decide seat, generative view). A split would add functions, so none is asked. qwen3::parse_args, glm::parse_args, qwen38::parse_args, SeatFlags::parse, Flags::take: one added call each, even growth.
  • Silent failure: 9 sites followed (levers.expect, two unreachable!, .transpose, then_some, file_snapshot cached Err, reference UTF-8, view Err, any_seat). Each ends in a named error or an unreachable behind the check that precedes it.
  • Tests: mutants tried in words: early call removed from run (serve_preflight refusal tests go red); check_head comparison flipped (conflict assertion red); --levers dropped from serve_takes_value (serve_options_skip_values_and_keep_switches red); --ctx-size check moved after the fetch (clean_refusal finds first start, red).
  • Gates: no pin moved. No band, tolerance or lint level changed.
  • Escape catalog: no match. No shell script changed.
  • Performance: load-time and start-up code only. No decode or prefill path touched.

Notes

  • gpu.json evidence is false: the PR body has a gate result and the card name, but no nvidia-smi line and no commit hashes. The body lists just contrib-check --tier t0, tools/check-recipes.sh and cargo check --workspace as not run.

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)

…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.
@juliankang4
juliankang4 force-pushed the dgx-spark-q38-usab-preflight branch from 85b4684 to e0df07b Compare October 28, 2026 05:26

@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 one must-fix of the last review is fixed, and the new lines add no failure path.

Since the last review:

  • Must-fix 1 (one owner for "the repo may supply the projector"): fixed. may_pick(from_repo) is the only spelling of the rule. check_source (line 159) and encoder (line 185) both call it. The test at line 1394 covers both values of from_repo.
  • ⚠ A lever the seat does not read is reported twice: still open, crates/gpu-gates/src/bind.rs:512. check_seat and run both call at_main_with_flags, so a set Direct lever prints its "not applied" note more than once. Direction: suppress the notes in the early call, or read the levers once and hand them to run. This does not block the merge.

Checked

  • Duplicates: 2 new items checked in this interdiff (may_pick parameter, the changed test), none duplicated. dryer searched crates/serve only and found no pair.
  • Complexity: the new commits touch no function crapper flagged.
  • Silent failure: 1 site followed. from_repo comes from hf_repo().is_some() at both call sites, so a missing source stays a named error.
  • Tests: mutant "from_repo ignored in may_pick" turns a_repository_can_supply_limits_only_in_a_vision_build red on check_source(false).
  • Gates: no pin moved.
  • Escape catalog: no match. No shell script changed.

Notes

  • gpu.json evidence is false: the PR body has a gate result and the card name, but no nvidia-smi line and no commit hashes.

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

Superseded by #912.

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 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