Hugging Face adds native TPU support through TorchTPU

Hugging Face adds native TPU support through TorchTPU

Ondřej Barták
Ondřej Barták
Entrepreneur and Programmer
20. 10. 2026
3 minutes reading · 9 views
Listen to the article
Audio version of the article
Hugging Face adds native TPU support through TorchTPU

Hugging Face has introduced native TPU support in Transformers, Diffusers and Kernels through the TorchTPU backend. Developers can now run models from the Hub directly from PyTorch. Transformers and Diffusers no longer require Optimum TPU, which previously provided TPU support for these models.

Standard PyTorch code replaces the XLA route

Previously, running PyTorch on TPUs meant using PyTorch/XLA. Its lazy execution meant operations did not necessarily run when the code invoked them. According to Hugging Face, even small changes could trigger recompilation of the computation graph, and this execution approach made debugging harder.

TorchTPU adds TPUs as another PyTorch backend, allowing developers to use standard PyTorch code. It includes TPU-optimized Pallas kernels, distributed training support and integration with torch.compile.

Transformers v5 loads models directly onto TPUs

In Transformers v5, developers select the target device when loading a model by setting device_map="tpu". Models run in eager mode by default, without requiring compilation. Developers can also use torch.compile or run the model in a distributed setup.

Diffusers supports compilation and splitting across chips

For prototyping or debugging in eager mode, a Diffusers pipeline moves to the TPU with pipe.to("tpu"). Deployment in compiled mode adds a single compilation call while keeping the pipeline code unchanged. There is no need to maintain a separate TPU-specific branch.

A compiled pipeline builds its computation graph on the first call. Subsequent calls reuse that graph as long as the image size stays the same.

For models that exceed a single chip's capacity, developers can pass TensorParallelConfig to from_pretrained. This splits the transformer across chips during loading, so the entire model does not have to fit in one place. Support varies between pipelines, however: some require a tp_plan to be added.

Demonstrations compare compiled and eager execution

Hugging Face demonstrated the difference between the two modes on a Cloud TPU v6e-4. For both demonstrations, Hugging Face split the models across four chips and used bf16 precision and a batch size of 1. MiniMax-H3 generated a 5.2-second video with audio at 1344 × 768 resolution, using 49 steps, in 188 seconds in compiled mode. The same demonstration took 262 seconds in eager mode.

Under the same hardware conditions, Hugging Face demonstrated Qwen-Image-2.1 generating a 1024 × 1024 image in 40 steps. Compiled execution took 3.5 seconds, compared with 8.0 seconds in eager mode.

Kernels Hub offers ready-to-use TPU kernels

The support also includes ready-to-use TPU kernels on Kernels Hub, loaded through the Kernels library. These are written in Pallas, and developers can also integrate kernels from the Tokamax library. One example is ragged-dot for Mixture-of-Experts models.

Hugging Face also reports results comparing a Hub kernel with the default implementation on a TPU v6e-8. At a batch size of 64, the company says decoding was 21.5× faster for Qwen3-30B-A3B and 12.8× faster for Gemma 4 26B-A4B.

Google Cloud access and the state of support

TPUs are available through Google Cloud, ranging from a single chip to pods containing thousands of chips. TorchTPU can be installed on a TPU-equipped virtual machine with one command.

Support is not yet passing every test. Hugging Face says 96.5% of the Transformers tests that run on TPUs pass. The team has reported 34 issues in the TorchTPU repository, of which 19 have already been fixed.

Hugging Face is also working on nightly testing of Transformers on TPUs. It plans to make the results available in the Transformers dashboard.

Advertisement

Content created with help from UpTier.

SEO and GEO on autopilot. UpTier’s multi-agent systems write and optimize content for search engines and AI answers.

Discover UpTier ↗

Category:AI
Did you enjoy this article?
Discover more interesting posts on our blog
Back to blog

Related posts

Tencent releases Hy4 Flash with image support and a context window of up to 1 million tokensTencent releases Hy4 Flash with image support and a context window of up to 1 million tokens
The lighter Hy4 Flash model targets chat, documents and routine code edits. It accepts text and images, supports tool use and, according to Tencent, matched Claude Haiku 5.5 in tests of everyday tasks.
1 min read
16. 11. 2026
Companies Linked to Chinese Spy Invested in DeepSeek and Promised Banned Nvidia ChipsCompanies Linked to Chinese Spy Invested in DeepSeek and Promised Banned Nvidia Chips
Companies linked to an alleged Chinese spy joined DeepSeek’s latest funding round. In exchange for a stake, they reportedly promised banned Nvidia Blackwell chips.
3 min read
16. 11. 2026
Long Context Is an Expensive Luxury. Nvidia Study Shows How to Make AI Agents Faster and CheaperLong Context Is an Expensive Luxury. Nvidia Study Shows How to Make AI Agents Faster and Cheaper
AI agents do not need to process their entire history at every step. An Nvidia study shows that smart context trimming can significantly speed up their work, cut costs, and preserve accuracy.
5 min read
16. 11. 2026
Přihlaste se k odběru našeho newsletteru
Zůstaňte informováni o nejnovějších příspěvcích, exkluzivních nabídkách, a aktualizacích.
CodedTrip

Operated by CodedTrip LLC, USA.

YouTube
TikTok