Fine-tune and serve a vision-language-action (VLA) model for robotics with Ray on GKE

This tutorial shows you how to fine-tune, evaluate, and serve a vision-language-action (VLA) model for robot manipulation on Google Kubernetes Engine (GKE). A VLA model is also known as a robotics foundation model or a physical AI model. You use Ray and the KubeRay operator to run a complete robot learning pipeline on a single GKE cluster.

In this tutorial, you stream multi-camera robot demonstration data from Cloud Storage, fine-tune the Physical Intelligence PI0.5 model across 8 GPUs, evaluate the fine-tuned policy in parallel robot arm simulations, and deploy the policy as a long-running inference service.

This tutorial uses a single node that has 8 NVIDIA RTX PRO 6000 GPUs (96 GB of GPU memory each) on the g4-standard-384 machine type. The accelerator configuration that you need depends on the training batch size, simulation concurrency, and model parameters. You can adapt the workload to other multi-GPU configurations, such as NVIDIA L4, A100, or H100 GPUs. For more information, see Run the sample on smaller or alternative GPU node pools.

This tutorial is intended for Machine learning (ML) engineers, Platform admins and operators, and Data and AI specialists who want to use Kubernetes container orchestration for robotics model fine-tuning and closed-loop simulation. To learn more about common roles and example tasks referenced in Google Cloud content, see Common GKE user roles and tasks.

Background

The following sections provide a brief overview of the concepts used in this tutorial.

Vision-language-action models

A vision-language-action (VLA) model takes camera images, a natural-language task instruction, and the current robot state as input, and predicts the robot actions to perform next. In this tutorial, the model predicts action chunks, which are sequences of 50 future robot actions.

For more information, see Robotics foundation models.

Physical Intelligence PI0.5

PI0.5 is a 3.4-billion parameter robotics foundation model from Physical Intelligence. The model combines the following components:

  • A vision-language transformer backbone (PaliGemma) that stays frozen during fine-tuning.
  • Trainable Action Expert projection multi-layer perceptron (MLP) heads that predict 50-step action chunks. These heads train with a flow matching loss.

For more information, see Physical Intelligence openpi.

LIBERO robotics dataset

In this tutorial, you use demonstration data in the LIBERO robotics benchmark format. The dataset contains 37 manipulation tasks across 1,693 episodes and 273,465 frames. Each frame includes images from two cameras, the robot joint state, and the robot action.

For more information, see LIBERO.

Ray on GKE

Ray is an open-source framework for distributed compute. The Ray Operator add-on for GKE installs KubeRay, which manages Ray workloads by using Kubernetes custom resources. This tutorial uses the following Ray libraries and KubeRay resources:

  • Ray Data: streams and decodes the demonstration dataset.
  • Ray Train: runs Distributed Data Parallel (DDP) fine-tuning with PyTorch across 8 GPUs.
  • Ray Serve: serves the policy for simulation and inference.
  • RayJob resource: creates a Ray cluster, runs a batch job, and then deletes the Ray cluster.
  • RayService resource: runs a long-lived, self-healing Ray Serve application.

For more information, see About Ray on GKE.

Robot arm simulation

To evaluate the fine-tuned policy, the tutorial runs parallel simulations of a Franka Panda robot arm. Each simulation worker queries the served policy, steps through the simulated environment, and records camera observations and rewards. The pipeline adds high-reward trajectories to the training data and retrains the policy, which creates a closed-loop retraining cycle.

Architecture

The following diagram shows the components of the robot learning pipeline on GKE:

Architecture diagram of a GKE cluster that runs a robot learning pipeline.
Robot learning pipeline with Ray on GKE.

The pipeline runs in the following stages:

  1. Robotics data pipeline: Ray Data streams the 37 LIBERO tasks directly from Cloud Storage by using Cloud Storage FUSE. Workers decode H.264 video streams with PyAV as they read the data, and then assemble multimodal training batches.
  2. Distributed fine-tuning: Ray Train runs DDP training across 8 GPUs on a single node. The Action Expert heads train for 1,000 steps with FP16 mixed precision, and the Job saves the checkpoint to Cloud Storage.
  3. Demonstration generation and closed-loop retraining: a Kubernetes Job generates expert demonstrations. Ray Serve then deploys the policy on GPU 0 while 8 simulation workers run across all 8 GPUs. The pipeline filters and normalizes the evaluated trajectories, merges them with any expert demonstrations that are stored in Cloud Storage, and retrains the policy.
  4. Persistent policy serving: KubeRay deploys a RayService resource that exposes port 8000 through a Kubernetes ClusterIP Service for continuous inference.

Objectives

This tutorial shows you how to fine-tune and serve a VLA model on GKE by completing the following steps:

  1. Create a GKE Standard cluster with the Ray Operator and Cloud Storage FUSE CSI driver add-ons.
  2. Configure Workload Identity Federation for GKE and create the Kubernetes storage resources.
  3. Stream and process robot demonstration data with Ray Data.
  4. Fine-tune the PI0.5 model across 8 GPUs with Ray Train and PyTorch DDP.
  5. Generate expert manipulation trajectories for a Franka Panda robot arm.
  6. Evaluate policy rollouts in parallel simulated environments by using Ray Serve.
  7. Deploy the fine-tuned policy as a self-healing RayService resource.

Before you begin

  • Install the Google Cloud CLI.

  • Configure the gcloud CLI to use your federated identity.

    For more information, see Sign in to the gcloud CLI with your federated identity.

  • To initialize the gcloud CLI, run the following command:

    gcloud init
  • Create or select a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.
    • Create a Google Cloud project:

      gcloud projects create PROJECT_ID

      Replace PROJECT_ID with a name for the Google Cloud project you are creating.

    • Select the Google Cloud project that you created:

      gcloud config set project PROJECT_ID

      Replace PROJECT_ID with your Google Cloud project name.

  • Verify that billing is enabled for your Google Cloud project.

  • Enable the required APIs, if any are not already enabled:

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    gcloud services enable container.googleapis.com compute.googleapis.com storage.googleapis.com
  • Grant roles to your user account. Run the following command once for each of the following IAM roles: roles/container.admin, roles/storage.admin

    gcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE

    Replace the following:

  • Ensure that your project has sufficient GPU quota in your region for 8 GPUs on a single node:

    • For on-demand NVIDIA RTX PRO 6000 GPUs, check the regional quota for GPU_FAMILY:NVIDIA_RTX_PRO_6000 (quota ID GPUS-PER-GPU-FAMILY-per-project-region with dimension gpu_family=NVIDIA_RTX_PRO_6000). For Spot VMs, check PREEMPTIBLE_NVIDIA_RTX_PRO_6000_GPUS.
    • If you adapt the sample to other GPU types, such as NVIDIA L4, A100, or H100 GPUs, then check the quota for those accelerators.

    To learn more, see Plan GPU quota and GPU quota.

Prepare your environment

