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

Fix vision encoder decoder attention implementation pick #31203

Closed

Conversation

fxmarty
Copy link
Contributor

@fxmarty fxmarty commented Jun 3, 2024

Noticed this bug while making the CI pass for #30138.

Essentially, VisionEncoderDecoderModel.from_pretrained(xxx) does not correctly load with SDPA (e.g. with bert, deit) while it should be. The reason is that VisionEncoderDecoderModel does not have a class attribute _supports_sdpa, and we can not generally set _supports_sdpa = True (as multiple archs are supported). Thus, in from_pretrained logic to pick the attention implementation, SDPA is never picked.

We need to rely on the encoder/decoder classes to rightfully pick the attention implementation.

@fxmarty fxmarty changed the title fix vision encoder decoder attention implementation pick Fix vision encoder decoder attention implementation pick Jun 3, 2024
@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.

@amyeroberts
Copy link
Collaborator

This highlights a wider issue with how attention is selected for models through configs. Having things autoset breaks a lot of the "don't do things by magic" convention that we have in transformers and this has already caused quite a few issues / surpising behaviour within the library.

Instead, I think we should completely re-think how attention is passed through and selected.

@fxmarty
Copy link
Contributor Author

fxmarty commented Jun 4, 2024

agreed

@ArthurZucker ArthurZucker removed their request for review June 12, 2024 16:00
@huggingface huggingface deleted a comment from github-actions bot Jul 8, 2024
Copy link

github-actions bot commented Aug 2, 2024

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

@github-actions github-actions bot closed this Aug 11, 2024
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.

3 participants