-
Notifications
You must be signed in to change notification settings - Fork 89
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
Add rules for Symmetric/Hermitian eigen and svd #323
Conversation
Codecov Report
@@ Coverage Diff @@
## master #323 +/- ##
===========================================
- Coverage 97.64% 84.56% -13.08%
===========================================
Files 18 18
Lines 1018 1017 -1
===========================================
- Hits 994 860 -134
- Misses 24 157 +133
Continue to review full report at Codecov.
|
In the interest of getting this merged, I have added I think sufficient comments and references. A later PR can always add more about phase/normalization conventions. @willtebbutt could you re-review? |
The CI errors are unrelated to this PR and due to JuliaDiff/FiniteDifferences.jl#133. |
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.
I'm not going to pretend that I follow the details of the implementations, but I'm satisfied that what is implemented has been tested properly, so I'm happy to approve.
I've requested a couple of additional bits of documentation in the test sets because I had to squint to figure out what was being tested in each block and, since this is a comparatively complicated new bit of code, I feel that signposting what's going on is quite important. Would you mind making similar readability improvements to all of the testsets that you've added?
Done! Thanks! |
875: Remove eigen and eigvals adjoints for Symmetric/Hermitian r=DhairyaLGandhi a=sethaxen JuliaDiff/ChainRules.jl#323 added rrules for `eigen` and `eigvals` for Symmetric/Hermitian matrices. This PR removes those rules from Zygote. Once the old tests pass, I'll remove them, since the rrules are more thoroughly tested. Depends on JuliaRegistries/General#27508 is merged. Co-authored-by: Seth Axen <[email protected]>
* Add symmetric/hermitian eigendecomposition rules * Add utility functions * Add frules and rrules for sym/herm power series * Add int pow rules * Add sincos rules * Remove unused function argument * Fix and comment _nonzero * Make methods and signatures less ambiguous * Handle Zero() better * Standardize notation * Remove parens * Update src/rulesets/LinearAlgebra/structured.jl Co-authored-by: Nick Robinson <[email protected]> * Fix for Julia 1.0 * Use correct variable and method name * Accumulate in the triangle in the pullback * Remove comment * Add eigen and eigvals tests * Remove outdated comment * Clean up and make constraint functions faster * Make outputs of int pow of Hermitian are Hermitian * Fix typo in comment * Test most power series functions * Don't thunk tangents * Make type-stable and use optimal threshold * Split out symmetric/hermitian methods/tests * Use correct pullback of hermitrization * Stabilize eigenvector computation * Test composed pullback * Remove all eigendecomposition rules Moved to #323 * Move to utilities section * Move to utilities section * Separate shared code into its own function * Don't thunk * Use correct function name * Correctly broadcast * Remove power rules * Rename to matrix functions * Remove pow tests * Expand test suite * Remove sincos rules for now * Add references and comments * Add _isindomain * Refactor _matfun Return cache and handle type-unstable case * Add _matfun_frechet * Broadcast instead of indexing * Add comments and use indexing from paper * Handle Zeros * Contrain differentials according to primals * Support all matrix functions * Remove unused methods * Support Symmetric{Complex} * Add rules for sincos * Make atanh rule type-stable * Correctly test type-unstable functions * Use correct denominator * Add tests for almost-singular and low-rank matrices * Remove out-dated comments * Test alternate differentials * Don't use only * Remove _hermitrizeback! * Don't use hasproperty, not in old Julia versions * Reduce allocations * simplify section name * Simplify line * Handle mixture of non-Zero and Zero * Don't loop over unused functions * Test against component frules instead of fd * Test that rules produce same uplo as primal * Apply suggestions from code review Co-authored-by: Lyndon White <[email protected]> * Reuse variable name In this case it is type-stable * Use bang bang convention for maybe-in-place * Don't assume the wrapped matrix is mutable * Replace hermitrize! * Use diagind * Remove handling of Zero differential * Unify symbols * Use hasproperty * Load hasproperty from Compat * Replace refs with one to Higham * Add docstrings * Update src/rulesets/LinearAlgebra/symmetric.jl Co-authored-by: Lyndon White <[email protected]> * Increment version number * Use utility function * Stabilize jvp Jacobian dimensions * Don't use non-exported function * Bump required ChainRulesCore Co-authored-by: Nick Robinson <[email protected]> Co-authored-by: Lyndon White <[email protected]>
This PR adds
frule
s foreigen!
andeigvals!
andrrule
s foreigen
,eigvals
,svd
, andsvdvals
forHermitian
or realSymmetric
inputs. The rules for theeigen
functions are similar to those in #321 but are more efficient due to known types and unitary eigenvectors. Thesvd
functions are added because their primals in base call mutating functions, which will miss theeigen
rules, hence we don't need to add correspondingfrule
s.This PR will eventually also fix the normalization convention issue noted in #321, so it depends on that PR.