PyTorch/XLA is a Python package that bridges PyTorch with XLA devices (TPU, GPU, CPU) to enable high-performance machine learning. The current stable version is 2.9.0, with releases aligned to PyTorch minor versions. It supports Python 3.10-3.13 and provides both PJRT and XRT runtimes (PJRT recommended).
pip install torch torch_xla[tpu] -f https://storage.googleapis.com/libtpu-releases/index.htmlVerified import paths — ran on the pinned version, not inferred.
Basic example: get XLA device, create tensor, run ops, mark step.
Ensure you are using PJRT (default). If you explicitly used XRT, switch to PJRT by not setting XRT runtime env vars.
Call xm.mark_step() after each training step and xm.wait_device_ops() before measuring time or synchronizing.
Install libtpu directly: pip install torch_xla[tpu] -f https://storage.googleapis.com/libtpu-releases/index.html for PyTorch/XLA 2.9+ it installs libtpu automatically.