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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue: support auto generation of device check for sparse tensors #59058
Comments
cc @wenleix |
Device guard is only generated for CUDA dispatch key: pytorch/tools/codegen/dest/register_dispatch_key.py Lines 241 to 258 in 89d7885
I incorrectly also only generate device check for CUDA dispatch key, in your example, it's a CPU dispatch so there is no device check generated. I think the following lines needs to be removed (likely needs to fix some tests):
Will work on this. |
It shouldn't be cpu dispatch if at least one of the tensors is cuda, are we doing multi-dispatch incorrectly in this case? I don't know what's the priority between sparse/dense cuda/cpu keys, @ezyang do you know? |
Priority is SparseCUDA, SparseCPU, CUDA, CPU. So yes, if there is a sparse CUDA tensor anywhere, it will dispatch to SparseCUDA. |
So SparseCPU + Dense CUDA will dispatch to SparseCPU, and SparseCPU won't have device checks autogenerated. We don't have this problem in the dense land (if you are dispatched to dense CPU, there can't possibly be any cuda tensors around). |
Good catch, @ngimel |
馃悰 Bug
To Reproduce
If we disable checks
pytorch/aten/src/ATen/native/sparse/SparseCsrTensorMath.cpp
Line 100 in 1bd22e2
pytorch/aten/src/ATen/native/sparse/SparseTensorMath.cpp
Line 609 in 1bd22e2
Fails with
Segmentation fault (core dumped)
when(s.device, m1.device, m2.device)
arecpu, cpu, cuda:0
. Basicallygen_device_check->common_device_check_failure
is not called. It fails even when 2nd parameter ofaddmm
is a COO or CSR sparse tensor.Expected behavior
code-gen calls
gen_device_check->common_device_check_failure
.Additional info
Following PR #56872
cc @aocsa @nikitaved @pearu @cpuhrsch @IvanYashchuk @mruberry
The text was updated successfully, but these errors were encountered: