Skip to content
AI Learning Ground Start learning

Research ·

Hugging Face ❤️ TorchTPU: TPUs, Natively

Hugging Face announced native TPU support via TorchTPU, a PyTorch backend that makes TPUs just another device, so Transformers, Diffusers and Kernels run on TPUs without torch_xla or JAX.

Hugging Face ❤️ TorchTPU: TPUs, Natively
Image: Hugging Face

Hugging Face has integrated TorchTPU, a native PyTorch backend for Google's TPUs, into its ecosystem. Previously, running PyTorch on TPUs required torch_xla, which used lazy tensors, could trigger graph recompilations from small changes, and made debugging difficult. With TorchTPU, TPU becomes just another device: users can load Hub models onto 'tpu' with regular PyTorch code. Optimum TPU is no longer required for Transformers and Diffusers.

TorchTPU ships with Pallas kernels tuned for TPUs, distributed training support, and torch.compile integration. In Transformers, models load with device_map="tpu" and run eagerly by default, with torch.compile optional. In Diffusers, pipe.to("tpu") enables eager mode; compiled mode reuses the graph for repeated calls with the same image size. Models too large for one chip can be sharded across chips by passing a TensorParallelConfig to from_pretrained. The Kernels Hub offers ready-made TPU Pallas kernels, plus kernels from the Tokamax library; at batch size 64 on a TPU v6e-8, decoding with Hub kernels is 21.5x faster on Qwen3-30B-A3B and 12.8x faster on Gemma 4 26B-A4B.

Hugging Face is running the transformers test suite on TPUs, with nightly CI and a public dashboard in progress. Of tests run on TPU, 96.5% pass; 34 issues have been filed against TorchTPU, 19 already fixed, and the effort also surfaced upstream Transformers bugs in StaticCache and Qwen3 tensor-parallel plans. For builders, this means TPU access on Google Cloud with standard PyTorch workflows and no fork to maintain.

References

Read the full story at Hugging Face ↗Like, save or discuss on Buzz

#open-weights #tooling #research