Optimum-TPU
December 18, 2025 ยท View on GitHub
Caution
๐ง Optimum-TPU is now in maintenance mode.
Weโll continue to welcome community contributions for minor bug fixes, documentation improvements, and lightweight maintenance tasks.
Optimum-TPU was created to make it easier to train and run inference on TPUs using ๐ค Transformers and ๐ค Accelerate. Thanks to everyone who has contributed and supported the project! โค๏ธ
While this repository is no longer under active development, you can continue exploring TPU solutions with: โข tpu-inference for inference โข ๐ค Accelerate for training
Thank you for being part of the journey! ๐
Tensor Processing Units (TPU) are AI accelerator made by Google to optimize performance and cost from AI training to inference.
This repository exposes an interface similar to what Hugging Face transformers library provides to interact with a magnitude of models developed by research labs, institutions and the community.
We aim at providing our user the best possible performances targeting Google Cloud TPUs for both training and inference working closely with Google and Google Cloud to make this a reality.
Supported Model and Tasks
We currently support a few LLM models targeting text generation scenarios:
- ๐ Gemma (2b, 7b)
- ๐ฆ Llama2 (7b) and Llama3 (8b). On Text Generation Inference with Jetstream Pytorch, also Llama3.1, Llama3.2 and Llama3.3 (text-only models) are supported, up to 70B parameters.
- ๐จ Mistral (7b)
Installation
optimum-tpu comes with an handy PyPi released package compatible with your classical python dependency management tool.
pip install optimum-tpu -f https://storage.googleapis.com/libtpu-releases/index.html
export PJRT_DEVICE=TPU
Inference
optimum-tpu provides a set of dedicated tools and integrations in order to leverage Cloud TPUs for inference, especially
on the latest TPU version v5e and v6e.
Other TPU versions will be supported along the way.
Text-Generation-Inference
As part of the integration, we do support a text-generation-inference (TGI) backend allowing to deploy and serve incoming HTTP requests and execute them on Cloud TPUs.
Please see the TGI specific documentation on how to get started.
JetStream Pytorch Engine
optimum-tpu provides an optional support of JetStream Pytorch engine inside of TGI. This support can be installed using the dedicated CLI command:
optimum-tpu install-jetstream-pytorch
To enable the support, export the environment variable JETSTREAM_PT=1.
Training
Fine-tuning is supported and tested on the TPU v5e. We have tested so far:
- ๐ฆ Llama-2 7B, Llama-3 8B and newer;
- ๐ Gemma 2B and 7B.
You can check the examples: