Repository navigation
Studio: free the disk space when a GGUF quant is deleted or replaced - #11599
danielhanchen merged 5 commits into
Conversation
Review + GitHub Actions evidenceReviewed Actions A/B. Real
Both sides log Studio UI, same real cache, merge base vs head. Deleted Q2_K from the Model hub quant menu, where the dialog reads "Frees 88 MB". Settings → System → Cache files then shows the Hugging Face model cache at 182 MB before the fix and 94 MB after. Studio's Tests. With Conclusion. The leak and its fix are both verified on Linux, macOS and Windows. The one red on the fork CI run ( |
…ge shape huggingface_hub.utils._shared_blobs is private and unsloth sets no upper bound on huggingface_hub. A release that keeps both names but changes their arguments would raise TypeError after the snapshot links are already removed, which the OSError handler does not catch, so the delete would stop part way and return a 500. Check at import that both helpers accept the arguments Studio passes. If they do not, disable them and use the previous plain unlink. No per-call cost, and nothing changes on huggingface_hub 1.32.
huggingface_hub compares the blob path and the cache root lexically. Studio passes a resolved cache root, so a blob reached through a symlinked cache directory, or a Windows 8.3 short name such as C:\Users\RUNNER~1, no longer matches. The shared payload is then not collected and the old "freed" size is reported, which is the leak this PR fixes. Try the cache root in the blob's own form first (the grandparent of <repo>/blobs/<etag>), then the root Studio passed. This fixes test_delete_variant_keeps_shared_xet_blob_referenced_by_other_repo on windows-latest and adds a test that reproduces the mismatch with a symlinked cache on every OS.
…text test_delete_variant_keeps_shared_xet_blob_referenced_by_other_repo failed on windows-latest. huggingface_hub 1.32 rewrites the .refs manifest with os.fsync on a handle opened read-only, which Windows rejects with EBADF; the sweep catches it and keeps the payload, so the stale line for the removed link stays. It names nothing on disk and huggingface_hub already ignores it. Assert the manifest's live entries instead, then delete the other repo's copy and assert the payload and manifest are gone. That last step still fails on the merge base (the payload is never collected) and now passes on Linux, macOS and Windows.
|
Review record for #11599, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#73. 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
|
…nslothai#11599) * Studio: free the disk space when a GGUF quant is deleted or replaced * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Studio: fall back to the plain unlink if the shared-blob helpers change shape huggingface_hub.utils._shared_blobs is private and unsloth sets no upper bound on huggingface_hub. A release that keeps both names but changes their arguments would raise TypeError after the snapshot links are already removed, which the OSError handler does not catch, so the delete would stop part way and return a 500. Check at import that both helpers accept the arguments Studio passes. If they do not, disable them and use the previous plain unlink. No per-call cost, and nothing changes on huggingface_hub 1.32. * Studio: match the shared-blob cache root to the blob's own path form huggingface_hub compares the blob path and the cache root lexically. Studio passes a resolved cache root, so a blob reached through a symlinked cache directory, or a Windows 8.3 short name such as C:\Users\RUNNER~1, no longer matches. The shared payload is then not collected and the old "freed" size is reported, which is the leak this PR fixes. Try the cache root in the blob's own form first (the grandparent of <repo>/blobs/<etag>), then the root Studio passed. This fixes test_delete_variant_keeps_shared_xet_blob_referenced_by_other_repo on windows-latest and adds a test that reproduces the mismatch with a symlinked cache on every OS. * Studio: test the shared-blob outcome, not huggingface_hub's manifest text test_delete_variant_keeps_shared_xet_blob_referenced_by_other_repo failed on windows-latest. huggingface_hub 1.32 rewrites the .refs manifest with os.fsync on a handle opened read-only, which Windows rejects with EBADF; the sweep catches it and keeps the payload, so the stale line for the removed link stays. It names nothing on disk and huggingface_hub already ignores it. Assert the manifest's live entries instead, then delete the other repo's copy and assert the payload and manifest are gone. That last step still fails on the merge base (the payload is never collected) and now passes on Linux, macOS and Windows. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Han <[email protected]>

With huggingface_hub 1.32 or newer, deleting a GGUF quant from the Models page, or replacing it with an update, removes only a link. The file stays on disk, while the log says the space was freed.
After removing the link, Studio now asks huggingface_hub to remove the stored file. The file is kept if another model still uses it. Older huggingface_hub versions work as before.
Before / after in Studio
Same real huggingface_hub 1.32 cache on both sides (SmolLM2-135M-Instruct-GGUF, Q2_K and Q3_K_M), Q2_K deleted from the Model hub. The dialog promises 88 MB on both sides; only the PR actually frees it. Settings, System, Cache files then shows the Hugging Face model cache at 182 MB before the PR and 94 MB after (88,201,907 bytes left the disk on head, 0 on the merge base).