Open-source PyTorch backend for TPUs
TorchTPU
TorchTPU is an open-source PyTorch backend for Google's Tensor Processing Units that makes TPU a native PyTorch device. It provides ATen kernels for TPU, a compilation cache, torch.compile integration and distributed training support, and replaces the older PyTorch/XLA route for running Hugging Face transformers and diffusers models on Cloud TPUs.
Last reviewed 28 Oct 2026 · by Google
Facts at a glance
Questions people ask
- How is TorchTPU different from PyTorch/XLA?
- TorchTPU adds TPU as a native PyTorch device that runs in eager mode by default, while PyTorch/XLA used lazy tensors that could trigger graph recompilations, according to Hugging Face.
- Do I still need Optimum TPU to run Hugging Face models on TPUs?
- No. Hugging Face says Optimum TPU is no longer required to run models with Transformers and Diffusers now that TorchTPU provides native support.