Repolode
google-pytorch

google-pytorch/torch_tpu

A PyTorch backend that lets PyTorch models and operations run on Google's Tensor Processing Units (TPUs).

Stars
590
Forks
33
Open issues
282
Last commit
6 hours ago

What is it?

TorchTPU provides a PyTorch backend for Google's TPUs, so existing PyTorch code can execute on TPU devices. It includes custom ATen kernels for a range of PyTorch operations, along with a compilation cache that reuses compiled XLA computations to speed up repeated execution.

The project covers distributed training with data and tensor parallelism, integration with torch.compile() for graph mode execution, and utilities for debugging and benchmarking. Example code includes models such as Llama, Qwen, ResNet, DLRM, minGPT and UNet, and a user guide with interactive Marimo notebooks is provided. The notebooks are intended to run on a TPU VM.

Installation is via pip (torch_tpu on PyPI) or by building a wheel from source with Bazel. Python 3.11+ is supported.

Key features

  • 01Custom ATen kernel implementations for TPU.
  • 02Compilation cache for reusing compiled XLA computations.
  • 03Data and tensor parallelism for distributed training.
  • 04Integration with torch.compile() for graph mode execution.
  • 05Example code for models including Llama, Qwen, ResNet and UNet.
  • 06Debugging and benchmarking utilities.

Use cases

  • Running existing PyTorch training code on Google Cloud TPUs.
  • Distributed training of large models across TPU devices.
  • Serving PyTorch model inference on TPU hardware.
  • Studying example implementations of common models on TPU.

Quick start

  1. 1

    Create a Python virtual environment

    python -m venv .venv
  2. 2

    Install the latest public release from PyPI with the CPU PyTorch index

    pip install torch_tpu==0.2.0 --extra-index-url https://download.pytorch.org/whl/cpu

Things to know

  • Targets Google TPU hardware, so it is only useful if you have access to TPUs such as a TPU VM.
  • Requires Python 3.11 or newer.
  • Building from source needs Bazel and, for the full wheel build, Remote Build Execution credentials or the no_rbe flag.
  • The metadata license is listed as NOASSERTION, though the README states Apache 2.0.

Topics

FAQ

What is torch_tpu?
A PyTorch backend that lets PyTorch models and operations run on Google's Tensor Processing Units (TPUs). TorchTPU provides a PyTorch backend for Google's TPUs, so existing PyTorch code can execute on TPU devices. It includes custom ATen kernels for a range of PyTorch operations, along with a compilation cache that reuses compiled XLA computations to speed up repeated execution.
Is torch_tpu free to use? What license does it have?
torch_tpu is open source under the Other license. Check the license terms before using it in commercial products.
Is torch_tpu still maintained?
Actively maintained. The last commit to torch_tpu was on Oct 22, 2026.
What can I use torch_tpu for?
Running existing PyTorch training code on Google Cloud TPUs. Distributed training of large models across TPU devices. Serving PyTorch model inference on TPU hardware. Studying example implementations of common models on TPU.
How do I install torch_tpu?
Create a Python virtual environment: python -m venv .venv Install the latest public release from PyPI with the CPU PyTorch index: pip install torch_tpu==0.2.0 --extra-index-url https://download.pytorch.org/whl/cpu
Where can I get torch_tpu?
The source code and installation instructions are on GitHub: https://github.com/google-pytorch/torch_tpu

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects