Skip to content

hf: --hf takes a revision, <repo>@<rev>[:<quant>]; its listing, files and cache directory are that revision's - #963

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

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

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

--hf가 <repo>@<rev>[:<quant>] 형식으로 브랜치, 태그, 커밋 hash를 받고, 그 revision의 목록, 파일, cache 디렉터리를 함께 따르게 합니다.

Part of #565.

What and why

--hf <repo>[:<quant>] always read the repo's main branch. This adds --hf <repo>@<rev>[:<quant>], where rev is a branch, tag or commit hash. The file listing, every downloaded file and the cache directory all use that revision, so a pinned model does not move when main does. Without @<rev> nothing changes: the repo is read at main and the cache path stays <owner>/<name>/, so existing caches are not downloaded again. @main is the same as no revision.

  • Syntax (crates/hf/src/lib.rs): RepoRef::parse reads owner/name[@rev][:quant]. The revision follows the same character rule as the owner and the name. An empty revision, .., a second @, a / or a space is a named HfError::Repo. RepoRef::id() returns owner/name or owner/name@rev; the hub URLs and the cache both take that one name.
  • Fetch (crates/hf/src/fetch.rs): the listing reads tree/<rev> and each download reads resolve/<rev>. Client::hub_at(id) gives the repo and the revision for both: the revision id names, else the client's --revision pin. An explicit @<rev> wins over the pin. Cache paths, the offline check and the fetch events use id(), so offline start never serves another revision's verified files. A branch that moves during one start is refused by the existing digest check (HfError::Hash).
  • Architecture read (crates/gpu-gates/src/model_file/fetch.rs): the read of a repo's architecture before the download lists and reads the file header at the same revision, where it read main before. --hf with --revision is still refused; the message now points to --hf <repo>@<rev>.
  • Cache layout: a revision other than main is stored under <owner>/<name>@<rev>/. The same commit given once as a branch and once as a hash has two directories.
  • Companion fetches (crates/gpu-gates/src/model_file/fetch.rs, crates/gpu-gates/src/bin/bloomery_serve.rs, crates/gpu-gates/src/side_seat/flags.rs): the image projector, the sentence-transformers config, the decide seat's model card and the --embd-hf projector are fetched from the same revision as the model. A base_model: org/base@rev line in a model card reads the base's sentence-transformers config at that revision, not at main.
  • fixture fetch <repo>@<rev>:<quant> (crates/model-hf/src/bin/fixture.rs) uses the revision and refuses it together with --rev, also when the target says @main.
  • Docs: docs/serving.md, the bloomery-serve usage text, the BLOOMERY_CACHE description in crates/levers/src/registry.rs and the Ask::hf doc.

Release notes: Added: --hf <repo>@<rev>[:<quant>] fetches a model at a branch, tag or commit; without @<rev> it reads main as before.

Code shape

  • No second copy. The revision rule has one owner, RepoRef::parse with RepoRef::id, and the serve, fixture, projector and Metal paths all go through it.
  • Model code holds only architecture facts. The change is in the shared hf crate and its callers; no model file gained a branch.
  • Dead code is gone. Nothing was left unused.
  • No silent failure. A malformed revision is a named error, and fixture fetch names the conflict when the revision is given twice.
  • Comments state what is true now. The comments describe the code as it is.
  • No relaxed gate. No band, tolerance or lint level moved.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line): none. The duplicate scan reported no candidates.

What I ran

Head f2a15308f818a383a28a30974080eddd97a49a75, one commit on main 516e758a2267650a865a7d585e6fd123ad3277c7.

