-
Notifications
You must be signed in to change notification settings - Fork 68
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
Fix rules for cholesky
and ldiv!
on Cholesky
#1307
Conversation
I went back to ChainRules.jl and copied the rule from there. As noted previously, the rules looked completely different before the change, with the Enzyme rule just accumulating the |
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files@@ Coverage Diff @@
## main #1307 +/- ##
===========================================
- Coverage 96.30% 65.76% -30.54%
===========================================
Files 8 31 +23
Lines 406 12383 +11977
===========================================
+ Hits 391 8144 +7753
- Misses 15 4239 +4224 ☔ View full report in Codecov by Sentry. |
So the reverse rule for |
@michel2323 I think the rules are now fixed. I hope you did not mind me reformatting your tests. |
cholesky
cholesky
and ldiv!
on Cholesky
Go ahead. I went over it now. Looks good to me. I never could fully match the ChainRules implementation to this paper. But that may just be me. Thanks for taking a look at this! |
I did not look at the paper in detail. Maybe their method is faster than the current implementation, which matches ChainRules.jl. We can always improve things later, in my opinion it's more important to merge a correct rule now. |
@wsmoses, I tried to follow your guidance on the |
Ok, the additional forward unit tests for |
I noticed there are still errors. Please don't merge just yet. |
Seems CI is broken on master, but before the most recent commit there were still a number of failures in the tests for these rules on v1.8 and v1.9. Do you know why these are happening? |
I could make the other activities work, but I'm not able to make the complex element type work in all cases. Will get back to it later. |
I think I may have come across a bug or at least a major annoyance: square(A) = A * adjoin(A)
A = rand(ComplexF64, 5, 5)
ishermitian(square(A)) # true
dA = rand(ComplexF64, 5, 5)
S, dS = autodiff(Forward, square, Duplicated, Duplicated(A, dA))
S ≈ square(A) # true
ishermitian(S) # false
test_forward(square, Duplicated, (A, Duplicated)) # passes So somehow the forward mode does not produce the same result as the function for |
Seems there are still random failures that I did not see locally. Will try to fix those. |
hey folks just wanted to check back in here how things were going, and if I can be of any help. admittedly the cholesky math here is a bit out of my depth |
Hi, thanks for checking. I was gonna try to fix those failures but won't have time now for a few weeks. |
@simsurace the tests seem to work on everything except 1.8. Do you have an estimate of when you can look at this? Some of the pieces are blocking for folks so I may cherry-pick out the forward mode fix, in the interim |
Hi, thanks for taking care. From next week on I should be able to get back to this. |
This PR has been partially subsumed by additional support of lapack functions. In particular we now have lapack support for cholesky solve in forward/reverse, and cholesky ldiv in reverse mode [but not forward]. All of this is limited to real numbers. This PR still contains useful functionality for complex numbers, as well as testing, but as an FYI @simsurace |
Hi @wsmoses, thanks for the heads up. This is cool. I wonder what the best way is to get this PR merged. |
At this point with the new stuff already in place in main, I might actually recommend the other way -- trying to add all these tests and seeing what fails, and then adding back the missing stuff when needed |
Closing as stale |
I had a suspicion that the existing rule was somehow off. I managed to break it with something like this:
Working on a fix...