Skip to content

[upstream #3450] [ai_generated] XPU crash on torch.linalg.ldl_solve with invalid pivots instead of raising validation error#6

Open
Stonepia wants to merge 1 commit intomainfrom
agent/issue-346
Open

[upstream #3450] [ai_generated] XPU crash on torch.linalg.ldl_solve with invalid pivots instead of raising validation error#6
Stonepia wants to merge 1 commit intomainfrom
agent/issue-346

Conversation

@Stonepia
Copy link
Copy Markdown
Collaborator

@Stonepia Stonepia commented May 7, 2026

Summary

Fix for ZhaoqiongZ/torch-xpu-ops-exp#346

Issue: [upstream pytorch#3450] [ai_generated] XPU crash on torch.linalg.ldl_solve with invalid pivots instead of raising validation error

Root Cause: torch.linalg.ldl_solve falls back to CPU on XPU via XPUFallback.template. The upstream fix (pytorch#181032) added pivot validation (1 <= |pivot| <= N) inside ldl_solve_kernel in BatchLinearAlgebraKernel.cpp, which only runs on the CPU dispatch path. When XPU is used, the fallback occurs after the IMPL function (linalg_ldl_solve_out in BatchLinearAlgebra.cpp) copies B to result and calls ldl_solve_stub with the XPU device type — but the XPU fallback dispatches down to the CPU kernel without going through the validated path first, triggering a segfault in LAPACK SYTRS before validation runs.

Failed Tests:

  • No specific test method identified; reproducer is a standalone script targeting torch.linalg.ldl_solve on XPU with out-of-range pivots.

Diff stat:

aten/src/ATen/native/BatchLinearAlgebra.cpp       | 10 ++++++++++
 aten/src/ATen/native/BatchLinearAlgebraKernel.cpp | 10 ----------
 2 files changed, 10 insertions(+), 10 deletions(-)

[upstream pytorch#3450] [ai_generated] XPU crash on torch.linalg.ldl_solve with invalid pivots instead of raising validation error
@Stonepia Stonepia marked this pull request as ready for review May 7, 2026 09:17
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.

1 participant