Skip to main content

Compatibility Notes

  • Currently we only support Single Host TPU Topologies. If you have a use case that can benefit from Multi Host Topologies please reach out to us
  • Currently we only support provisioning/scheduling TPU workloads using Node Auto Provisioning (NAP). We’ll add support for nodepools soon.

Prerequistes

Kubernetes Version

While different TPU types require different mininum GKE version, considering all TPU types, Node Auto Provisioning Support and ability to run without privileded mode, we recommend using 1.28.7-gke.1020000 or later and 1.29.2-gke.1035000 or later Please refer to following links for up to date requirements

Regional Availability

TPUs are available in limited zones. Following table lists the availability for Single Host TPUs. Please refer to following links for up to date availability:

Quota

Please make sure you have enough quota available in the respective region. You can apply for Quotas on your GCP Console: https://console.cloud.google.com/iam-admin/quotas

Node Auto Provisioning

Once you have Quota, add the TPU accelerators to NAP’s limits. Please follow the guide at https://cloud.google.com/kubernetes-engine/docs/how-to/node-auto-provisioning#config_file to update these limits.

CPU and Memory Limits

TPU VMs often have large amounts of CPU and Memory. Please make sure to also adjust CPU and Memory resource limits in NAP config. Inadequate limits on CPU and Memory might block TPU nodes from scaling
Here is what a sample config looks like for adding TPU accelerators

Adding TPU Devices

Using Spec or Python SDK

Tip

You can use the UI to generate equivalent YAML or Python Spec
You can add TPU by simply adding it under the resources.devices section like folllows:
Supported values for name and topologies:

Using UI

You can add TPUs to your Service / Job / Notebook / SSH Server by simply selecting a TPU Type and a topology from the Resources section

Examples

Before you begin

We recommend reading through following pages first to understand basics of deployment with TrueFoundry

Enumerate TPU chips

This simple example Job installs Jax and enumerates the assigned TPU devices
On submitting, it would bring up a TPU node and produce the following output

Running Gemma 2B with Jax

This Sample Notebook demonstrates running Gemma 2B using Jax in an interactive environment. The notebook can be uploaded directly to Notebook instance running with TPUs on TrueFoundry

Deploying Gemma 2B LLM with Jestream & MaxText on TPU v5e

This section is adapted from official GKE Guide: https://cloud.google.com/kubernetes-engine/docs/tutorials/serve-gemma-tpu-jetstream Step 1: Get Access to the model on Kaggle Step 2: Addkaggle.json to Secrets Create a Secret add the contents of kaggle.json like follows.
Once you have saved, keep the secret fqn handy, we’ll use it later
Step 3: Create Workspace, GCS Bucket, GCP Service Account and Link Them
  • Create a Workspace to deploy the model to
  • Create a GCS Bucket from GCP Console
  • Run the following script to create GCP Service Account with correct permissions. Make sure to edit your project id, bucket name, regions, workspace name
  • Finally edit the workspace you created and add the service account principal
Step 4: Deploy and Run the Job to convert the model to MaxText Engine format This Job pulls in the model from Kaggle using the kaggle.json secret we created earlier and puts them in your GCS bucket using the serviceaccount we created earlier
Once this runs successfully, you will get the base and converted checkpoints in your bucket
Step 5: Deploy the model via MaxText Engine
This runs the maxengine server in gRPC mode on port 9000 Step 5: Deploy a HTTP Head Server Finally we can deploy a http head server that is just a gRPC client wrapped in FastAPI app
Once deployed, you can make request with the following body on the /generate endpoint