← News

Technology updates

Hugging Face Details TorchTPU, a Native PyTorch Backend That Makes TPU Just Another Device

Hugging Face says TorchTPU adds a native TPU backend to PyTorch, letting Transformers v5, Diffusers and Kernels send models to "tpu" without torch_xla or Optimum TPU.

Published: 2026-11-18 13:24 UTCUpdated: 2026-11-18 13:24 UTCSource date: 2026-10-20

Hugging Face published a blog post on October 20, 2026 introducing TorchTPU, which it describes as a native PyTorch backend for Google's Tensor Processing Units. The central claim is that TPU becomes just another device: users no longer need to port code to torch_xla or switch to JAX, but can pull a model from the Hub and send it to "tpu".

The post explains that TPUs are Google's own AI accelerators, designed over roughly a decade and used to train and serve its models, including Gemini, and available on Google Cloud from a single chip to pods of thousands. The real barrier has been software: the TPU stack grew up around TensorFlow and JAX, leaving PyTorch users with more work. The previous path through PyTorch/XLA worked but had quirks, according to the authors: tensors were lazy, code did not always run when expected, small changes could trigger graph recompilations, and debugging was hard to reason about. Hugging Face had built Optimum TPU for inference and training support; with native TorchTPU support, the post says Optimum TPU is no longer required to run Transformers and Diffusers models.

TorchTPU ships Pallas kernels tuned for TPUs, distributed training support and a torch.compile integration, and installs on a TPU VM with a single pip command that points at PyTorch's CPU build index to avoid pulling the larger CUDA build. In the ecosystem, Transformers v5 was designed so model definitions can run anywhere; passing device_map="tpu" loads a model directly on the accelerator, running in eager mode by default with optional compilation or distributed setups. Diffusers treats TPU as a first-class device, needing only pipe.to("tpu") for prototyping and one compile call for deployment, and models too large for one chip can be sharded while loading by passing a TensorParallelConfig to from_pretrained. The Kernels Hub also offers ready-made TPU kernels, demonstrated by swapping in a Tokamax ragged-dot kernel for a Mixture-of-Experts model.

All performance figures come from Hugging Face's own runs and should be read as author claims rather than independent verification. On a Cloud TPU v6e-4 with tensor parallelism across four chips, bf16 and batch size 1, a MiniMax-H3 video and audio sample at 1344×768, 5.2 seconds and 49 steps took 188 seconds compiled versus 262 seconds eager, while a 1024×1024, 40-step Qwen-Image-2.1 sample took 3.5 seconds versus 8.0 seconds. With the Tokamax ragged-dot kernel at batch size 64, decoding was 21.5x faster on Qwen3-30B-A3B and 12.8x faster on Gemma 4 26B-A4B, with gains said to grow with batch size.

Testing transparency is a second focus. Hugging Face says it is adding nightly CI on TPU for the Transformers test suite, with results surfaced in a public dashboard. It reports that 96.5% of tests that run on TPU pass, that every failure becomes a small repro script and an issue on the TorchTPU repository, and that 34 issues have been filed with 19 already fixed. The effort also caught bugs in Transformers itself, including in StaticCache and Qwen3 tensor-parallel plans, which were fixed upstream.

The implication is that Google's accelerators are being wired into mainstream PyTorch and Hugging Face workflows, lowering the cost of moving between hardware. For developers, the practical questions are the gap between eager and compiled modes, how much sharded loading actually relieves memory pressure for large models, and the compatibility risk implied by a test matrix that is not yet all green.


Related articles