pymc-devs / pymc-devs/pymc-examples

How to wrap a JAX function for use in PyMC (the automatic way)

Open
#755 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

proposal
Dominant language
Python
Stars
398
Forks
325
Avg merge
9d 15m
Merged PRs (30d)
1

Description

Notebook proposal

Title: How to wrap a JAX function for use in PyMC (the automatic way)

Why should this notebook be added to pymc-examples?

The new wrapper @as_jax_op (still in a draft PR, but the functionality is there) requires some examples to showcase its functionality.

I would propose to have two parts, first an example of solving an ODE, similar to what I wrote here, but with only diffrax as external dependency.

Second, rewrite the existing notebook on how to wrap a function a Jax function, but using @as_jax_op instead of defining the operators manually.

Suggested categories:

  • Level: Intermediate
  • Diataxis type: How-to guide

Related notebooks

Relates to
https://www.pymc.io/projects/examples/en/latest/howto/wrapping_jax_function.html but simplifies the building of the Op. I would keep the existing one, as it explains in more depth what is happening behind the scenes.

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

Review the existing “How to wrap a Jax function” notebook and the linked draft PyTensor PR for @as_jax_op. Plan the proposed ODE example with diffrax and the rewrite using the automatic wrapper. Done means both notebook examples are added to pymc-examples and clearly demonstrate the wrapper without removing the existing guide.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter, python
Domain
documentation, machine-learning
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.