-
Notifications
You must be signed in to change notification settings - Fork 970
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
Better error when device mismatches when calling gather() on CUDA #2180
Conversation
The documentation is not available anymore as the PR was closed or merged. |
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.
👍 for better error messages.
I have two nits, not blockers for the PR.
@@ -298,6 +298,13 @@ def _gpu_gather_one(tensor): | |||
if not tensor.is_contiguous(): | |||
tensor = tensor.contiguous() | |||
|
|||
# Check if `tensor` is not on CUDA | |||
if state.device.type == "cuda" and tensor.device.type != "cuda": |
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.
Are there other device mismatches that could be checked here?
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.
@muellerzr @BenjaminBossan Can this logic be extended to other devices ? Seems like a generic exception handling case.
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.
Yes it can, for now it’s just a thing on CUDA but if it’s useful for other devices that can be added. This is just a known base case
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 !
Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>
What does this PR do?
This PR adds a new explicit error when a user tries to call
.gather()
in a GPU scenario and the device of the passed in tensor != the device inPartialState
(aka CUDA). Avoids users getting err:And instead gives them a much clearer err:
Fixes # (issue)
https://discuss.huggingface.co/t/problem-with-model-inference-using-accelerate/63078
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
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.
@BenjaminBossan @SunMarc