fix: handle absent sys.modules entry in modeling_utils#44978
Closed
cjkindel wants to merge 2 commits intohuggingface:mainfrom
Closed
fix: handle absent sys.modules entry in modeling_utils#44978cjkindel wants to merge 2 commits intohuggingface:mainfrom
cjkindel wants to merge 2 commits intohuggingface:mainfrom
Conversation
Author
|
This isn't slop @Cyrilvallez , this is a legitimate problem affecting Griptape Nodes users with the Advanced Media library. Telling our customers to use my personal fork of Transformers isn't a healthy solution for us, even though it does mitigate the problem. I acknowledge that Griptape Nodes does some dumb/hacky stuff with sys.modules but this does fix the problem and is 'right'. Without this change, our customers are facing errors when trying to use Flux.1 ControlNets with Diffusers. |
4 tasks
Collaborator
|
Actually I think vllm had similar issues |
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.
What does this PR do?
_can_set_attn_implementationand_can_set_experts_implementationboth do a direct subscript lookup intosys.modules:If the module is not registered under its dotted name in sys.modules — which can happen with lazy loaders, frozen importers, or certain packaging environments on Windows — this raises a KeyError instead of returning False as intended.
The existing comment already acknowledges this class of problem ("This can happen for a custom model in a jupyter notebook or repl for example") but the file guard only ran after the subscript, so it never had a chance to fire.
First introduced: commit 0642963 (PR #42697, merged January 5, 2026).
Real-world traceback reported by Griptape Nodes users:
Reproducing code:
Code Agent Policy
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@ArthurZucker (original author)
@Cyrilvallez (model loading)
Closes #45003