Hi!,
I am currently working on integrating the new CuSolver XGeev Eigendecomposition into PyTorch.
As my code is mostly working, I have moved on to testing.
Now I did some testing on my own. I mainly checked if the eigenvectors and eigenvalues fulfill the eigenvalue equation
![]()
This seems to be the case, I get deviations in the order of magnitude of the numerical precision of the used datatype. However, when I am running the official tests, I am getting multiple failures in TestLinalgCUDA.test_eig_compare_backends_cuda_…
I am not entirely sure, but I think that the tests might not be mathematicaly valid. The tests just compare the eigenvalues to each other elementwise. However, eigenvalues are not unique. The documentation seems to reflect that:
The returned eigenvectors are normalized to have norm 1. Even then, the eigenvectors of a matrix are not unique, nor are they continuous with respect to A. Due to this lack of uniqueness, different hardware and software may compute different eigenvectors.
This non-uniqueness is caused by the fact that … produces another set of valid eigenvectors of the matrix. For this reason, the loss function shall not depend on the phase of the eigenvectors, as this quantity is not well-defined. This is checked when computing the gradients of this function. As such, when inputs are on a CUDA device, the computation of the gradients of this function synchronizes that device with the CPU.
(https://docs.pytorch.org/docs/stable/generated/torch.linalg.eig.html)
Therefore, I think this test might be disregarded, and it only worked until now, because MAGMA performed most of its eigenvalue decomposition on the CPU, and that happened to cause the Eigenvalues to be similar.
I would love to hear from someone who has worked more with the different implementations of the eigenvalue problem in MAGMA and on CPU, as I am not entirely sure if my deduction is correct. If it is, I think we could probably move to a pure mathematical test, that is testing if the number of values matches the ones from CPU and if all the eigenvalues fulfill the eigenvalue equation within the expected accuracy of the datatype.
Happy for any input!
Best
Johannes