This tutorial shows you how to deploy and serve the multimodal mixture of
experts model
Gemma 4 26B (google/gemma-4-26B-A4B-it)
on Google Kubernetes Engine (GKE) using multi-host
Cloud TPU v6e (Trillium) accelerators and
vLLM TorchTPU.
Because the workload spans multiple TPU hosts in a 2x4 topology, you use the
Kubernetes LeaderWorkerSet API and Ray to coordinate distributed tensor-parallel
inference across eight TPU chips.
Objectives
- Set up your GKE cluster and multi-host TPU v6e node pool.
- Deploy the multi-host vLLM server with LeaderWorkerSet.
- Send text and multimodal inference requests.
- Run a serving benchmark workload.
- Clean up.
Costs
In this document, you use the following billable components of Google Cloud:
To generate a cost estimate based on your projected usage, use the pricing calculator.
When you finish the tasks that are described in this document, you can avoid continued billing by deleting the resources that you created. For more information, see Clean up.
Before you begin
You need a Hugging Face access token to use this tutorial. You can sign up for a free account at Hugging Face. After you have an account, generate an access token:
- On the Welcome to Hugging Face page, click your account avatar and select Access tokens.
- On the Access tokens page, click Create new token.
- Select the Read token type and enter a name for your token.
- Your access token is displayed. Save the token in a safe place.
- Install and initialize the
Google Cloud CLI, and install
kubectl. If you use Cloud Shell, both tools are preinstalled.
To get the permissions that you need to complete this tutorial, ask your administrator to grant you the following IAM roles on your project:
- Kubernetes Engine Admin (
roles/container.admin) - Compute Admin (
roles/compute.admin) - Service Account User (
roles/iam.serviceAccountUser)
For more information about granting roles, see Manage access to projects, folders, and organizations.
You might also be able to get the required permissions through custom roles or other predefined roles.
Set up your environment variables
Set up your environment variables:
Replace the following:
YOUR_PROJECT_ID: the ID of your Google Cloud project.YOUR_RESERVATION_NAME: the name of your reservation.YOUR_REGION: the region where you want to deploy your GKE cluster.YOUR_ZONE: the zone where you want to deploy your TPU v6e node pool.YOUR_CLUSTER_NAME: the name of your GKE cluster.YOUR_HF_TOKEN: your Hugging Face access token.YOUR_VLLM_TPU_IMAGE: the vLLM TPU image to use. For public images, refer to the vLLM TorchTPU repository.
Create the GKE cluster
To create the GKE cluster and attach a multi-host TPU v6e node pool, complete the following steps:
Create a regional GKE cluster that uses
e2-standard-4nodes for the default node pool, and a TPU v6e node pool with twoct6e-standard-4tnodes arranged in a2x4topology (eight TPU chips total). The default GKE machine type (e2-medium) doesn't provide enough CPU resources for the LeaderWorkerSet controller, so this tutorial specifiese2-standard-4:Instead of using a specific reservation, you can also create the node pool using Spot capacity or Flex-start VMs by passing the following flags:
- Spot VMs: replace the
--reservation-affinityand--reservationflags with--spotto use Spot capacity. Instances that use Spot capacity might take time to be created after the node pool is created, and they might be preempted during workload runs. If your Pods take time to be created, or workloads stop in the middle of running, this could be the cause. - Flex-start VMs: Pass
--flex-startto provision the node pool using the Flex-start consumption option. For more information, see Run a small batch workload with TPUs and Flex-start VMs.
- Spot VMs: replace the
Configure
kubectlcredentials to communicate with your cluster:
Configure credentials and install LeaderWorkerSet
To prepare your cluster for the multi-host deployment, complete the following steps:
Export your Hugging Face token and create a Kubernetes Secret named
hf-secret:Install the LeaderWorkerSet CustomResourceDefinition and controller on your cluster:
Deploy the multi-host vLLM server
The workload manifest (gemma4-26b-multihost-v6e-2x4.yaml) defines two
resources:
- A LeaderWorkerSet resource (
vllm-tpu-gemma4-26b) withsize: 2(one leader Pod and one worker Pod) scheduled across the twoct6e-standard-4tnodes in the2x4TPU slice. Each Pod runs an InitContainer that prefetches thegoogle/gemma-4-26B-A4B-itmodel weights from Hugging Face into an in-memory volume before starting Ray and the vLLM OpenAI API server with the--tensor-parallel-size=8,--kv-cache-dtype=fp8,--max-model-len=5248, and--max-num-seqs=128flags. - A ClusterIP Service (
vllm-service) that exposes port8000on the leader Pod.
To deploy and monitor the workload, complete the following steps:
Fetch the LeaderWorkerSet manifest from GitHub:
Alternatively, create a file named
gemma4-26b-multihost-v6e-2x4.yamlwith the following contents:Apply the LeaderWorkerSet manifest:
Monitor the leader Pod status and logs until application startup completes:
Initial service startup takes approximately 9 minutes while the Pods prefetch the model weights, form the two-node Ray cluster across all eight TPU chips, and compile the model. Wait until the logs report
Application startup completebefore sending traffic.In a second terminal session, forward local port
8000tovllm-service:Leave port forwarding running in this terminal session.
Send inference requests
Return to your first terminal session and test the deployed model with both text and multimodal chat completion requests:
Send a text chat completion request to the
/v1/chat/completionsendpoint:Send a multimodal request containing both an image URL and a text prompt:
Run a benchmark workload
To benchmark the deployed model, run the following command:
Clean up
To avoid incurring additional ongoing charges to your Google Cloud account for the resources used in this tutorial, delete the Kubernetes workloads, the TPU node pool, and the GKE cluster:
Delete the vLLM server deployment and the Hugging Face secret:
Delete the TPU v6e node pool and the GKE cluster:
Return to your second terminal session and stop port forwarding.
What's next
- Learn more about vLLM TorchTPU.
- Learn more about Cloud TPU.