You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(studio): keep scoped download progress tied to current files - #12390
When a scoped media download reuses a repository with a different file set, progress can read the previous manifest and retain its larger total indefinitely. For example, switching to a 6.3 GB file can leave the queue showing 6.7 GB and initially omit bytes already transferred.
Validate scoped manifests against the current job's file paths and resolved hashes before using them for sizing, disk counts, or completion. While a new manifest is pending, use the current job's hashes and caller estimate. Once variant metadata is resolved, allow its authoritative total to replace an oversized hint. Preserve conservative sizing for full snapshots and hint fallback when metadata is unavailable.
Validation:
18 new regression tests pass, covering both existing diffusion and Hub scopes, larger/smaller/equal-size switches, same-file retries, changed revisions, missing manifests/hashes, restored jobs, companions, completion, and full-snapshot fallback.
Before the fix, 15 of the original 16 regression cases failed; the same-file retry control passed.
Existing Hub suite: 755 pass on both baseline and fixed backend, with the same five pre-existing deletion fixture failures (SimpleNamespace missing source). Full run with the initial 16 added cases: 771 pass, same five failures. Final focused run after two additional controls: 41 pass.
Ruff and git diff --check pass.
Playwright renders the unchanged production download panel against each backend progress service in isolated seeded-cache harnesses: BEFORE 8.0 MB / 6.7 GB; AFTER 8.0 MB / 6.3 GB. The fixed first poll also reports the current 8 MB. No live Hugging Face download was performed in this evidence scene.
Independent of asset-disclosure PR #12387. No frontend changes in this patch.
Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.
Round 1: reviewed mirror 0702ec0c9 (no equivalent commit found on this PR)
chatgpt-codex-connector[bot] on studio/backend/hub/services/snapshot_progress.py (on the mirror)
@@ -343,6 +343,22 @@ def _snapshot_resolves_to(
return True
+def manifest_matches_download(+ manifest: Optional[download_manifest.Manifest],+ metadata: Optional[download_registry.DownloadMetadata],+) -> bool:+ """A reused scope must not read a previous file set or revision's manifest."""+ files = frozenset(getattr(metadata, "scoped_files", ()) or ())+ if manifest is None or not files:+ return True+ if frozenset(file.path for file in manifest.expected_files) != files:+ return False+ hashes = frozenset(getattr(metadata, "progress_blob_hashes", ()) or ())+ return not hashes or hashes == frozenset(+ file.sha256 for file in manifest.expected_files if file.sha256+ )
Bind manifest validation to the launched job
If the repository changes between the parent’s scoped_file_blob_hashes preflight and the worker’s later _model_info_with_retry, the worker downloads the newer revision and publishes its manifest, but progress_blob_hashes still describes the older revision. This equality check then rejects the manifest produced by the current worker; subsequent polls filter out its new blobs and never report complete_on_disk, even after the job succeeds. Associate the manifest with the job generation or refresh the registered hashes rather than treating the preflight hash set as permanently authoritative.
Useful? React with 👍 / 👎.
Rejected on the mirror
Reply from danielhanchen:
Not changing this. The registry hashes and the worker's manifest are both resolved from model_info at claim time, seconds apart; a mismatch needs the upstream repo to replace these exact files inside that window (or during a same-job transport retry). A fresh start re-resolves both. Treating the manifest as authoritative instead would reopen the stale-manifest window this PR closes.
chatgpt-codex-connector[bot] on studio/backend/hub/services/snapshot_progress.py (on the mirror)
@@ -373,10 +389,18 @@ def compute_snapshot_progress(
active_root = Path(metadata_hub_cache) if metadata_hub_cache else None
expected_total = max(expected_bytes, 0)
- # Always resolve the revision's blob hashes so stale blobs from a superseded revision cannot inflate the count; they degrade to empty (count-all) only when metadata is unavailable (e.g. offline). Take the larger total so a low caller hint cannot cap the bar.+ # Resolve revision hashes so superseded blobs cannot inflate the count.+ # Unavailable metadata falls back to the caller's estimate.
meta_total, expected_hashes = metadata_resolver(repo_id, hf_token)
meta_total = max(0, meta_total)
- expected_total = max(expected_total, meta_total)+ # A resolved variant's total is exact: max() with a hint left over from an earlier scoped pick never shrinks.+ expected_total = (+ meta_total if variant is not None and meta_total > 0 else max(expected_total, meta_total)+ )
Preserve the hint when the total comes from an old manifest
When remote variant metadata is unavailable, _metadata_resolver can obtain meta_total from _variant_manifest_decision, which may be an older locally installed revision rather than an authoritative current total. Unconditionally replacing a larger caller hint for every variant lets that old manifest shrink the total; its old snapshot can then satisfy the completion check and report the current, larger variant as fully downloaded. Only allow totals from current remote metadata or a manifest verified against the active scoped job to reduce the caller’s estimate.
Useful? React with 👍 / 👎.
Accepted on the mirror
Reply from danielhanchen:
Fixed in 0554a1b: a quant variant whose total comes only from a local manifest (remote metadata unavailable) now keeps max(manifest, caller estimate); remote requirements and scope manifests stay authoritative. Regression test test_offline_variant_manifest_does_not_shrink_hint fails without it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a scoped media download reuses a repository with a different file set, progress can read the previous manifest and retain its larger total indefinitely. For example, switching to a 6.3 GB file can leave the queue showing 6.7 GB and initially omit bytes already transferred.
Validate scoped manifests against the current job's file paths and resolved hashes before using them for sizing, disk counts, or completion. While a new manifest is pending, use the current job's hashes and caller estimate. Once variant metadata is resolved, allow its authoritative total to replace an oversized hint. Preserve conservative sizing for full snapshots and hint fallback when metadata is unavailable.
Validation:
Independent of asset-disclosure PR #12387. No frontend changes in this patch.