Learn how to enable Pathways in a Cluster Toolkit blueprint and submit distributed JAX workloads on Google Kubernetes Engine (GKE) clusters with Cloud TPU node pools.
For more information about general Pathways architecture and components, see Introduction to Pathways on Cloud. For more information about how Cluster Toolkit configures cluster resources, execution modes, head node sizing, runtime behavior, and colocated Python sidecar image resolution, see About Pathways in Cluster Toolkit.
Before you begin
Before you start, complete the following tasks:
- Install the
gclusterCLI and configure your environment. For more information, see Set up Cluster Toolkit. - Install and initialize the Google Cloud CLI, the
kubectlcommand-line tool, and thegke-gcloud-auth-pluginauthentication plugin. - Create a Cloud Storage bucket in the same region as your cluster. Pathways uses this bucket to store temporary job files and cached compiled code so that workloads don't need to recompile on restart.
Required roles
To get the permissions that you need to deploy the GKE cluster and submit Pathways jobs, ask your administrator to grant you the following IAM roles on your project:
- Kubernetes Engine Admin (
roles/container.admin) - Compute Admin (
roles/compute.admin) - Storage Admin (
roles/storage.admin) - Project IAM Admin (
roles/resourcemanager.projectIamAdmin) - Service Account Admin (
roles/iam.serviceAccountAdmin) - Service Account User (
roles/iam.serviceAccountUser) - Service Usage Consumer (
roles/serviceusage.serviceUsageConsumer) - Role Administrator (
roles/iam.roleAdmin) - Secret Manager Secret Version Manager (
roles/secretmanager.secretVersionManager)
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.
To ensure that the workload service account has the necessary
permissions to store temporary job files and cached compiled code for Pathways,
ask your administrator to grant the
Storage Admin (roles/storage.admin) IAM role to the workload service account on your Cloud Storage bucket.
For more information about granting roles, see Manage access to projects, folders, and organizations.
Your administrator might also be able to give the workload service account the required permissions through custom roles or other predefined roles.
Enable Pathways in your blueprint
In the standard and advanced Cloud TPU blueprints, such as
examples/gke-tpu-v6e/gke-tpu-v6e-advanced.yaml
and
examples/gke-tpu-7x/gke-tpu-7x-advanced.yaml,
the enable_pathways_for_tpus variable is set to true in the vars block by
default:
vars:
enable_pathways_for_tpus: true
To deploy a GKE cluster with the advanced blueprint, complete the
steps in Deploy the advanced blueprint for a Cloud TPU v6e
cluster
or Deploy the advanced blueprint for a Cloud TPU 7x
cluster,
or deploy your updated blueprint by using the gcluster deploy
command.
For more information about the CPU node pool and Kueue resources that the
enable_pathways_for_tpus variable configures, see Blueprint
configuration.
Submit a batch Pathways job
To submit a containerized batch Pathways workload, run the gcluster job
submit command with the
--pathways and --pathways-gcs-location flags.
Submit a batch Pathways job:
./gcluster job submit \
--project PROJECT_ID \
--name JOB_NAME \
--cluster CLUSTER_NAME \
--location LOCATION \
--compute-type COMPUTE_TYPE \
--topology TOPOLOGY \
--num-slices NUM_SLICES \
--pathways \
--pathways-gcs-location gs://BUCKET_NAME/PATHWAYS_PREFIX \
--command "COMMAND" \
--image IMAGE_NAME
Replace the following:
PROJECT_ID: your Google Cloud project ID.JOB_NAME: the name of theJobSetresource to create. For Pathways jobs, the name can't exceed 22 characters.CLUSTER_NAME: the name of your GKE cluster.LOCATION: the zone or region of your cluster.COMPUTE_TYPE: the Cloud TPU compute target, such asv6e-16orct6e-standard-4tfor Cloud TPU v6e, ortpu7xortpu7x-standard-4tfor Cloud TPU 7x.TOPOLOGY: the Cloud TPU slice topology, such as4x4for Cloud TPU v6e, or2x2x1or2x2x4for Cloud TPU 7x. This flag is required for Cloud TPU 7x. For Cloud TPU v6e, if thegclusterCLI determines the topology from a chip-count shorthand or the cluster, then you can omit the--topologyflag.NUM_SLICES: the number of Cloud TPU slices to allocate to the job, such as2.BUCKET_NAME: the name of your Cloud Storage bucket for temporary job files and cached compiled code for Pathways.PATHWAYS_PREFIX: the folder prefix in your Cloud Storage bucket.COMMAND: the command to run inside the container for your JAX workload.IMAGE_NAME: the URI of the container image for your workload. To build and push an image as needed from a local directory instead, set theGCLUSTER_IMAGE_REPOenvironment variable and pass the--base-imageand--build-contextflags.
For more information about sizing the CPU head node pool for large models, see Head node resources and sizing. For more information about worker restart defaults, termination grace periods, and environment variable overrides, see Runtime behavior.
Optional: Submit a job with a colocated Python sidecar
A colocated Python sidecar is an optional container that runs alongside the
pathways-worker container in each Cloud TPU worker Pod. It lets JAX
@colocated_python functions execute host-bound work, such as data loading and
checkpointing, directly on worker VMs rather than through the single
controller.
For more information about supported release tags, aligning client packages
with the /opt/venv/server_constraints.txt file, building custom sidecar
images, and verifying colocated Python execution, see Run colocated Python
with
Pathways.
For more information about how the gcluster
CLI matches server and proxy
container images, see Colocated Python image
resolution.
To run a batch workload with a prebuilt public sidecar release, pass the
--pathways-colocated-python-sidecar-image flag so that the gcluster CLI
selects the matching cloud-pathways server and proxy images automatically:
./gcluster job submit \
--project PROJECT_ID \
--name my-sidecar-job \
--cluster CLUSTER_NAME \
--location LOCATION \
--compute-type COMPUTE_TYPE \
--topology TOPOLOGY \
--pathways \
--pathways-gcs-location gs://BUCKET_NAME/PATHWAYS_PREFIX \
--command "COMMAND" \
--image IMAGE_NAME \
--pathways-colocated-python-sidecar-image us-docker.pkg.dev/cloud-tpu-v2-images/cloud-pathways/colocated_python_sidecar:TAG
In addition to the placeholders in Submit a batch Pathways job,
replace the TAG placeholder with a Pathways release tag that
matches your workload's JAX version, such as jax-0.11.2 or
20261124-jax_0.11.2.
To run a batch workload with a custom sidecar image built from the public
image, also pass matching --pathways-server-image and
--pathways-proxy-server-image flags from the cloud-pathways Artifact Registry
repository:
./gcluster job submit \
--project PROJECT_ID \
--name custom-sidecar-job \
--cluster CLUSTER_NAME \
--location LOCATION \
--compute-type COMPUTE_TYPE \
--topology TOPOLOGY \
--pathways \
--pathways-gcs-location gs://BUCKET_NAME/PATHWAYS_PREFIX \
--command "COMMAND" \
--image IMAGE_NAME \
--pathways-colocated-python-sidecar-image SIDECAR_IMAGE \
--pathways-server-image us-docker.pkg.dev/cloud-tpu-v2-images/cloud-pathways/server:TAG \
--pathways-proxy-server-image us-docker.pkg.dev/cloud-tpu-v2-images/cloud-pathways/proxy_server:TAG
In addition to the preceding placeholders, replace the following:
SIDECAR_IMAGE: the URI of your custom colocated Python sidecar image.TAG: the Pathways release tag that matches your sidecar's base image, such as20261124-jax_0.11.2.
Optional: Test in headless mode
You can deploy persistent Pathways infrastructure without running an in-cluster
workload container by passing the --pathways-headless
flag. Headless mode
lets you connect interactively to the Pathways cluster from an external client,
such as a local workstation or notebook environment.
When you enable headless mode with the --pathways-headless flag, the
--image, --base-image, and --command flags aren't required.
To deploy a headless Pathways cluster and connect an external client, do the following:
Submit a headless Pathways job by using the
gcluster job submitcommand:./gcluster job submit \ --project PROJECT_ID \ --name JOB_NAME \ --cluster CLUSTER_NAME \ --location LOCATION \ --compute-type COMPUTE_TYPE \ --topology TOPOLOGY \ --pathways \ --pathways-gcs-location gs://BUCKET_NAME/PATHWAYS_PREFIX \ --pathways-headlessReplace the placeholders as described in Submit a batch Pathways job.
Get the name of the
pathways-headPod:kubectl get pods \ -l jobset.sigs.k8s.io/jobset-name=JOB_NAME,jobset.sigs.k8s.io/replicatedjob-name=pathways-headForward local port
29000to container port29000on the Pathways proxy server:kubectl port-forward PATHWAYS_HEAD_POD_NAME 29000:29000Replace the
PATHWAYS_HEAD_POD_NAMEplaceholder with the name of thepathways-headPod from the output of thekubectl get podscommand.Initialize your JAX client to connect to the forwarded proxy endpoint at
grpc://127.0.0.1:29000. For more information, see Run an interactive workload with Pathways.
Verify the job
To verify that your Pathways JobSet resource is scheduled and running, use
the following gcluster job commands:
Inspect cluster health and the
JobSetand KueueWorkloadstatus by using thegcluster job inspectcommand:./gcluster job inspect \ --project PROJECT_ID \ --name JOB_NAME \ --cluster CLUSTER_NAME \ --location LOCATION \ --showList the jobs in your cluster by using the
gcluster job listcommand:./gcluster job list \ --project PROJECT_ID \ --cluster CLUSTER_NAME \ --location LOCATIONStream the logs for your job by using the
gcluster job logscommand:./gcluster job logs JOB_NAME \ --project PROJECT_ID \ --cluster CLUSTER_NAME \ --location LOCATION \ --follow
Clean up
To stop a running batch or persistent headless Pathways job and release its
Cloud TPU slices, cancel the job by using the gcluster job cancel
command:
./gcluster job cancel JOB_NAME \
--project PROJECT_ID \
--cluster CLUSTER_NAME \
--location LOCATION
To avoid recurring charges for the resources created on this page, destroy your
cluster deployment by using the gcluster destroy
command.
What's next
- Learn about execution modes, head node sizing, and runtime behavior in About Pathways in Cluster Toolkit.
- Learn how to build and verify custom sidecar images in Run colocated Python with Pathways.
- Learn how to deploy Cloud TPU workloads with dynamic slicing.
- Learn more about GKE deployment options.