Skip to content

Pass attn_implementation when using AutoXXX.from_config#30507

Merged
amyeroberts merged 2 commits intohuggingface:mainfrom
amyeroberts:pass-attn-implementation-for-auto-model
Apr 29, 2024
Merged

Pass attn_implementation when using AutoXXX.from_config#30507
amyeroberts merged 2 commits intohuggingface:mainfrom
amyeroberts:pass-attn-implementation-for-auto-model

Conversation

@amyeroberts
Copy link
Copy Markdown
Contributor

@amyeroberts amyeroberts commented Apr 26, 2024

What does this PR do?

Passes attn_implementation=config._attn_implementation when creating a model using AutoXxx.from_config. This ensures the attention implementation selected is complementary with the parent model.

Not added for some models, as the default attn implementation selected for the model isn't compatible with the component model c.f. a57b9b5

If this is not passed, then breaking changes can occur when the attention implementation in the component model being loaded changes -- see #30506 for an example of breaking changes.

For example, when SDPA was added to BERT, this attention mechanism was then selected by default. This however wasn't supported by other models using it as an encoder.

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

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 amyeroberts removed the request for review from younesbelkada April 26, 2024 17:57
Copy link
Copy Markdown
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Makes sense ! Thanks a lot for the investigation and fix ! 🚀

@amyeroberts amyeroberts merged commit e8acb70 into huggingface:main Apr 29, 2024
@amyeroberts amyeroberts deleted the pass-attn-implementation-for-auto-model branch April 29, 2024 09:22
@VictorSanh
Copy link
Copy Markdown
Contributor

thank you!

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.

4 participants