-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Allow CustomDist with inferred logp in Mixture #6746
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9eb1f25
to
ea68b01
Compare
ricardoV94
commented
May 31, 2023
adfb3bf
to
fe3ed61
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6746 +/- ##
==========================================
- Coverage 91.99% 90.48% -1.51%
==========================================
Files 95 95
Lines 16205 16125 -80
==========================================
- Hits 14907 14591 -316
- Misses 1298 1534 +236
|
628008f
to
afe476b
Compare
950494a
to
8529ff0
Compare
8529ff0
to
90e17c0
Compare
5 tasks
This commit changes the logic used for logprob inference. Instead of eager bottom-up conversion to measurable variables in the IR rewrites, we only convert nodes whose outputs were marked as "needs_measuring". This is achieved with the new `PreserveRVMappings.request_measurable` method. This strategy obviates the need to undo unnecessary conversions. It also obviates a subtle need for graph cloning via the `ignore_logprob` helper, which prevented intermediate measurable rewrites from being reversed when they were needed to derive the logprob of valued variables, but were not directly valued. This indirect role of `ignore_logprob` is now done more explicitly and efficiently via the `request_measurable` method. All other uses of `ignore_logprob` (and `reconsider_logprob`) were removed from the codebase The `get_measurable_outputs` dispatching was also abandoned in favor of only considering outputs associated with value variables. A new MergeOptimizerRewrite was written to further target local rewrites to only those nodes whose variables have been marked as `needs_measuring`.
90e17c0
to
3dd6dcb
Compare
Join/MakeVector/IfElse can output multiple interdependent variables. These are potentially measurable because in the logp each output is given a distinct value variable. However, this isn't known during the IR rewrites. To circumvent this issue, we run an inner IR rewrite after giving dummy value variables to each output
3dd6dcb
to
b23ec35
Compare
twiecki
approved these changes
Jun 5, 2023
5 tasks
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes the logic used for logprob inference. Instead of eager bottom-up conversion to measurable variables in the IR rewrites, we only convert nodes whose outputs were marked as "needs_measuring". This is achieved with the new
PreserveRVMappings.request_measurable
method.This strategy obviates the need to undo unnecessary conversions. It also obviates a subtle need for graph cloning via the
ignore_logprob
helper, which prevented intermediate measurable rewrites from being reversed when they were needed to derive the logprob of valued variables, but were not directly valued. This indirect role ofignore_logprob
is now done more explicitly and efficiently via therequest_measurable
method.All other uses of
ignore_logprob
(andreconsider_logprob
) were removed from the codebaseThe
get_measurable_outputs
dispatching was also abandoned in favor of only considering outputs associated with value variables.A new MergeOptimizerRewrite was written to further target local rewrites to only those nodes whose variables have been marked as
needs_measuring
. This should be rather more efficientCloses #6728
Supersedes #6698
CC @shreyas3156 @Dhruvanshu-Joshi
📚 Documentation preview 📚: https://pymc--6746.org.readthedocs.build/en/6746/