pymc-devs / pymc-devs/pytensor
Keep jit_fn through pickle
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Description
When we pickle a pytensor function (which we do all the time in PyMC for multiprocessing), the whole jit_fn / dispatch machinery reruns. That's how we even found out about https://github.com/pymc-devs/pytensor/pull/2099#issuecomment-4347362527
This is rather slow, specially numba where we string exec a bunch of stuff. And useless, because the already attained jit_fn is safely (and cheaply) pickable. Caching (if enabled) saves us the cost of recompiling, but it's still wasted work.
We could easily make sure it's not thrown away during pickling and skip the fgraph_convert step.
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 by tracing the pickle path for PyTensor functions and locate where jit_fn is discarded and where fgraph_convert runs. Follow jit_fn creation and restoration, then verify with the relevant pickle behavior that an attained jit_fn is retained and fgraph_convert is not rerun after unpickling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100