-
Notifications
You must be signed in to change notification settings - Fork 122
Use sparse symmetric factorization when possible #457
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
Conversation
ericphanson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mtanneau!
I see LDLFactorizations is LGPL licensed. From some brief reading it seems like that should be fine, but since it’s the first non-MIT license I wonder if any of our users would have an issue with it?
I think Invenia uses or used to use Convex, maybe @nickrobinson251 or @iamed2 knows if the license would be an issue for them?
Codecov Report
@@ Coverage Diff @@
## eph/optional_psd #457 +/- ##
====================================================
- Coverage 92.36% 92.32% -0.04%
====================================================
Files 83 83
Lines 5120 5134 +14
====================================================
+ Hits 4729 4740 +11
- Misses 391 394 +3
Continue to review full report at Codecov.
|
We're only linking against it, so we're fine. The only restriction is that, if someone distributes something that includes the source code (I think a docker image or a compiled executable would qualify), then they have to make the code of LDLFactorizations available. |
|
Invenia used to use Convex, but it also wouldn't have been a problem for us then. |
ericphanson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, thanks both!
* add `assume_psd` option to `quadform` * Use sparse symmetric factorization when possible (#457) * Use sparse symmetric factorization when possible * Address review comments * Test PSD-ness of sparse input * Fix imports and type conflicts Co-authored-by: mtanneau <9593025+mtanneau@users.noreply.github.com>
Ideally, we would be using a pure iterative method to estimate the smallest (most negative) eigenvalue of a hermitian matrix
A... similar to what they use in cvxpy.For pointer, I think we would want something like Rayleigh quotient method.
As far as I understand (though I might be wrong here), something similar is implemented in both the scipy method used by cvxpy and IterativeSolvers' invpowm when "shift-invert" mode is enabled (the same operator shows up).
While these are iterative methods, the hidden fact is that every iteration requires a left-product with
inv(A - shift * I), which would require either a factorization, or another iterative method embedded in the first.Thus, I decided to systematically use a factorization, namely, the code will attempt to factorize
A + shift*I, and if it fails or finds a negative eigenvalue,Ais declared not PSD.The last hurdle is to use an efficient factorization backend, and I try to use sparse fallbacks as much as possible.
The final fallbacks are as follows:
Ais sparse and real-valued, I use LDLFactorizationsAis sparse andComplex{Float32}orComplex{Float64}-valued, I use SuiteSparseThe tolerance for negative eigenvalues is the parameter
tol, which is set to the square-root of the machine precision, after conversion to floating-point and real as appropriate.