Repository navigation
Studio Hub download: keep refs/main on the last complete snapshot under failed updates and concurrent workers - #16422
Conversation
…er failed updates and concurrent workers
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…der snapshot, a rolled-back restart does not block a peer's publication [skip ci]
…ed ledger, checked over every 2 and 3 worker interleaving [skip ci]
…the ledger lock; manifests attest the resolved commit [skip ci]
…ed attempts are pruned by owner liveness
…aved manifest's commit and files [skip ci]
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…as benign timing (#16526) ## Summary `workflow-trigger lint` is red on main since #16422 (`1a951a93d6`). Its "Workflow guard suites" step fails on unrelated PRs. In the last hour that was the staging runs for #16423, #16182 and #16523: ``` tests/studio/test_backend_ci_parallel_isolation.py::test_every_tight_elapsed_bound_is_isolated AssertionError: these backend tests compare clock-derived values and still run under -n 4 ...: {'test_hf_download_fallback_and_kill.py': ['...:32 one duration against another'], 'test_hf_download_reclaim_race.py': ['...:113 one duration against another'], 'test_hf_download_ref_concurrency.py': ['...:72 one duration against another']} ``` All three sites are the same poll loop, which waits for a child process to touch a `ready` file: ```python deadline = time.monotonic() + 20 # 10 in test_hf_download_ref_concurrency.py while not (tmp_path / "ready").exists(): assert child.poll() is None, child.communicate() assert time.monotonic() < deadline, "worker did not reach the transfer barrier" time.sleep(0.01) ``` Being descheduled under `-n 4` only delays a poll; it cannot make the condition false. The guard casts a deliberately wide net, and its message names this exact case: a poll deadline goes in `BENIGN_TIMING` as `(file, enclosing function)` with a reason. The tests and #16422's download logic are fine; those entries were just never added. ## Change `tests/studio/test_backend_ci_parallel_isolation.py`: three `BENIGN_TIMING` entries under one reason comment. Each names the function that holds the loop: - `_wait_for_transfer` - `test_gguf_reclaim_preserves_publication_and_active_peer` - `test_peer_completion_survives_an_older_process` I checked each of those functions: its only uses of `time.` are this deadline, the comparison and the `sleep`, so the entries hide no other timing check. ## Testing - `tests/studio/test_backend_ci_parallel_isolation.py`: - main: `test_every_tight_elapsed_bound_is_isolated` fails with the error above; - this branch: 43 passed. - No product or workflow file changes.
…16530) ## Summary Since #16422 (`1a951a93d6`), `(Python 3.13, rest)` fails on unrelated PRs. On staging CI it hit #16423, #16182 and #16523 in the last hour, and it reproduces on current main: ``` studio/backend/tests/test_scoped_download_worker.py::test_offline_scoped_download_fails_when_the_files_are_not_on_disk studio/backend/tests/test_scoped_download_worker.py::test_offline_scoped_download_passes_when_every_file_is_present studio/backend/tests/test_scoped_download_worker.py::test_a_dangling_symlink_does_not_count_as_present hub/workers/hf_download.py:476: in _pinned_snapshot_download E OSError: Cannot resolve an immutable revision for black-forest-labs/FLUX.1-dev; retry when metadata is available ``` #16422 made every download pin an immutable commit. When metadata is unreachable, `_pinned_snapshot_download` takes the commit from the Hub cache's `refs/main` and refuses when there is none, rather than letting `snapshot_download` hand back whatever folder is there. That is the point of #16422, and I left it alone. These tests' `offline` fixture predates it. It returns a bare tmp `snapshot` dir and never puts a `refs/main` in the Hub cache, so every case now stops at "no revision to pin" before reaching what it checks: an incomplete copy, a complete copy, a dangling blob symlink. A real offline user with a previously downloaded model has `refs/main` and its `snapshots/<commit>`, so nothing changes for them. ## Change `studio/backend/tests/test_scoped_download_worker.py` only: - The fixture points `huggingface_hub.constants.HF_HUB_CACHE` at a tmp dir. It writes `refs/main` and returns `snapshots/<commit>` there, the layout an earlier download leaves behind. - The three existing tests and their assertions are unchanged. - New `test_offline_with_no_cached_revision_refuses_before_downloading`: with no metadata and no `refs/main`, the worker raises the "immutable revision" `OSError` and never calls `snapshot_download`. This pins #16422's refusal, so the fixture change cannot hide a regression there. ## Testing - `tests/test_scoped_download_worker.py`: - main: 3 failed, 1 passed (the error above); - this branch: 5 passed. - Sabotage: with the offline missing-file refusal in `_download_scoped_snapshot` disabled, the incomplete-copy and dangling-symlink tests fail, so they still guard what they were written for. - `tests/test_hf_download*.py` plus this file: 102 passed.
Summary
Failed or overlapping Studio model updates can leave
refs/mainon an incomplete or older snapshot, breaking later offline loads by repository ID even when complete files remain in the cache. Downloads now resolve an immutable revision, verify its expected files, and publish only the most recently started successful attempt.A process-shared ledger coordinates publication and cancellation. Native owner locks let a later worker prune an abandoned attempt without guessing from PIDs, and GGUF reclamation protects the published revision and active peers. Saved manifests retain the revision needed for offline resumes.
The Windows run also exposed a cache identity mismatch: a symlink target can use an extended Windows path while the cache root uses an ordinary drive path. Blob classification now uses directory identity when resolved spellings differ, so obsolete blobs can be reclaimed without classifying outside-directory hard links as cache blobs.
Validation
The publication protocol coordinates participating Studio workers. It does not claim a power-loss transaction across journal/reference writes, and external or older workers that ignore the ledger remain outside its ordering guarantee.