gcluster job submit

NAME

gcluster job submit - submits a workload to a cluster.

SYNOPSIS

gcluster job submit [FLAGS]

DESCRIPTION

The gcluster job submit command submits a workload to a cluster. On Google Kubernetes Engine (GKE) clusters, Cluster Toolkit deploys workloads as Kubernetes JobSet resources integrated with Kueue. For single-slice, non-Pathways workloads, the gcluster CLI falls back to a standalone batch/v1 Indexed Job and headless Service when the JobSet API isn't available or the GCLUSTER_DISABLE_JOBSET=1 environment variable is set.

FLAGS

  • -i, --image IMAGE: The name of the prebuilt container image to run, including the registry path. Specify either the --image or --base-image flag, except in the following cases:

    • You submit a headless Pathways job (--pathways-headless flag).
    • You deploy a Shared Pathways Service (SPS) instance (--pathways-deploy-sps flag).
    • You run a local workload against an SPS instance (--pathways-run-sps-workload flag).
  • -B, --base-image IMAGE: The name of the base image used to build a new container image and push it to Artifact Registry or another Open Container Initiative (OCI) registry by using Crane. This flag requires the --build-context flag and can't be combined with the --image flag.

  • -b, --build-context DIR: The path to the build context directory for Crane. This flag is required when you use the --base-image flag. Set the GCLUSTER_IMAGE_REPO environment variable to an Artifact Registry repository name or a full REGISTRY_HOST/REPOSITORY OCI prefix. When the --base-image image is hosted in a custom OCI registry and the GCLUSTER_IMAGE_REPO environment variable is unset, the gcluster CLI defaults to HOST/library/gcluster.

  • -e, --command COMMAND: The command to run in the workload container, such as python3 train.py. This flag is required for job submissions, unless you submit a headless Pathways job with the --pathways-headless flag or deploy an SPS instance with the --pathways-deploy-sps flag.

  • --compute-type TYPE: The compute resource to request. This flag is required unless you set the --pathways-run-sps-workload flag. Specify one of the following formats:

    • Compute Engine machine type, such as n2-standard-32 or a3-highgpu-8g
    • GPU or TPU shorthand, such as h100-80gb-8, l4-1, v5e-8, v5litepod-32, or v6e-8
    • GKE accelerator label, such as nvidia-l4
  • -o, --dry-run-out PATH: The path to output the generated Kubernetes manifest instead of applying it.

  • -f, --platform PLATFORM: The target platform for the image build, such as linux/amd64 or linux/arm64. The default value is linux/amd64. Use this flag with the --base-image flag.

  • --mount VOLUME: Mounts Cloud Storage buckets, Filestore instances, Network File System (NFS) exports, PersistentVolumeClaim (PVC) resources, or host paths. You can specify this flag multiple times:

    --mount="SRC;DEST[;MODE][;profile=PROFILE][;options=OPTIONS][;attributes=KEY=VALUE[,...]]"
    
    • Sources (SRC): Supports gs://BUCKET[/SUBPATH], filestore://INSTANCE_OR_IP/SHARE, nfs://SERVER/EXPORT, PVC_NAME[/SUBPATH], or a host path starting with /. For nfs:// sources, the gcluster CLI provisions a shared NFS PersistentVolume (PV) and PVC on port 2049 and reclaims them when you run the gcluster job cancel command.
    • Access mode (MODE): ro (default) or rw. For PVCs, the gcluster CLI rejects the ;rw mode on ReadOnlyMany claims and requires the ReadWriteMany or ReadOnlyMany access mode for multi-node and Pathways jobs.
    • Cloud Storage FUSE options (profile=, options=, attributes=): Valid only for gs:// sources. Use hyphenated Container Storage Interface (CSI) mount options without leading dashes in the options= segment, such as options=implicit-dirs for flat-namespace buckets on inline mounts. Inline gs:// mounts scope SUBPATH with the only-dir option, while the profile= segment (training, checkpointing, or serving) provisions a shared gateway PV and PVC by using the Pod subPath field. For existing Cloud Storage FUSE PVCs, the gcluster CLI automatically adds the gke-gcsfuse/volumes: "true" Pod annotation.
  • --env KEY=VALUE: Custom environment variables in KEY=VALUE format to pass to the workload container. Replaces matching gcluster defaults, such as the JAX_PLATFORMS variable on Pathways or --verbose logging variables. For standard workloads, the gcluster CLI presets the WORKERS_0_HOSTNAME and MASTER_ADDR environment variables to NAME-main-job-0-0.NAME (JobSet) or NAME-0.NAME (standalone batch/v1 Job) unless overridden. You can specify this flag multiple times.

  • -n, --name NAME: The name of the workload to create. The name can't exceed 28 characters for standard jobs or 22 characters for Pathways jobs, which use the --pathways flag. This flag is required.

  • -q, --queue QUEUE: The name of the Kueue LocalQueue resource. If you omit this flag, then the gcluster CLI discovers the cluster's LocalQueue resource automatically. Ignored with a warning when Kueue isn't available or the GCLUSTER_DISABLE_KUEUE=1 environment variable is set.

  • --num-nodes N: The number of nodes to use per group or slice. The default value is 1. You can't use the --num-nodes flag with TPU jobs because the node count is calculated automatically from the --topology value.

  • --num-slices N: The number of independent groups or slices to use. The default value is 1.

  • --restarts N: The maximum number of restarts for the JobSet resource. Ignored with a warning on standalone batch/v1 Job workloads, which use the backoffLimit: 0 setting. Defaults to one of the following values:

    • 1 for standard jobs
    • 0 when the --pathways-run-sps-workload flag is set
    • 30 when the --pathways-deploy-sps flag is set
  • --gke-ttl-after-finished DURATION: The time to retain the JobSet or standalone Job resource after it finishes. The default value is 1h.

  • --grace-period DURATION: The time to wait before forcefully terminating a Pod. The default value is 30s. On Pathways jobs, this flag applies only to worker Pods (the pathways-head Pod keeps 30s); it is ignored when the --pathways-run-sps-workload flag is set.

  • --gke-disable-parallel-containers: Turns off parallel containers for TPU7x on GKE.

  • --placement-policy POLICY: The name of an existing Compute Engine compact placement or workload policy to use. If you omit this flag for A4X or multi-host TPU7x workloads, then the gcluster CLI resolves the policy automatically.

  • --node-constraint KEY=VALUE: Key-value pairs for node labels to target specific nodes. Supports a pipe separator (|) to specify multiple allowed values.

  • --cpu-affinity AFFINITY: CPU affinity rules.

  • --restart-on-exit-codes CODES: A comma-separated list of workload container exit codes from 1 to 255 that trigger a job restart up to the --restarts limit. Sidecar container exit codes aren't evaluated.

  • --image-pull-secret SECRET: A comma-separated list of secrets for pulling images from private registries. If you omit this flag, then the gcluster CLI attaches matching kubernetes.io/dockerconfigjson secrets from the target namespace for workload, Pathways, and ML Diagnostics images. To attach no pull secrets, pass the --image-pull-secret="" flag.

  • --service-account ACCOUNT: The Kubernetes service account name for the Pods. On TPU and Pathways jobs, setting this flag turns off the hostNetwork field so that Pods authenticate by using Workload Identity Federation for GKE. GPU jobs use the hostNetwork: true setting, so their Pods authenticate as the GKE node pool's service account.

  • --topology TOPOLOGY: The TPU slice topology, such as 2x4 or 2x4x4. This flag is required for TPU7x workloads.

  • --gke-scheduler SCHEDULER: The Kubernetes Scheduler name.

  • --await-job-completion: Waits for the submitted job to complete.

  • --timeout TIMEOUT: The time to wait for the job to complete, such as 1h or 10m. The default value is -1s, which waits indefinitely when the --await-job-completion flag is turned on. Setting a custom timeout automatically turns on the --await-job-completion flag.

  • --priority PRIORITY: A priority class name.

  • --verbose: Turns on verbose logging for the workload. Matching --env values on standard jobs or --pathways-worker-env values on Pathways jobs take precedence.

  • --enable-ml-diagnostics: Turns on ML Diagnostics for the workload. By default, this flag uses the GKE managed webhook and requires the target cluster to have ML Diagnostics turned on. If you also set the --ml-diagnostics-image flag or the GCLUSTER_TELEMETRY_IMAGE environment variable, then the gcluster CLI injects the built-in ai-telemetry-collector sidecar container on Kubernetes 1.29 and later TPU Pods.

  • --ml-diagnostics-image IMAGE: The container image for the built-in ai-telemetry-collector sidecar on Kubernetes 1.29 and later TPU workloads. This flag requires the --enable-ml-diagnostics flag and overrides the GCLUSTER_TELEMETRY_IMAGE environment variable. To ignore the GCLUSTER_TELEMETRY_IMAGE environment variable and use the GKE managed webhook, pass the --ml-diagnostics-image="" flag.

  • --ml-diagnostics-telemetry-port PORT: The Prometheus metrics port exposed by the ML Diagnostics collector sidecar. The default value is 8889. This flag requires the --enable-ml-diagnostics flag together with either the --ml-diagnostics-image flag or the GCLUSTER_TELEMETRY_IMAGE environment variable. Ports 8431 to 8438, 8471, 8476 to 8479, and 13133 are reserved.

  • --gke-nap-provisioning MODEL: The compute provisioning model for GKE node auto-provisioning, such as on-demand, spot, or reservation.

  • --gke-nap-reservation RESERVATION: The name of the Google Cloud reservation for GKE node auto-provisioning. This flag is required when you set the --gke-nap-provisioning=reservation flag.

  • --pathways: Generates a manifest for a Pathways job.

  • --pathways-proxy-server-image PW_PROXY_IMAGE: The image for the pathways-proxy container. Defaults to us-docker.pkg.dev/cloud-tpu-v2-images/pathways/proxy_server:latest, the matching cloud-pathways/proxy_server release tag when using a public --pathways-colocated-python-sidecar-image flag, or an image derived from the SPS instance. Required explicitly when the SPS server image is pinned by digest (@sha256:...).

  • --pathways-server-image PW_SERVER_IMAGE: The image for the pathways-rm container and the default for the pathways-worker container. Defaults to us-docker.pkg.dev/cloud-tpu-v2-images/pathways/server:latest, or the matching cloud-pathways/server release tag when using a public --pathways-colocated-python-sidecar-image flag.

  • --pathways-worker-image IMAGE: The image for the pathways-worker container. Defaults to the --pathways-server-image flag value.

  • --pathways-headless: Prevents deploying your workload container within the pathways-head job.

  • --pathways-deploy-sps: Deploys an SPS instance with a resource-manager-only pathways-head Pod and persistent TPU worker Pods. This flag requires the --pathways flag and can't be used with the --pathways-headless, --image, --base-image, --build-context, or --command flags.

  • --pathways-run-sps-workload INSTANCE_OR_ENDPOINT: Runs the --command flag against an existing SPS instance. Specify either the JobSet name or the service endpoint, such as NAME-pathways-head-0-0.NAME:29001.

    • Local mode. If you omit the --image and --base-image flags, then the gcluster CLI runs the command locally against a port-forwarded pathways-proxy Pod. The gcluster CLI sets the JAX_PLATFORMS=proxy environment variable unless overridden with the --env flag and sets the JAX_BACKEND_TARGET environment variable to the port-forward endpoint. The --mount flag isn't supported in local mode.
    • In-cluster mode. If you set the --image or --base-image flag, then the gcluster CLI runs the workload in the cluster and supports the --mount flag.

    This flag requires the --pathways flag and can't be combined with the following flags:

    • --compute-type
    • --gke-mtc-enabled
    • --ml-diagnostics-image
    • --ml-diagnostics-telemetry-port
    • --num-nodes
    • --pathways-colocated-python-sidecar-image
    • --pathways-deploy-sps
    • --pathways-elastic-slices
    • --pathways-headless
    • --pathways-max-slice-restarts
    • --pathways-server-*
    • --pathways-worker-*
    • --topology
  • --pathways-gcs-location PW_GCS_LOCATION: The Cloud Storage location to store Pathways artifacts. This flag is required when the --pathways flag is set, unless you also set the --pathways-run-sps-workload flag.

  • --pathways-elastic-slices N: Configures the number of elastic slices.

  • --pathways-max-slice-restarts N: The maximum number of failed-Pod replacements per worker index, from 0 to 2147483647. Sets the backoffLimitPerIndex field to N and caps the backoffLimit field at 2147483647. Defaults to one of the following values:

    • 0 for standard Pathways jobs
    • 4000 when the --pathways-elastic-slices flag is greater than 0 or the --pathways-headless flag is set
    • 1000000 when the --pathways-deploy-sps flag is set
  • --pathways-proxy-args ARGS: Additional arguments for the pathways-proxy container.

  • --pathways-server-args ARGS: Additional arguments for the pathways-rm container.

  • --pathways-worker-args ARGS: Additional arguments for the pathways-worker container.

  • --pathways-proxy-env KEY=VALUE: Environment variables for the pathways-proxy container in KEY=VALUE format. Replaces matching gcluster defaults. You can specify this flag multiple times.

  • --pathways-server-env KEY=VALUE: Environment variables for the pathways-rm container in KEY=VALUE format. Replaces matching gcluster defaults. You can specify this flag multiple times.

  • --pathways-worker-env KEY=VALUE: Environment variables for the pathways-worker container in KEY=VALUE format. Replaces matching gcluster defaults. You can specify this flag multiple times.

  • --pathways-colocated-python-sidecar-image IMAGE: The image for the Python-based sidecar container that runs in each Pathways worker Pod and shares memory with the worker at the /tmp/sidecar directory. Setting this flag mounts --mount volumes into the sidecar and passes the --sidecar_name=external argument to the pathways-proxy container unless the --pathways-proxy-args flag already sets the --sidecar_name argument. For public cloud-pathways sidecar tags, the gcluster CLI auto-matches the server and proxy release tags. For custom or digest-pinned sidecar images, pass matching --pathways-server-image and --pathways-proxy-server-image flags.

  • --pathways-head-np NP: The node pool to use for the Pathways head job. If you omit this flag, then the gcluster CLI detects a node pool named cpu-np or pathways-np automatically.

  • --gke-mtc-enabled: Turns on Multi-Tier Checkpointing (MTC).

  • --gke-mtc-ramdisk-dir DIR: The ramdisk directory path for MTC. This flag is required when the --gke-mtc-enabled flag is set.

  • --gke-custom-templates-path PATH: The path to the local directory containing custom GKE templates, such as base.tmpl, job.tmpl, jobset.tmpl, or pathways_jobset.tmpl. Any template file or shared base.tmpl block that you omit from the custom directory falls back to its embedded default.