In this tutorial, you use Cloud Shell.

  1. Go to the Google Cloud console.

  2. At the top of the Google Cloud console window, click the Activate Cloud Shell button.

  3. Set the environment variables:

    export PROJECT_ID=$(gcloud config get-value project)
    export REGION=YOUR_REGION
    export ZONE=YOUR_ZONE
    export CLUSTER_NAME=YOUR_CLUSTER_NAME
    export GCS_BUCKET_NAME=YOUR_BUCKET_NAME
    export K8S_SA_NAME=workload-identity-k8s-sa
    export K8S_NAMESPACE=default
    export PROJECT_NUMBER=$(gcloud projects describe ${PROJECT_ID} --format="value(projectNumber)")
    

    Replace the following values:

    • YOUR_REGION: the Compute Engine region for your cluster and Cloud Storage bucket, for example, us-central1.
    • YOUR_ZONE: the zone for your GPU nodes, for example, us-central1-b. Select a zone where your GPUs are available.
    • YOUR_CLUSTER_NAME: the name of your GKE cluster.
    • YOUR_BUCKET_NAME: a globally unique name for your Cloud Storage bucket. You don't need to specify the gs:// prefix.

    The sample manifests use the workload-identity-k8s-sa Kubernetes ServiceAccount in the default namespace, so don't change the values of the K8S_SA_NAME and K8S_NAMESPACE variables. The PROJECT_NUMBER variable stores your project number, which you use to grant the Kubernetes ServiceAccount access to your bucket.

  4. Clone the sample repository:

    git clone https://github.com/GoogleCloudPlatform/kubernetes-engine-samples.git
    
  5. Navigate to the working directory:

    cd kubernetes-engine-samples/ai-ml/physical-ai-on-gke
    

    In the rest of the tutorial, look in this directory to find the files that you need to inspect or apply.

Set up infrastructure

In this section, you create the GKE cluster and the GPU node pool.

  1. Create a Standard cluster with Workload Identity Federation for GKE, the Ray Operator add-on, and the Cloud Storage FUSE CSI driver add-on enabled:

    gcloud container clusters create ${CLUSTER_NAME} \
        --location=${REGION} \
        --release-channel=stable \
        --machine-type=e2-standard-8 \
        --num-nodes=1 \
        --workload-pool=${PROJECT_ID}. \
        --addons=RayOperator=ENABLED,GcsFuseCsiDriver=ENABLED
    

    The default node pool runs the CPU-only Kubernetes Jobs that stage data and generate demonstrations. These Jobs request up to 4 vCPUs and 16 GiB of memory, so the command uses the e2-standard-8 machine type. The --num-nodes=1 flag creates one node in each zone of the region.

  2. Create a GPU node pool with one g4-standard-384 node that has 8 NVIDIA RTX PRO 6000 GPUs:

    gcloud container node-pools create gpu-pool-8x \
        --cluster=${CLUSTER_NAME} \
        --location=${REGION} \
        --node-locations=${ZONE} \
        --machine-type=g4-standard-384 \
        --accelerator=type=nvidia-rtx-pro-6000,count=8,gpu-driver-version=latest \
        --num-nodes=1 \
        --no-enable-autoscaling
    
  3. Get credentials for your cluster:

    gcloud container clusters get-credentials ${CLUSTER_NAME} \
        --location=${REGION}
    

Prepare data and storage

All stages of this tutorial read datasets and store checkpoints in a single Cloud Storage bucket. The Ray Pods mount the bucket at the /checkpoint path by using the Cloud Storage FUSE CSI driver.

Create the bucket and configure access

  1. Create a Cloud Storage bucket:

    gcloud storage buckets create gs://${GCS_BUCKET_NAME} \
        --location=${REGION} \
        --uniform-bucket-level-access
    
  2. Grant the Kubernetes ServiceAccount permission to manage objects in your bucket by using Workload Identity Federation for GKE:

    gcloud storage buckets add-iam-policy-binding gs://${GCS_BUCKET_NAME} \
        --member="principal://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/${PROJECT_ID}./subject/ns/${K8S_NAMESPACE}/sa/${K8S_SA_NAME}" \
        --role="roles/storage.objectAdmin"
    

    This command grants the roles/storage.objectAdmin role directly to the workload-identity-k8s-sa Kubernetes ServiceAccount in the default namespace. You can grant the role before the ServiceAccount exists. You create the ServiceAccount in the next section.

Create the Kubernetes storage resources

  1. Inspect the 00-infrastructure.yaml manifest:

    # Copyright 2026 Google LLC. All rights reserved.
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    # ---------------------------------------------------------------------------
    # Physical AI on GKE - Base Infrastructure
    #
    # Creates the Kubernetes ServiceAccount (granted direct bucket access via
    # Workload Identity Federation for GKE) and the Cloud Storage FUSE
    # PersistentVolume / Claim that every phase of this sample mounts at
    # /checkpoint.
    #
    # BEFORE APPLYING, replace the placeholder below:
    #   GCS_BUCKET_NAME  -> your Cloud Storage bucket (no gs:// prefix)
    #
    # Example:
    #   sed "s/GCS_BUCKET_NAME/${BUCKET}/g" \
    #     models/pi05/manifests/00-infrastructure.yaml | kubectl apply -f -
    # ---------------------------------------------------------------------------
    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: workload-identity-k8s-sa
      namespace: default
    ---
    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: physical-ai-checkpoint-pv
    spec:
      accessModes:
        - ReadWriteMany
      capacity:
        # Ignored by the Cloud Storage FUSE CSI driver, but required by the API.
        storage: 64Gi
      persistentVolumeReclaimPolicy: Retain
      storageClassName: ""
      mountOptions:
        - implicit-dirs
        - uid=1000
        - gid=100
      csi:
        driver: gcsfuse.csi.storage.gke.io
        # The Cloud Storage bucket backing /checkpoint.
        volumeHandle: GCS_BUCKET_NAME
    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: physical-ai-checkpoint-pvc
      namespace: default
    spec:
      accessModes:
        - ReadWriteMany
      resources:
        requests:
          storage: 64Gi
      storageClassName: ""
      volumeName: physical-ai-checkpoint-pv
    

    This manifest defines the following resources:

    • A ServiceAccount resource named workload-identity-k8s-sa, which the Ray Pods use to access your bucket. This ServiceAccount has the roles/storage.objectAdmin role on your bucket that you granted in the previous section.
    • A PersistentVolume resource that uses the gcsfuse.csi.storage.gke.io CSI driver. The volumeHandle field specifies the bucket to mount.
    • A PersistentVolumeClaim resource named physical-ai-checkpoint-pvc that requests the volume with the ReadWriteMany access mode.

    The volumeHandle field contains the GCS_BUCKET_NAME placeholder. You must replace this placeholder before you apply the manifest.

  2. Replace the GCS_BUCKET_NAME placeholder in the manifest with your bucket name, and then apply the manifest:

    sed "s/GCS_BUCKET_NAME/${GCS_BUCKET_NAME}/g" \
        models/pi05/manifests/00-infrastructure.yaml | kubectl apply -f -
    

    The GCS_BUCKET_NAME environment variable contains your bucket name without the gs:// prefix. If you include the prefix, then the Cloud Storage FUSE CSI driver can't mount the bucket.

  3. Verify that the PersistentVolume references your bucket:

    kubectl get pv physical-ai-checkpoint-pv \
        -o jsonpath='{.spec.csi.volumeHandle}{"\n"}'
    

    The output is your bucket name. If the output is GCS_BUCKET_NAME, then delete the PersistentVolumeClaim and PersistentVolume, and run the sed command from the previous step again:

    kubectl delete pvc physical-ai-checkpoint-pvc
    kubectl delete pv physical-ai-checkpoint-pv
    
  4. Verify that the status of the PersistentVolumeClaim is Bound:

    kubectl get pvc physical-ai-checkpoint-pvc
    

    The output is similar to the following:

    NAME                         STATUS   VOLUME                      CAPACITY   ACCESS MODES   STORAGECLASS   AGE
    physical-ai-checkpoint-pvc   Bound    physical-ai-checkpoint-pv   64Gi       RWX                           12s
    

