Skip to content
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

Siglip: add _no_split_module #31566

Merged
merged 2 commits into from
Jun 25, 2024
Merged

Conversation

zucchini-nlp
Copy link
Member

What does this PR do?

Fixes #31400. Adds a '_no_split_module' in SigLipModel by combining those specified in Text and Vision components.

Otherwise, when we call SiglipModel with device_map an error will be thrown because Text/Vision components are not children of SiglipModel and we need to add _no_split_module

@HuggingFaceDocBuilderDev

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.

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing!

General comment / question about the best approach

Comment on lines 1021 to 1027
_no_split_modules = [
"SiglipTextEmbeddings",
"SiglipEncoderLayer",
"SiglipVisionEmbeddings",
"SiglipEncoderLayer",
"SiglipMultiheadAttentionPoolingHead",
]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if we have modules defined in _no_split_modules which aren't in the model? It probably makes more sense to move this into the PretrainedModel definition than repeat e.g. "SiglipVisionEmbeddings" for all models which use the vision components

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! Didn't think that extra split_modules will not affect anything. Moved to SiglipPretrained model and ran tests. Had to skip offloading, same way it's skipped in SigLipVision

Copy link
Collaborator

@amyeroberts amyeroberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding!

@zucchini-nlp zucchini-nlp merged commit 7e86cb6 into huggingface:main Jun 25, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SiqlipVisionModel does not support "device map= auto": no split modules`attribute
3 participants