pymc-devs / pymc-devs/pytensor

Keep jit_fn through pickle

Open
#2,108 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

performance
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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.