Publish scripts and tools as ConfigMaps

To make the Python training scripts and environment tools available inside your Ray Pods without building a custom container image, publish them as Kubernetes ConfigMaps:

kubectl create configmap physical-ai-scripts \
    --from-file=models/pi05/scripts/ \
    --dry-run=client -o yaml | kubectl apply -f -
kubectl create configmap physical-ai-tools \
    --from-file=models/pi05/tools/ \
    --dry-run=client -o yaml | kubectl apply -f -

Stage the dataset and pretrained model weights

The sample uses LIBERO demonstration data and pretrained PI0.5 weights.

  1. Inspect the 00-mirror-sync-job.yaml manifest, which configures a Kubernetes Job that copies the demonstration data and base weights into your bucket:

    # Copyright 2026 Google LLC. All rights reserved.
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    apiVersion: batch/v1
    kind: Job
    metadata:
      name: physical-ai-mirror-sync
      namespace: default
      labels:
        app.kubernetes.io/name: physical-ai-mirror-sync
    spec:
      backoffLimit: 2
      ttlSecondsAfterFinished: 600
      template:
        metadata:
          annotations:
            gke-gcsfuse/volumes: "true"
            gke-gcsfuse/mount-options: "uid=1000,gid=1000"
        spec:
          restartPolicy: OnFailure
          serviceAccountName: workload-identity-k8s-sa
          securityContext:
            fsGroup: 100
          containers:
            - name: mirror-sync
              image: rayproject/ray:2.55.1-py311
              command: ["/bin/bash", "-c"]
              args:
                - |
                  python3 /app/tools/sync_mirror_from_anyscale.py --dest-dir /checkpoint/physical-ai/mirror --workers 16
              resources:
                requests:
                  cpu: "4"
                  memory: "8Gi"
                limits:
                  cpu: "8"
                  memory: "16Gi"
              volumeMounts:
                - name: checkpoint-storage
                  mountPath: /checkpoint
                - name: tools-volume
                  mountPath: /app/tools
          volumes:
            - name: checkpoint-storage
              persistentVolumeClaim:
                claimName: physical-ai-checkpoint-pvc
            - name: tools-volume
              configMap:
                name: physical-ai-tools
    
  2. Apply the manifest:

    kubectl apply -f models/pi05/manifests/00-mirror-sync-job.yaml
    
  3. Wait for the Job to complete:

    kubectl wait --for=condition=complete job/physical-ai-mirror-sync --timeout=3600s
    

Deploy RayCluster for data processing

In this section, you submit a RayJob resource. KubeRay creates a Ray cluster for the job, runs the robotics data pipeline, and then deletes the Ray cluster. The pipeline reads multi-camera demonstration episodes directly from Cloud Storage FUSE, without downloading files to local node disks.

The 01_robotics_data_pipelines.py script performs the following operations:

  • Streams the 37 LIBERO tasks from the /checkpoint/physical-ai/mirror/libero directory.
  • Decodes the H.264 camera streams observation.images.image and observation.images.image2 by using PyAV while the data streams.
  • Extracts 8-dimensional robot joint states from the observation.state field and 7-dimensional actions from the action field.
  • Validates the dimensions of the multimodal tensor batches for training.

The following animation shows how a Ray Data read task streams one demonstration row from Cloud Storage:

Animation of a Ray Data read task. The task reads LIBERO Parquet files and camera video files from the /checkpoint path that Cloud Storage FUSE mounts. The task seeks to a Parquet row, reads a byte range of the video file from Cloud Storage, decodes the H.264 frames with PyAV, and assembles a multimodal row that contains two camera images, the robot state, and the robot action.
Ray Data streams and decodes a demonstration row directly from Cloud Storage.

To deploy the data processing workload, do the following:

  1. Inspect the 01-data-processing-rayjob.yaml manifest:

    # Copyright 2026 Google LLC. All rights reserved.
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    apiVersion: ray.io/v1
    kind: RayJob
    metadata:
      name: physical-ai-01-data-processing
      namespace: default
      labels:
        app.kubernetes.io/name: physical-ai-data-processing
        app.kubernetes.io/component: data-pipeline
        stage: phase-1-data-processing
    spec:
      submissionMode: K8sJobMode
      shutdownAfterJobFinishes: true
      submitterPodTemplate:
        spec:
          restartPolicy: Never
          containers:
            - name: ray-job-submitter
              image: rayproject/ray:2.55.1-py311
      entrypoint: bash -c "PYTHONPATH=/app:/app/tools:$PYTHONPATH python3 /app/scripts/01_robotics_data_pipelines.py --dataset-uri /checkpoint/physical-ai/mirror/libero --storage-root /checkpoint/physical-ai --batch-size 32 --sample-rows 10"
      runtimeEnvYAML: |
        env_vars:
          HF_HUB_OFFLINE: "1"
          HF_HUB_ENABLE_HF_TRANSFER: "1"
          HF_HUB_DOWNLOAD_TIMEOUT: "60"
          PYTHONPATH: "/app:/app/tools:$PYTHONPATH"
        pip:
          - av==15.1.0
          - pyarrow>=14.0.0
          - s3fs>=2024.1
          - fsspec[s3]>=2024.1
          - numpy>=1.26,<2
          - imageio[ffmpeg]==2.37.0
      rayClusterSpec:
        rayVersion: "2.55.1"
        headGroupSpec:
          rayStartParams:
            dashboard-host: "0.0.0.0"
            num-cpus: "16"
          template:
            metadata:
              annotations:
                gke-gcsfuse/volumes: "true"
                gke-gcsfuse/mount-options: "uid=1000,gid=1000"
              labels:
                ray.io/node-type: head
            spec:
              serviceAccountName: workload-identity-k8s-sa
              tolerations:
                - key: "nvidia.com/gpu"
                  operator: "Exists"
                  effect: "NoSchedule"
              securityContext:
                fsGroup: 100
              containers:
                - name: ray-head
                  image: rayproject/ray:2.55.1-py311
                  imagePullPolicy: IfNotPresent
                  resources:
                    limits:
                      cpu: "16"
                      memory: "64Gi"
                    requests:
                      cpu: "8"
                      memory: "32Gi"
                  volumeMounts:
                    - name: gcs-fuse-checkpoint-vol
                      mountPath: /checkpoint
                    - name: scripts-volume
                      mountPath: /app/scripts
                    - name: tools-volume
                      mountPath: /app/tools
                  ports:
                    - containerPort: 6379
                      name: gcs-server
                    - containerPort: 8265
                      name: dashboard
                    - containerPort: 10001
                      name: client
              volumes:
                - name: gcs-fuse-checkpoint-vol
                  persistentVolumeClaim:
                    claimName: physical-ai-checkpoint-pvc
                - name: scripts-volume
                  configMap:
                    name: physical-ai-scripts
                - name: tools-volume
                  configMap:
                    name: physical-ai-tools
        workerGroupSpecs:
          - groupName: data-workers
            replicas: 2
            minReplicas: 1
            maxReplicas: 4
            rayStartParams:
              num-cpus: "32"
            template:
              metadata:
                annotations:
                  gke-gcsfuse/volumes: "true"
                  gke-gcsfuse/mount-options: "uid=1000,gid=1000"
                labels:
                  ray.io/node-type: worker
              spec:
                serviceAccountName: workload-identity-k8s-sa
                tolerations:
                  - key: "nvidia.com/gpu"
                    operator: "Exists"
                    effect: "NoSchedule"
                securityContext:
                  fsGroup: 100
                containers:
                  - name: ray-worker
                    image: rayproject/ray:2.55.1-py311
                    imagePullPolicy: IfNotPresent
                    resources:
                      limits:
                        cpu: "32"
                        memory: "128Gi"
                      requests:
                        cpu: "16"
                        memory: "64Gi"
                    volumeMounts:
                      - name: gcs-fuse-checkpoint-vol
                        mountPath: /checkpoint
                      - name: scripts-volume
                        mountPath: /app/scripts
                      - name: tools-volume
                        mountPath: /app/tools
                volumes:
                  - name: gcs-fuse-checkpoint-vol
                    persistentVolumeClaim:
                      claimName: physical-ai-checkpoint-pvc
                  - name: scripts-volume
                    configMap:
                      name: physical-ai-scripts
                  - name: tools-volume
                    configMap:
                      name: physical-ai-tools
    
  2. Apply the manifest:

    kubectl apply -f models/pi05/manifests/01-data-processing-rayjob.yaml
    
  3. Monitor the status of the RayJob resource:

    kubectl get rayjob physical-ai-01-data-processing -w
    
  4. View the logs from the submitter Pod. KubeRay creates a Kubernetes Job with the same name as the RayJob resource to submit the Ray job, so you can read the logs from that Job:

    kubectl logs -f job/physical-ai-01-data-processing
    

