A PyTorch frontend for JAX that enables running PyTorch code on TPUs and provides seamless PyTorch-JAX interoperability.
torchax is a PyTorch frontend for JAX that enables running PyTorch programs on Google Cloud TPUs and other JAX-supported hardware. It solves the problem of PyTorch's limited native TPU support by providing a backend that translates PyTorch operations to JAX equivalents, allowing seamless execution on accelerators. The project also facilitates interoperability between PyTorch and JAX, letting developers mix syntax from both frameworks in a single machine learning program.
Machine learning engineers and researchers who use PyTorch but want to leverage TPU hardware or combine PyTorch models with JAX's optimization and compilation features. It's particularly valuable for teams working on Google Cloud TPUs or those building hybrid PyTorch-JAX pipelines.
Developers choose torchax because it provides the easiest path to run existing PyTorch code on TPUs without major rewrites, while offering full interoperability between PyTorch and JAX ecosystems. Its unique selling point is maintaining PyTorch's familiar API while unlocking JAX's performance benefits and hardware support.
torchax is a PyTorch frontend for JAX. It gives JAX the ability to author JAX programs using familiar PyTorch syntax. It also provides JAX-Pytorch interoperability, meaning, one can mix JAX & Pytorch syntax together when authoring ML programs, and run it in every hardware JAX can run.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Allows existing PyTorch code to run on TPUs by simply enabling torchax and setting device='jax', as shown in the running example where a standard nn.Module executes on JAX hardware.
Supports bidirectional calls between PyTorch and JAX, enabling use of JAX libraries like optax and jax.grad with PyTorch models for hybrid ML pipelines.
Provides JittableModule helper to apply jax.jit to PyTorch models, compiling them for better performance, as demonstrated in the functional model example.
Offers torchax.save_checkpoint and load_checkpoint to handle states mixing PyTorch weights and JAX optimizer states, simplifying hybrid workflow persistence.
At version 0.0.4, torchax is in early development, so APIs may change and bugs are more likely, as indicated by the citation date and lack of a stable release.
Requires separate installations of PyTorch CPU, JAX for specific hardware (e.g., jax[tpu] or jax[cuda12]), and torchax, adding complexity compared to standard PyTorch setups.
Tied to JAX's hardware support and ops compatibility; unsupported PyTorch ops in the registry could break functionality, limiting use cases where PyTorch has native alternatives.