-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Unnecessary cuda synchronizations that we should remove in PyTorch #108968
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
Comments
On point 2, see data-apis/array-api#654. The array API will have |
I hope that tensor/array can also be accepted where tuple is expected - this might be important for PyTorch where we can have some minor improvements if the |
@vadimkantorov |
@lezcano Currently, most array libraries support a one-dimensional array for |
Uh oh!
There was an error while loading. Please reload this page.
🚀 The feature, motivation and pitch
There are a number of unnecessary cuda synchronizations in PyTorch ops, and I think we should endeavor to remove them whenever possible.
To check syncs, you can use
torch.cuda.set_sync_debug_mode("warn")
I'm creating this issue to track ones that I've seen/found.
num_samples=1
. For this I think we should simply remove the error check causing the sync, and ideally turn it into a cuda async error. https://github.com/pytorch/pytorch/blob/main/aten/src/ATen/native/Distributions.cpp#L615repeats
with a non-cuda tensor, and that forces a synchronization. For this I think we should add a list of ints overload or allow passing a CPU tensor for repeats.Indexing with a scalar tensor performs a synchronization. See Turn indexing with a scalar tensor into an copy into a view and avoid a D2H synchronization. #105641 for more details.
torch.normal
also incurs a sync on std: https://github.com/pytorch/pytorch/blob/main/aten/src/ATen/native/DistributionTemplates.h#L222nanmedian
incurs a sync: https://github.com/pytorch/pytorch/blob/main/aten/src/ATen/native/cuda/Sorting.cpp#L149prod_backward: torch.prod cannot be used with cudagraphs #128396
Alternatives
No response
Additional context
No response
cc @ptrblck
The text was updated successfully, but these errors were encountered: