Vibeleaderboard
Index / tool
Category
Developer Tools
Rank
No. 1079Tools index
Pricing
Open Source
Type
TOOL
Use case
Models: Train & Run
GitHub
885 stars
Date

About

A PyTorch backend that lets users run PyTorch models and operations on Google TPU devices. It includes custom ATen kernels, a compilation cache for XLA computations, data and tensor parallel training, torch.compile integration, and examples for models such as Llama, Qwen, ResNet and UNet.

What it does

Plug Google's tensor chips into ordinary PyTorch code. Once installed on a TPU machine, it loads automatically when you import PyTorch and registers a new device name, so porting from a GPU mostly means swapping the device string and the distributed backend name. Each operation is deferred, turned into an XLA compiler program, looked up in a cache, and only then dispatched to the chip. You choose between op-by-op eager execution, a fusing eager mode, or full graph compilation.

Why it's ranked here

This is the official successor path for PyTorch on TPUs: its own FAQ states that PyTorch/XLA is deprecated and replaced by this project, built jointly by Google and the PyTorch team at Meta. The docs claim 450 core operators with forward and backward passes, continuous validation across 5,000 Hugging Face models, and validated support for v5e, v5p, v6e and v7 chips. It is Apache 2.0 licensed and drops the JAX runtime dependency the older bridge carried. For anyone running PyTorch on Google Cloud, that makes it the default starting point.

What's good

The porting story is concrete: change the device and the collective backend, and an unmodified model runs in eager mode. A three-tier compilation cache (in-process, shared across processes on one host, and an optional remote store) attacks the warm-up cost that TPUs are known for. Distributed training works through standard PyTorch process groups, with collectives compiled straight into the chip program rather than through a separate communication library. The public API page sorts every call and environment variable into stable, experimental, deprecated and internal tiers, and calling an internal one raises an error instead of failing quietly.

Tradeoffs

Most of the TPU-specific surface is experimental: streams, eager-mode switches, custom optimizers, Pallas kernels and the topology-aware mesh helper can change without a deprecation cycle. Dynamic shapes cause recompilation unless you set explicit upper bounds, which hurts LLM decode loops. FSDPv2 and multi-program collectives are marked low performance, there is no native FlexAttention, and only one process can hold a TPU device. Building from source needs Bazel and remote-build flags, and the readme's dependency section literally says TBD. Python-side checks on tensor values silently force a full sync and break fusion.

How to use it well

Pick this when you already have a PyTorch codebase and want it on Cloud TPUs without a JAX rewrite. Start on a TPU VM with the pip wheel, and add the CPU-only PyTorch index so you do not pull the CUDA build. Use the fusing eager mode for a quick speedup without code changes, then compile hot paths. Turn on the persistent remote cache to cut startup time across restarts. Keep inputs to compiled functions contiguous, avoid branching on tensor values, and mark known-identical training steps as SPMD-safe so communication overlaps compute. It does not help on GPUs or other accelerators.

Technical notes+

docs/how_torchtpu_works.md describes an out-of-tree backend registered as PrivateUse1 and renamed to tpu on autoload; each ATen callback creates a Deferred Op holding a StableHLO builder, and Dynamo graphs go to XLA rather than TorchInductor. docs/torchtpu_execution_model.md: strict eager compiles single ops at -O1, while TORCH_TPU_DEFER_AND_FUSE=1 and torch.compile use -O2; the doc claims up to 50% gain for defer-and-fuse over default eager and warns of microbubbles when enqueues under about 50 microseconds dominate. docs/distributed_support.md: tpu_dist lowers collectives to stablehlo.all_reduce and friends, inserts graph breaks around them by default, and offers @torch.tpu.distributed.spmd_safe or TORCH_TPU_SPMD_HANDSHAKE_STAGE to fuse. pyproject.toml requires torch>=2.11.0 and libtpu>=0.0.50; README.md notes the wheel aborts on import if built without --config=wheel_common. docs/public_apis.md lists only torch.accelerator calls and max_pool ops as stable.

Observed

License
Apache 2.0 (LICENSE); minGPT example implementation under MIT
Language
Python package with a C++ backend, built with Bazel
Install surface
pip wheel torch_tpu (pyproject.toml), or wheel built from source with Bazel
Python requirement
requires-python >=3.11 (pyproject.toml)
Interfaces
PyTorch device backend, tpu_dist process group, Dynamo compile backend, environment variables (docs/public_apis.md)
Hardware support
Validated on TPU v5e, v5p, v6e and v7 (docs/feature_set.md)
Platform
Requires a Google Cloud TPU VM or GKE TPU slice (docs/get_started_on_a_vm.md)
API stability
Most torch.tpu APIs are experimental; stable tier is torch.accelerator plus max_pool ops (docs/public_apis.md)
Predecessor
FAQ states PyTorch/XLA is deprecated and replaced by this project (docs/faq.md)

Read from README.md, pyproject.toml, LICENSE, docs/intro_to_torchtpu.md, docs/how_torchtpu_works.md, docs/torchtpu_execution_model.md, docs/feature_set.md, docs/get_started_on_a_vm.md, docs/distributed_support.md, docs/faq.md, docs/public_apis.md.

Similar tools

Browse all tools →

Intel on TorchTPU

More in Intel

Tags

pytorchtpuxlamldistributed-traininggoogle

Tech Stack

Python

Editorially curated, with community endorsements as a secondary signal. Corrections welcome.