|
| 1 | +# Copyright 2025 "Google LLC" |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +blueprint_name: gke-tpu-v6 |
| 16 | + |
| 17 | +vars: |
| 18 | + # The following variables should be over-written in the deployment.yaml file. |
| 19 | + # Your GCP Project ID |
| 20 | + project_id: |
| 21 | + |
| 22 | + # This should be unique across all of your Cluster |
| 23 | + # Toolkit Deployments. |
| 24 | + deployment_name: gke-tpu-v6 |
| 25 | + |
| 26 | + # The GCP Region used for this deployment. |
| 27 | + region: |
| 28 | + |
| 29 | + # The GCP Zone used for this deployment. |
| 30 | + zone: |
| 31 | + |
| 32 | + # The number of TPU slices to create |
| 33 | + num_slices: |
| 34 | + |
| 35 | + # Machine type |
| 36 | + machine_type: |
| 37 | + |
| 38 | + # The TPU placement topology for pod slice node pool. |
| 39 | + tpu_topology: |
| 40 | + |
| 41 | + # The number of nodes to be created in each nodepool |
| 42 | + static_node_count: |
| 43 | + |
| 44 | + # Cidr block containing the IP of the machine calling terraform. |
| 45 | + # To allow all (IAM restrictions still enforced), use 0.0.0.0/0 |
| 46 | + # To allow only your IP address, use <YOUR-IP-ADDRESS>/32 |
| 47 | + authorized_cidr: |
| 48 | + |
| 49 | + # The name of the compute engine reservation of TPU v6 nodes |
| 50 | + reservation: |
| 51 | + |
| 52 | + system_node_pool_disk_size_gb: 200 |
| 53 | + v6e_node_pool_disk_size_gb: 100 |
| 54 | + |
| 55 | + |
| 56 | +deployment_groups: |
| 57 | +- group: primary |
| 58 | + modules: |
| 59 | + - id: gke-tpu-v6-net |
| 60 | + source: modules/network/vpc |
| 61 | + settings: |
| 62 | + subnetworks: |
| 63 | + - subnet_name: $(vars.deployment_name)-sub-0 |
| 64 | + subnet_region: $(vars.region) |
| 65 | + subnet_ip: 192.168.0.0/18 |
| 66 | + secondary_ranges_list: |
| 67 | + - subnetwork_name: $(vars.deployment_name)-sub-0 |
| 68 | + ranges: |
| 69 | + - range_name: pods |
| 70 | + ip_cidr_range: 10.4.0.0/14 |
| 71 | + - range_name: services |
| 72 | + ip_cidr_range: 10.0.32.0/20 |
| 73 | + firewall_rules: |
| 74 | + - name: $(vars.deployment_name)-internal-0 |
| 75 | + ranges: [192.168.0.0/18] |
| 76 | + allow: |
| 77 | + - protocol: tcp |
| 78 | + ports: ["0-65535"] |
| 79 | + - protocol: udp |
| 80 | + ports: ["0-65535"] |
| 81 | + - protocol: icmp |
| 82 | + |
| 83 | + - id: node_pool_service_account |
| 84 | + source: community/modules/project/service-account |
| 85 | + settings: |
| 86 | + name: gke-np-sa |
| 87 | + project_roles: |
| 88 | + - logging.logWriter |
| 89 | + - monitoring.metricWriter |
| 90 | + - monitoring.viewer |
| 91 | + - stackdriver.resourceMetadata.writer |
| 92 | + - storage.objectViewer |
| 93 | + - artifactregistry.reader |
| 94 | + |
| 95 | + - id: workload_service_account |
| 96 | + source: community/modules/project/service-account |
| 97 | + settings: |
| 98 | + name: gke-wl-sa |
| 99 | + project_roles: |
| 100 | + - logging.logWriter |
| 101 | + - monitoring.metricWriter |
| 102 | + - monitoring.viewer |
| 103 | + - stackdriver.resourceMetadata.writer |
| 104 | + - storage.objectAdmin |
| 105 | + - artifactregistry.reader |
| 106 | + - container.admin |
| 107 | + |
| 108 | + - id: training_bucket |
| 109 | + source: community/modules/file-system/cloud-storage-bucket |
| 110 | + settings: |
| 111 | + local_mount: /training-data |
| 112 | + name_prefix: training-data |
| 113 | + random_suffix: true |
| 114 | + force_destroy: false |
| 115 | + enable_hierarchical_namespace: true |
| 116 | + |
| 117 | + - id: checkpoint_bucket |
| 118 | + source: community/modules/file-system/cloud-storage-bucket |
| 119 | + settings: |
| 120 | + local_mount: /checkpoint-data |
| 121 | + name_prefix: checkpoint-data |
| 122 | + random_suffix: true |
| 123 | + force_destroy: false |
| 124 | + enable_hierarchical_namespace: true |
| 125 | + |
| 126 | + - id: gke-tpu-v6-cluster |
| 127 | + source: modules/scheduler/gke-cluster |
| 128 | + use: [gke-tpu-v6-net, workload_service_account] |
| 129 | + settings: |
| 130 | + system_node_pool_machine_type: "n2-standard-8" |
| 131 | + system_node_pool_disk_size_gb: $(vars.system_node_pool_disk_size_gb) |
| 132 | + system_node_pool_taints: [] |
| 133 | + enable_private_endpoint: false # Allows access from authorized public IPs |
| 134 | + configure_workload_identity_sa: true |
| 135 | + enable_gcsfuse_csi: true |
| 136 | + master_authorized_networks: |
| 137 | + - cidr_block: $(vars.authorized_cidr) # Allows your machine to run the kubectl command. Required for multi network setup. |
| 138 | + display_name: "kubectl-access-network" |
| 139 | + # Cluster versions cannot be updated through the toolkit after creation |
| 140 | + # Please manage cluster version from the Google Cloud Console directly |
| 141 | + version_prefix: "1.32." |
| 142 | + release_channel: RAPID |
| 143 | + maintenance_exclusions: |
| 144 | + - name: no-minor-or-node-upgrades-indefinite |
| 145 | + start_time: "2024-12-01T00:00:00Z" |
| 146 | + end_time: "2025-12-22T00:00:00Z" |
| 147 | + exclusion_scope: NO_MINOR_OR_NODE_UPGRADES |
| 148 | + outputs: [instructions] |
| 149 | + |
| 150 | + - id: gke-tpu-v6-pool |
| 151 | + source: modules/compute/gke-node-pool |
| 152 | + use: [gke-tpu-v6-cluster, node_pool_service_account] |
| 153 | + settings: |
| 154 | + num_slices: $(vars.num_slices) |
| 155 | + name: gke-tpu-v6-pool |
| 156 | + disk_type: hyperdisk-balanced |
| 157 | + machine_type: $(vars.machine_type) |
| 158 | + auto_upgrade: true |
| 159 | + zones: [$(vars.zone)] |
| 160 | + disk_size_gb: $(vars.v6e_node_pool_disk_size_gb) |
| 161 | + static_node_count: $(vars.static_node_count) |
| 162 | + reservation_affinity: |
| 163 | + consume_reservation_type: SPECIFIC_RESERVATION |
| 164 | + specific_reservations: |
| 165 | + - name: $(vars.reservation) |
| 166 | + placement_policy: |
| 167 | + type: COMPACT |
| 168 | + tpu_topology: $(vars.tpu_topology) |
| 169 | + outputs: [instructions] |
| 170 | + |
| 171 | + - id: workload-manager-install |
| 172 | + source: modules/management/kubectl-apply |
| 173 | + use: [gke-tpu-v6-cluster] |
| 174 | + settings: |
| 175 | + jobset: |
| 176 | + install: true |
| 177 | + |
| 178 | + - id: gcs-training |
| 179 | + source: modules/file-system/pre-existing-network-storage |
| 180 | + settings: |
| 181 | + remote_mount: $(training_bucket.gcs_bucket_name) |
| 182 | + local_mount: /training-data |
| 183 | + fs_type: gcsfuse |
| 184 | + mount_options: >- |
| 185 | + implicit-dirs, |
| 186 | + metadata-cache:ttl-secs:-1, |
| 187 | + metadata-cache:stat-cache-max-size-mb:-1, |
| 188 | + metadata-cache:type-cache-max-size-mb:-1, |
| 189 | + file-cache:max-size-mb:-1, |
| 190 | + file-cache:cache-file-for-range-read:true |
| 191 | +
|
| 192 | + - id: gcs-checkpointing |
| 193 | + source: modules/file-system/pre-existing-network-storage |
| 194 | + settings: |
| 195 | + remote_mount: $(checkpoint_bucket.gcs_bucket_name) |
| 196 | + local_mount: /checkpoint-data |
| 197 | + fs_type: gcsfuse |
| 198 | + mount_options: >- |
| 199 | + implicit-dirs, |
| 200 | + metadata-cache:ttl-secs:-1, |
| 201 | + metadata-cache:stat-cache-max-size-mb:-1, |
| 202 | + metadata-cache:type-cache-max-size-mb:-1, |
| 203 | + file-cache:max-size-mb:-1, |
| 204 | + file-cache:cache-file-for-range-read:true, |
| 205 | + file-cache:enable-parallel-downloads:true, |
| 206 | + rename-dir-limit=200000 |
| 207 | +
|
| 208 | + # Persistent Volume for training data |
| 209 | + - id: training-pv |
| 210 | + source: modules/file-system/gke-persistent-volume |
| 211 | + use: [gcs-training, gke-tpu-v6-cluster] |
| 212 | + settings: |
| 213 | + gcs_bucket_name: $(training_bucket.gcs_bucket_name) |
| 214 | + capacity_gib: 1000000 |
| 215 | + |
| 216 | + # Persistent Volume for checkpoint data |
| 217 | + - id: checkpointing-pv |
| 218 | + source: modules/file-system/gke-persistent-volume |
| 219 | + use: [gcs-checkpointing, gke-tpu-v6-cluster] |
| 220 | + settings: |
| 221 | + gcs_bucket_name: $(checkpoint_bucket.gcs_bucket_name) |
| 222 | + capacity_gib: 1000000 |
| 223 | + |
| 224 | + # This is an example job that will install and run an `fio` |
| 225 | + # benchmark against the training and checkpointing buckets. |
| 226 | + - id: fio-bench-job-template |
| 227 | + source: modules/compute/gke-job-template |
| 228 | + use: [checkpointing-pv, training-pv, gke-tpu-v6-pool] |
| 229 | + settings: |
| 230 | + node_count: $(vars.static_node_count) |
| 231 | + security_context: # to make sure the job have enough access to install the fio packages |
| 232 | + - key: runAsUser |
| 233 | + value: 0 |
| 234 | + - key: runAsGroup |
| 235 | + value: 100 |
| 236 | + - key: fsGroup |
| 237 | + value: 100 |
| 238 | + |
| 239 | + k8s_service_account_name: workload-identity-k8s-sa |
| 240 | + requested_cpu_per_pod: 8 |
| 241 | + image: ubuntu:latest |
| 242 | + |
| 243 | + command: |
| 244 | + - bash |
| 245 | + - -c |
| 246 | + - | |
| 247 | +
|
| 248 | + set -eux |
| 249 | + export DEBIAN_FRONTEND=noninteractive |
| 250 | +
|
| 251 | + # Install fio |
| 252 | + apt update -y && apt install -y fio |
| 253 | +
|
| 254 | + # Use a tag to create a unique path for tests |
| 255 | + TAG=`date +%s` |
| 256 | +
|
| 257 | + # Verify mountpoints |
| 258 | + df -h |
| 259 | + mountpoint /checkpoint-data |
| 260 | + mountpoint /training-data |
| 261 | +
|
| 262 | + # Create temporary directory for fio benchmarks |
| 263 | + mkdir -p /{training,checkpoint}-data/fio-benchmarks-${TAG} |
| 264 | +
|
| 265 | + # The following will take roughly 5 minutes to complete |
| 266 | +
|
| 267 | + # Test reading from the training bucket |
| 268 | + fio --ioengine=libaio --filesize=1G --ramp_time=2s --runtime=30s \ |
| 269 | + --numjobs=8 --create_serialize=0 --direct=1 --verify=0 \ |
| 270 | + --randrepeat=0 --group_reporting --directory=/training-data/fio-benchmarks-${TAG} \ |
| 271 | + --name=training-read --blocksize=1m --iodepth=16 --readwrite=randread |
| 272 | +
|
| 273 | + # Test writing to the checkpointing bucket |
| 274 | + fio --ioengine=libaio --filesize=1G --ramp_time=2s --runtime=30s \ |
| 275 | + --numjobs=8 --create_serialize=0 --direct=1 --verify=0 \ |
| 276 | + --randrepeat=0 --group_reporting --directory=/checkpoint-data/fio-benchmarks-${TAG} \ |
| 277 | + --name=checkpoint-write --blocksize=10m --iodepth=16 --readwrite=write |
| 278 | +
|
| 279 | + # Perform checkpoint data reading performance test |
| 280 | + fio --ioengine=libaio --filesize=1G --ramp_time=2s --runtime=30s \ |
| 281 | + --numjobs=8 --create_serialize=0 --direct=1 --verify=0 \ |
| 282 | + --randrepeat=0 --group_reporting --directory=/checkpoint-data/fio-benchmarks-${TAG} \ |
| 283 | + --name=checkpoint-read --blocksize=10m --iodepth=16 --readwrite=read |
| 284 | +
|
| 285 | + rm -rf /{training,checkpoint}-data/fio-benchmarks-${TAG} |
| 286 | +
|
| 287 | + outputs: [instructions] |
0 commit comments