-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Support Scans in CustomDist
#6696
Conversation
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.
When reviewing I slowed down at find_default_update
inside collect_default_update
. This entire local function can be extracted which would make it a lot easier to review & test.
Overall it looks good, but I'd recommend to add some comments to make it comprehensible without knowing the context of this PR.
It's the inner recursive function, I don't think it makes sense to be outside of the initial caller function. |
6fa3a31
to
3710b69
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6696 +/- ##
===========================================
- Coverage 92.01% 81.02% -10.99%
===========================================
Files 95 95
Lines 16180 16176 -4
===========================================
- Hits 14888 13107 -1781
- Misses 1292 3069 +1777
|
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 think I understand what's going on here. The key change is just to add a check for Scan
Op
s and, if so, reach into the outer_out_from_outer_inp
mapping and grab the rng
object, raising an error if it's not found.
I also found the function inside recursive function a bit unusual. This SO thread claims there is some overhead associated with doing things this way, so I'm wondering if that would matter in a worst-case recursion (very big graph? multiple scans?).
Otherwise looks good to me. I would second a bit of documentation in the functions -- a general complaint I have about the Theano codebase is a lack of useful docstrings.
Yup
I think that's only meaningful when you are calling the outer function many times, in this case the outer function is called once and then the inner function is called multiple times. Also this is not performance critical code at all since it's done once before compiling a pytensor function. The compilation is orders of magnitude more expensive than this one time graph recursion. And this compilation is itself order of magnitude faster than the presumed heavy use of the final compiled function. The comments in that thread seem to agree with this. One user also mentions the uncluttering of the module namespace which is the main motivation I had.
Sure |
3710b69
to
4e6510f
Compare
This comment was marked as outdated.
This comment was marked as outdated.
4e6510f
to
2977ba8
Compare
This allows proper seeding in CustomDists with Scans
2977ba8
to
5532cb2
Compare
Updated docstrings and added one code example |
Here is how one can now write an AR with StudentT innovations:
The part that was not supported was that we would not be able to collect the update for the scan (used in prior/posterior predictive), and the user had no way of specifying it manually either.
📚 Documentation preview 📚: https://pymc--6696.org.readthedocs.build/en/6696/