cargo fmt --all -- --check
rc 0
cargo test -p bloomery-hf -p bloomery-model-hf
test result: ok. 123 passed; 0 failed; 2 ignored
test result: ok. 113 passed; 0 failed; 3 ignored
test result: ok. 14 passed; 0 failed; 1 ignored
test result: ok. 10 passed; 0 failed; 1 ignored
test result: ok. 20 passed; 0 failed; 27 ignored
cargo clippy --target x86_64-unknown-linux-gnu --workspace --all-targets (the repo's lint feature set)
0 warnings

The new test fetch::tests::a_revision_names_the_listing_the_files_and_the_cache serves two listings from a local fixture. It checks that a/b@v1 downloads the v1 listing and files into cache/a/b@v1/, that no revision and @main share cache/a/b/ without mixing contents, and that resolve_exact finds the v1 directory. Offline, @v1 uses its verified files and @v2 is refused with HfError::Offline even when the main set is cached. The parse test gained accepted and refused revision spellings.

bloomery-serve, built and started on a DGX Spark (GB10) with an empty cache:

bloomery-serve --hf ggml-org/lev-GGUF@2ef3b3c3ab3defcab1058ab34cac52c467fa9304:Q4_K_M
bloomery-serve --hf ggml-org/lev-GGUF:Q4_K_M
  • With the revision: the download passes its sha256 check, the server listens, /v1/models answers ggml-org/lev-GGUF@2ef3b3c3ab3defcab1058ab34cac52c467fa9304, and the file is cached under ggml-org/lev-GGUF@2ef3b3c3ab3defcab1058ab34cac52c467fa9304/.
  • Without a revision: the server starts from ggml-org/lev-GGUF/, the existing cache path, and /v1/models answers ggml-org/lev-GGUF. The two directories do not share files.

The sentence-prompts gate and the fixture fetch refusals ran on a DGX Spark (GB10), see Hardware:

cargo test -p bloomery-model-hf --bin fixture fetch_refuses_a_revision_named_twice
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 15 filtered out
cargo test -p bloomery-gpu-gates --features hf --test sentence_prompts
sentence-prompts base-rev/online: passed
sentence-prompts base-rev/cached: passed
sentence-prompts base-rev/offline: passed
sentence-prompts base-rev/down: passed
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
fixture fetch a/b@main:Q4_K_M --rev v1
fixture: error: a/b@main:Q4_K_M: the revision is named twice, @main and --rev v1
fixture fetch a/b@v2:Q4_K_M --rev v1
fixture: error: a/b@v2:Q4_K_M: the revision is named twice, @v2 and --rev v1

The new base-rev case puts different prefixes at the base's main and v1 on a local hub fixture and requires the v1 prefix. The other 20 sentence-prompts cases (base, own, no-card, no-base-config, malformed) pass as well.

The architecture read against the real hub, on an RTX 5090 machine, bloomery-serve built with --features glm5next,clef,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf --release. A curl wrapper on PATH lets only listing and Range requests through and records each hub URL; no model file is downloaded:

bloomery-serve --hf unsloth/Qwen3.8-Flash-Next-GGUF@0000000000000000000000000000000000000000:UD-Q4_K_XL
bloomery-serve: curl listing https://huggingface.co/api/models/unsloth/Qwen3.8-Flash-Next-GGUF/tree/0000000000000000000000000000000000000000?recursive=true: exit 22: curl: (22) The requested URL returned error: 404 (no such repo or file)
hub URLs asked, with the revisions main, 766911a6b7369840a91dbcd95f9f997acaab6cd6 and 0000000000000000000000000000000000000000:
      2 https://huggingface.co/api/models/unsloth/Qwen3.8-Flash-Next-GGUF/tree/0000000000000000000000000000000000000000
      1 https://huggingface.co/api/models/unsloth/Qwen3.8-Flash-Next-GGUF/tree/main
      1 https://huggingface.co/api/models/unsloth/Qwen3.8-Flash-Next-GGUF/tree/766911a6b7369840a91dbcd95f9f997acaab6cd6
      3 https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/766911a6b7369840a91dbcd95f9f997acaab6cd6/UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf
      3 https://huggingface.co/unsloth/Qwen3.8-Flash-Next-GGUF/resolve/main/UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004.gguf

With @766911a6b7369840a91dbcd95f9f997acaab6cd6 the listing and the header reads go to that commit; without a revision they go to main.

Hardware (if the change is for a machine)

DGX Spark: NVIDIA GB10, 595.84
RTX 5090 machine: NVIDIA GeForce RTX 5090, 595.99.02

DGX Spark (GB10): bloomery-serve with the two --hf forms above, the sentence-prompts gate and the fixture fetch refusals. RTX 5090: the architecture read above.

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 host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja needs-gpu Changes code a card must check, and carries no gate run on a card serve The HTTP server: crates/serve labels Oct 29, 2026
@juliankang4
juliankang4 force-pushed the dgx-spark-q38-usab-hf-revision branch from f2a1530 to f314f99 Compare October 29, 2026 10:50

@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 was found in revision selection, cache isolation, or companion fetches.

Non-blocking

⚠ FAIL-first evidence: crates/hf/src/fetch.rs:1805. The body gives passing results without a failing run. Force Client::hub_at to select main, run the revision test, and paste the failure followed by the restored passing run. This confirms the regression is caught before users populate revision caches.

Checked

Duplicates: 5 new functions checked; no duplicate owner or unused addition found. dryer reported 0 candidate pairs.

Complexity: crapper flagged no function. Growth consists of revision parsing and revision-conflict branches. The changes affect startup and tools, with no decode or prefill work added.

Silent failure: 3 changed default expressions followed to their consumers. They select the client revision or main when no revision is supplied. Malformed revisions return HfError::Repo.

Tests, static mutation checks: dropping revision storage at crates/hf/src/lib.rs:225 fails the parse assertion; storing Some("main") for an omitted revision there fails the source and Metal struct assertions. Ignoring the explicit revision at crates/hf/src/fetch.rs:380 fails the downloaded-content assertion; using the unqualified repo in offline_set fails the cached-path assertion. Dropping the base revision at crates/gpu-gates/src/model_file/fetch.rs:300 fails the sentence-prefix assertion and its parent process check. Removing the refusal at crates/model-hf/src/bin/fixture.rs:475 fails the duplicate-revision assertion, including @main.

Gates: no pin, tolerance, lint level, test, or case removed or relaxed.

Escape catalog: C1–C4 do not match the changes. Invalid revisions, an uncached revision beside cached main, and revision-qualified checkpoint/projector paths were traced through their guards and consumers.

Notes

dryer skipped crates/gpu-gates; its changes were searched manually. Tests were reviewed statically and were not rerun. The body supplies no just gate-* card run with the required evidence.

Card check: needs-gpu. This pull request changes crates/gpu-gates/src/bin/bloomery_serve.rs, crates/gpu-gates/src/model_file/fetch.rs, crates/gpu-gates/src/side_seat/flags.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 95b8ba9 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 host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja needs-gpu Changes code a card must check, and carries no gate run on a card serve The HTTP server: crates/serve

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant