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

Avoid class attribute _keep_in_fp32_modules being modified #27867

Merged
merged 4 commits into from
Dec 6, 2023
Merged

Conversation

ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Dec 6, 2023

What does this PR do?

Another approach to #26433. Fix #25910

@ydshieh ydshieh changed the title Fix fp 32 v2 Avoid class attribute _keep_in_fp32_modules being modified Dec 6, 2023
# Overwrite the class attribute to make it an instance attribute, so models like
# `InstructBlipForConditionalGeneration` can dynamically update it without modifying the class attribute
# when a different component (e.g. language_model) is used.
self._keep_in_fp32_modules = copy.copy(self.__class__._keep_in_fp32_modules)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can't do self._keep_in_fp32_modules = self.__class__._keep_in_fp32_modules , otherwise the in place operation like extend will modify the same object.

Copy link
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

A lot better thanks 🤗

@ydshieh
Copy link
Collaborator Author

ydshieh commented Dec 6, 2023

cc @younesbelkada

@ydshieh ydshieh merged commit 87714b3 into main Dec 6, 2023
21 checks passed
@ydshieh ydshieh deleted the fix_fp_32_v2 branch December 6, 2023 16:19
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.

Load instructblip-flan-t5-xl changes the results of instructblip-vicuna-7b
2 participants