TorchTPU: Google's PyTorch backend for TPUs reaches 0.2.0 on PyPI

TorchTPU: Google's PyTorch backend for TPUs reaches 0.2.0 on PyPI

The google-pytorch/torch_tpu repository on GitHub presents TorchTPU, a PyTorch backend for Google's Tensor Processing Units. Its README says the project lets users run PyTorch models and operations on TPU devices. It includes custom ATen kernels for various PyTorch operations, a compilation cache for optimizing execution, and examples for distributed training and model inference.

The README lists the feature set: an ATen kernel implementation for TPU; a compilation cache for optimized execution of XLA computations; support for distributed training with Data Parallelism and Tensor Parallelism; examples for Llama, Qwen, ResNet, DLRM, minGPT and UNet; integration with torch.compile() for graph mode execution; and utilities for debugging and benchmarking.

Installation is a pip install. The README gives the latest public release as 0.2.0 on PyPI, installed with pip install torch_tpu==0.2.0 --extra-index-url https://download.pytorch.org/whl/cpu. The extra index matters: installing without it pulls the CUDA build of torch rather than the CPU build. Python 3.11 or newer is supported, and the project's Python version policy follows PyTorch's Release Compatibility Matrix.

A user guide lives at torchtpu.readthedocs.io. It is a static version of the interactive notebooks, which are also in the repo's docs folder. The notebooks are written for Marimo (similar to Jupyter) and are launched with marimo edit file.py. They have to be run from a TPU VM, and the README says a v6e GCE instance is easiest.

Building from source uses Bazel, installed through Bazelisk. The wheel target is bazel build --config=wheel_common //ci/wheel:torch_tpu_wheel. Builds default to optimized mode (-c opt). The --config=wheel_common flag is required: without it the build fails, because the flag routes the shared XLA/MLIR backend so it is packed into a single libxla_base.so. Built without the flag, each per-version common ships its own copy of the backend, and the resulting wheel aborts on import torch with duplicate static registrations. The same config turns on Remote Build Execution (RBE) remote cache and executor; anyone without RBE credentials appends --config=no_rbe, and it must come after --config=wheel_common because the later config wins.

For C++ work the README recommends VSCode with the clangd extension and a compile_commands.json generated by tools/setup_clangd.py. The first run may take more than 30 minutes because it makes a full build; reruns are incremental. The project accepts contributions under a Contributor License Agreement, and it is licensed under Apache 2.0. The section on key Python dependencies reads only "TBD".

Key facts

  • The google-pytorch/torch_tpu repo provides a PyTorch backend for Google's TPUs, with custom ATen kernels, a compilation cache for XLA computations and torch.compile() integration.
  • The latest public release is 0.2.0 on PyPI; Python 3.11+ is supported; the license is Apache 2.0.
  • Distributed training support is listed as Data Parallelism and Tensor Parallelism, with examples for Llama, Qwen, ResNet, DLRM, minGPT and UNet.
  • The interactive Marimo notebooks must be run from a TPU VM; a v6e GCE instance is described as easiest.
  • Source builds use Bazel, and wheel builds fail without --config=wheel_common.

Why it matters

The repository describes a way to run ordinary PyTorch models and operations on TPU hardware, with TPU-specific ATen kernels, a compilation cache for XLA computations and torch.compile() for graph mode. It is hosted under a google-pytorch GitHub organization and published as a package on PyPI. The README does not say how TorchTPU relates to or replaces PyTorch/XLA.

Who it affects

People who train or serve PyTorch models and have access to Google TPUs. The listed examples (Llama, Qwen, ResNet, DLRM, minGPT, UNet) suggest language, vision and recommendation workloads. Contributors who want to work on the C++ and Bazel side are also addressed, with a CLA and CONTRIBUTING.md.

How to use it

Create a Python 3.11+ virtual environment (venv or uv) and run pip install torch_tpu==0.2.0 --extra-index-url https://download.pytorch.org/whl/cpu. Without the extra index you get the CUDA build of torch. The user guide is at torchtpu.readthedocs.io, and the Marimo notebooks in the docs folder run with marimo edit file.py from a TPU VM; a v6e GCE instance is easiest. To build a wheel yourself, install Bazel through Bazelisk and run bazel build --config=wheel_common //ci/wheel:torch_tpu_wheel, adding --config=no_rbe after it if you lack RBE credentials. The license is Apache 2.0.

How solid is it

The only source is the repository README, which describes features and build steps but gives no performance numbers, benchmarks or comparisons with JAX or PyTorch/XLA. It names no authors or team. It makes no roadmap, stability or production-readiness statement. The release number, 0.2.0, is the README's own figure for the latest public release.

Risks and caveats

The key Python dependencies section says only TBD. The README names v6e only as a convenient dev instance for the notebooks and does not list other supported TPU generations. Installing without the CPU extra-index-url pulls the CUDA version of torch. Wheel builds abort at build time without --config=wheel_common, and a wheel built without it fails on import torch with duplicate static registrations. The first full build for clangd setup may take more than 30 minutes.

“enabling users to run PyTorch models and operations on TPU devices.”

— TorchTPU repository README