Learn how to run distributed AI workloads by using the Pathways framework on Google Kubernetes Engine (GKE) clusters deployed with Cluster Toolkit.
Pathways is a distributed AI execution framework designed to coordinate large-scale multi-slice Cloud TPU workloads under a single-controller programming model. You can use Cluster Toolkit to deploy Pathways workloads across independent Cloud TPU slices without manually writing multi-role Kubernetes JobSet manifests.
How Pathways workloads are orchestrated
When you submit a workload with the gcluster job submit --pathways
flag,
Cluster Toolkit automatically generates a Kubernetes JobSet manifest
that coordinates three functional roles:
- ResourceManager (
pathways-rm): A CPU-based coordinator service that manages Cloud TPU slice allocations, topology assignments, and elastic worker recovery across slices. - Proxy (
pathways-proxy): An IFRT proxy server that compiles and dispatches client JAX programs across the allocated Cloud TPU slices. - Workers and co-located sidecars: Cloud TPU worker Pods that execute compiled XLA computations alongside optional co-located Python sidecar containers.
Before you begin
Before you start, make sure that you have performed the following tasks:
- Install the
gclusterbinary and configure your environment. For more information, see Set up Cluster Toolkit. - Install the Google Cloud SDK (
gcloud),kubectl, 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 following IAM roles to the workload service account on your Cloud Storage bucket:
- Storage Object Admin (
roles/storage.objectAdmin) - Storage Admin (
roles/storage.admin)
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 advanced Cloud TPU blueprints,
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.
Cluster configuration requirements
When you set the enable_pathways_for_tpus variable to true in your
gke-cluster module,
Cluster Toolkit applies the following configuration:
- Dedicated CPU node pool for the coordinator: Cluster Toolkit
creates a dedicated, autoscaled (0-100 nodes) CPU node pool named
cpu-npby using then4-standard-64machine type. - Kueue configuration for Pathways: The
kueue-configuration-pathways.yaml.tftpltemplate binds thepathways-flavorResourceFlavorcustom resource to thecloud.google.com/gke-nodepool: cpu-npnode pool. Thecpu-npnode pool is automatically provisioned when you set the valueenable_pathways_for_tpus: true, or when you use the--pathways-head-npflag to override the default CPU node pool. To specify a custom configuration template for Kueue, set thekueue.config_pathsetting in your blueprint. - Unified resource groups in Kueue: Because Cloud TPU worker Pods
in a Pathways JobSet request CPU, memory, and
google.com/tpuresources simultaneously, Cluster Toolkit groups["google.com/tpu", "cpu", "memory"]into a single resource group in the KueueClusterQueue(tpu_flavor_cpu_quota,tpu_flavor_memory_quota, andtpu_quota) to prevent conflicts between resource flavors. You can override these default quotas in theconfig_template_varsblock of your Kueue module.
Use the gcluster deploy
command to deploy your cluster
with the updated blueprint before you submit Pathways jobs.
Test your Pathways infrastructure with 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 are not 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 \ --name JOB_NAME \ --cluster CLUSTER_NAME \ --location LOCATION \ --compute-type COMPUTE_TYPE \ --pathways \ --pathways-gcs-location gs://BUCKET_NAME/PATHWAYS_PREFIX \ --pathways-headlessGet the name of the Pathways head Pod:
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
PATHWAYS_HEAD_POD_NAMEwith the name of the Pathways head Pod 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.
Submit a Pathways job
To submit a Pathways workload, run the gcluster job submit
command with the
--pathways and --pathways-gcs-location flags.
Submit a Pathways job:
./gcluster job submit \
--name JOB_NAME \
--cluster CLUSTER_NAME \
--location LOCATION \
--compute-type COMPUTE_TYPE \
--num-slices NUM_SLICES \
--pathways \
--pathways-gcs-location gs://BUCKET_NAME/PATHWAYS_PREFIX \
--command "COMMAND" \
--image IMAGE_NAME
Replace the following:
JOB_NAME: the name of the JobSet to create.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, ortpu7x,tpu7x-16, ortpu7x-standard-4tfor Cloud TPU 7x.NUM_SLICES: the number of Cloud TPU slices to allocate to the job (for example,2).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.
Verify the job
To verify that your Pathways JobSet is scheduled and running, use the following
gcluster job commands:
Inspect the JobSet status and generated manifest by using the
gcluster job inspectcommand:./gcluster job inspect \ --name JOB_NAME \ --cluster CLUSTER_NAME \ --location LOCATION \ --showList the jobs in your cluster by using the
gcluster job listcommand:./gcluster job list \ --cluster CLUSTER_NAME \ --location LOCATIONStream the logs for your job by using the
gcluster job logscommand:./gcluster job logs JOB_NAME \ --cluster CLUSTER_NAME \ --location LOCATION
What's next
- Learn more about GKE deployment options.
- Understand Pathways distributed AI orchestration.
- Learn how to deploy TPU workloads with dynamic slicing.