-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
module: correctness (silent)issue that returns an incorrect result silentlyissue that returns an incorrect result silentlymodule: cudaRelated to torch.cuda, and CUDA support in generalRelated to torch.cuda, and CUDA support in generalmodule: linear algebraIssues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmulIssues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmultriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🐛 Bug
The cuSOLVER path in torch.inverse
seems not to raise an error for non-invertible input.
To Reproduce
Single matrix and 2xNxN batched input inversion is based on cuSOLVER
import torch
batch_dim = 2
A = torch.eye(3, 3, dtype=dtype, device=device)
A = A.reshape((1, 3, 3))
A = A.repeat(batch_dim, 1, 1)
A[0, -1, -1] = 0 # Now A[0] is singular
Ainv = torch.inverse(A) # Doesn't raise errors Ainv[0] contains NaNs
General batched input case is based on MAGMA
import torch
batch_dim = 3
A = torch.eye(3, 3, dtype=dtype, device=device)
A = A.reshape((1, 3, 3))
A = A.repeat(batch_dim, 1, 1)
A[0, -1, -1] = 0 # Now A[0] is singular
Ainv = torch.inverse(A) # Raises RuntimeError because input is singular
Expected behavior
torch.inverse
should raise an error for singular input when input is single matrix or a batch of matrices with batch size less or equal than 2 (cuSOLVER's code path).
cc: @xwang233
cc @ngimel @vishwakftw @jianyuh @nikitaved @pearu @mruberry @heitorschueroff
xwang233
Metadata
Metadata
Assignees
Labels
module: correctness (silent)issue that returns an incorrect result silentlyissue that returns an incorrect result silentlymodule: cudaRelated to torch.cuda, and CUDA support in generalRelated to torch.cuda, and CUDA support in generalmodule: linear algebraIssues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmulIssues related to specialized linear algebra operations in PyTorch; includes matrix multiply matmultriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module