Back to Blogs
#gke#vllm#torchtpu#tpu

Deploying open-weight models to vLLM-TorchTPU on GKE

Recently, Google released TorchTPU and so I thought I'd put together a practical field guide for...

3 min read
Cover for Deploying open-weight models to vLLM-TorchTPU on GKE

Recently, Google released TorchTPU and so I thought I'd put together a practical field guide for using TPU on GKE.

Source: vllm.ai

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-1t machine 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
  }'
Enter fullscreen mode Exit fullscreen mode

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.