In a verified test run, the job completed with the SUCCEEDED status in 32 seconds and produced the following results:

Metric Result
Frames streamed 273,465 frames from 37 tasks and 1,693 episodes
Validation latency 8.43 seconds for PyAV decoding and Apache Arrow table assembly
Batch tensor shapes
  • Cameras 1 and 2: (10, 3, 256, 256), uint8
  • State: (10, 8), float64
  • Action: (10, 7), float64

Launch the VLA fine-tuning job

In this section, you fine-tune the PI0.5 model across 8 GPUs by using Ray Train in DDP mode. The training job uses the following configuration:

  • Architecture: the PaliGemma backbone stays frozen in FP16 precision. Training updates only the Action Expert MLP heads, which have 27,270,158 trainable parameters.
  • Objective: behavior cloning with a continuous-time flow matching loss that predicts 50-step action chunks.
  • Distributed engine: the Ray Train TorchTrainer class coordinates 8 DDP worker processes across 8 GPUs.
  • Optimization: the AdamW optimizer with cosine learning rate decay and linear warmup (lr=5e-5), a batch size of 16 for each worker, and a gradient accumulation of 1, for an effective batch size of 128.

To launch the fine-tuning job, do the following:

  1. If an earlier run of the training job exists, then delete it:

    kubectl delete rayjob physical-ai-02-vla-finetuning --ignore-not-found=true
    
  2. Inspect the 02-vla-training-rayjob.yaml manifest:

    # Copyright 2026 Google LLC. All rights reserved.
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    # ---------------------------------------------------------------------------
    # Phase 2: Distributed VLA fine-tuning (PI0.5, 1000 steps).
    #
    # Reference node shape: 1 x g4-standard-384
    #   8 x NVIDIA RTX PRO 6000 (96 GB VRAM each) | 384 vCPUs | ~1.5 TB host RAM
    #
    # Worker group below requests the whole node: 8 GPUs / 128 vCPUs / 512 GiB,
    # giving one Ray Train DDP worker per GPU (--num-workers 8).
    # To run on a smaller node pool, lower num-gpus, nvidia.com/gpu, cpu, memory
    # and --num-workers together.
    # ---------------------------------------------------------------------------
    apiVersion: ray.io/v1
    kind: RayJob
    metadata:
      name: physical-ai-02-vla-finetuning
      namespace: default
      labels:
        app.kubernetes.io/name: physical-ai-vla-finetuning
        app.kubernetes.io/component: model-training
        stage: phase-2-vla-finetuning
    spec:
      submissionMode: K8sJobMode
      shutdownAfterJobFinishes: true
      # Release the RayCluster (and therefore all 8 GPUs) as soon as training
      # finishes. A non-zero TTL keeps the GPUs reserved and prevents the Phase 3
      # RayJob from scheduling on a single-node GPU cluster. Submitter pod logs are
      # retained independently of the cluster, so `kubectl logs` still works after.
      ttlSecondsAfterFinished: 0
      submitterPodTemplate:
        spec:
          restartPolicy: Never
          containers:
            - name: ray-job-submitter
              image: rayproject/ray:2.55.1-py311
      entrypoint: bash -c "bash /app/tools/setup_vla_deps.sh && PYTHONPATH=/app:/app/tools:$PYTHONPATH python3 /app/scripts/02_vla_finetuning.py --dataset-uri /checkpoint/physical-ai/mirror/libero --storage-root /checkpoint/physical-ai --num-workers 8 --max-steps 1000 --batch-size 16 --grad-accum 1 --lr 5e-5 --val-batches 8 --round-name round1"
      runtimeEnvYAML: |
        env_vars:
          HF_HUB_OFFLINE: "1"
          HF_HUB_ENABLE_HF_TRANSFER: "1"
          HF_HUB_DOWNLOAD_TIMEOUT: "60"
          TORCHDYNAMO_DISABLE: "1"
          PYTHONPATH: "/app:/app/tools:$PYTHONPATH"
      rayClusterSpec:
        rayVersion: "2.55.1"
        headGroupSpec:
          rayStartParams:
            dashboard-host: "0.0.0.0"
            num-cpus: "8"
          template:
            metadata:
              annotations:
                gke-gcsfuse/volumes: "true"
                gke-gcsfuse/mount-options: "uid=1000,gid=1000"
              labels:
                ray.io/node-type: head
            spec:
              serviceAccountName: workload-identity-k8s-sa
              tolerations:
                - key: "nvidia.com/gpu"
                  operator: "Exists"
                  effect: "NoSchedule"
              securityContext:
                fsGroup: 100
              containers:
                - name: ray-head
                  image: rayproject/ray:2.55.1-py311-gpu
                  imagePullPolicy: IfNotPresent
                  resources:
                    limits:
                      cpu: "8"
                      memory: "32Gi"
                    requests:
                      cpu: "4"
                      memory: "16Gi"
                  volumeMounts:
                    - name: gcs-fuse-checkpoint-vol
                      mountPath: /checkpoint
                    - name: scripts-volume
                      mountPath: /app/scripts
                    - name: tools-volume
                      mountPath: /app/tools
                  ports:
                    - containerPort: 6379
                      name: gcs-server
                    - containerPort: 8265
                      name: dashboard
                    - containerPort: 10001
                      name: client
              volumes:
                - name: gcs-fuse-checkpoint-vol
                  persistentVolumeClaim:
                    claimName: physical-ai-checkpoint-pvc
                - name: scripts-volume
                  configMap:
                    name: physical-ai-scripts
                - name: tools-volume
                  configMap:
                    name: physical-ai-tools
        workerGroupSpecs:
          - groupName: gpu-train-workers
            replicas: 1
            minReplicas: 1
            maxReplicas: 1
            rayStartParams:
              num-gpus: "8"
              num-cpus: "128"
            template:
              metadata:
                annotations:
                  gke-gcsfuse/volumes: "true"
                  gke-gcsfuse/mount-options: "uid=1000,gid=1000"
                labels:
                  ray.io/node-type: worker
              spec:
                serviceAccountName: workload-identity-k8s-sa
                tolerations:
                  - key: "nvidia.com/gpu"
                    operator: "Exists"
                    effect: "NoSchedule"
                securityContext:
                  fsGroup: 100
                containers:
                  - name: ray-worker
                    image: rayproject/ray:2.55.1-py311-gpu
                    imagePullPolicy: IfNotPresent
                    resources:
                      limits:
                        nvidia.com/gpu: "8"
                        cpu: "128"
                        memory: "512Gi"
                      requests:
                        nvidia.com/gpu: "8"
                        cpu: "64"
                        memory: "256Gi"
                    volumeMounts:
                      - name: gcs-fuse-checkpoint-vol
                        mountPath: /checkpoint
                      - name: scripts-volume
                        mountPath: /app/scripts
                      - name: tools-volume
                        mountPath: /app/tools
                volumes:
                  - name: gcs-fuse-checkpoint-vol
                    persistentVolumeClaim:
                      claimName: physical-ai-checkpoint-pvc
                  - name: scripts-volume
                    configMap:
                      name: physical-ai-scripts
                  - name: tools-volume
                    configMap:
                      name: physical-ai-tools
    
  3. Apply the manifest:

    kubectl apply -f models/pi05/manifests/02-vla-training-rayjob.yaml
    
  4. View the training logs from the submitter Pod:

    kubectl logs -f job/physical-ai-02-vla-finetuning
    

