pymc icon indicating copy to clipboard operation
pymc copied to clipboard

Add gufunc signature to SymbolicRandomVariables

Open ricardoV94 opened this issue 1 year ago β€’ 3 comments

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

  • [ ] Closes #
  • [x] Related to https://github.com/pymc-devs/pymc-experimental/pull/300

Checklist

Type of change

  • [ ] New feature / enhancement
  • [ ] Bug fix
  • [ ] Documentation
  • [x] Maintenance
  • [ ] Other (please specify):

πŸ“š Documentation preview πŸ“š: https://pymc--7159.org.readthedocs.build/en/7159/

ricardoV94 avatar Feb 16 '24 15:02 ricardoV94

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

@@            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 Coverage Ξ”
pymc/distributions/censored.py 100.00% <100.00%> (ΓΈ)
pymc/distributions/mixture.py 95.08% <100.00%> (+0.12%) :arrow_up:
pymc/distributions/multivariate.py 93.81% <100.00%> (+0.02%) :arrow_up:
pymc/distributions/timeseries.py 94.58% <100.00%> (+0.12%) :arrow_up:
pymc/distributions/distribution.py 94.29% <87.50%> (-0.76%) :arrow_down:

... and 2 files with indirect coverage changes

codecov[bot] avatar Feb 16 '24 16:02 codecov[bot]

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

zaxtax avatar Feb 21 '24 12:02 zaxtax

That's not a thing in PyTensor

ricardoV94 avatar Feb 21 '24 13:02 ricardoV94