pymc-devs / pymc-devs/pytensor

Port SymbolicRandomVariable Op to PyTensor and get rid of many RVs in PyTensor

Open
#1,221 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backend compatibility OpFromGraph random variables refactor
Dominant language
Python
Stars
644
Forks
208
Avg merge
2d 14h
Merged PRs (30d)
16

Description

Description

In PyMC we have a SymbolicRandomVariable that allows defining an OpFromGraph that looks almost like a RandomVariable but is just built symbolically. This avoids having to define too many Ops (and backend dispatches). We should try to port it to PyTensor and make sure that everything than in PyTensor works with pure RandomVariable also works with the Symbolic counterparts.

From the top of the mind we have to make RandomStreams and RV rewrites compatible.

This is the class (it contains things that don't make sense in PyTensor, like the MeasurableOp):
https://github.com/pymc-devs/pymc/blob/ce5f2a27170a9f422f974fdf9fc415dfe53c35cb/pymc/distributions/distribution.py#L211-L399

Here is an example of how a Symbolic RV is then defined:
https://github.com/pymc-devs/pymc/blob/ce5f2a27170a9f422f974fdf9fc415dfe53c35cb/pymc/distributions/continuous.py#L1217-L1238

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the SymbolicRandomVariable class in pymc/distributions/distribution.py and its example in pymc/distributions/continuous.py. Then inspect how PyTensor handles RandomStreams and RV rewrites. Done means porting the symbolic RV support without PyMC-only concepts and making the relevant pure-RandomVariable behavior work for symbolic counterparts.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.