Repository navigation
Only turn on HF_HUB_ENABLE_HF_TRANSFER in synthetic.py when hf_transfer is installed - #12406
Merged
Merged
Conversation
Member
Author
|
@codex review |
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. |
|
Codex Review: Didn't find any major issues. Nice work! 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". |
danielhanchen
deleted the
fix/synthetic-hf-transfer-only-when-installed
branch
October 1, 2026 09:18
danielhanchen
added a commit
that referenced
this pull request
Oct 1, 2026
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.
Problem
Core zoo (HF=4.57.6 + TRL<1)still fails on runs that already include unslothai/unsloth-zoo#1532 (zoo2bbe3d81d), for example #12390 and #12389:unsloth-zoo#1532 stopped zoo from setting the flag when
hf_transferis missing. unsloth has its own copy of the same unconditional setter, inunsloth/dataprep/synthetic.py, andimport unslothreaches it throughunsloth/dataprep/__init__.py. I traced every write to the variable during the zoo suite with a small pytest plugin. On main, the only write that turns it on is:On huggingface_hub < 1.0 (the 4.57.6 lane resolves 0.36.2), every plain HTTP download then raises unless
hf_transferis installed. That affects users too, not just CI:hf_transferis optional and is not available on Windows on ARM at all. The setter dates back to the originalsynthetic.py(8babbeade, 2025-04-29). The offline guard from #5598 kept it unconditional otherwise.Fix
synthetic.pyonly sets the flag whenimportlib.util.find_spec("hf_transfer")finds the package. It uses the same probe as unsloth-zoo#1532: it never imports the package, and treats asys.modulesstub with no__spec__(wherefind_specraisesValueError) as not installed. Offline mode still leaves the flag unset.New
tests/test_synthetic_hf_transfer_gate.pyruns the module's own probe and guard from source, since the module needs torch and unsloth_zoo to import. It covers:HF_HUB_OFFLINE/TRANSFORMERS_OFFLINEwith the package installed: the flag is unset.On the relation to #12394: that PR installs
hf_transferin the Core CPU setup, which makes this lane green by giving CI the package. This PR fixes the product, so an environment withouthf_transfer, like the users above, keeps working.Verification
tests/test_synthetic_hf_transfer_gate.pyplus the two existing synthetic test files: 36 passed.synthetic.pyreverted, the missing and stub cases fail.hf_transfer, with the tracing plugin, overtests/test_relative_imports_resolve.pyandtests/test_gemma3_processor_token_type_ids.pyfrom unsloth-zoo main: main shows 1 traced write turning the flag on, fromsynthetic.py; this branch shows 0.