Repository navigation
Load the zoo Hub download helpers without unsloth_zoo's package init - #13849
Merged
Merged
Conversation
Prefer the init-free unsloth_zoo_downloads package (unslothai/unsloth-zoo#1752) for the Studio Xet fallback shim and the early read-only cache redirect, and fall back to the unsloth_zoo names on older zoo releases.
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. |
[skip ci]
Member
Author
|
@codex review |
1 similar comment
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep it up! 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". |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Companion to unslothai/unsloth-zoo#1752, which moves the Hub download helpers (
hf_xet_fallback,hf_xet_health,hf_xet_tuning,hf_cache,hf_cache_state) intounsloth_zoo_downloads, a sibling package that imports without runningunsloth_zoo/__init__(no torch, transformers or temporary patches). This PR makes Unsloth use it when the installed zoo ships it, and keeps today's behaviour on an older zoo.What changes
studio/backend/utils/hf_xet_fallback.py:_load_sharedand_load_optionalfirst try_import_light(name). It returns a module already insys.modulesunder theunsloth_zoo.*name (keeps the identity of an earlier full import and of test doubles), else importsunsloth_zoo_downloads.<module>. On a zoo without that package it returnsNoneand the existing path runs unchanged (torch gate, GPU-init retry, degrade).unsloth/_gpu_init.py: the early read-only cache redirect importsredirect_hf_cache_if_readonlyfromunsloth_zoo_downloads.hf_cache, and falls back to executingunsloth_zoo/hf_cache.pyby path as before._import_lighttoNoneor also blockunsloth_zoo_downloads, so they keep testing the path they were written for whichever zoo is installed. Three new tests cover the light route against a stand-in package: the shared backend and an optional module load without anyunsloth_zooimport attempt, torch gate orUNSLOTH_ZOO_DISABLE_GPU_INIT, and an already loaded zoo module wins.First download in a Studio process
Fresh process per run, torch already imported (as after the backend's startup warm), then
import utils.hf_xet_fallback,xet_health()andhf_hub_download_with_xet_fallbackof one small file. Colab T4-HM, 4 interleaved rounds per arm (ABCCBA x2):unsloth_zooinit ranSo the first Hub download in Studio starts about 4.8 s sooner and the backend process stays about 270 MB smaller until something else imports the zoo. With an older zoo nothing changes (row 1 is what this PR runs there).
Compatibility
unsloth_zoo_downloads):_import_lightreturnsNone, every existing branch runs as before. The suite below passes against zoo main and zoo#1752 alike.unsloth_zoo/__init__'s environment steps. The download children size their ownHF_XET_*(resize_for_cache_dirbefore the spawn,apply_xet_envindownload_lifecycle), and training / inference workers import Unsloth, which runs the init there. Before this PR those steps reached the backend process only if a download happened to come first, so nothing could rely on them.import unslothwith a read-onlyHF_HOME: the cache redirect result is identical with zoo main (by-path) and zoo#1752 (light import).Tests
16 files (
test_hf_xet_fallback,test_hub_download_transport_auto,test_gguf_xet_fallback_integration,test_training_xet_fallback,test_scoped_download_worker,test_training_worker_import_discipline,test_dynamo_import_race,test_gpu_init_crash_message, roottest_cold_import_order,test_import_time_floors,test_hf_xet_broken_wheel,test_prefetch_snapshot_scope, ...): 524 passed, 1 skipped against zoo main and against zoo#1752. The one failure on both,test_startup_defers_torch::test_import_main_does_not_import_torch, fails the same way on main without this PR. Disabling_import_lightmakes the two new routing tests fail.