Recently, Google released TorchTPU and so I thought I'd put together a practical field guide for using TPU on GKE.
Introduction
With Google open-sourcing TorchTPU and releasing vLLM-TorchTPU, serving PyTorch models on Cloud TPUs no longer relies on the legacy torch_xla LazyTensor wrapper approach of PyTorch XLA. Instead, it uses PyTorch’s PrivateUse1 mechanism to register TPUs as a native hardware device without modifying core PyTorch source code.
Using my Free-Tier-GKE Terraform repository, I set out to deploy the smallest, most cost-effective TPU footprint on a GKE Standard cluster to serve open-weight models.
Note
A GKE Autopilot cluster would be more hassle-free, but I prefer using a GKE Standard cluster and learning about the various configuration option and settings.
Measure twice, cut once
A huge part of deploying TPU on GKE is planning. Follow this GKE TPU planning guide, you will find the lowest-barrier entry point for a inference is:
- TPU v5e (where “e” stands for efficiency/inference)
-
ct5lp-hightpu-1tmachine type (a single-host slice with 1 TPU chip and 16GB HBM) - On-demand, scale-to-zero provisioning model
For those of us in North America, many of the zones that support TPU v5e are heavily contested, and because I’m not reserving any TPU resources ahead of time, I suggest performing your testing in zones during off-peak hours.
Note
I did much of my testing late at night in europe-west4-b zone as they were 5 hrs ahead of my Eastern timezone.
Another capacity lesson I learned is while Spot TPUs are supported, you will see from the planning guide that smaller machine types have the highest preemption rates, so I highly recommend disabling Spot TPUs when running my demo.
Deploying the demo
You can find the demo code --> here
For this, you will need a HuggingFace account and read-only token to be able to pull open-weight models to serve. You will be gated from pulling models that do not have an Apache 2.0/MIT license, so please make sure the model you want to try has the correct licensing (I chose a Gemma 4 model as all Gemma 4 models are released under the Apache 2.0 license).
Cold start does take about ~9 min while cluster autoscaler provisions the TPU node and vllm-torchtpu compiles the model’s XLA/Pallas execution graphs for tensor shapes. I encourage you to follow the pod logs to watch the startup progress, and check out my repo’s troubleshooting section for common errors I encountered around resource constraints, HuggingFace model licensing, and HBM limits.
Testing
Once the pod is ready, I just simply do a kubectl port-forward svc/vllm-torchtpu-service 8000:8000 to forward local 8000 to the service, then send in a query:
curl --noproxy '*' http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemma-4-E2B-it",
"messages": [{"role": "user", "content": "Explain how TPUs accelerate matrix multiplication."}],
"max_tokens": 512
}'
In my testing, I got 51.2 tokens/s generation throughput, which is pretty respectable on a single TPU v5e chip.
Conclusion
Running open-weight models on Cloud TPUs no longer requires rewriting PyTorch code in JAX or wrestling with torch_xla sync barriers. With torch_tpu wiring directly into PyTorch's PrivateUse1 mechanism and vllm-torchtpu plugging into upstream vLLM, getting from an empty Terraform plan to 51.2 tokens/s on a single TPU chip is less about fighting the ML framework and more about understanding the infrastructure underneath it. Once you navigate the initial Terraform quirks, zone capacity limits, and HBM sizing constraints, a scale-to-zero TPU v5e pool gives you a standard OpenAI-compatible serving stack with predictable costs and strong out-of-the-box performance.

Top comments (5)
One thing worth addressing is the scale-to-zero behavior: the Deployment is fixed at
replicas: 1, and its Pod requires the selected TPU topology, so the node can't scale down while that workload remains active. I'd add an idle-time scaling mechanism and consider a PVC for/cache, sinceemptyDirloses the compiled XLA artifacts when the Pod is deleted. How are you planning to trigger scale-down during idle periods and reactivate the endpoint on the next request?You are correct in that external storage would certainly help reduce cold-starts on subsequent boots. In the current define deployment, a scale down would wipe all the safetensor shards and a recompilation would have to happen each time.
You can scale down the deployment to 0 replicas and the autoscaler should reclaim the TPU node. As for triggering scale-downs 9I haven't tried it), I would probably try the new HPA that can now scale workloads to zero (kubernetes.io/blog/2026/09/02/kube...), which should be supported in GKE provided you're running a supported version.
That makes sense. You're right that scaling the Deployment to zero should allow the cluster autoscaler to reclaim the TPU node. The v1.37 HPA support looks promising, especially with an external metric that remains available when no inference Pods are running. One additional consideration is handling incoming HTTP requests during TPU provisioning, since the Kubernetes Service won't buffer them automatically. Would you consider putting a request-buffering gateway in front of the inference endpoint?
I haven't really dug too deep in to that yet. In the example I have, I don't have any gateway at all, but I think I would put something like an agentgateway (agentgateway.dev/) in front, though I'm not sure how capable it might be at request-buffering for the inference point.
I looked into agentgateway's buffering capabilities. Its request buffering appears to handle HTTP bodies in memory before forwarding, rather than holding requests in a queue until an unavailable backend becomes ready. Its retry policies could help with transient failures, but I wouldn't rely on them for a multi-minute TPU cold start. Would an asynchronous architecture using Pub/Sub or another durable queue, with a
202 Acceptedresponse and request ID, be a better fit for this scenario?