You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test_cdist_backward_large_index (test/test_torch.py, added upstream alongside the CUDA fix pytorch/pytorch#128791) causes a GPU segfault that aborts the process on XPU for both parametrizations:
importtorchb, r, m=2, 1024, 2048# also fails with 32, 8192, 1dev="xpu"x1=torch.randn(b, r, m, device=dev, requires_grad=True)
x2=torch.randn(b, r, m, device=dev)
grad=torch.randint(-4, 5, (b, r, r), device=dev, dtype=torch.float)
(actual,) =torch.autograd.grad(torch.cdist(x1, x2, p=1), x1, grad)
Segmentation fault from GPU at 0xff0000020b800000, ctx_id: 1 (CCS) type: 0 (NotPresent), level: 2 (PDP), access: 1 (Write), banned: 1, aborting.
Abort was called at 288 line in file:
./shared/source/os_interface/linux/drm_neo.cpp
Root cause: in src/ATen/native/xpu/sycl/DistanceKernels.cpp, cdist_backward_kernel_impl_func:
constint l_size = r_size * m; // int32
...
scalar_t* buff_i = buff_data + l * l_size + (r1 * j + i) * m + init;
l_size and l are declared int. For (b=2, r=1024, m=2048), r_size = r1*r2 = 2^20, so l_size = r_size*m = 2^31 overflows int32, and l * l_size wraps, producing an out-of-bounds GPU write. The (32, 8192, 1) case overflows dist.numel() == 2^31 similarly. This is the same int32 indexing bug fixed for CUDA in pytorch/pytorch#128791.
Fix: widen l_size (and l/k/y) to int64_t, mirroring the CUDA fix. (r1 * j + i) * m is already int64.
Because the failure is a process-aborting GPU segfault (not a catchable exception), the upstream test is skipped on XPU via @skipIfXpu referencing this issue.
Versions
torch 2.15.0.dev20260923+xpu
GPU: Intel(R) Data Center GPU Max 1550
Root cause: int32 l = y / r_size, l_size = r_size * m overflow in cdist_backward_kernel_impl_func
(src/ATen/native/xpu/sycl/DistanceKernels.cpp:468,471,484), giving an OOB GPU write; owner torch-xpu-ops (CUDA fixed in pytorch#128791).
axis
value
reason
type
Bug
issue_type empty; GPU segfault aborts the process.
test
test: ut
Upstream UT test_cdist_backward_large_index in test/test_torch.py; no e2e/oob signal.
module
module: ops
Index overflow in cdist backward SYCL kernel DistanceKernels.cpp:471, a native ATen op.
priority
Medium
2 UT cases in group; GPU segfault on cdist backward, not a listed Core API.
symptom
functionality
Process-aborting GPU segfault from out-of-bounds write.
symptom
training
Failure is in the backward/gradient path (torch.autograd.grad of cdist).
Activity
daisyden commentedon Nov 10, 2026
label-issue: #5660
Root cause: int32
l = y / r_size,l_size = r_size * moverflow incdist_backward_kernel_impl_func(src/ATen/native/xpu/sycl/DistanceKernels.cpp:468,471,484), giving an OOB GPU write; owner torch-xpu-ops (CUDA fixed in pytorch#128791).
typeBugissue_typeempty; GPU segfault aborts the process.testtest: uttest_cdist_backward_large_indexin test/test_torch.py; no e2e/oob signal.modulemodule: opspriorityMediumfunctionalitytrainingtorch.autograd.gradof cdist).Test cases (2):
Applied to this issue. Generated by a local
label-issuerun.Use 64-bit indices in cdist backward kernel to fix large-input OOB write