Skip to content

bloomery-serve, model-hf: a --hf repo's architecture picks the seats that check the arguments before the fetch - #958

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

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

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

--model 없이 --hf로 시작할 때, 일부 seat만 거절하는 인자를 모델을 받기 전에 그 repo의 seat 기준으로 거절하게 고쳤습니다.

Part of #565.

What and why

Without --model or --head, the model file picks the seat, so the argument check before the download could only refuse what every seat refuses. An argument that only some seats refuse passed that check and failed after the whole download. For example --prefill steps is taken only by the glm and mimo2 seats, and --parallel 2 is refused by Nemotron.

Now, when the seats disagree about the arguments, the start reads the --hf repo's file list and the architecture of the model it holds, and ends with the refusal of the seats that may serve that model, still before the download. The read is the first GGUF shard's header by HTTP Range (a sparse file created exclusively, so an existing file or symlink at that path is refused and never written through, and removed afterwards), or a checkpoint's config.json. No weights are fetched. A start every seat accepts reads nothing extra. Under HF_HUB_OFFLINE, or when the repo cannot be read, the check passes as before and the seat checks again after the fetch.

  • model-hf: FolderMap::architecture (the nemotron_h map included) gives the general.architecture each map writes in its header, and folder::architecture reads it from a config.json through the same model_type lookup open uses.
  • gpu-gates: model_file::repo_architecture (built with the hf feature, so the default bloomery-serve build runs the read) picks the file a fetch would open first with the existing rules and reads its architecture and <arch>.decision.type. bloomery_serve.rs gains Model::serves_arch, seats_of and a held argument on early. The list of seats it names always contains the seat a real start would use, so it never refuses an argument the real seat accepts.
  • docs/serving.md describes the new behavior.

Release notes: Fixed: bloomery-serve --hf <repo> without --model now refuses an argument the repo's model cannot take (for example --prefill steps on Qwen3.8, or --parallel 2 on Nemotron) before the download starts.

Code shape

  • No second copy. The seat rule that serves held by architecture string moved into Model::serves_arch, and serves calls it. The repo read reuses gguf_sets, pick, checkpoint_files, sparse_shard and gguf::inventory_of. Each map's architecture string has one owner, the header it already writes.
  • Model code holds only architecture facts. The map files gained one method each that returns their architecture name. The common owner gained no per-model branch.
  • Dead code is gone.
  • No silent failure. Every read failure (offline, listing, Range, header parse, unknown model_type) is a named error. The check passes on it by design, and the fetch then reports the same failure by name.
  • Comments state what is true now.
  • No relaxed gate. No test, band or lint moved.
  • cargo fmt is clean on what I touched.

Duplication found or removed (path:line): none.

What I ran

Head 9d43ddfdc2483f3910ff2e8747b165a3f866c32d on top of 822b3f181d644bf109a6c021ecbcabdfac9c14e4. Hardware is below.

On a DGX Spark, the new test first fails with the repo read switched off (rc 101), then passes with it on:

bash tools/gate.sh --oxide -p bloomery-gpu-gates --release --features glm5next,clef,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf,checkpoint --bin bloomery-serve -- a_repo_s_model_picks_the_seats_that_check_before_the_fetch --nocapture
bash tools/gate.sh --oxide -p bloomery-gpu-gates --release --features glm5next,clef,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf,checkpoint --bin bloomery-serve -- drive::tests
bash tools/gate.sh -p bloomery-model-hf --release --lib -- a_small_qwen3_folder_opens_as_a_qwen3moe_file a_target_opens_whatever_its_mtp_layer_holds folder::
  • With the read switched off: a_repo_s_model_picks_the_seats_that_check_before_the_fetch panics with --hf o/r --prefill steps: (), test result: FAILED. 0 passed; 1 failed, rc 101.
  • drive::tests: test result: ok. 7 passed; 0 failed.
  • model-hf: test result: ok. 12 passed; 0 failed. a_small_qwen3_folder_opens_as_a_qwen3moe_file and a_target_opens_whatever_its_mtp_layer_holds now also assert that folder::architecture equals the architecture open writes in its header.

The built bloomery-serve binary, an empty BLOOMERY_CACHE, network on, timeout 45:

bloomery-serve --hf unsloth/Qwen3.8-Flash-Next-GGUF:UD-Q4_K_XL --prefill steps
bloomery-serve --hf nvidia/Qwen3.8-Flash-Next-FP4-Local --prefill steps
bloomery-serve --hf nvidia/NVIDIA-Nemotron-3-Nano-4B-GGUF:Q4_K_M --parallel 2
HF_HUB_OFFLINE=1 bloomery-serve --hf unsloth/Qwen3.8-Flash-Next-GGUF:UD-Q4_K_XL --prefill steps
  • Qwen3.8 GGUF, --prefill steps: rc 1, 0 hf records, 0 cache bytes. First line: bloomery-serve: --hf unsloth/Qwen3.8-Flash-Next-GGUF:UD-Q4_K_XL holds a qwen4exp model, and no seat that may serve it takes these arguments, each refusing them as follows (--model names the seat):
  • Qwen3.8 FP4-Local checkpoint, --prefill steps: rc 1, 0 hf records, 0 cache bytes. First line: bloomery-serve: --hf nvidia/Qwen3.8-Flash-Next-FP4-Local holds a qwen4exp model, and no seat that may serve it takes these arguments, each refusing them as follows (--model names the seat):
  • Nemotron GGUF, --parallel 2: rc 1, 0 hf records, 0 cache bytes. First line: bloomery-serve: --hf nvidia/NVIDIA-Nemotron-3-Nano-4B-GGUF:Q4_K_M holds a nemotron_h model, and no seat that may serve it takes these arguments, each refusing them as follows (--model names the seat):
  • Qwen3.8 GGUF, --prefill steps, HF_HUB_OFFLINE=1: rc 1, 0 hf records, 0 cache bytes. It passes the early check and stops at the fetch with no listing (HF_HUB_OFFLINE is set).

The Qwen3.8 refusal names --model qwen38: unknown argument "--prefill". No temporary header file was left in the temp directory after the runs.

On an RTX 5090 machine and a CPU host, for the exclusive header file and the hf-only build:

