Skip to content

Enable _linalg_det, _linalg_slogdet and _linalg_solve_ex related operations on xpu #1660

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

huiyan2021
Copy link
Contributor

@huiyan2021 huiyan2021 commented May 14, 2025

This pull request stacks on #1563. It introduces support for _linalg_det, _linalg_slogdet and _linalg_solve_ex related operations on XPU devices:

  • _linalg_det & _linalg_det.result
  • _linalg_slogdet & _linalg_slogdet.sign
  • '_linalg_solve_ex' & _linalg_solve_ex.result

It also removes fallback implementations for these operations in favor of optimized XPU-specific implementations. Corresponding tests have been updated to reflect the new support.

New XPU Kernel Implementations:

Since _linalg_det, _linalg_slogdet and _linalg_solve_ex call linalg_lu_factor_ex.out underneath, which has been implemented in #1563, no new kernels need to be added in this pull request. Only dispatching these operations in third_party/torch-xpu-ops/yaml/native/native_functions.yaml would work.

Removal of Fallbacks:

Removed fallback entries for _linalg_det, _linalg_slogdet and _linalg_solve_ex related operations from third_party/torch-xpu-ops/src/ATen/native/xpu/XPUFallback.template. These operations now have dedicated XPU implementations.

Test Adjustments:

Updated the skip list in test/xpu/skip_list_common.py to remove passed and removed linalg_det, linalg_slogdet and _linalg_solve_ex related UTs.

Fix #1597

@huiyan2021 huiyan2021 requested a review from Copilot May 14, 2025 09:02
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces optimized XPU-specific support for determinant and sign/log-determinant operations by dispatching to dedicated XPU kernels and removing fallbacks. It also updates the test suite and skip lists accordingly to reflect the new support.

  • Added YAML entries for _linalg_det and _linalg_slogdet with structured delegates and XPU-specific dispatch.
  • Updated test files to include new LU-family and LU-solve tests while removing obsolete fallback tests.
  • Removed fallback implementations and adjusted skip lists in test files.

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
yaml/native/native_functions.yaml Added structured function entries for _linalg_det and _linalg_slogdet with XPU dispatch support.
test/xpu/test_linalg_xpu.py Introduced new tests for LU-family and LU-solve operations; refactored imports and test registration.
test/xpu/skip_list_common.py Removed skip tests related to linalg_det and linalg_slogdet operations.
src/ATen/native/xpu/mkl/BatchLinearAlgebra.h Defined new MKL-based linear algebra function prototypes for XPU.
src/ATen/native/xpu/BatchLinearAlgebra.cpp Added XPU kernel implementations for SVD, LU solve, and LU factor with CPU fallback support.
Files not reviewed (1)
  • src/ATen/native/xpu/XPUFallback.template: Language not supported

@huiyan2021 huiyan2021 requested review from CuiYifeng and xytintel May 14, 2025 09:05
@huiyan2021 huiyan2021 changed the title Enable _linalg_det and _linalg_slogdet related operations on xpu Enable _linalg_det, _linalg_slogdet and _linalg_solve_ex related operations on xpu May 22, 2025
@CuiYifeng CuiYifeng force-pushed the huiyan/linalg_det branch 2 times, most recently from a33b0a8 to a37b03e Compare May 23, 2025 03:02
Comment on lines 9379 to 9387
- func: lu_unpack(Tensor LU_data, Tensor LU_pivots, bool unpack_data=True, bool unpack_pivots=True) -> (Tensor P, Tensor L, Tensor U)
structured_delegate: lu_unpack.out
variants: function

- func: lu_unpack.out(Tensor LU_data, Tensor LU_pivots, bool unpack_data=True, bool unpack_pivots=True, *, Tensor(a!) P, Tensor(b!) L, Tensor(c!) U) -> (Tensor(a!) P, Tensor(b!) L, Tensor(c!) U)
variants: function
structured: True
dispatch:
CPU, CUDA: lu_unpack_out
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@huiyan2021 Some missing code, right? Found in the commit enable _linalg_det and _linalg_det.result on xpu.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These come from original #1563, will rebase after #1563 has been merged.

@CuiYifeng CuiYifeng force-pushed the huiyan/linalg_det branch from a37b03e to aadfc3a Compare May 28, 2025 17:29
@CuiYifeng CuiYifeng requested a review from Copilot May 28, 2025 17:30
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables optimized XPU support for linalg determinant, sign-logdet, and solve_ex functions by registering new dispatch entries and removing legacy fallback implementations.

  • Added dispatch entries with structured delegates for _linalg_det, _linalg_slogdet, and _linalg_solve_ex in yaml/native/native_functions.yaml.
  • Removed corresponding fallback entries and updated the test skip list in test/xpu/skip_list_common.py to reflect that these operations are now supported on XPU.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
yaml/native/native_functions.yaml Introduced new dispatch entries and structured delegates for determinant, slogdet, and solve_ex operations.
test/xpu/skip_list_common.py Removed skip list entries for linalg_det, linalg_slogdet, and linalg_solve_ex tests.
Files not reviewed (1)
  • src/ATen/native/xpu/XPUFallback.template: Language not supported

@xytintel xytintel requested a review from CuiYifeng May 29, 2025 01:19
@CuiYifeng CuiYifeng added the mkl label May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement aten::_linalg_solve_ex.result on xpu
2 participants