In a verified test run of 1,000 training steps, the job produced the following results:

Metric Result
Duration 1,000 optimizer updates in 1,571.2 seconds, about 0.64 steps per second
Cluster topology 8 NVIDIA RTX PRO 6000 GPUs (world_size=8) that run PyTorch DDP
Peak GPU memory 14.4 GB per GPU, out of 96 GB available
Held-out validation loss 0.5699 to 0.1775, a 68.9% improvement on 4 validation episodes (1,128 rows)
Saved checkpoint /checkpoint/physical-ai/checkpoint_round1/state.pkl (24.8 MiB)
kubectl logs $(kubectl get pods -o name | grep 'physical-ai-02-vla-finetuning-' | grep -vE 'head|worker' | head -1) > 02-vla-training.log
kubectl delete rayjob physical-ai-02-vla-finetuning --wait=true

Generate expert demonstrations

In this section, you generate high-reward demonstration trajectories for Franka Panda manipulation. If you store these trajectories in your bucket, then they provide kinematic grounding for coordinate normalization during closed-loop retraining.

The generate_franka_demos.py script writes the demonstrations to the /checkpoint/physical-ai/franka_demos directory only if that directory already exists in your bucket. Otherwise, the script writes them to the /tmp/franka_demos directory in the Job Pod, and the demonstrations are deleted when the Pod ends. In that case, the closed-loop retraining stage doesn't use the demonstrations.

  1. Optional: to store the demonstrations in your bucket so that the closed-loop retraining stage uses them, create the franka_demos directory in your bucket:

    echo -n | gcloud storage cp - gs://${GCS_BUCKET_NAME}/physical-ai/franka_demos/.keep
    

    This command creates an empty placeholder object. Because the PersistentVolume uses the implicit-dirs mount option, Cloud Storage FUSE shows the franka_demos directory in the /checkpoint mount.

  2. Inspect the 02b-generate-demos-job.yaml manifest:

    # Copyright 2026 Google LLC. All rights reserved.
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    apiVersion: batch/v1
    kind: Job
    metadata:
      name: physical-ai-generate-demos
      namespace: default
      labels:
        app.kubernetes.io/name: physical-ai-generate-demos
    spec:
      backoffLimit: 2
      ttlSecondsAfterFinished: 600
      template:
        metadata:
          annotations:
            gke-gcsfuse/volumes: "true"
            gke-gcsfuse/mount-options: "uid=1000,gid=1000"
        spec:
          restartPolicy: OnFailure
          serviceAccountName: workload-identity-k8s-sa
          securityContext:
            fsGroup: 100
          containers:
            - name: demo-generator
              image: rayproject/ray:2.55.1-py311
              command: ["/bin/bash", "-c"]
              args:
                - |
                  pip install --no-cache-dir Pillow numpy torch
                  python3 /app/tools/generate_franka_demos.py
              resources:
                requests:
                  cpu: "4"
                  memory: "16Gi"
                limits:
                  cpu: "8"
                  memory: "32Gi"
              volumeMounts:
                - name: checkpoint-storage
                  mountPath: /checkpoint
                - name: tools-volume
                  mountPath: /app/tools
          volumes:
            - name: checkpoint-storage
              persistentVolumeClaim:
                claimName: physical-ai-checkpoint-pvc
            - name: tools-volume
              configMap:
                name: physical-ai-tools
    
  3. Apply the manifest:

    kubectl apply -f models/pi05/manifests/02b-generate-demos-job.yaml
    
  4. Wait for the Job to complete:

    kubectl wait --for=condition=complete job/physical-ai-generate-demos --timeout=3600s
    
  5. Check where the Job saved the demonstrations:

    kubectl logs job/physical-ai-generate-demos | grep "Saved to"
    

    If you created the franka_demos directory, then the output is similar to the following:

    Saved to: /checkpoint/physical-ai/franka_demos/expert_dataset.pkl
    

    If the output shows the /tmp/franka_demos directory, then the demonstrations aren't stored in your bucket.

The Job generates 25 expert episodes in the expert_dataset.pkl file. The episodes contain 2,500 frames of pick-and-lift execution, with an average episode reward of +87.86.

Evaluate the policy in simulation

In this section, you connect model serving, parallel simulation, and retraining in a closed loop:

  1. Model serving: Ray Serve deploys the PI05PolicyServer deployment on GPU 0 and exposes an HTTP /predict endpoint.
  2. Parallel simulation: 8 Franka Panda simulation workers run on GPUs 0-7. Worker 0 shares GPU 0 with Ray Serve. The workers query the served policy over HTTP, step through the simulated environment, and record observation images and rewards.
  3. Closed-loop retraining: the pipeline extracts high-reward trajectories, merges them with the demonstration dataset by using the ray.data.union method, and then retrains the policy on 8 GPUs for 100 steps. The pipeline includes the expert demonstrations only if the /checkpoint/physical-ai/franka_demos/expert_dataset.pkl file exists. If no expert demonstrations or high-reward trajectories are available, then the pipeline retrains the policy on the base LIBERO dataset, and the logs show the following message:

    No demonstration or sim frames available; using base dataset.
    

