Skip to content

hf: give each listing its own header file - #989

Merged
juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-hf-listing-headers
Oct 29, 2026
Merged

juliankang4 merged 1 commit into
midagedev:mainfrom
juliankang4:dgx-spark-q38-fix-hf-listing-headers

Conversation

@juliankang4

Copy link
Copy Markdown
Collaborator

Hugging Face 목록 조회가 동시에 돌 때 서로의 헤더 파일을 덮어써 페이지를 놓치던 문제를 호출마다 헤더 파일을 따로 두어 고쳤습니다.

What and why

Client::listing_at named its curl header file by process id only, so listings running at once in one process shared a single file. One call could read or delete another call's headers, and a repo with several pages returned only its first page or followed another repo's next link. This change names the header file per call (.listing-<pid>-<call>.headers, with a process-wide counter) and turns an unreadable header file after a successful curl into HfError::Io instead of an empty header, which had read as "last page". The header file is removed on both paths.

Closes #986.

Release notes: Fixed: concurrent Hugging Face listings of multi-page repos no longer return another repo's pages or stop after the first page.

Code shape

The review reads these first. A box left unticked needs one line of why.

  • No second copy. Logic two models (or two call sites) share has one common owner; I lifted it there instead of
    copying it (AGENTS.md "Common code first", docs/rust-quality.md R14). Where I found an existing copy, I
    named it below.
  • Model code holds only architecture facts. A model's own files carry only what its architecture forces
    (tensor shapes, the attention kind, the quant). A common owner gained no per-model branch, flag or trait method.
  • Dead code is gone. Nothing I made unused is left behind (functions, flags, gate clauses, docs).
  • No silent failure. Undefined input is a named error or panic, never a defined-looking output.
  • Comments state what is true now. No dates, issue numbers or how a bug was found (tools/check-comments.sh).
  • No relaxed gate. No band, tolerance or lint moved to make a check pass; a re-pin carries PIN(YYYY-MM-DD):
    and its reason.
  • cargo fmt and cargo clippy are clean on what I touched; the lint count did not go up.

Duplication found or removed (path:line), or "none": none. The only other process::id() file name in crates/hf/src is in test code.

What I ran

Base 7f04223bc467b76b443ebb0910947072eb1007b0, head 109d22f6688571a880704d241a18655feb12ae4e. The change is in crates/hf/src/fetch.rs and adds two tests:

  • concurrent_paginated_listings_each_read_their_own_pages: a local HTTP server serves 8 repos of 2 pages each (Link: rel="next") and holds every first page until all 8 requests have arrived, so the header files overlap. Each repo must return its own two pages.
  • a_listing_page_without_its_headers_is_an_error (unix): a fake curl prints [] and writes no header file. The listing must fail with HfError::Io on the .headers path.

Before the fix (the tests on the base code), five runs of cargo test -p bloomery-hf --lib concurrent_paginated_listings:

test fetch::tests::concurrent_paginated_listings_each_read_their_own_pages ... FAILED
  left: ["r0-1.gguf"]
 right: ["r0-1.gguf", "r0-2.gguf"]
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 154 filtered out

All five runs failed. Another run returned left: ["r0-1.gguf", "r3-2.gguf"], another repo's second page. With both new tests on the base code, cargo test -p bloomery-hf --lib listing:

test fetch::tests::concurrent_paginated_listings_each_read_their_own_pages ... FAILED
test fetch::tests::a_listing_page_without_its_headers_is_an_error ... FAILED
test result: FAILED. 7 passed; 2 failed; 0 ignored; 0 measured; 147 filtered out

After the fix, cargo test -p bloomery-hf, and the concurrent test ten times in a row:

test result: ok. 154 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 155 filtered out   (10 of 10 runs)

The real binary against the real hub, built with cargo oxide build --arch sm_121a -- -p bloomery-gpu-gates --features glm5next,clef,mimo2,solar2,minimaxm3,flint,gemma-embedding2,hf,checkpoint --release --bin bloomery-serve, then bloomery-serve --recommend --json. A curl wrapper on PATH let only listing and range requests through, logged each URL and refused full downloads:

Finished `release` profile [optimized] target(s) in 9m 39s
stale listing header files before: 0
rc=0
models 16 picked 5
listing requests: 13 (next pages: 0)
range requests: 134
stale listing header files after: 0

The 13 catalog repos each fit on one page, so the multi-page path is covered by the local-server test above.

Hardware (if the change is for a machine)

The card run above used one DGX Spark: NVIDIA GB10, driver 595.84, CUDA 13.3.1 (build container).

AI help

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

Concurrent listings in one process named their curl header file by the
process ID alone, so one call could read or remove another's headers and
end on its first page or follow another repository's next link. Each
call now names its own file, and a header file that cannot be read after
curl succeeded is an error instead of a last page.

Fixes midagedev#986
@github-actions github-actions Bot added the model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja label 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: Concurrent listings use separate header files, and unreadable headers return a named error.

Non-blocking

⚠ Reusable diagnosis: crates/hf/src/fetch.rs:407. The PR describes a temporary curl wrapper, but the diff retains no diagnostic listing trace. Keep that trace in an existing tool, or explain why the path-bearing I/O error is sufficient for diagnosis. This avoids reconstructing the probe during another concurrency failure.

Checked

Duplicates: dryer reported 0 pairs; the diff adds a call counter, a fixture repo count and two regression tests.
Complexity: crapper flagged no changed functions.
Silent failure: unreadable headers now propagate as HfError::Io; cleanup remains best effort. Fixture accept/write failures cannot fabricate the expected pages.
Tests: the concurrent test asserts each repo's two pages; the missing-header test requires HfError::Io naming the header path. Restoring the empty-header default defeats expect_err. The PR body reports FAIL-first results for both tests.
Gates: no bands, tolerances or lint levels moved. The spawn inventory accounts for the three new test spawn sites.
Escape catalog: no patterns matched.
Performance: HTTP discovery only; no decode, prefill or kernel path changes.

Notes

Tests were not executed here because their scratch helper writes under PR_TREE.

🔨 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 795f6e6 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

model The CPU engine and model files: crates/model, models, hf, gguf, tokenizer, jinja

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hf: concurrent listings share pagination headers and silently omit pages

1 participant