[modular] Fix the prefix-based renaming if the old and new model share a common name suffix#37829
[modular] Fix the prefix-based renaming if the old and new model share a common name suffix#37829Cyrilvallez merged 7 commits intomainfrom
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.
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.
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
| 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 |
…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!