pymc-devs / pymc-devs/pytensor
Add option to disable OpFromGraph.L_Op/R_Op from being wrapped in their own OpFromGraph
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
The fact that we wrap a graph in OpFromGraph, doesn't mean we also want to wrap it's gradient. It can also lead to troubles as in https://github.com/pymc-devs/pymc/issues/7657
I suggest adding a wrap_grad_in_ofg: bool kwarg that toggles this behavior. The easiest way to get this change is to keep the behavior as is, but call the inline_ofg rewrite manually after calling it here:
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/compile/builders.py at the referenced locations around lines 612-614 and 689. Read how OpFromGraph currently wraps gradients and inspect the inline_ofg rewrite mentioned in the issue. Done means adding the wrap_grad_in_ofg option and ensuring it controls whether L_Op/R_Op are wrapped in their own OpFromGraph.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100