-
Notifications
You must be signed in to change notification settings - Fork 55
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
Implement the canonical metric on the Stiefel manifold #335
Conversation
…nical metric on manifolds.
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 haven't looked at this super closely, but I had some suggestions to reduce allocations and improve efficiency
Co-authored-by: Seth Axen <[email protected]>
Co-authored-by: Seth Axen <[email protected]>
…ces a bug (see JuliaPlots/Plots.jl#3341) in the next version
Hm, setting plots to Similarly, I can also not convince the documenters |
Codecov Report
@@ Coverage Diff @@
## master #335 +/- ##
==========================================
- Coverage 97.63% 97.62% -0.02%
==========================================
Files 74 76 +2
Lines 5794 5848 +54
==========================================
+ Hits 5657 5709 +52
- Misses 137 139 +2
Continue to review full report at Codecov.
|
I just checked your code – at one point the small/economic Q or QR was expanded to the full one, which I would avoid using a view – and I forgot one line of code. Now testing should work and cover all new functions. |
I am not yet sure, whether the inner for loop is now correct. In the old form I
Though I am still looking for an example that
I wrote the author of the algorithm about that last point. |
Co-authored-by: Mateusz Baran <[email protected]>
some strange autocorrect (German past participle of “sein” - to be) who I meant to type |
My only issue with introducing that on a generic level is that last time I checked Julia did a relatively poor job at optimizing out kwargs. Maybe it's better now, I'll have to check it carefully before this change is made. |
Sure. I am also not 100% sure a global level would be that good, also for further usage (in algorithms say). We can keep it the current way for not, surely. |
Regarding the failure on Julia 1.4, I think it's fine to check ambiguities only on Julia >=1.5. By the way, Julia nightly also has a similar problem: JuliaLang/julia#37711 . |
Ok, I till change that as soon as I find time to look for the remaining code lines to be covered. |
Perhaps unrelated, but the ambiguity test stackoverflows for me on Windows only on Julia 1.5: https://github.com/JuliaManifolds/Manifolds.jl/pull/249/checks?check_run_id=2093697330#step:5:329. |
Yes, here in the checks the same happens for Julia 1.4, seems to be unrelated, though I have not yet seen how to fix that. |
So with the commit from today this should be feature complete and all new lines tested. If you could take another look and check if all changes are good and the changes are good, that would be great. Concerning the avoidance of allocations, the only thing I had to revert is the use of |
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.
Just a few comments and a few more allocation-reductions. There are more allocations that can be removed using e.g. qr!
but I don't think they'll have a huge impact on performance, and it's less likely that qr!
will be overloaded for some special matrix than qr
will be.
n == k && return mul!(q, p, exp(A)) | ||
QR = qr(X - p * A) | ||
BC_ext = exp([A -QR.R'; QR.R 0*I]) | ||
q .= [p Matrix(QR.Q)] * @view(BC_ext[:, 1:k]) |
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.
If you blockwise multiply here, then instead of the 3 allocations here, I think you can do with none.
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.
How would I do that? I twiddled so much with these few lines of code, before and after your allocation reduction (about 2 days to find that we can not use the svd!
) that I don't see directly how to do this block wise.
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'll take a stab at it.
Co-authored-by: Seth Axen <[email protected]>
…aManifolds/Manifolds.jl into kellertuer/steifel-canonical-metric
I don't feel comfortable currently trying that after it took me two full days changing to |
Should we maybe deactivate the windows test or at least ambiguities thereon until it has come to conclusion not to do stack overflows when looking for those? |
Oh, I meant to say that these changes are probably not worth the code complexity or effort. I'm sorry for not being clear. |
This is probably a good idea. |
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.
Assuming tests pass and you approve of the changes, I think this is ready to merge. Nice work!
…aManifolds/Manifolds.jl into kellertuer/steifel-canonical-metric
This PR adds a second metric to the Stiefel Manifold that provides both a exp and a log map.