TorchTPU: Move PyTorch from GPU to TPU in one word

Fiber optical network cables glowing with light

On 20 October 2026, Google and Meta announced TorchTPU, open-source software that lets PyTorch operate directly on Google TPUs. In the simplest case, you change one word in your code: "cuda" becomes "tpu". The model then operates on a TPU, a chip that Google designed specifically for machine learning.

PyTorch is (one of) the most popular frameworks for AI work , but until now it did not operate well on TPUs. TorchTPU wants to remove this barrier. The first results are good, but some parts are not ready yet.

Why PyTorch and TPUs did not fit

Before TorchTPU, PyTorch on TPUs meant difficult tools. In 2020, Google released PyTorch/XLA to connect PyTorch to TPUs. But teams had to change their source code, and compilation (the step that converts code into chip instructions) was slow.

PyTorch/XLA also did not support eager mode, the native PyTorch mode that executes each operation immediately, one at a time. PyTorch/XLA was also slow to support new PyTorch functions for work across many chips.

TorchTPU is a new design, not an update of PyTorch/XLA. It connects to PyTorch as a backend, the layer that sends PyTorch operations to one type of hardware. It does not need JAX to operate, and eager mode is a top priority.

GPU and TPU: one similarity, one difference

GPUs and TPUs both have special units for fast matrix multiplication. On a GPU, these are Tensor Cores; on a TPU, they are matrix-multiply units (MXUs).

The main difference is parallel work. A GPU has many compute cores that operate in parallel. A TPU compute core does one calculation at a time, so a model needs wide data shapes for maximum speed.

What you get

TorchTPU gives PyTorch users familiar tools on new hardware.

A move in one word. For a simple model, you change the device name from "cuda" to "tpu". The model should then operate, but not at maximum speed, because its data shapes were made for a GPU.

Three ways to execute. 
 – The default eager mode operates the same as on a GPU.
 – A new hybrid mode, DeferAndFuse, compiles many small operations together and can be 50% or more faster.
 – For more speed, you use
torch.compile, the standard PyTorch compiler.

The same ecosystem. The team validated vLLM and SGLang for inference, and also validated TorchTitan for large-scale training, plus Ray, TorchRec, FSDP and DTensor.

Custom kernels. For maximum speed, engineers can write kernels, small programs that do one calculation on the chip.

Results reported by the TorchTPU team

The team reports that TorchTPU is already in production for inference and training at some of the largest Google Cloud customers.

The team tested 4917 popular Hugging Face models, and 4821 (98%) operated with no crash. In 657 models that represent different designs, 638 (97%) matched the GPU results within a set tolerance.

The team also trained Muse Glimmer 30B, a large model written for GPUs, on 4 TPU v7 chips. It needed only small changes.

In the largest test, Qwen3 MoE 235B trained on up to 8192 TPU v7 chips. From 1,024 to 8192 chips, the speed for each compute core decreased by approximately 6%. This loss is small: more chips need more communication, and a core does no work while it waits for data.

On 64 chips, TorchTPU processed 1828 tokens (small pieces of text) per second, and JAX processed 1937.

Third-party result

SemiAnalysis published an independent benchmark, InferenceX, that measured inference cost on TPU v7 with vLLM and TorchTPU. The TorchTPU blog reports the 8K/1K test result: 2.01 cents for each 1 million tokens. This was the lowest cost overall, down from 3.6 cents in September.

TestResultReported by
Hugging Face models with no crash98% (4821 of 4917)TorchTPU team
Results that match a GPU97% (638 of 657)TorchTPU team
Largest training test8192 TPU v7 chipsTorchTPU team
Inference cost, InferenceX 8K/1K2.01 cents for each 1 million tokensSemiAnalysis benchmark

What is not ready yet

Some parts of TorchTPU are not complete. Now, torch.compile operates only with fixed data sizes. Support for variable sizes is in development.

By default, communication between chips can make training 30% to 40% slower than an optional, faster method. Some PyTorch functions are not available yet. GPU code operates on TPUs, but for maximum speed, a team must adjust the model for the TPU design.

Why this matters

The biggest advantage is choice, because the same PyTorch code can operate on GPUs and on TPUs. Teams can select the hardware with the best price for each task.

The second advantage is less effort. Teams can start with their current code and make it faster step by step. In one example, these steps decreased one training step from 11.49 s to 2.78 s, approximately 4 times faster.

The code is open source, and all developers can contribute.

Sources

Picture of Nelson Eiró

Nelson Eiró

Senior Data Engineer

LinkedIn

Add comment: