Repository navigation
[XPU] Register _spsolve for the SparseCsrXPU backend - #97
Open
laifenxiawucha wants to merge 1 commit into
Open
laifenxiawucha wants to merge 1 commit into
laifenxiawucha wants to merge 1 commit into
Conversation
torch.sparse.spsolve (aten::_spsolve) previously had only a SparseCsrCUDA dispatch, so on XPU it raised "Could not run 'aten::_spsolve' with arguments from the 'SparseCsrXPU' backend". Add a SparseCsrXPU dispatch entry mapping to _sparse_csr_linear_solve_xpu, mirroring the existing SparseCsrCUDA registration. The XPU kernel is implemented out-of-tree in torch-xpu-ops (densify + at::linalg_solve, mirroring the cuDSS backend contract). Verified on Intel Data Center GPU Max 1100 (source build, torch 2.14.0a0): with this dispatch line plus the torch-xpu-ops kernel, torch.sparse.spsolve returns the correct identity solve and a 5-case regression suite passes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enables
torch.sparse.spsolveon Intel XPU.aten::_spsolvepreviously had only aSparseCsrCUDAdispatch, so on XPU it raised:This adds the
SparseCsrXPUdispatch line (one line), mirroring the existingSparseCsrCUDAregistration:Coordinated out-of-tree change
The XPU kernel
_sparse_csr_linear_solve_xpuis implemented in torch-xpu-ops (intel-sandbox/torch-xpu-ops-exp#1965): since XPU has no native sparse direct solver, it densifies the CSR matrix and defers to the denseat::linalg_solve, mirroring the CUDA cuDSS backend's semantics and validation contract. That PR also carries the identical dispatch line in the torch-xpu-ops codegen yaml (astriangular_solvealready does across both yamls).Verification (Intel Data Center GPU Max 1100, source build
torch 2.14.0a0)With this dispatch line plus the torch-xpu-ops kernel built in:
torch.sparse.spsolveon an identity CSR system returns[1,1,1,1](was: dispatchRuntimeError).test_spsolve_sparse_csr.pypasses 5/5 (identity, dense reference + residualA@x==b, CPU-dense parity, float32, size-mismatch error).🤖 Generated with Claude Code