JAX is a widely used tool in machine learning and scientific computing, but incorporating existing high-performance code into JAX can be challenging. The JAXbind package aims to reduce the effort required to bind custom functions from other programming languages to JAX. It provides a Python interface for defining custom JAX primitives that support various transformations. The package allows registering any function, its partial derivatives, and transpose functions as a JAX native call without deep knowledge of JAX's internals or C++ backend.
The package is intended to bridge high-performance code with JAX without the need for rewriting it in JAX itself. This can be particularly useful in scientific computing applications where mixing existing code with JAX is desired. The authors plan to connect various transforms and algorithms from different packages to enhance their capabilities using JAXbind. While similar tools like Enzyme-JAX exist, they have limitations in connecting arbitrary code to JAX.
Automatic differentiation is a key feature of JAX, and custom functions registered with JAX must support it. The article outlines the requirements for connecting a nonlinear function to JAX using the example of f(x1, x2) = x1x2^2. Higher-order derivatives are not automatically computed by JAX for general functions, but linear functions simplify differentiation significantly.
JAXbind also supports linear functions like spherical harmonic transforms and provides an interface for implementing higher-order derivatives if needed in specific use cases. Currently, the package only supports CPU memory primitives, but future versions could include GPU support seamlessly due to the backend-agnostic nature of automatic differentiation in JAX.
To Another Language
from source content
arxiv.org
Key Insights Distilled From
by Jakob Roth,M... at arxiv.org 03-15-2024
https://arxiv.org/pdf/2403.08847.pdfDeeper Inquiries