-
-
Notifications
You must be signed in to change notification settings - Fork 236
Improve performance with sparse Jacobians #4037
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
base: master
Are you sure you want to change the base?
Conversation
|
Alternatively, if you think the bounds check should be preserved for safety, I suggest to change it to check only the number of nonzero entries, and not the correctness of every index. Something like |
fe2296b to
e14cc64
Compare
AayushSabharwal
left a comment
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 for the contribution! I think this definitely makes sense. I have just a couple minor suggestions below. Could you also add this case to the benchmark script? We can then notice future regressions.
|
Good idea, I will try to make an example that doesn't need any external dependencies and add it to the benchmarks. |
|
I think these are the benchmark results, although they fail to be posted here? Copy-paste: println(replace(copypasta, "\\n" => "\n"))Benchmark Results (Julia vlts)Time benchmarks
Memory benchmarks
|
|
Yeah, the workflow isn't able to comment if the PR comes from a fork. I don't yet know how to fix that. |
|
You might have to update some of the tests for this - they expect an |
|
Got it. Running those failing tests locally segfaults instead of giving me a |
|
I set |
|
That makes sense for the test. |
|
I believe the tests are ok now. |


I noticed two things when profiling with sparse+analytical Jacobians generated by MTK in my package:
ODEProblem(...; jac = true, sparse = true)is spent inside thisiszerocheck:solveis slowed by this sparsity pattern check every time the analytically generated Jacobian function is called:I suggest two changes:
iszeroaltogether. It is used when nonzeros of W are explicitly stored in J. But this can be done equivalently by recreating the sparse Jacobian in(I, J, V)-form with explicit zeros added at all of W's nonzero entries.checkbounds = true. I am sure there are also other ways to solve this.With these changes, the respective sections of the flamegraph disappear and the timings improve:
to
Checklist
contributor guidelines, in particular the SciML Style Guide and
COLPRAC.