-
Notifications
You must be signed in to change notification settings - Fork 46
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
WIP: Add specifications for computing eigenvalues and eigenvectors #113
Conversation
One thought following the resolution #105 could be that we still accept this PR to define the signatures clearly, but say that the actual standardization will come along with the complex number support in the next version of Array API. This way the array libraries like CuPy which already support complex number can work out the support very quickly. |
One thing interesting (which I mentioned in today's meeting) is that ROCm currently does not provide an eigensolver for general Hermitian matrices, only for tridiagonal matrices: https://rocsolver.readthedocs.io/en/latest/userguide_api.html#eigensolvers. |
|
Yes, working out the signatures that we expect to add to the next version makes sense to me. |
@rgommers I am guessing that Torch's decision to use |
Yes indeed, just for compat. API design wise |
0607525
to
138e963
Compare
I have been doing the annual linalg check of SciPy overhaul and currently linalg.eig is underway. It seems to me that At the face value this might seem like a regression but as I recently convinced myself about it, it really doesn't add anything interesting because the array is already allocated. In fact the rectangular packing or other ways of allocating the array is way more economical instead of forcing eig or eigh to serve every use case in every library. Hence I'd definitely recommend checking out the options for low level 1D storage of half triangle data should there be a need for this. Similarly, eigvals and eigvalsh is, I think, just API clutter. eig and eigh is in my opinion just good enough with already We have always been looking at these functions as the thin-wrappers of the LAPACK routines but I think we should clearly separate the UX of Python funcs I'm curious to what others think about this. |
@kgryte I assume this PR has a successor and so can be closed? |
@leofang Yeah, we should probably just close this one out and create a new PR for the relevant APIs, rather than try to retrofit the current PR. |
This PR is currently a WIP.
This PR
Notes
This PR is blocked by lack of complex number support. Real-valued matrices may have complex-valued eigenvalues, so limiting inputs to real-valued arrays is not sufficient. Torch currently returns an
nx2
eigenvalue matrix, where each row consists of a real and an imaginary component. This is a possibility, but would seem more prudent to hold off until complex number support is included in the spec.In contrast to NumPy's
UPLO
keyword pattern (following LAPACK), this PR follows Torch and uses anupper
keyword to have better consistency with other linalg spec'd functions.Open question whether a separate
eigvals
API is needed in addition toeig
. For example, in SciPy, can setleft
andright
toFalse
to only return eigenvalues. Presumably something similar could be done here to consolidate into a single API.Open question whether, like SciPy, the spec should support returning either
left
orright
or both eigenvectors. Supporting one or both is supported outside of the PyData ecosystem (e.g., in LAPACK and MATLAB).