-
-
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
Implement Symbolic RVs #6072
Implement Symbolic RVs #6072
Conversation
a315834
to
d369158
Compare
Codecov Report
@@ Coverage Diff @@
## main #6072 +/- ##
==========================================
- Coverage 91.74% 89.67% -2.07%
==========================================
Files 86 72 -14
Lines 17692 12953 -4739
==========================================
- Hits 16232 11616 -4616
+ Misses 1460 1337 -123
|
825e90b
to
be4de60
Compare
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.
Very nice work Ricardo! I skimmed through things and left a bunch of comments. Once you think this isn’ta draft anymore I’ll do a more thorough review of the tests. Did anything change in aeppl or aesara to enable this?
I'll re-request your review then.
Nope. It's all PyMC insfrastructure. |
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.
This is amazing @ricardoV94! 🙂 I feel like having an explicit SymbolicRandomVariable
class would make the code structure of symbolic distributions much more clear.
Would #5931 need to be first merged before this PR?
be4de60
to
cfd80bb
Compare
7ad9621
to
7fcaa2a
Compare
I don't think so |
bc2c07d
to
61a4bb7
Compare
The failing |
61a4bb7
to
754fb97
Compare
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.
Excellent work Ricardo! I like that everything is cleaner now.
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.
Asking some more questions 😅
d4e94a7
to
fe088db
Compare
* This meant that the intended checks were not being run
This allows us to treat these variables as if they were pure RandomVariables (dispatch moments, resize, etc.) Co-authored-by: Michael Osthege <michael.osthege@outlook.com>
* change_rv_size is now called change_dist_size
* Display the dists and their inputs used by SymbolicDistributions
* Also fixes index error in AR when init_dist is scalar and size is None * Remove unused rv_class attribute
This is necessary because the distribution is in fact a "Factory distribution" that needs to be able to resize `sd_dist` dynamically in order to work correctly.
* Implements distribution agnostic univariate RandomWalk
This risk is present when resizing a RandomVariable, whose new size depends on the size of the original RandomVariable. This can lead to wrong update expressions for the reused RNG variables that still depended on the original RandomVariable. Similarly, there is a risk when clone-replacing RandomVariables, as the cloned variables will share the same RNGs. This happened when attempting to use Metropolis with Simulator variables. * change_rv_size does not reuse old RNG * compile_pymc raises if distinct update expression are inferred for the same RNG
fe088db
to
8653d18
Compare
This PR wraps the graphs returned by the old
SymbolicDistribution.rv_op
in aSymbolicRV
OpFromGraph
Op
so that they can be manipulated like vanillaRandomVariable
s. The main benefit is that we can now:SymbolicRV
s (nested mixtures, censored mixtures, AR with censored init_dist, you name it)When these
OpFromGraph
don't have a specialized logprob dispatched, they can be inlined inside Aeppl, so that their logprob can be derived dynamically. This was one of the main reasons for creatingSymbolicDistribution
s in the first place.Closes #5533
Checklist
Major / Breaking Changes
Bugfixes / New features
Docs / Maintenance
SymbolicRV
s to encapsulate graphs from distribution factoriesSymbolicDistribution
class in favor ofDistribution
change_rv_size
was removed in favor of the more generalchange_dist_size
_LKJCholeskyCov
andGaussianRandomWalk
are nowSymbolicRV
s