cargo test -p bloomery-gpu-gates --features hf --lib model_file::fetch::tests
cargo test -p bloomery-model-hf --lib
cargo oxide build -- -p bloomery-gpu-gates --features glm5next,clef,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf --release --bin bloomery-serve
env -u BLOOMERY_REF_MODEL BLOOMERY_CACHE=<empty> bloomery-serve --hf unsloth/Qwen3.8-Flash-Next-GGUF:UD-Q4_K_XL --prefill steps
HF_HUB_OFFLINE=1 bloomery-serve --hf unsloth/Qwen3.8-Flash-Next-GGUF:UD-Q4_K_XL --prefill steps
just gate-gpu-qwen3-serve
  • model_file::fetch::tests: test result: ok. 4 passed; 0 failed. The new a_shard_header_is_never_written_through_an_existing_path refuses a pre-made symlink, leaves the target's bytes unchanged, then reads general.architecture (qwen4exp) with one Range read and leaves no file. With File::create_new replaced by a truncating OpenOptions::open, it panics: test result: FAILED. 0 passed; 1 failed, rc 101.
  • model-hf: test result: ok. 113 passed; 0 failed; 3 ignored.
  • The build without checkpoint succeeds (rc 0). The Qwen3.8 GGUF case refuses with the same first line as above, rc 1, cache_bytes=0, no header file left in /tmp. With HF_HUB_OFFLINE=1 it stops at the fetch with no listing (HF_HUB_OFFLINE is set), rc 1, cache_bytes=0.
  • just gate-gpu-qwen3-serve (--model qwen3-q4_k_m, BLOOMERY_BOX_LOCAL=1): 132 PASS, 1 FAIL (completion_ids_are_the_cli_ids: cli split (host, card, ctx) Some((4608, 1536, 262144)) against the server's Some((4606, 1538, 262144))), then ref_manifest: cannot read /root/bloomery-data/ref_qwen35moe_vis_chatids_e1/MANIFEST.tsv: Permission denied, rc 1. Upstream main gives the same 132 PASS, 1 FAIL and the same Permission denied on that machine, so both come from outside this change.

The two Nemotron seat gates on the RTX 5090 machine, at the head above:

BLOOMERY_REF_MODEL=<NVIDIA-Nemotron3-Nano-4B-Q4_K_M.gguf> just gate-gpu-nemotron-serve
just gate-gpu-nemotron-h-moe-serve
  • gate-gpu-nemotron-serve on nvidia/NVIDIA-Nemotron-3-Nano-4B-GGUF Q4_K_M (revision ba223d14, sha256 checked): check parallel_above_one_is_refused: PASS with bloomery-serve: --parallel 2: the nemotron body holds one sequence and no resident slots; the seat serves --parallel 1, the other seven checks pass, then PASSED: gate_nemotron_serve, rc 0.
  • gate-gpu-nemotron-h-moe-serve on the nemotron-bolt fixture: check parallel_above_one_is_refused: PASS, the other seven checks pass, then PASSED: gate_nemotron_serve, rc 0.

This PR makes no speed claim.

Hardware (if the change is for a machine)

DGX Spark, nvidia-smi --query-gpu=name,driver_version --format=csv,noheader prints NVIDIA GB10, 595.84. It ran the three test commands and the four binary cases. An RTX 5090 machine ran the hf-only build, the two binary cases, just gate-gpu-qwen3-serve and the two Nemotron seat gates; a CPU host ran the two cargo test commands.

AI help

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

…that check the arguments before the fetch

With no --model or --head, arguments only some seats refuse no longer pass
the early check on the strength of a seat the file will never pick. The
start reads the repo's listing and the architecture of the file the fetch
would open (a GGUF set's first shard's header by HTTP Range, a
checkpoint's config.json through its folder map) and ends with the
refusal of the seats that may serve it: --prefill steps on a Qwen3.8 repo
is the qwen38 seat's refusal, and --parallel 2 on a Nemotron repo the
nemotron seat's, both before the download. Arguments every seat takes
read nothing, and a repo that cannot be read that way (HF_HUB_OFFLINE, no
network) leaves them to the picked seat after the fetch, as before. A
folder map names its header's architecture from the config alone
(FolderMap::architecture), which its header now uses too.
@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 tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo labels Oct 29, 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 three failure scenarios against the seat narrowing and the repo header read, and the code blocks each of them.

Non-blocking

⚠ The "no GGUF set, then checkpoint" rule now has a third copy: crates/gpu-gates/src/model_file/fetch.rs:282 repeats gguf_sets + checkpoint_files + pick from Client::resolve_drafts (crates/hf/src/fetch.rs:659) and offline_set (line 724). The PR body says it uses "the existing rules", but it copies them. If the rule in hf changes, the early check reads another file than the fetch and may refuse arguments the real seat takes. Direction: put the choice (set's first file, or checkpoint's config.json) in one hf function that all three call, only if it removes more lines than it adds.

Checked

  • Duplicates: 14 new items checked. One duplicate of an existing rule (the ⚠ above). dryer reported 0 pairs in crates/model-hf; gpu-gates was not searched, so I grepped it by hand.
  • Complexity: crapper flagged drive::early (27 → 29). The growth is one closure and one argument. any_seat was split into each_refusal, which lowers its own nesting.
  • Silent failure: 6 sites followed. held(r).ok() drops every read error, so the start goes on and the fetch reports the same error by name. This is documented and the new test pins it (early(None, ..) with a failing reader). shard_header surfaces the remove error and the create error.
  • Failure scenarios built and refuted: (1) seats_of returns an empty list, so any_seat prints a refusal with no lines. The qwen3 seat answers None for every architecture, so named(None) is never empty. (2) The qwen3 seat serves a file whose architecture another seat names, so the narrowed list misses the real seat. Family::of takes only the qwen3moe, qwen35moe, qwen35 and llama programs, and no other seat names those. (3) A fixed /tmp name is pre-made as a link. File::create_new refuses it and the check passes; the new test pins this.
  • Tests: a_repo_s_model_picks_the_seats_that_check_before_the_fetch. Mutant refused.len() < seats.len() → <= turns the qwen4exp and nemotron cases green on an Err they expect, so they go red. Dropping the Decide push for backbones turns the qwen35 case red. a_shard_header_is_never_written_through_an_existing_path: truncating open instead of create_new turns it red (the body shows it).
  • Gates: no pin moved. The Model::serves mirror in tools/hf-arch-check.py follows the rename, including the self-test's doctored arm.
  • Escape catalog: none matched (no shell changes).

Notes

  • The PR body names head 9d43ddfd…, but the PR head is 8139eb6f…. Say which commit the card runs used.
  • The speed claim is absent. No performance finding: the new work runs once at start, not in a decode step.

Card check: gpu-evidence. This pull request changes crates/gpu-gates/Cargo.toml, crates/gpu-gates/src/bin/bloomery_serve.rs, crates/gpu-gates/src/model_file.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 29, 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 133b1d3 into midagedev:main Oct 29, 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 gpu-evidence Verified on the author's card: the pull request carries the gate run and its output 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