Google’s TorchTPU runs PyTorch code directly on TPU chips, with Hugging Face support
Google has released TorchTPU as open source, allowing PyTorch code to run on Google’s TPU chips. Hugging Face said its Transformers, Diffusers and Kernels libraries work with TorchTPU, but support is still incomplete.
Google has released TorchTPU as open source, TechCrunch reported on Tuesday 20 October. TorchTPU adds a new device to PyTorch – Google’s TPU chip – and developers can send computation to it in much the same way as to a GPU. TPUs (Tensor Processing Units) are Google’s own AI chips, designed for the matrix calculations used in neural networks. Google rents them out through Google Cloud. Developers can move existing PyTorch applications to TPUs by changing a setting, without rewriting them, TechCrunch reported.
Hugging Face wrote in a blog post that its Transformers, Diffusers and Kernels libraries work on TPU directly. Users can move a model to a TPU by setting the device to ‘tpu’, for example device_map="tpu" in Transformers. Previously, PyTorch code ran on TPUs through the PyTorch/XLA library. With that approach, Hugging Face said, computation did not always happen at the point in the code where it appeared to, even small changes could trigger a fresh compilation, and debugging was difficult. Transformers and Diffusers models no longer need to run through Optimum TPU, Hugging Face’s own helper library.
Users install TorchTPU on a TPU virtual machine with a single pip command. By default, a model runs in eager mode, carrying out operations one at a time. When a model is compiled with torch.compile, the first call turns it into an optimised computation graph, and later runs with inputs of the same size reuse that graph. In Hugging Face’s examples, the compiled model was faster on a four-chip Cloud TPU v6e-4. The MiniMax-H3 model produced a 5.2-second video with sound in 188 seconds, compared with 262 seconds in eager mode. A 1024×1024-pixel image was ready in 3.5 seconds, against 8.0 seconds in eager mode.
The Kernels Hub offers ready-made TPU kernels. A kernel is a small program that performs a single operation on the chip as efficiently as possible. Hugging Face measured the effect of a kernel from the Tokamax library on mixture-of-experts (MoE) models on a TPU v6e-8 at batch size 64. Text generation became 21.5 times faster on Qwen3-30B-A3B and 12.8 times faster on Gemma 4 26B-A4B. The comparison is with the same TPU hardware without the kernel, not with a GPU. The gain grows as the batch size increases.
Support is not yet complete. Of the Transformers tests that run on TPU, 96.5 per cent pass. Hugging Face has reported 34 issues to the TorchTPU developers, and 19 of them have been fixed. Hugging Face is also building a system that runs the TPU tests every night.
Google said it had worked with Meta, Hugging Face and the creators of vLLM and SGLang, TechCrunch reported. Google also released TPU agent suite, a package that helps developers move applications to TPUs. Its GitHub page describes it as a set of skills and tools for AI agents that assist with tasks such as porting a model to TPU, profiling performance and optimising kernels. The package installs into a harness: the program that controls an agent, gives the model its tools and runs its steps. Supported harnesses are Claude Code and Antigravity, with support for Codex and Cursor coming. The package requires Python 3.12 or later and other tools, such as the gcloud command-line tool.
Amazon released a similar tool, TorchNeuron, for its own Trainium chips on Monday, TechCrunch reported. The publication pointed out that developers are not abandoning Nvidia hardware en masse simply because moving to other chips is becoming easier.