-
Notifications
You must be signed in to change notification settings - Fork 43
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 sparse Hessian decompression #190
Conversation
Codecov Report
@@ Coverage Diff @@
## master #190 +/- ##
==========================================
+ Coverage 79.94% 81.14% +1.20%
==========================================
Files 14 15 +1
Lines 753 801 +48
==========================================
+ Hits 602 650 +48
Misses 151 151
Continue to review full report at Codecov.
|
- Include a ForwardDiff.GradientConfig in the ForwardColorHesCache to eliminate allocations - Reduce the number of signatures for forwarddiff_color_hessian to the minimum needed to match forwarddiff_color_jacobian - Get rid of default arguments for colorvec and sparsity for now
|
1 |
I currently have two signatures for
There are also two corresponding signatures for |
started implementing an "All-One" array, decided not worth the complexity at this point
Make sure it has the right signature, modify to accept GradientConfig if needed. Also some tests for it.
Ok, I think this is getting pretty close. @ChrisRackauckas when you've got a second, lemme know what else you think it needs and I'll try to take care of it! |
Also change order to put optional argument last
hes_cache.grad!(hes_cache.dG, x, hes_cache.grad_config) | ||
x .-= ϵ .* @view hes_cache.D[:, j] | ||
hes_cache.buffer[:, j] .= (hes_cache.dG .- hes_cache.G) ./ ϵ |
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.
hes_cache.grad!(hes_cache.dG, x, hes_cache.grad_config) | |
x .-= ϵ .* @view hes_cache.D[:, j] | |
hes_cache.buffer[:, j] .= (hes_cache.dG .- hes_cache.G) ./ ϵ | |
hes_cache.grad!(hes_cache.dG, x, hes_cache.grad_config) | |
x .-= 2ϵ .* @view hes_cache.D[:, j] | |
hes_cache.buffer[:, j] .= (hes_cache.dG .- hes_cache.G) ./ 2ϵ |
If you're not going to use a cached f
here, is there a reason to not do a central difference?
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.
The only reason not to is because it modifies x
three times as opposed to two, saving a little time. However, profiling shows that the time saved is only ~2% of the total, and the centered difference decreases error by more than 10x, so a worthwhile tradeoff. Changed as suggested.
Can you clarify what you mean by "use a cached f
?"
Is this still WIP? Looks close to done. |
Following up on #142, this is a basic implementation of sparse Hessian decompression using matrix coloring. (See also SciML/Optimization.jl#269.) Basic interface is modeled on the existing one for Jacobians; it includes
forwarddiff_color_hessian
andforwarddiff_color_hessian!
methods for in-place and out-of-place computations, and aForwardColorHesCache
type containing buffers for computation. Feedback welcome!To do: