pymc-devs / pymc

Bayesian Modeling and Probabilistic Programming in Python
https://docs.pymc.io/
Other
8.67k stars 2k forks source link

Add gufunc signature to SymbolicRandomVariables #7159

Closed ricardoV94 closed 7 months ago

ricardoV94 commented 7 months ago

Description

This meta-info is necessary to reason about batch dims of SymbolicRandomVariables in the context of https://github.com/pymc-devs/pymc-experimental/pull/300

This is probably what we should use for RandomVariables, instead of defining ndims_params and ndim_supp. Those can be properties derived from the gufunc signature.

There is however a limitation with gufunc signatures, which has to do with inputs and outputs that are not tensors, such as RNGs and the size vector which obviously cannot have batch dimensions. For now I am treating those as scalars so in the signature they show up as (), but perhaps it makes sense to deviate a bit from numpy and use [] or None?

For vanilla RandomVariables like Normal. the signature would be None,None,None,(),()->None,(), for the inputs: rng, size, dtype, mu, sigma and outputs: next_rng, draws.

Related Issue

Checklist

Type of change


📚 Documentation preview 📚: https://pymc--7159.org.readthedocs.build/en/7159/

codecov[bot] commented 7 months ago

Codecov Report

Attention: Patch coverage is 91.30435% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 92.23%. Comparing base (a2988c7) to head (45eb6ef). Report is 1 commits behind head on main.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/pymc-devs/pymc/pull/7159/graphs/tree.svg?width=650&height=150&src=pr&token=JFuXtOJ4Cb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs)](https://app.codecov.io/gh/pymc-devs/pymc/pull/7159?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs) ```diff @@ Coverage Diff @@ ## main #7159 +/- ## ========================================== - Coverage 92.28% 92.23% -0.06% ========================================== Files 101 100 -1 Lines 16923 16889 -34 ========================================== - Hits 15618 15578 -40 - Misses 1305 1311 +6 ``` | [Files](https://app.codecov.io/gh/pymc-devs/pymc/pull/7159?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs) | Coverage Δ | | |---|---|---| | [pymc/distributions/censored.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7159?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9kaXN0cmlidXRpb25zL2NlbnNvcmVkLnB5) | `100.00% <100.00%> (ø)` | | | [pymc/distributions/mixture.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7159?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9kaXN0cmlidXRpb25zL21peHR1cmUucHk=) | `95.08% <100.00%> (+0.12%)` | :arrow_up: | | [pymc/distributions/multivariate.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7159?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9kaXN0cmlidXRpb25zL211bHRpdmFyaWF0ZS5weQ==) | `93.81% <100.00%> (+0.02%)` | :arrow_up: | | [pymc/distributions/timeseries.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7159?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9kaXN0cmlidXRpb25zL3RpbWVzZXJpZXMucHk=) | `94.58% <100.00%> (+0.12%)` | :arrow_up: | | [pymc/distributions/distribution.py](https://app.codecov.io/gh/pymc-devs/pymc/pull/7159?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs#diff-cHltYy9kaXN0cmlidXRpb25zL2Rpc3RyaWJ1dGlvbi5weQ==) | `94.29% <87.50%> (-0.76%)` | :arrow_down: | ... and [2 files with indirect coverage changes](https://app.codecov.io/gh/pymc-devs/pymc/pull/7159/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pymc-devs)
zaxtax commented 7 months ago

Just for clarity, we don't have any sections of the code that use a tensor of RNG seeds right?

ricardoV94 commented 7 months ago

That's not a thing in PyTensor