A machine learning and math framework for Go with XLA-accelerated training, a pure Go backend, and HuggingFace model loading.
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
Create a Python virtual environment
python -m venv .venv - 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
A JAX-based open-source LLM library and reference implementation for pre-training and post-training large models on Google Cloud TPUs and GPUs.
Ray is a unified framework for scaling Python and AI applications from a laptop to a cluster, with a distributed runtime and AI libraries.
A deep learning optimization library for making distributed training and inference of large models easier and more efficient.
A PyTorch-based distributed training and inference system for large AI models, offering parallelism, memory optimization and heterogeneous training.
PyTorch library of image model architectures, pretrained weights, and training, validation, and export scripts for computer vision tasks.