torchax

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 interoperabil

What is torchax?

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.

Overview of torchax

What it is

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 and PyTorch syntax together when authoring ML programs and run it on every hardware JAX can run.

Key features

  • Run PyTorch code on TPUs with minimal code changes.
  • Call JAX functions from PyTorch, passing in jax.Arrays.
  • Call PyTorch functions from JAX, passing in torch.Tensors.
  • Use JAX features like jax.grad, optax, and GSPMD to train PyTorch models.
  • Use a PyTorch model as a feature extractor with a JAX model.
  • Save and load training state using torchax.save_checkpoint and torchax.load_checkpoint.

Use cases

  • Running PyTorch programs on Google Cloud TPUs.
  • Mixing JAX and PyTorch code in the same ML program.
  • Using JAX compilation (jax.jit) to accelerate PyTorch models.
  • Training PyTorch models with JAX optimizers like optax.
  • Using a PyTorch model as a feature extractor within a JAX pipeline.

Getting started

First, install the CPU version of PyTorch: bash # On Linux pip install torch --index-url https://download.pytorch.org/whl/cpu # On Mac pip install torch Next, install JAX for your desired accelerator: bash # On Google Cloud TPU pip install -U jax[tpu] # On GPU machines pip install -U jax[cuda12] # On Linux CPU machines or Macs pip install -U jax Finally, install torchax: bash pip install torchax # Or from source pip install git+https://github.com/google/torchax

License and pricing

The license is Apache-2.0. The project is open source.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/googletorchax.svg)](https://yunodb.com/tools/googletorchax?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/googletorchax?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/googletorchax.svg" alt="Featured on YunoDB" height="20"></a>