pymc-devs / pymc-devs/pytensor

Implement helper `@as_jax_op` to wrap JAX functions in PyTensor

Open
#537 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backend compatibility feature request jax torch
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:

  1. Wrap jitted forward pass in Op
  2. Wrap jitted jvp (or vjp I can never remember) as a GradOp to provide gradient implementation
  3. 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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.