pymc-devs / pymc-devs/pytensor
Vectorize node should return list of variables not node
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Description
vectorize_node implicitly assumes that whenever we want to vectorize a node, we will return a new node that has a 1-to-1 mapping with the original outputs, but this is too restrictive. It could be the case we want to vectorize a single node with two variables coming from different nodes, or a single output from a multi-valued node. There's no reason why we need a one node -> one node mapping.
For backwards compatibility we should check if the returned object is an Apply and issue a warning that this form is deprecated (but still use it) and instead a list of outputs (like in the rewrites) should be returned. All our implementations in PyTensor should switch to returning a list of variables.
The catch/warning could be done here: https://github.com/pymc-devs/pytensor/blob/79ff97a54bfdd98aa877cc6a04b5a4e3782cfbd6/pytensor/graph/replace.py#L214-L217
Then everything that calls vectorize_node should now expect a list as output. Like here:
https://github.com/pymc-devs/pytensor/blob/79ff97a54bfdd98aa877cc6a04b5a4e3782cfbd6/pytensor/graph/replace.py#L301-L308
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pytensor/graph/replace.py at the linked vectorize_node implementation and its callers. Inspect the existing vectorization implementations and update them to return lists of variables, while preserving the Apply form with a deprecation warning. Done means vectorize_node callers expect list output and the one-node-to-one-node restriction is removed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100