-
Notifications
You must be signed in to change notification settings - Fork 0
fix: skip redundant HfFileSystem().glob() calls in loader.py #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dac1b60
c50591b
30db8f3
b83d57f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -508,7 +508,7 @@ def from_pretrained( | |||||
| model_type = model_types | ||||||
|
|
||||||
| # New transformers need to check manually. | ||||||
| if SUPPORTS_LLAMA32: | ||||||
| if SUPPORTS_LLAMA32 and is_model and is_peft: | ||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [12/12 reviewers] This guard is correct -- it avoids the Note: the entire block (lines 511-527) is effectively dead code on modern transformers because
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this change correctly avoids a redundant network call, I've noticed two related points:
I'd suggest refactoring this duplicated logic into a helper function. This would improve maintainability and allow fixing the potential bug in one place. The fix would involve ensuring that an error is raised if both configs exist, regardless of the transformers version. |
||||||
| # Check if folder exists locally | ||||||
| if os.path.isdir(model_name): | ||||||
| exist_adapter_config = os.path.exists( | ||||||
|
|
@@ -1282,7 +1282,7 @@ def from_pretrained( | |||||
| os.environ["UNSLOTH_DISABLE_STATIC_GENERATION"] = "1" | ||||||
|
|
||||||
| # New transformers need to check manually. | ||||||
| if SUPPORTS_LLAMA32: | ||||||
| if SUPPORTS_LLAMA32 and is_model and is_peft: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [12/12 reviewers] Same as the
Suggested change
|
||||||
| # Check if folder exists locally | ||||||
| if os.path.isdir(model_name): | ||||||
| exist_adapter_config = os.path.exists( | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for skipping the glob call is duplicated in two places. Consider refactoring this into a helper function to improve maintainability and reduce code duplication.