-
Notifications
You must be signed in to change notification settings - Fork 27.7k
torch.cholesky fails exceedingly slow on non-pd matrices #34272
Copy link
Copy link
Closed
Labels
module: 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 matmulmodule: performanceIssues related to performance, either of kernel code or framework glueIssues related to performance, either of kernel code or framework gluetriagedThis 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
Metadata
Metadata
Assignees
Labels
module: 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 matmulmodule: performanceIssues related to performance, either of kernel code or framework glueIssues related to performance, either of kernel code or framework gluetriagedThis 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
🐛 Bug
If a tensor is not positive definite,
torch.choleskytakes forever to raise an error. In the example below it takes almost 100 times longer to raise an error than to actually perform the decomposition for a positive definite matrix of the same size. That happens even if the matrix has evals far from zero, or if the matrix is far from symmetric.This is really problematic, since attempting a Cholesky decomposition is a standard way of determining whether a matrix is positive definite.
To Reproduce
Runtime is comparable
Time for catching failure is not at all
Even if the matrix has only very negative evals
Things look bleak even if the matrix is not symmetric
Expected behavior
Should fail fast.
Environment
Can reproduce this both on MacOS on the latest conda package and on FB infra.
cc @vincentqb @vishwakftw @jianyuh @nikitaved @pearu @VitalyFedyunin @ngimel @nazanint (who brought this to my attention), @vishwakftw, @gchanan