-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
DifferentialEquation Op refactor #3634
DifferentialEquation Op refactor #3634
Conversation
(not yet implemented)
+ full support for test_values + explicit input/output types + 2D return shape + optional return of sensitivities + gradient without helper Op
Check out this pull request on You'll be able to see Jupyter notebook diff and discuss changes. Powered by ReviewNB. |
+ whitespace & condensed formatting + test for equality of identical Ops
(due to downcast exception)
Codecov Report
@@ Coverage Diff @@
## master #3634 +/- ##
==========================================
- Coverage 89.79% 89.78% -0.01%
==========================================
Files 134 134
Lines 20050 20088 +38
==========================================
+ Hits 18004 18037 +33
- Misses 2046 2051 +5
|
+ add notebooks to examples index
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.
Code changes look good to me!
I did not check for "scientific correctness", but it looks like it follows the old code pretty closely.
I will try to also look at the notebooks and make sure they run on my machine later today, but I am ok merging before that happens (or if I do not get to it). |
@michaelosthege This looks great! Thanks for all the effort |
Merging! Good work on this! |
The sampling for the ODE models in the notebooks all take 4+ hours to run, even on my souped-up MBP. Is this expected (and why they are unrendered)? |
@fonnesbeck Both notebooks? Even the original one which doesn't use |
I'm looking specifically at the one with the SIR and falling object examples. |
Hmm. Can confirm. Models say sampling will take approx 2.5 hours. The first example in that notebook shouldn't take longer than 10 minutes from what I remember. |
I can confirm as well. With From the relative speeds that sounds realistic, because NUTS evaluates the model several times per iteration. The absolute speed however is quite slow indeed. I will try to check out the previous version and run the same comparison. |
So here the puzzle:
Here are two hypotheses:
For reference, the approximate seconds/it/chain
Maybe my benchmark did not capture the relevant parts of the graph?
|
I found two things that look suspicious: 1.: Benchmark gradient is not representativeThe benchmark (ODE_API_shapes_and_benchmarking notebook) does a different gradient than the HMC implementation:
compared to 2.: Symbolic sensitivity handover does not work when using NUTSIf you take
The output above shows that for The following output shows that the
Finally, running NUTS gives a similar output to the one above:
Conclusion & ActionsThe failure to cache symbolic sensitivities could explain a 2x slowdown. Maybe, the internalization of the sensitivity-vector product from numpy to theano could explain the rest? @ColCarroll @aseyboldt do you have an idea how I could repair the symbolic sensitivity cache? If the sensitivity cache trick does not work with HMC gradients For re-use of Should this be impossible, Op instance re-use will cause a 2x slowdown. |
I'm continuing the discussion over in #3676 |
Why
The current implementation of the
DifferentialEquation
Op currently involves a few "hacks":compute_test_value
Changes (WIP)
The notebook
ODE_API_WIP.ipynb
implements a simple enzymatic reaction (S->P) model with sparse observations.It also has a benchmark cell that we can use for future ODE performance testing.
Finally, in the computation graph, one can see (after zooming in a lot) that the modified implementation does not use a helper Op for the gradient, but directly uses the symbolic output from the forward pass.
In a previous commit on this branch, the new refactors were benchmarked against the existing implementation. There was no significant performance difference.
ToDo