---
title: "Hugging Face ❤️ TorchTPU: TPUs, Natively"
description: "TorchTPU adds a native PyTorch backend for Google TPUs, eliminating the need for torch_xla or JAX. Installing it on a TPU VM requires a single pip command with a CPU-only torch index. Users can load any Hugging Face model onto a TPU with device_map=“tpu” and run it in eager mode without code changes. Diffusers pipelines also support TPU natively, requiring only pipe.to(“tpu”) for eager execution or an optional compile call for deployment. The Kernels Hub provides ready-to-use TPU kernels written in Pallas, which can accelerate MoE models by over 20× at large batch sizes, as demonstrated with Qwen3-30B-A3B. The Hugging Face team is continuously testing TPU support, with 96.5% of tests passing and upstream fixes for discovered issues, including bugs in StaticCache and Qwen3 tensor-parallel plans."
---

# Hugging Face ❤️ TorchTPU: TPUs, Natively

[Hugging Face](https://yomu.fyi/company/hugging-face) · Alvaro Moran, Jingya Huang, Simon Pagezy, Jeff Boudier, Régis Pierrard · Oct 20, 2026

**Type:** Announcement

## Summary

TorchTPU adds a native PyTorch backend for Google TPUs, eliminating the need for torch\_xla or JAX. Installing it on a TPU VM requires a single pip command with a CPU-only torch index. Users can load any Hugging Face model onto a TPU with device\_map=“tpu” and run it in eager mode without code changes. Diffusers pipelines also support TPU natively, requiring only pipe.to(“tpu”) for eager execution or an optional compile call for deployment. The Kernels Hub provides ready-to-use TPU kernels written in Pallas, which can accelerate MoE models by over 20× at large batch sizes, as demonstrated with Qwen3-30B-A3B. The Hugging Face team is continuously testing TPU support, with 96.5% of tests passing and upstream fixes for discovered issues, including bugs in StaticCache and Qwen3 tensor-parallel plans.

## Context

PyTorch users previously needed torch\_xla or JAX to run on TPUs; TorchTPU adds a native backend.

## Approach / What changed

TorchTPU adds TPU as a native PyTorch backend, installable via pip with a CPU-only torch index. Users set device\_map=‘tpu’ in Transformers or call pipe.to(‘tpu’) in Diffusers. It supports eager and compiled modes, distributed training, and Pallas kernels.

## Takeaways

- TorchTPU allows running PyTorch models on TPUs with device\_map=“tpu” without code changes, supporting eager and compiled modes.
- Diffusers pipelines work on TPU natively with pipe.to(“tpu”) and optional torch.compile for performance.
- TPU kernels from the Hub can accelerate MoE models significantly, e.g., 21.5× faster decoding on Qwen3-30B-A3B at batch size 64.

## FAQ

### How do I install TorchTPU?

Run pip install torch-tpu --extra-index-url https://download.pytorch.org/whl/cpu on a TPU VM. The extra index provides the CPU-only torch build.

### What models work with TorchTPU?

Any model from the Hugging Face Hub works. Load it with device\_map='tpu' in Transformers or pipe.to('tpu') in Diffusers.

### How do I use TPU kernels?

Load a kernel from the Kernels Hub using get\_kernel, then register it with ALL\_EXPERTS\_FUNCTIONS for MoE models. The bigger the batch, the bigger the speedup.

**Tags:** [Diffusers](https://yomu.fyi/topic/diffusers), [Hugging Face](https://yomu.fyi/topic/hugging-face), [PyTorch](https://yomu.fyi/topic/pytorch), [TPU](https://yomu.fyi/topic/tpu), [Transformers](https://yomu.fyi/topic/transformers)

- Source: [Hugging Face](https://huggingface.co/blog/hf-torchtpu)
- Source URL: https://huggingface.co/blog/hf-torchtpu
- Ingested by Yomu: 2026-10-20T18:00:13.569Z

[Read original post](https://huggingface.co/blog/hf-torchtpu)