To run the simulation and retraining workload, do the following:

  1. Inspect the 03-serving-sim-eval-rayjob.yaml manifest:

    # Copyright 2026 Google LLC. All rights reserved.
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    # ---------------------------------------------------------------------------
    # Phase 3: Ray Serve policy + parallel Franka sim eval + DDP retraining.
    #
    # Reference node shape: 1 x g4-standard-384
    #   8 x NVIDIA RTX PRO 6000 (96 GB VRAM each) | 384 vCPUs | ~1.5 TB host RAM
    #
    # Worker group requests the whole node: 8 GPUs / 128 vCPUs / 512 GiB.
    # GPU 0 hosts the Ray Serve replica (0.5 GPU) alongside sim worker 0; sim
    # workers 1-7 occupy GPUs 1-7 (--sim-workers 8). Retraining then uses all 8
    # GPUs, one DDP worker each.
    # ---------------------------------------------------------------------------
    apiVersion: ray.io/v1
    kind: RayJob
    metadata:
      name: physical-ai-03-serving-sim-eval
      namespace: default
      labels:
        app.kubernetes.io/name: physical-ai-serving-sim-eval
        app.kubernetes.io/component: closed-loop-flywheel
        stage: phase-3-serving-sim-eval
    spec:
      submissionMode: K8sJobMode
      shutdownAfterJobFinishes: true
      submitterPodTemplate:
        spec:
          restartPolicy: Never
          containers:
            - name: ray-job-submitter
              image: rayproject/ray:2.55.1-py311
      entrypoint: bash -c "bash /app/tools/setup_vla_deps.sh && PYTHONPATH=/app:/app/tools:$PYTHONPATH python3 /app/scripts/03_serving_and_sim_eval.py --storage-root /checkpoint/physical-ai --dataset-uri /checkpoint/physical-ai/mirror/libero --sim-workers 8 --sim-episodes 1 --max-sim-steps 100 --retrain-steps 100"
      runtimeEnvYAML: |
        env_vars:
          HF_HUB_OFFLINE: "1"
          HF_HUB_ENABLE_HF_TRANSFER: "1"
          HF_HUB_DOWNLOAD_TIMEOUT: "60"
          TORCHDYNAMO_DISABLE: "1"
          PYTHONPATH: "/app:/app/tools:$PYTHONPATH"
      rayClusterSpec:
        rayVersion: "2.55.1"
        headGroupSpec:
          rayStartParams:
            dashboard-host: "0.0.0.0"
            num-cpus: "8"
          template:
            metadata:
              annotations:
                gke-gcsfuse/volumes: "true"
                gke-gcsfuse/mount-options: "uid=1000,gid=1000"
              labels:
                ray.io/node-type: head
            spec:
              serviceAccountName: workload-identity-k8s-sa
              tolerations:
                - key: "nvidia.com/gpu"
                  operator: "Exists"
                  effect: "NoSchedule"
              securityContext:
                fsGroup: 100
              containers:
                - name: ray-head
                  image: rayproject/ray:2.55.1-py311-gpu
                  imagePullPolicy: IfNotPresent
                  resources:
                    limits:
                      cpu: "8"
                      memory: "32Gi"
                    requests:
                      cpu: "4"
                      memory: "16Gi"
                  volumeMounts:
                    - name: gcs-fuse-checkpoint-vol
                      mountPath: /checkpoint
                    - name: scripts-volume
                      mountPath: /app/scripts
                    - name: tools-volume
                      mountPath: /app/tools
                  ports:
                    - containerPort: 6379
                      name: gcs-server
                    - containerPort: 8265
                      name: dashboard
                    - containerPort: 10001
                      name: client
                    - containerPort: 8000
                      name: serve
              volumes:
                - name: gcs-fuse-checkpoint-vol
                  persistentVolumeClaim:
                    claimName: physical-ai-checkpoint-pvc
                - name: scripts-volume
                  configMap:
                    name: physical-ai-scripts
                - name: tools-volume
                  configMap:
                    name: physical-ai-tools
        workerGroupSpecs:
          - groupName: gpu-flywheel-workers
            replicas: 1
            minReplicas: 1
            maxReplicas: 1
            rayStartParams:
              num-gpus: "8"
              num-cpus: "128"
            template:
              metadata:
                annotations:
                  gke-gcsfuse/volumes: "true"
                  gke-gcsfuse/mount-options: "uid=1000,gid=1000"
                labels:
                  ray.io/node-type: worker
              spec:
                serviceAccountName: workload-identity-k8s-sa
                tolerations:
                  - key: "nvidia.com/gpu"
                    operator: "Exists"
                    effect: "NoSchedule"
                securityContext:
                  fsGroup: 100
                containers:
                  - name: ray-worker
                    image: rayproject/ray:2.55.1-py311-gpu
                    imagePullPolicy: IfNotPresent
                    resources:
                      limits:
                        nvidia.com/gpu: "8"
                        cpu: "128"
                        memory: "512Gi"
                      requests:
                        nvidia.com/gpu: "8"
                        cpu: "64"
                        memory: "256Gi"
                    volumeMounts:
                      - name: gcs-fuse-checkpoint-vol
                        mountPath: /checkpoint
                      - name: scripts-volume
                        mountPath: /app/scripts
                      - name: tools-volume
                        mountPath: /app/tools
                volumes:
                  - name: gcs-fuse-checkpoint-vol
                    persistentVolumeClaim:
                      claimName: physical-ai-checkpoint-pvc
                  - name: scripts-volume
                    configMap:
                      name: physical-ai-scripts
                  - name: tools-volume
                    configMap:
                      name: physical-ai-tools
    
  2. Apply the manifest:

    kubectl apply -f models/pi05/manifests/03-serving-sim-eval-rayjob.yaml
    
  3. View the logs from the submitter Pod:

    kubectl logs -f job/physical-ai-03-serving-sim-eval
    

Best practice: This stage demonstrates the closed-loop pattern end to end on GKE. For production robotics pipelines, replace the simplified kinematic environment with a high-fidelity physics simulator, such as NVIDIA Isaac Lab or MuJoCo. Also increase the number of evaluation episodes and reduce the retraining learning rate.

Serve the fine-tuned policy

In this section, you deploy the fine-tuned policy as a long-running, self-healing RayService resource. The 03b-vla-serving-rayservice.yaml manifest deploys a dedicated Ray cluster and a Ray Serve application with the following configuration:

  • Allocates 1 GPU (cuda:0) and 4 vCPUs to the PI05PolicyServer deployment. This configuration shows inference on a single GPU.
  • Loads the fine-tuned checkpoint from the /checkpoint/physical-ai/checkpoint_round1/state.pkl file.
  • Exposes port 8000 through the physical-ai-vla-serving-head-svc ClusterIP Service.

