Hugging Face adds native TPU support through TorchTPU
Brief by TrendCue AI · Dates refer to the original sources.
Hugging Face says its Transformers, Diffusers and Kernels libraries now run natively on Google TPUs through TorchTPU, a PyTorch backend. The integration removes the need for Optimum TPU when running Transformers and Diffusers models on the accelerators.
A native PyTorch backend
Previously, PyTorch users ran TPU workloads through PyTorch/XLA. Hugging Face says TorchTPU adds TPU as a PyTorch backend, with distributed training and torch.compile support. In Transformers v5, developers can load a model using device_map="tpu". Google says TorchTPU, co-developed with Meta’s PyTorch team, is open source on GitHub.
Diffusion workflows and constraints
Diffusers supports eager execution, compilation and tensor parallelism across TPU chips. Its documentation says compiled execution requires static shapes: the first call compiles, and a new image height or width triggers another compilation. The guide’s main version requires installation from source.
Testing remains in progress
Hugging Face says it is working to add nightly TPU testing for Transformers and publish the results. It reports that 96.5% of tests that run on TPU pass, while acknowledging that support is still a work in progress.
Original sources
Original websites and X posts open in a new tab.
- Official announcement — Hugging Face ↗https://huggingface.co/blog/hf-torchtpu
- Official announcement — Google Cloud ↗https://cloud.google.com/blog/topics/ai-infrastructure/torchtpu-is-now-open-source-run-native-pytorch-on-tpus
- Official announcement — Hugging Face ↗https://huggingface.co/docs/diffusers/main/optimization/tpu