Pre-train Muse Glimmer 30B on GKE with TorchTitan on TPU v6e

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_ce TorchTitan configuration with an 8,192-token context for 30 steps.
  • Dataset and tokenizer: the built-in TorchTitan c4_test dataset (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 (gcluster version 1.106.0), on TPU v6e (ct6e-standard-4t, with an 8x8 topology). The framework is TorchTitan (tag torch-tpu-v0.2.0) with TorchTPU 0.2.0, PyTorch 2.15.0, and libtpu 0.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 8x8 node 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.

New Google Cloud users might be eligible for a free trial.

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:

    Enable APIs

  • Install and initialize the Google Cloud CLI. If you're using Cloud Shell, then you can skip this step.

  • Install the kubectl CLI and the gke-gcloud-auth-plugin plugin. 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 deploy command in this tutorial passes the --download-dependencies flag, 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:

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:

  1. Authenticate by using the gcloud CLI and set up Application Default Credentials (ADC):

    gcloud auth login
    gcloud auth application-default login
  2. Export your environment variables and set your default project and quota project:

    export PROJECT_ID="YOUR_PROJECT_ID"
    export REGION="YOUR_REGION"
    export ZONE="YOUR_ZONE"
    export CLUSTER_NAME="YOUR_CLUSTER_NAME"
    export RESERVATION_NAME="YOUR_RESERVATION_NAME"
    export TF_STATE_BUCKET="YOUR_STATE_BUCKET_NAME"
    export BUCKET_NAME="YOUR_OUTPUT_BUCKET_NAME"
    export AR_REPO="YOUR_REPOSITORY_NAME"
    export TOPOLOGY="8x8"
    export NNODES=16
    export NPROC_PER_NODE=4
    export BASE_OUTPUT_DIR="gs://${BUCKET_NAME}"
    export WORKLOAD_IMAGE="${REGION}-docker.pkg.dev/${PROJECT_ID}/${AR_REPO}/torchtitan-runner:torch-tpu-v0.2.0"
    export CTK_VERSION="1.106.0"
    
    gcloud config set project "${PROJECT_ID}"
    gcloud auth application-default set-quota-project "${PROJECT_ID}"

    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 as us-east5.
    • YOUR_ZONE: the zone where your TPU v6e reservation is located, such as us-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's project field to your deployment file, under specific_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:

curl -L -O "https://github.com/GoogleCloudPlatform/cluster-toolkit/releases/download/v${CTK_VERSION}/gcluster_bundle_linux_amd64.tgz"
mkdir -p ~/cluster-toolkit && tar -xzf gcluster_bundle_linux_amd64.tgz -C ~/cluster-toolkit
cd ~/cluster-toolkit && ./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:

  1. Create an Artifact Registry Docker repository for the training image:

    gcloud artifacts repositories create "$AR_REPO" --repository-format=docker --location="$REGION" --project="$PROJECT_ID"
  2. Clone the TorchTitan repository on GitHub into your home directory, check out the torch-tpu-v0.2.0 tag (pinned to TorchTPU version 0.2.0 and PyTorch version 2.15.0), and pin libtpu to version 0.0.54:

    cd ~
    git clone https://github.com/google-pytorch/torchtitan.git
    cd torchtitan && git checkout torch-tpu-v0.2.0
    sed -i 's/libtpu==0.0.50/libtpu==0.0.54/' torchtitan/experiments/tpu/requirements.txt

    Pinning libtpu to version 0.0.54 reduces compile time for the first training step on TPU v6e.

  3. Create a Cloud Build configuration file named cloudbuild.yaml that builds the container image from the TorchTitan TPU Dockerfile by using the released TorchTPU and PyTorch versions:

    cat > cloudbuild.yaml <<'EOF'
    steps:
      - name: gcr.io/cloud-builders/docker
        args: [build, -t, '${_IMAGE}', -f, torchtitan/experiments/tpu/Dockerfile,
               --build-arg, TORCH_TPU_VERSION=0.2.0,
               --build-arg, TORCH_VERSION=2.15.0,
               --build-arg, TORCH_INDEX_URL=https://download.pytorch.org/whl/cpu, .]
    images: ['${_IMAGE}']
    options: {machineType: E2_HIGHCPU_8, diskSizeGb: 200, logging: CLOUD_LOGGING_ONLY}
    timeout: 3600s
    EOF
  4. Build the image and push it to Artifact Registry:

    gcloud builds submit --project "$PROJECT_ID" --region "$REGION" \
      --config cloudbuild.yaml --substitutions=_IMAGE="$WORKLOAD_IMAGE" .

    The build takes about 10 minutes to finish. When the build finishes, the output shows a STATUS of SUCCESS. 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:

  1. Create a Cloud Storage bucket to store Cluster Toolkit state, and turn on object versioning so that you can recover earlier state files:

    gcloud storage buckets create "gs://$TF_STATE_BUCKET" --project="$PROJECT_ID" --location="$REGION" --uniform-bucket-level-access
    gcloud storage buckets update "gs://$TF_STATE_BUCKET" --versioning
  2. Create a Cloud Storage bucket for training outputs, including the resolved TorchTitan configuration and TensorBoard logs:

    gcloud storage buckets create "gs://$BUCKET_NAME" --project="$PROJECT_ID" --location="$REGION" --uniform-bucket-level-access
  3. Change to your ~/cluster-toolkit directory:

    cd ~/cluster-toolkit
  4. Create a cluster deployment file (${CLUSTER_NAME}-deployment.yaml) that specifies your project, region, zone, machine type, topology, reservation, and Terraform state bucket:

    cat > "${CLUSTER_NAME}-deployment.yaml" <<EOF
    terraform_backend_defaults:
      type: gcs
      configuration:
        bucket: ${TF_STATE_BUCKET}
    vars:
      project_id: ${PROJECT_ID}
      deployment_name: ${CLUSTER_NAME}
      region: ${REGION}
      zone: ${ZONE}
      num_slices: 1
      machine_type: ct6e-standard-4t
      tpu_topology: ${TOPOLOGY}
      authorized_cidr: 0.0.0.0/0
      enable_pathways_for_tpus: false
      reservation_affinity:
        consume_reservation_type: SPECIFIC_RESERVATION
        specific_reservations:
        - name: ${RESERVATION_NAME}
    EOF

    The deployment file supplies your environment-specific values and overrides the default variables defined in the Cluster Toolkit blueprint.

  5. 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 deploy command with your deployment file:

    cp examples/gke-tpu-v6e/gke-tpu-v6e.yaml gke-tpu-v6e.yaml
    sed -i '/- id: gke-tpu-v6e-cluster/,/settings:/ s/^\( *\)settings:$/&\n\1  enable_gcsfuse_csi: true/' gke-tpu-v6e.yaml
    ./gcluster deploy -d "${CLUSTER_NAME}-deployment.yaml" gke-tpu-v6e.yaml --download-dependencies --auto-approve

    The blueprint defines the cluster architecture and modules, and the -d flag 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 shows Apply 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:

  1. Write the cluster address and credentials to the ~/.kube/config file by using the gcloud container clusters get-credentials command so that kubectl and gcluster target your cluster:

    gcloud container clusters get-credentials "$CLUSTER_NAME" --location "$REGION" --project "$PROJECT_ID"
  2. 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:

    PROJECT_NUMBER=$(gcloud projects describe "$PROJECT_ID" --format='value(projectNumber)')
    gcloud storage buckets add-iam-policy-binding "gs://${BUCKET_NAME}" \
      --member="principal://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/${PROJECT_ID}.svc.id.goog/subject/ns/default/sa/default" \
      --role=roles/storage.objectUser
  3. To let Cloud Storage FUSE read and write files, grant the roles/storage.objectUser role on the same bucket to the node pool service account (${CLUSTER_NAME}-gke-np-sa):

    gcloud storage buckets add-iam-policy-binding "gs://${BUCKET_NAME}" \
      --member="serviceAccount:${CLUSTER_NAME}-gke-np-sa@${PROJECT_ID}.iam.gserviceaccount.com" \
      --role=roles/storage.objectUser
  4. Verify that all 16 TPU nodes show the 8x8 topology and Ready status:

    kubectl get nodes -L cloud.google.com/gke-tpu-topology

    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):

  1. Set the smoke test configuration:

    cd ~/cluster-toolkit
    export CONFIG=muse_glimmer_debugmodel
    export EXTRA=""
    export WORKLOAD_NAME="${CLUSTER_NAME}-smoke"
  2. From your ~/cluster-toolkit directory, submit the smoke test job by using the gcluster job submit command:

    ./gcluster job submit \
      --skip-prereqs \
      --mount "${BASE_OUTPUT_DIR};/job-logs;rw" \
      --name "${WORKLOAD_NAME}" --cluster "${CLUSTER_NAME}" \
      --project "${PROJECT_ID}" --location "${ZONE}" \
      --restarts 0 \
      --compute-type v6e-64 --topology "${TOPOLOGY}" --num-slices 1 \
      --image "${WORKLOAD_IMAGE}" \
      --gke-disable-parallel-containers \
      --env=PYTHONUNBUFFERED=1 \
      --env=WORKERS_0_HOSTNAME=${WORKLOAD_NAME}-main-job-0-0.${WORKLOAD_NAME} \
      --env=JAX_PLATFORMS= \
      --env="TORCHRUN_WORKLOAD_OVERRIDE=--training.steps=30 --dump-folder=/job-logs/${WORKLOAD_NAME} --metrics.save-tb-folder=tb --metrics.enable-tensorboard --debug.save-config-file=torchtitan_config.json --module=torchtitan.experiments.tpu.muse_glimmer --config=${CONFIG} ${EXTRA}" \
      --command "torchrun --nnodes=${NNODES} --nproc_per_node=${NPROC_PER_NODE} --rdzv_backend=static --rdzv_endpoint=\${WORKERS_0_HOSTNAME}:29501 --node_rank=\${TPU_WORKER_ID} -m torchtitan.experiments.tpu.train \${TORCHRUN_WORKLOAD_OVERRIDE}"

    On your first submission in this cluster, gcluster displays 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:

  1. Set the muse_glimmer_30b_fused_ce configuration with an 8,192-token context:

    export CONFIG=muse_glimmer_30b_fused_ce
    export EXTRA="--training.max-context-length=8192 --training.num-tokens-per-microbatch-per-dp-rank=8192"
    export WORKLOAD_NAME="${CLUSTER_NAME}-mg30b"
  2. From your ~/cluster-toolkit directory, submit the 30B training job by using the gcluster job submit command:

    ./gcluster job submit \
      --skip-prereqs \
      --mount "${BASE_OUTPUT_DIR};/job-logs;rw" \
      --name "${WORKLOAD_NAME}" --cluster "${CLUSTER_NAME}" \
      --project "${PROJECT_ID}" --location "${ZONE}" \
      --restarts 0 \
      --compute-type v6e-64 --topology "${TOPOLOGY}" --num-slices 1 \
      --image "${WORKLOAD_IMAGE}" \
      --gke-disable-parallel-containers \
      --env=PYTHONUNBUFFERED=1 \
      --env=WORKERS_0_HOSTNAME=${WORKLOAD_NAME}-main-job-0-0.${WORKLOAD_NAME} \
      --env=JAX_PLATFORMS= \
      --env="TORCHRUN_WORKLOAD_OVERRIDE=--training.steps=30 --dump-folder=/job-logs/${WORKLOAD_NAME} --metrics.save-tb-folder=tb --metrics.enable-tensorboard --debug.save-config-file=torchtitan_config.json --module=torchtitan.experiments.tpu.muse_glimmer --config=${CONFIG} ${EXTRA}" \
      --command "torchrun --nnodes=${NNODES} --nproc_per_node=${NPROC_PER_NODE} --rdzv_backend=static --rdzv_endpoint=\${WORKERS_0_HOSTNAME}:29501 --node_rank=\${TPU_WORKER_ID} -m torchtitan.experiments.tpu.train \${TORCHRUN_WORKLOAD_OVERRIDE}"

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-logs through 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 for torchrun static rendezvous.
  • --env=JAX_PLATFORMS=: clears the JAX_PLATFORMS variable 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:

  1. Check the status of the JobSet, its Kueue workload, and the Pods:

    kubectl get jobset,workloads
    kubectl get pods

    When training finishes, all 16 Pods show the Completed status.

  2. Read the per-step training metrics—loss, tokens per second, model FLOPs utilization (MFU), and memory usage—from Cloud Logging:

    gcloud logging read 'resource.type="k8s_container" AND resource.labels.cluster_name="'$CLUSTER_NAME'" AND resource.labels.pod_name:"'$WORKLOAD_NAME'-main-job-0-0-" AND resource.labels.container_name="workload-container" AND textPayload:"step:"' \
      --project "$PROJECT_ID" --freshness=1h --order=asc --format='value(textPayload)'

    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.56s
    
  3. List the outputs that the job writes to Cloud Storage, including the resolved TorchTitan configuration (torchtitan_config.json) and TensorBoard logs (tb/):

    gcloud storage ls -r "${BASE_OUTPUT_DIR}/${WORKLOAD_NAME}/"

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:

  1. Delete the JobSet and Kueue resources that the gcluster job submit command created:

    kubectl delete jobset --all
    kubectl delete localqueue --all
    kubectl delete clusterqueue,resourceflavor --all
  2. Change to your ~/cluster-toolkit directory:

    cd ~/cluster-toolkit
  3. Destroy the GKE cluster and its associated infrastructure by using the gcluster destroy command:

    ./gcluster destroy "$CLUSTER_NAME" --auto-approve

    Destroying the cluster takes about 10 to 25 minutes to finish.

  4. Optional: After Cluster Toolkit destroys the cluster, delete both Cloud Storage buckets and the Artifact Registry repository:

    gcloud storage rm -r "gs://${BUCKET_NAME}" "gs://${TF_STATE_BUCKET}"
    gcloud artifacts repositories delete "$AR_REPO" --location "$REGION" --quiet

What's next