Deploy the RayService

  1. Inspect the 03b-vla-serving-rayservice.yaml manifest:

    # Copyright 2026 Google LLC. All rights reserved.
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    
    # ---------------------------------------------------------------------------
    # Phase 3b: Persistent 24/7 RayService serving the fine-tuned PI0.5 policy.
    #
    # Reference node shape: 1 x g4-standard-384
    #   8 x NVIDIA RTX PRO 6000 (96 GB VRAM each) | 384 vCPUs | ~1.5 TB host RAM
    #
    # Serving needs only 1 GPU (8 vCPUs / 32 GiB), leaving the remaining 7 GPUs on
    # the node free for other workloads.
    # ---------------------------------------------------------------------------
    apiVersion: ray.io/v1
    kind: RayService
    metadata:
      name: physical-ai-vla-serving
      namespace: default
      labels:
        app.kubernetes.io/name: physical-ai-vla-serving
        app.kubernetes.io/component: inference-service
        stage: phase-3-persistent-serving
    spec:
      serviceUnhealthySecondThreshold: 300
      deploymentUnhealthySecondThreshold: 300
      serveConfigV2: |
        applications:
          - name: pi05-policy
            route_prefix: /
            import_path: tools.policy_server:app
            runtime_env:
              env_vars:
                LEROBOT_S3_ANON: "1"
                HF_HUB_OFFLINE: "1"
                HF_HUB_ENABLE_HF_TRANSFER: "1"
                HF_HUB_DOWNLOAD_TIMEOUT: "60"
                TORCHDYNAMO_DISABLE: "1"
                PYTHONPATH: "/app:/app/tools:$PYTHONPATH"
                MIRROR_ROOT: "/checkpoint/physical-ai/mirror"
            deployments:
              - name: PI05PolicyServer
                num_replicas: 1
                max_replicas_per_node: 1
                ray_actor_options:
                  num_gpus: 1
                  num_cpus: 4
                user_config:
                  checkpoint_path: "/checkpoint/physical-ai/checkpoint_round1/state.pkl"
                  base_model_dir: "/tmp/lerobot/pi05_libero_finetuned"
      rayClusterConfig:
        rayVersion: "2.55.1"
        headGroupSpec:
          rayStartParams:
            dashboard-host: "0.0.0.0"
            num-cpus: "8"
          template:
            metadata:
              annotations:
                gke-gcsfuse/volumes: "true"
                gke-gcsfuse/mount-options: "uid=1000,gid=1000"
              labels:
                ray.io/node-type: head
            spec:
              serviceAccountName: workload-identity-k8s-sa
              tolerations:
                - key: "nvidia.com/gpu"
                  operator: "Exists"
                  effect: "NoSchedule"
              securityContext:
                fsGroup: 100
              containers:
                - name: ray-head
                  image: rayproject/ray:2.55.1-py311-gpu
                  imagePullPolicy: IfNotPresent
                  resources:
                    limits:
                      cpu: "8"
                      memory: "32Gi"
                    requests:
                      cpu: "4"
                      memory: "16Gi"
                  volumeMounts:
                    - name: gcs-fuse-checkpoint-vol
                      mountPath: /checkpoint
                    - name: scripts-volume
                      mountPath: /app/scripts
                    - name: tools-volume
                      mountPath: /app/tools
                  ports:
                    - containerPort: 6379
                      name: gcs-server
                    - containerPort: 8265
                      name: dashboard
                    - containerPort: 10001
                      name: client
                    - containerPort: 8000
                      name: serve
              volumes:
                - name: gcs-fuse-checkpoint-vol
                  persistentVolumeClaim:
                    claimName: physical-ai-checkpoint-pvc
                - name: scripts-volume
                  configMap:
                    name: physical-ai-scripts
                - name: tools-volume
                  configMap:
                    name: physical-ai-tools
        workerGroupSpecs:
          - groupName: gpu-serving-workers
            replicas: 1
            minReplicas: 1
            maxReplicas: 2
            rayStartParams:
              num-gpus: "1"
              num-cpus: "8"
            template:
              metadata:
                annotations:
                  gke-gcsfuse/volumes: "true"
                  gke-gcsfuse/mount-options: "uid=1000,gid=1000"
                labels:
                  ray.io/node-type: worker
              spec:
                serviceAccountName: workload-identity-k8s-sa
                tolerations:
                  - key: "nvidia.com/gpu"
                    operator: "Exists"
                    effect: "NoSchedule"
                securityContext:
                  fsGroup: 100
                containers:
                  - name: ray-worker
                    image: rayproject/ray:2.55.1-py311-gpu
                    imagePullPolicy: IfNotPresent
                    resources:
                      limits:
                        nvidia.com/gpu: "1"
                        cpu: "8"
                        memory: "32Gi"
                      requests:
                        nvidia.com/gpu: "1"
                        cpu: "4"
                        memory: "16Gi"
                    volumeMounts:
                      - name: gcs-fuse-checkpoint-vol
                        mountPath: /checkpoint
                      - name: scripts-volume
                        mountPath: /app/scripts
                      - name: tools-volume
                        mountPath: /app/tools
                volumes:
                  - name: gcs-fuse-checkpoint-vol
                    persistentVolumeClaim:
                      claimName: physical-ai-checkpoint-pvc
                  - name: scripts-volume
                    configMap:
                      name: physical-ai-scripts
                  - name: tools-volume
                    configMap:
                      name: physical-ai-tools
    
  2. Apply the manifest:

    kubectl apply -f models/pi05/manifests/03b-vla-serving-rayservice.yaml
    
  3. Verify that the status of the RayService resource is Running:

    kubectl get rayservice physical-ai-vla-serving
    

    The output is similar to the following:

    NAME                      SERVICE STATUS   NUM SERVE ENDPOINTS   AGE
    physical-ai-vla-serving   Running          2                     45s
    

Send inference requests

  1. Forward local port 8000 to the RayService head Service:

    kubectl port-forward svc/physical-ai-vla-serving-head-svc 8000:8000
    

    This command keeps your terminal busy while the session is active. To continue, open a separate terminal.

  2. In a separate terminal, check the health status of the service:

    curl -s http://localhost:8000/stats | jq .
    
  3. Send an inference request that contains images from two cameras, an 8-dimensional robot state vector, and a task instruction:

    python3 -c "
    import urllib.request, pickle, numpy as np
    obs = {
        'observation.images.image': np.zeros((224, 224, 3), dtype=np.uint8),
        'observation.images.image2': np.zeros((224, 224, 3), dtype=np.uint8),
        'observation.state': np.zeros(8, dtype=np.float32),
        'task': 'pick up the alphabet soup and put it in the basket',
    }
    req = urllib.request.Request(
        'http://localhost:8000/predict',
        data=pickle.dumps(obs),
        headers={'Content-Type': 'application/octet-stream'}
    )
    res = pickle.loads(urllib.request.urlopen(req).read())
    print('Action Chunk Shape:', res['action'].shape)
    "
    

    The output shows that the service returns a 50-step action trajectory:

    Action Chunk Shape: (50, 7)
    

    In a verified test run, the deployment returned an inference result in 371.37 ms for each forward pass.

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this tutorial, either delete the individual resources, or delete the project that contains them.

Delete the resources

  1. Delete the Ray workloads and Kubernetes Jobs:

    kubectl delete rayjob physical-ai-01-data-processing --ignore-not-found=true
    kubectl delete rayjob physical-ai-02-vla-finetuning --ignore-not-found=true
    kubectl delete rayjob physical-ai-03-serving-sim-eval --ignore-not-found=true
    kubectl delete job physical-ai-mirror-sync --ignore-not-found=true
    kubectl delete job physical-ai-generate-demos --ignore-not-found=true
    kubectl delete rayservice physical-ai-vla-serving --ignore-not-found=true
    
  2. Delete the ConfigMaps, PersistentVolumeClaim, PersistentVolume, and ServiceAccount:

    kubectl delete configmap physical-ai-scripts physical-ai-tools --ignore-not-found=true
    kubectl delete pvc physical-ai-checkpoint-pvc --ignore-not-found=true
    kubectl delete pv physical-ai-checkpoint-pv --ignore-not-found=true
    kubectl delete serviceaccount workload-identity-k8s-sa --ignore-not-found=true
    
  3. If you created a dedicated GKE cluster for this tutorial, then delete the cluster:

    gcloud container clusters delete ${CLUSTER_NAME} \
        --location=${REGION} \
        --quiet
    
  4. Delete the Cloud Storage bucket and all stored checkpoints:

    gcloud storage rm -r gs://${GCS_BUCKET_NAME}
    

