-
-
Notifications
You must be signed in to change notification settings - Fork 235
Fix inability to use sparse Jacobian with colorvec for OOP #1049
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
Codecov Report
@@ Coverage Diff @@
## master #1049 +/- ##
==========================================
+ Coverage 76.87% 77.02% +0.14%
==========================================
Files 95 95
Lines 31107 31044 -63
==========================================
- Hits 23914 23911 -3
+ Misses 7193 7133 -60
Continue to review full report at Codecov.
|
|
Thanks! Can we get a test on this? |
|
Which file to add the test? |
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 a lot! Maybe we should add the interface factorization(A) -> FactorizationType in ArrayInterface.
Yeah, that's what would need to happen. |
|
I'll add some tests and update the PR to use Yingbo's ArrayInterface changes. |
test/interface/sparsediff_tests.jl
Outdated
| for prob in map(f->ODEProblem(f,u0,tspan), | ||
| [ODEFunction(f,colorvec=colors,jac_prototype=jac_sp), | ||
| ODEFunction(f,jac_prototype=jac_sp), | ||
| #ODEFunction(f,colorvec=colors) # this one fails both the u[end] and length tests |
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.
Any idea why the commented-out test would behave differently?
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.
Because one must have sparsity to get sparse jacobian work appropriately.
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.
Is this still the case now with our update? Because some tests still behave erratically.
|
This will now fail tests because it needs JuliaArrays/ArrayInterface.jl#39. I added some tests but I don't know to test the type of the used Jacobian. Oh, and I should add OOP tests... Edit: ok some tests are failing locally, so, it will need some more work. |
e30ce3e to
8ac8574
Compare
- tests are failing for SDIRK methods, needs investigating
8ac8574 to
b7b1cb6
Compare
| isbroken = i==3 && ( | ||
| (f, ad, tol) == (f_oop, true, nothing) || | ||
| (f, ad, Solver, tol) == (f_oop, false, Trapezoid, nothing) || | ||
| (f, Solver, tol) == (f_ip, Trapezoid, nothing) || | ||
| (f, Solver) == (f_oop, Rodas5) || | ||
| (f, Solver) == (f_ip, Rodas5) || | ||
| (f, Solver) == (f_oop, KenCarp4) || | ||
| (f, Solver) == (f_ip, KenCarp4) | ||
| ) |
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.
These failing tests need investigation.
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 wouldn't expect colors without sparsity to work.
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.
IMO, the color stuff should be independent of the matrix type of J.
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.
These are still "broken".
|
The tests failed because the Jacobians sometimes got converted to dense arrays. I updated all the instances where I think that occurred. However, I do not fully understand the code, so this needs a careful review! Also note that with JuliaArrays/ArrayInterface.jl#39, CI should now pass. (Although I haven't run the full test suite locally... but the new tests did pass locally.) |
| ODEFunction(f,colorvec=colors) | ||
| ])) | ||
| isbroken = i==3 && ( | ||
| (f, ad, tol) == (f_oop, true, nothing) || |
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.
all with AD fail?
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.
Only those with ODEFunction(f,colorvec=colors), and Trapezoid passes there too. Note that they are not completely wrong, just about a factor 10 larger (different) error.
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 had a closer look at the broken tests:maximum(sol_std.u[end].-sol.u[end]) is around 1e-5 for tol=1e-10 and around 1e-3 for tol=nothing.
|
It looks like that this touches a lot of the code from PR #937 of @huanglangwen. Maybe @huanglangwen has time to look at this? |
|
Tests will fail because it now needs SciML/DiffEqBase.jl#449. |
|
The tests pass (apart from https://travis-ci.org/JuliaDiffEq/OrdinaryDiffEq.jl/jobs/658621217?utm_medium=notification&utm_source=github_status, which is due to SciML/DiffEqBase.jl#449 needing changes in DelayDiffEq) and I think this is ready to be merged. For the broken tests, I would suggest to create an issue to not forget about them. |
As discussed on slack, this allows to use a sparse jacobian for out-of-place objective functions. This works for my case but probably could be done more general.
The solve time of https://gist.github.com/mauro3/e85c85a4257a46ed73999b08f9b80ec2 (a FD PDE code) improves from >100s to <1s with this PR.