-
Notifications
You must be signed in to change notification settings - Fork 31.9k
[modular] Fix the prefix-based renaming if the old and new model share a common name suffix #37829
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
Conversation
|
Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the |
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
beb65a5 to
a08301e
Compare
| # Check that adding the second base class correctly set the parent, even though in clip it does not have the "Vision" part | ||
| class Multimodal2VisionSdpaAttention(CLIPSdpaAttention, Multimodal2VisionAttention): | ||
| pass | ||
|
|
||
|
|
||
| # Check that adding the second base class correctly set the parent, even though in clip it does not have the "Vision" part | ||
| class Multimodal2VisionFlashAttention2(CLIPFlashAttention2, Multimodal2VisionAttention): | ||
| pass | ||
|
|
||
|
|
||
| MULTIMODAL2_VISION_ATTENTION_CLASSES = { | ||
| "eager": Multimodal2VisionAttention, | ||
| "sdpa": Multimodal2VisionSdpaAttention, | ||
| "flash_attention_2": Multimodal2VisionFlashAttention2, | ||
| } | ||
|
|
||
|
|
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.
They no longer exist
| else: | ||
| for i, model_name in enumerate(args.files_to_parse): | ||
| if os.sep not in model_name: | ||
| full_path = os.path.join("src", "transformers", "models", model_name, f"modular_{model_name}.py") | ||
| # If it does not exist, try in the examples section | ||
| if not os.path.isfile(full_path): | ||
| full_path = os.path.join("examples", "modular-transformers", f"modular_{model_name}.py") | ||
| # We did not find it anywhere | ||
| if not os.path.isfile(full_path): | ||
| raise ValueError(f"Cannot find a modular file for {model_name}. Please provide the full path.") | ||
| args.files_to_parse[i] = full_path |
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.
Because I'm too lazy to write the full path each time. It allows to do e.g.
python utils/modular_model_converter.py --files_to_parse aria instead of python utils/modular_model_converter.py --files_to_parse src/transformers/models/aria/modular_aria.py
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.
big win haha
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.
love it!
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.
Ah yessss 🙏
ArthurZucker
left a comment
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.
thanks!
| else: | ||
| for i, model_name in enumerate(args.files_to_parse): | ||
| if os.sep not in model_name: | ||
| full_path = os.path.join("src", "transformers", "models", model_name, f"modular_{model_name}.py") | ||
| # If it does not exist, try in the examples section | ||
| if not os.path.isfile(full_path): | ||
| full_path = os.path.join("examples", "modular-transformers", f"modular_{model_name}.py") | ||
| # We did not find it anywhere | ||
| if not os.path.isfile(full_path): | ||
| raise ValueError(f"Cannot find a modular file for {model_name}. Please provide the full path.") | ||
| args.files_to_parse[i] = full_path |
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.
big win haha
…e a common name suffix (huggingface#37829) * first try * Fix and set examples * style * fix * Update modular_test_detr.py * Update image_processing_new_imgproc_model.py * Update modular_model_converter.py
What does this PR do?
As per the title. See #36895 (comment) for details. It's mostly an issue for all the
detrmodels, as they share the suffix in the base name.cc @qubvel for viz!