Delete your project

Delete a Google Cloud project:

gcloud projects delete PROJECT_ID

Troubleshoot

This section describes how to diagnose and resolve common issues when you run this tutorial.

Pods stay pending because of insufficient GPUs

Symptom: Ray worker Pods or submitter Pods stay in the Pending or Initializing state. The output of the kubectl describe pod command shows the following event:

Warning  FailedScheduling  0/1 nodes are available: 1 Insufficient nvidia.com/gpu.

Cause: when a RayJob resource finishes, its Ray cluster stays active until the duration in the ttlSecondsAfterFinished field elapses. If this field is omitted or greater than 0, the completed Ray cluster holds all 8 GPUs, and the next stage can't schedule.

Resolution:

  1. List the active Ray clusters:

    kubectl get rayclusters
    
  2. Delete the completed RayJob resource before you submit the next stage:

    kubectl delete rayjob physical-ai-02-vla-finetuning --wait=true
    
  3. In multi-stage workflows, set the ttlSecondsAfterFinished field to 0 in all RayJob manifests.

Binary incompatibility error with NumPy 2.x

Symptom: Ray worker tasks fail on import with the following error:

ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Cause: in the rayproject/ray:2.55.1 image, the C extensions for ray.data, ray.train, pandas, and scipy are compiled against the NumPy 1.x Application Binary Interface (ABI). If an unpinned dependency installs NumPy 2.x, the binary incompatibility causes import failures.

Resolution: pin NumPy to the 1.26 release branch (numpy>=1.26,<2) and cap opencv-python-headless<4.10 in your dependencies script. In the sample, the setup_vla_deps.sh script sets these pins. If you customize packages, then keep these version restrictions.

To check the installed NumPy version in the Ray container image, run the following command in the container:

python3 -c "import numpy; print(numpy.__version__)"

Import error for PyArrow with NumPy 1.x

Symptom: the fine-tuning RayJob resource ends in the FAILED state, and the logs show the following errors:

ImportError: pyarrow requires NumPy 2.0 or newer, found 1.26.4
ImportError: Can't import ray.train as some dependencies are missing.

Cause: the setup_vla_deps.sh script pins NumPy to 1.x and installs the datasets package, which requires PyArrow 21.0.0 or later. If PyArrow isn't pinned, then pip upgrades PyArrow to the latest release. PyArrow 26.0.0 and later require NumPy 2.x, so the ray.train import fails.

Resolution: do the following:

  1. In the models/pi05/tools/setup_vla_deps.sh script, add a PyArrow version pin to the pip install command, after the NumPy pin:

    python3 -m pip install --no-cache-dir \
        "numpy>=1.26,<2" \
        "pyarrow>=21,<26" \
        ...
    

    PyArrow versions 21.0.0 through 25.0.0 work with NumPy 1.26.4, Ray Data, and Ray Train in the rayproject/ray:2.55.1-py311 image.

  2. Update the physical-ai-tools ConfigMap with the modified script:

    kubectl create configmap physical-ai-tools \
        --from-file=models/pi05/tools/ \
        --dry-run=client -o yaml | kubectl apply -f -
    
  3. Delete the failed RayJob resource, and then submit it again:

    kubectl delete rayjob physical-ai-02-vla-finetuning --wait=true
    kubectl apply -f models/pi05/manifests/02-vla-training-rayjob.yaml
    

Permission denied when accessing the Cloud Storage FUSE mount

Symptom: Ray Pods fail to read datasets or write checkpoints in the /checkpoint directory, with errors such as PermissionDenied or StorageException: 403 Forbidden.

Cause: the workload-identity-k8s-sa Kubernetes ServiceAccount doesn't have the roles/storage.objectAdmin role on the bucket, or the PersistentVolume references the wrong bucket.

Resolution:

  1. Verify that the PersistentVolume references your bucket name, not the GCS_BUCKET_NAME placeholder:

    kubectl get pv physical-ai-checkpoint-pv \
        -o jsonpath='{.spec.csi.volumeHandle}{"\n"}'
    

    If the output is incorrect, then delete the PersistentVolumeClaim and PersistentVolume, and apply the 00-infrastructure.yaml manifest again with the sed command from Create the Kubernetes storage resources.

  2. Check the IAM policy on your bucket:

    gcloud storage buckets get-iam-policy gs://${GCS_BUCKET_NAME}
    

    The output must include a binding for the roles/storage.objectAdmin role with a principal:// member that ends in subject/ns/default/sa/workload-identity-k8s-sa.

  3. If the binding is missing, then grant the role to the Kubernetes ServiceAccount again:

    gcloud storage buckets add-iam-policy-binding gs://${GCS_BUCKET_NAME} \
        --member="principal://iam.googleapis.com/projects/${PROJECT_NUMBER}/locations/global/workloadIdentityPools/${PROJECT_ID}./subject/ns/${K8S_NAMESPACE}/sa/${K8S_SA_NAME}" \
        --role="roles/storage.objectAdmin"
    

Pods take several minutes to start

Symptom: Ray Pods take 3-5 minutes to move from the PodInitializing state to the Running state.

Cause: the sample uses the public rayproject/ray:2.55.1-py311-gpu image, which doesn't include PyTorch with CUDA 12.8 support. During Pod initialization, the setup_vla_deps.sh startup script downloads and installs PyTorch (about 820 MB) and other VLA dependencies.

To view the container logs during startup, run the following command:

kubectl logs -f RAY_POD_NAME -c ray-head

Replace RAY_POD_NAME with the name of your Ray Pod.

Resolution: for production deployments, build a container image that includes PyTorch and the VLA dependencies, push the image to Artifact Registry, and specify your image in the image field of your RayJob and RayService manifests. This approach removes the dependency installation at startup.

Run the sample on smaller or alternative GPU node pools

To run the sample on a node pool with fewer than 8 GPUs, or with other GPU models such as NVIDIA L4, A100, or H100 GPUs, update the manifests as follows:

  1. In the 02-vla-training-rayjob.yaml manifest, make the following changes:
    • Set the resources.requests.nvidia.com/gpu and resources.limits.nvidia.com/gpu fields to your GPU count, for example, 4.
    • In the entrypoint field, set the --num-workers flag to your GPU count, for example, --num-workers 4.
  2. In the 03-serving-sim-eval-rayjob.yaml manifest, make the following changes:
    • Update the GPU resource requests and limits.
    • In the entrypoint field, adjust the --sim-workers flag.
  3. If your cluster has multiple node pools, then add a nodeSelector field to pin the Pods to your GPU node pool:

    nodeSelector:
      cloud.google.com/gke-nodepool: YOUR_GPU_NODE_POOL_NAME
    

    Replace YOUR_GPU_NODE_POOL_NAME with the name of your GPU node pool.

What's next