Skip to main content

jaxify

Write Python. Run JAX.

CI Codecov Ruff ty uv Publish PyPI PyPI - Python Version

⚠️ jaxify is an experimental project under development
You're welcome to try it out and report any issues!

jaxify lets you apply JAX transformations (like @jax.jit and/or @jax.vmap) to functions with common Python constructs that JAX cannot itself handle, such as if conditions that depend on input values.

Installation

pip install jaxify

Getting started

import jax
import jax.numpy as jnp
from jaxify import jaxify


@jax.jit
@jax.vmap
@jaxify  # <-- Just decorate your function with @jaxify
def absolute_value(x):
    if x >= 0:  # <-- If block in a JIT-compiled function
        return x
    else:
        return -x


xs = jnp.arange(-1000, 1000)
ys = absolute_value(xs)  # <-- Runs at JAX speed!
print(ys)

How it works

The @jaxify decorator transforms Python functions using static analysis to replace unsupported Python constructs with JAX-compatible alternatives. After the transformations, the functions become traceable by JAX, enabling you to apply functional JAX transformations like @jax.jit and @jax.vmap in a seamless manner.

Compatibility status

The following Python constructs are currently supported within @jaxify-decorated functions:

🔀 Conditionals

Construct Works? Notes
if statements ✅ Fully supported including elif and else clauses. Translated to calls to jax.lax.cond
if expressions (e.g. a if b else c) ✅ Translated to jax.lax.cond

⚖️ Comparisons

Construct Works? Notes
==, !=, <, >, <=, >= ✅ Chained comparisons (e.g. x < y <= z) are supported by translation to the equivalent chain of individual comparisons

1️⃣ Logical operators

Construct Works? Notes
and / or ✅ Short-circuiting of traced values supported via translation to jax.lax.cond calls
not ✅ Translates to jnp.logical_not for traced single values

🔄 Loops

Construct Works? Notes
for loops ❌ Currently unsupported. Use jax.lax.fori_loop, jax.lax.scan, or jax.lax.while_loop instead
while loops ❌ Currently unsupported. Use jax.lax.while_loop instead

🎯 Pattern matching

Construct Works? Notes
match-case ✅⚠️ Static values only. For traced values, use an if-elif-else chain or jax.lax.switch instead

Metadata

Release files for jaxify 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jaxify 0.0.5
File Size Uploaded Provenance
jaxify-0.0.5.tar.gz 6.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for jaxify 0.0.5
File Interpreter ABI Platform
jaxify-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 12.9 kB

Release files / jaxify-0.0.5.tar.gz

Download URL jaxify-0.0.5.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d5ef08e7db71b2095913e6794acbe17c342710b38e7998003d5dd0403b309c7b
BLAKE2b-256 checksum
How to use checksums
cb154865281715fedd7b5234f4ee127fd3b0bc2086d7d5b3833748aa2721dd69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / jaxify-0.0.5-py3-none-any.whl

Download URL jaxify-0.0.5-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2108f701d66a705bbc4ca36584e4552c91c216f2d73a8c01a7df9f96330a8922
BLAKE2b-256 checksum
How to use checksums
f3b1d6a2a465ce58135da6e04ec8fd3249a81ee78f486e08ce5e658b7fbc811c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for jaxify 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page