PERSISTENT FLAGS

These flags are available to all gcluster job commands:

  • -c, --cluster CLUSTER_NAME: The name of the GKE cluster or Kubernetes kubeconfig context. Optional in Kubernetes mode when the current-context field is set.
  • -l, --location LOCATION: The location, either a region or a zone, of the GKE cluster (GKE only).
  • -p, --project PROJECT_ID: The Google Cloud project ID (GKE only).
  • --gke-namespace NAMESPACE: The target Kubernetes namespace for the operation. If you omit this flag, then the gcluster CLI detects the namespace automatically.
  • --skip-prereqs: Skips local environment prerequisite checks, such as kubectl and gcloud checks, and container registry authentication for Crane builds.

EXAMPLES

To submit a workload named train-job to a cluster:

gcluster job submit \
    --cluster=CLUSTER_NAME \
    --project=PROJECT_ID \
    --location=LOCATION \
    --name=train-job \
    --image=IMAGE \
    --compute-type=TYPE \
    --command="python3 train.py"

To submit a workload that mounts Cloud Storage buckets with storage profiles, mount options, and CSI volume attributes:

gcluster job submit \
    --cluster=CLUSTER_NAME \
    --project=PROJECT_ID \
    --location=LOCATION \
    --name=storage-train-job \
    --image=IMAGE \
    --compute-type=TYPE \
    --service-account=SERVICE_ACCOUNT \
    --mount="gs://my-dataset-bucket/imagenet;/data;ro;profile=training;options=implicit-dirs;attributes=anywhereCacheZones=us-central1-a" \
    --mount="gs://my-ckpt-bucket/run-42;/checkpoints;rw;profile=checkpointing" \
    --command="python3 train.py --data=/data --ckpt=/checkpoints"

To submit a multi-node workload:

gcluster job submit \
    --cluster=CLUSTER_NAME \
    --project=PROJECT_ID \
    --location=LOCATION \
    --name=multi-node-job \
    --image=IMAGE \
    --command="python3 train.py" \
    --compute-type=TYPE \
    --num-nodes=N

To submit a multi-slice workload:

gcluster job submit \
    --cluster=CLUSTER_NAME \
    --project=PROJECT_ID \
    --location=LOCATION \
    --name=multi-slice-job \
    --image=IMAGE \
    --command="python3 train.py" \
    --compute-type=TYPE \
    --num-slices=N

To submit a Pathways workload:

gcluster job submit \
    --cluster=CLUSTER_NAME \
    --project=PROJECT_ID \
    --location=LOCATION \
    --name=pw-train-job \
    --compute-type=TYPE \
    --image=IMAGE \
    --pathways-server-image=PW_SERVER_IMAGE \
    --pathways-proxy-server-image=PW_PROXY_IMAGE \
    --command="python3 train.py" \
    --pathways \
    --pathways-gcs-location=PW_GCS_LOCATION