Google Kubernetes Engine (GKE) and Cloud TPU v6e (Trillium) let
you run distributed large language model (LLM) pre-training workloads by using
PyTorch and TorchTitan. In this tutorial, you use
Cluster Toolkit to create a
GKE cluster and pre-train the dense
Muse Glimmer 30B
model by using fully sharded data parallelism (FSDP). You run the workload on 16
ct6e-standard-4t nodes, which form one TPU v6e slice of 64 chips in an 8x8
topology. This tutorial is intended for machine learning engineers and platform
administrators.
Workload summary
Running this pre-training workload on Cloud TPU and GKE involves the following components:
- Model: Muse Glimmer 30B, a dense decoder-only model with 27.85 billion parameters, defined in TorchTitan. Training starts from randomly initialized weights, so you don't download a checkpoint.
- Training method: pre-training with FSDP across all 64 TPU devices by
using the
muse_glimmer_30b_fused_ceTorchTitan configuration with an 8,192-token context for 30 steps. - Dataset and tokenizer: the built-in TorchTitan
c4_testdataset (a small sample of C4) and test tokenizer, both included in the container image. You don't need a Hugging Face token. - Infrastructure and framework: GKE, managed by
Cluster Toolkit (
gclusterversion 1.106.0), on TPU v6e (ct6e-standard-4t, with an8x8topology). The framework is TorchTitan (tagtorch-tpu-v0.2.0) with TorchTPU 0.2.0, PyTorch 2.15.0, andlibtpu0.0.54, built into a container image by using Cloud Build. The workload writes training outputs to Cloud Storage through Cloud Storage FUSE.
Objectives
- Install Cluster Toolkit and build the TorchTitan TPU container image by using Cloud Build.
- Deploy a GKE cluster that has a TPU v6e
8x8node pool. - Optional: Run a smoke test.
- Pre-train Muse Glimmer 30B by using FSDP.
- Monitor the training job and review its outputs in Cloud Storage.
- 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
Set up your environment for the tutorial:
Enable the Kubernetes Engine API, Compute Engine API, Artifact Registry API, Cloud Build API, Cloud Storage API, Identity and Access Management API, Cloud Resource Manager API, and Service Usage API in your Google Cloud project:
Install and initialize the Google Cloud CLI. If you're using Cloud Shell, then you can skip this step.
Install the
kubectlCLI and thegke-gcloud-auth-pluginplugin. If you're using Cloud Shell, then both tools are preinstalled.If you run this tutorial from a Linux or macOS workstation rather than Cloud Shell, then install the required Cluster Toolkit dependencies, such as Git. You don't need to install Terraform manually because the
gcluster deploycommand in this tutorial passes the--download-dependenciesflag, which automatically downloads Terraform version 1.12.2 or later.
Required roles
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 Admin (
roles/iam.serviceAccountAdmin) - Service Account User (
roles/iam.serviceAccountUser) - Project IAM Admin (
roles/resourcemanager.projectIamAdmin) - Storage Admin (
roles/storage.admin) - Artifact Registry Administrator (
roles/artifactregistry.admin) - Cloud Build Editor (
roles/cloudbuild.builds.editor) - Service Usage Admin (
roles/serviceusage.serviceUsageAdmin) - Logs Viewer (
roles/logging.viewer)
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
To configure authentication and export the environment variables for this tutorial, complete the following steps:
Authenticate by using the gcloud CLI and set up Application Default Credentials (ADC):
Export your environment variables and set your default project and quota project:
Replace the following:
YOUR_PROJECT_ID: the ID of your Google Cloud project.YOUR_REGION: the region where your TPU v6e reservation is located and where you deploy your cluster, such asus-east5.YOUR_ZONE: the zone where your TPU v6e reservation is located, such asus-east5-a.YOUR_CLUSTER_NAME: the name of your GKE cluster. The name must be 20 characters or fewer, start with a lowercase letter, and contain only lowercase letters, numbers, and hyphens. This length limit keeps the service account IDs that Cluster Toolkit derives from the name within the 30-character Identity and Access Management (IAM) limit.YOUR_RESERVATION_NAME: the name of your TPU v6e reservation in your project. If you use a shared reservation, then also add the owner project'sprojectfield to your deployment file, underspecific_reservations. For more information, see Configure capacity reservations.YOUR_STATE_BUCKET_NAME: a globally unique name for the Cloud Storage bucket that stores Cluster Toolkit (Terraform) state. For more information about naming rules, see Bucket names.YOUR_OUTPUT_BUCKET_NAME: a globally unique name for the Cloud Storage bucket that stores training outputs.YOUR_REPOSITORY_NAME: a name for the Artifact Registry Docker repository that stores the training image.
Install Cluster Toolkit
Download and extract the prebuilt Linux (amd64) bundle for
Cluster Toolkit version 1.106.0 (as specified in the
CTK_VERSION environment variable) into the ~/cluster-toolkit directory, and
then verify the gcluster version:
For other platforms, see
Install the prebuilt bundle.
Extracting the bundle provides the gcluster binary and the examples/
blueprints that you use in later steps. Use the exact version 1.106.0 so that
the blueprint variables match the deployment configuration in this tutorial.
Build the training image
To build the TorchTitan TPU container image by using Cloud Build and push it to Artifact Registry, complete the following steps:
Create an Artifact Registry Docker repository for the training image:
Clone the TorchTitan repository on GitHub into your home directory, check out the
torch-tpu-v0.2.0tag (pinned to TorchTPU version 0.2.0 and PyTorch version 2.15.0), and pinlibtputo version 0.0.54:Pinning
libtputo version 0.0.54 reduces compile time for the first training step on TPU v6e.Create a Cloud Build configuration file named
cloudbuild.yamlthat builds the container image from the TorchTitan TPU Dockerfile by using the released TorchTPU and PyTorch versions:Build the image and push it to Artifact Registry:
The build takes about 10 minutes to finish. When the build finishes, the output shows a
STATUSofSUCCESS. While the build runs, you can export your environment variables and continue with Create your Cluster Toolkit cluster in another terminal.
Create your Cluster Toolkit cluster
To create the required Cloud Storage buckets and deploy a
GKE cluster with a TPU v6e 8x8 node pool, complete the
following steps:
Create a Cloud Storage bucket to store Cluster Toolkit state, and turn on object versioning so that you can recover earlier state files:
Create a Cloud Storage bucket for training outputs, including the resolved TorchTitan configuration and TensorBoard logs:
Change to your
~/cluster-toolkitdirectory:Create a cluster deployment file (
${CLUSTER_NAME}-deployment.yaml) that specifies your project, region, zone, machine type, topology, reservation, and Terraform state bucket:The deployment file supplies your environment-specific values and overrides the default variables defined in the Cluster Toolkit blueprint.
Copy the bundled TPU v6e cluster blueprint, enable the Cloud Storage FUSE CSI driver in the copy, and deploy the cluster by using the
gcluster deploycommand with your deployment file:The blueprint defines the cluster architecture and modules, and the
-dflag overlays your deployment file on the blueprint. This command creates the Virtual Private Cloud (VPC) network, GKE cluster, system and TPU node pools, service accounts, Kueue, and JobSet. Deployment takes about 20 to 30 minutes to finish. When deployment finishes, the output showsApply complete!.
Configure cluster access
To configure credentials for kubectl and gcluster, grant the required role
on your output bucket for Cloud Storage FUSE, and verify node readiness,
complete the following steps:
Write the cluster address and credentials to the
~/.kube/configfile by using thegcloud container clusters get-credentialscommand so thatkubectlandgclustertarget your cluster:To let Cloud Storage FUSE perform the mount check, grant the Storage Object User role (
roles/storage.objectUser) on the output bucket to the default Kubernetes service account:To let Cloud Storage FUSE read and write files, grant the
roles/storage.objectUserrole on the same bucket to the node pool service account (${CLUSTER_NAME}-gke-np-sa):Verify that all 16 TPU nodes show the
8x8topology andReadystatus:The output is similar to the following:
NAME STATUS ROLES AGE VERSION GKE-TPU-TOPOLOGY gke-my-cluster-system-353b0fa5-ab Ready <none> 6m v1.35.9-gke.1673000 gke-tpu-ebaf8cc4-0c37 Ready <none> 4m v1.35.9-gke.1673000 8x8 gke-tpu-ebaf8cc4-2qjd Ready <none> 4m v1.35.9-gke.1673000 8x8 ...
Start the pre-training workload
You can run an optional debug smoke test to verify your cluster setup or go directly to the Muse Glimmer 30B pre-training job.
Optional: Run a smoke test
To catch setup problems before you start the 30B job, you can run a short smoke
test that trains an 8-layer debug model (muse_glimmer_debugmodel) for 30
steps (about 5 to 10 minutes):
Set the smoke test configuration:
From your
~/cluster-toolkitdirectory, submit the smoke test job by using thegcluster job submitcommand:On your first submission in this cluster,
gclusterdisplays a prompt similar to the following:LocalQueue 'default' does not exist ... create default Kueue resources? [Y/n]To create the default Kueue resources, enter
Y.
Run the Muse Glimmer 30B pre-training job
To pre-train Muse Glimmer 30B, complete the following steps:
Set the
muse_glimmer_30b_fused_ceconfiguration with an 8,192-token context:From your
~/cluster-toolkitdirectory, submit the 30B training job by using thegcluster job submitcommand:
This command creates a JobSet that runs torchrun on all 16 TPU VMs. The
command uses the following key flags:
--mount "${BASE_OUTPUT_DIR};/job-logs;rw": mounts your output bucket in read-write mode at/job-logsthrough Cloud Storage FUSE.--gke-disable-parallel-containers: turns off GKE parallel containers (multiple workload containers per host) so that one workload container accesses all TPU chips on a host. This flag applies to TPU7x and has no effect on TPU v6e, which runs one container per host by default.--env=WORKERS_0_HOSTNAME=...: sets the worker-0 DNS hostname used fortorchrunstatic rendezvous.--env=JAX_PLATFORMS=: clears theJAX_PLATFORMSvariable to avoid JAX and TorchTPU initialization conflicts.--env="TORCHRUN_WORKLOAD_OVERRIDE=...": passes the TorchTitan step count (30), model configuration (muse_glimmer_30b_fused_ce), and 8,192-token context length.
If you skipped the smoke test, then gcluster displays a prompt to create the
default Kueue resources on this first submission. To create the default Kueue
resources, enter Y.
The first Muse Glimmer 30B training step takes about 10 to 15 minutes to finish. For most of this time, while the job initializes and shards the model and while XLA compiles the first step, the job produces no log output, which is expected.
Monitor training and review results
To monitor the training job, read step-level metrics, and inspect the outputs in Cloud Storage, complete the following steps:
Check the status of the JobSet, its Kueue workload, and the Pods:
When training finishes, all 16 Pods show the
Completedstatus.Read the per-step training metrics—loss, tokens per second, model FLOPs utilization (MFU), and memory usage—from Cloud Logging:
The output is similar to the following:
[titan] 2026-12-15 18:59:29,425 - root - INFO - step: 1 loss: 12.24096 grad_norm: 0.0000 memory: 15.88GiB(49.63%) tps: 12 tflops: 2.01 mfu: 0.22% time_end_to_end: 684.96s [titan] 2026-12-15 18:59:34,999 - root - INFO - step: 2 loss: 10.38802 grad_norm: 0.0000 memory: 15.88GiB(49.63%) tps: 1,470 tflops: 247.30 mfu: 26.94% time_end_to_end: 5.57s ... [titan] 2026-12-15 19:02:10,531 - root - INFO - step: 30 loss: 2.92049 grad_norm: 0.0000 memory: 15.88GiB(49.63%) tps: 1,474 tflops: 247.88 mfu: 27.00% time_end_to_end: 5.56sList the outputs that the job writes to Cloud Storage, including the resolved TorchTitan configuration (
torchtitan_config.json) and TensorBoard logs (tb/):
After step 1 completes, the workload averages about 5 to 6 seconds per step,
based on the configuration in this tutorial. The workload averages about 1,500
tokens per second per device and 25% to 30% MFU, although your measurements can
vary slightly. Loss decreases over the 30 steps. Because c4_test is a small
sample dataset, the model memorizes it, and absolute loss values aren't
meaningful.
This tutorial trains for 30 steps on the small c4_test sample dataset to
validate your setup. For a representative pre-training run, train for more
steps on a full dataset.
This tutorial doesn't save model checkpoints. For longer training runs, enable TorchTitan checkpointing so that you can resume training or use the trained weights.
Clean up
To avoid incurring charges to your Google Cloud account for the resources that you created in this tutorial, delete the Kubernetes workloads and the GKE cluster, and optionally delete the storage and container resources:
Delete the JobSet and Kueue resources that the
gcluster job submitcommand created:Change to your
~/cluster-toolkitdirectory:Destroy the GKE cluster and its associated infrastructure by using the
gcluster destroycommand:Destroying the cluster takes about 10 to 25 minutes to finish.
Optional: After Cluster Toolkit destroys the cluster, delete both Cloud Storage buckets and the Artifact Registry repository:
What's next
- Explore the TorchTitan repository on GitHub to learn more about TPU configurations and distributed training recipes.
- Review architecture and topology details in TPU v6e.
- Learn more about Cluster Toolkit in the Cluster Toolkit overview.
- Learn how Cloud Storage FUSE mounts Cloud Storage buckets in the Cloud Storage FUSE documentation.
- Read Introduction to Cloud TPU.