pymc-devs / pymc-devs/pytensor
Implement helper `@as_jax_op` to wrap JAX functions in PyTensor
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 644
- Forks
- 208
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 16
Description
Description
This blogpost walks through the logic for 3 different examples: https://www.pymc-labs.com/blog-posts/jax-functions-in-pymc-3-quick-examples/ and shows the logic is always the same:
- Wrap jitted forward pass in Op
- Wrap jitted jvp (or vjp I can never remember) as a GradOp to provide gradient implementation
- Dispatch unjitted versions of the two Ops for integration with `function(... , mode="JAX")
Things that cannot be obtained automatically (or maybe they can?) and should be opt-in as in @as_op:
4. Input and outputs types
5. infer_shape
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 with the linked blog post and compare its three examples with the existing @as_op behavior and function(..., mode="JAX") integration. The work is complete when an opt-in @as_jax_op helper covers the forward pass, gradient operation, unjitted JAX dispatch, input and output types, and infer_shape behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100