-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
[Idefics3] Move image features to same device as input embeds #35100
[Idefics3] Move image features to same device as input embeds #35100
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, let's just move the device placement in the same line as
reshaped_image_hidden_states = reshaped_image_hidden_states.to(inputs_embeds.dtype)
. So that we assign the correct dtype/device in one line for more readability on what's going on
You want me to have a change like this?
I will try to run this on my multi device setup. |
@shyshin you can do in one go as |
485df3a
to
31a5e10
Compare
@zucchini-nlp I have updated the code with your suggestions |
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. |
Seems like a tiny fix without need for core maintainer's approval, so maybe another review from @qubvel and let's merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @shyshin, thanks for the fix! What would be a self.device
in case the model is split across multiple devices? Would it be safer to use new_inputs_embeds.device
instead?
Hey @shyshin ! Would you be able to incorporate the suggested changes ? If you are busy, I can push the changes and merge the PR :) |
@qubvel @zucchini-nlp I am sorry I am really swamped with work atm. It would be really nice if you could push the changes and merge the PR :) |
What does this PR do?
Fixes #35031
Summary:
Got a device mismatch issue on running
trainer.train()
.Moved
image_features
to same device asinput_embeds
.Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@zucchini-nlp
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.