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 device in rope module when using dynamic updates #35608

Merged
merged 1 commit into from
Jan 13, 2025
Merged

Conversation

Cyrilvallez
Copy link
Member

What does this PR do?

If a model is initialized on cpu, then moved with .cuda() or .to(device), the parameters and buffers are automatically moved, but not the other internal tensors. This can lead to wrong device when going back to self.original_inv_freq in the rope module as the model was originally on cpu, thus self.original_inv_freq is still on cpu.
This fixes it.

@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
Member

@Rocketknight1 Rocketknight1 left a comment

Choose a reason for hiding this comment

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

Yes, this is an issue we've seen elsewhere. LGTM, but I'll let @ArthurZucker do the final review

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.

Sounds good, this does not seem to require a patch, so let's leave it as is!

@Cyrilvallez Cyrilvallez merged commit cd44bdb into main Jan 13, 2025
18 checks passed
@Cyrilvallez Cyrilvallez deleted the fix-rope branch January 13, 2025 09:11
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