From 3e0b1f2db3c77c8c8f43cf48315441bb5a5e7dd9 Mon Sep 17 00:00:00 2001 From: Zeleena Kearney Date: Tue, 3 Dec 2024 23:38:51 +0000 Subject: [PATCH 1/4] Add NetworkConfig and NetworkConfigs to TPU v2 QueuedResource --- mmv1/products/tpuv2/QueuedResource.yaml | 102 ++++++++++++++++++ .../tpu_v2_queued_resource_full.tf.tmpl | 44 ++++++++ 2 files changed, 146 insertions(+) create mode 100644 mmv1/templates/terraform/examples/tpu_v2_queued_resource_full.tf.tmpl diff --git a/mmv1/products/tpuv2/QueuedResource.yaml b/mmv1/products/tpuv2/QueuedResource.yaml index 9cddb9428079..f09966d08af7 100644 --- a/mmv1/products/tpuv2/QueuedResource.yaml +++ b/mmv1/products/tpuv2/QueuedResource.yaml @@ -54,6 +54,17 @@ examples: test_env_vars: project: 'PROJECT_NAME' skip_vcr: true + - name: 'tpu_v2_queued_resource_full' + primary_resource_id: 'qr' + min_version: 'beta' + vars: + qr_name: 'test-qr' + tpu_name: 'test-tpu' + network_name: 'tpu-net' + subnet_name: 'tpu-subnet' + test_env_vars: + project: 'PROJECT_NAME' + skip_vcr: true parameters: - name: 'zone' type: String @@ -107,3 +118,94 @@ properties: - name: 'description' description: | Text description of the TPU. + - name: 'networkConfig' + type: NestedObject + description: | + Network configurations for the TPU node. + immutable: true + default_from_api: true + conflicts: + - network_configs + properties: + - name: 'network' + type: String + description: | + The name of the network for the TPU node. It must be a preexisting Google Compute Engine + network. If none is provided, "default" will be used. + immutable: true + default_from_api: true + - name: 'subnetwork' + type: String + description: | + The name of the subnetwork for the TPU node. It must be a preexisting Google Compute + Engine subnetwork. If none is provided, "default" will be used. + immutable: true + default_from_api: true + - name: 'enableExternalIps' + type: Boolean + description: | + Indicates that external IP addresses would be associated with the TPU workers. If set to + false, the specified subnetwork or network should have Private Google Access enabled. + immutable: true + send_empty_value: true + - name: 'canIpForward' + type: Boolean + description: | + Allows the TPU node to send and receive packets with non-matching destination or source + IPs. This is required if you plan to use the TPU workers to forward routes. + immutable: true + send_empty_value: true + - name: 'queueCount' + type: Integer + description: | + Specifies networking queue count for TPU VM instance's network interface. + required: false + immutable: true + default_from_api: true + - name: 'networkConfigs' + type: Array + description: | + Repeated network configurations for the TPU node. This field is used to specify multiple + network configs for the TPU node. + min_version: 'beta' + immutable: true + conflicts: + - network_config + item_type: + type: NestedObject + properties: + - name: 'network' + type: String + description: | + The name of the network for the TPU node. It must be a preexisting Google Compute Engine + network. If none is provided, "default" will be used. + immutable: true + default_from_api: true + - name: 'subnetwork' + type: String + description: | + The name of the subnetwork for the TPU node. It must be a preexisting Google Compute + Engine subnetwork. If none is provided, "default" will be used. + immutable: true + default_from_api: true + - name: 'enableExternalIps' + type: Boolean + description: | + Indicates that external IP addresses would be associated with the TPU workers. If set to + false, the specified subnetwork or network should have Private Google Access enabled. + immutable: true + send_empty_value: true + - name: 'canIpForward' + type: Boolean + description: | + Allows the TPU node to send and receive packets with non-matching destination or source + IPs. This is required if you plan to use the TPU workers to forward routes. + immutable: true + send_empty_value: true + - name: 'queueCount' + type: Integer + description: | + Specifies networking queue count for TPU VM instance's network interface. + required: false + immutable: true + default_from_api: true diff --git a/mmv1/templates/terraform/examples/tpu_v2_queued_resource_full.tf.tmpl b/mmv1/templates/terraform/examples/tpu_v2_queued_resource_full.tf.tmpl new file mode 100644 index 000000000000..708e7d1ad81f --- /dev/null +++ b/mmv1/templates/terraform/examples/tpu_v2_queued_resource_full.tf.tmpl @@ -0,0 +1,44 @@ +resource "google_tpu_v2_queued_resource" "{{$.PrimaryResourceId}}" { + provider = google-beta + + name = "{{index $.Vars "qr_name"}}" + zone = "us-central1-c" + project = "{{index $.TestEnvVars "project"}}" + + tpu { + node_spec { + parent = "projects/{{index $.TestEnvVars "project"}}/locations/us-central1-c" + node_id = "{{index $.Vars "tpu_name"}}" + node { + runtime_version = "tpu-vm-tf-2.13.0" + accelerator_type = "v2-8" + description = "Text description of the TPU." + + network_config { + can_ip_forward = true + enable_external_ips = true + network = google_compute_network.network.id + subnetwork = google_compute_subnetwork.subnet.id + queue_count = 32 + } + } + } + } +} + +resource "google_compute_subnetwork" "subnet" { + provider = google-beta + + name = "{{index $.Vars "subnet_name"}}" + ip_cidr_range = "10.0.0.0/16" + region = "us-central1" + network = google_compute_network.network.id +} + +resource "google_compute_network" "network" { + provider = google-beta + + name = "{{index $.Vars "network_name"}}" + auto_create_subnetworks = false +} + From d2cd2e2212fca901de63c0b6c1203bbc750b9319 Mon Sep 17 00:00:00 2001 From: Zeleena Kearney Date: Thu, 5 Dec 2024 22:30:50 +0000 Subject: [PATCH 2/4] Remove default_from_api from queue_count --- mmv1/products/tpuv2/QueuedResource.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/mmv1/products/tpuv2/QueuedResource.yaml b/mmv1/products/tpuv2/QueuedResource.yaml index f09966d08af7..ea6c2351d3fe 100644 --- a/mmv1/products/tpuv2/QueuedResource.yaml +++ b/mmv1/products/tpuv2/QueuedResource.yaml @@ -161,7 +161,6 @@ properties: Specifies networking queue count for TPU VM instance's network interface. required: false immutable: true - default_from_api: true - name: 'networkConfigs' type: Array description: | @@ -208,4 +207,3 @@ properties: Specifies networking queue count for TPU VM instance's network interface. required: false immutable: true - default_from_api: true From bd5cc82e723241b87d1bb6253c5efca59b676fab Mon Sep 17 00:00:00 2001 From: Zeleena Kearney Date: Mon, 9 Dec 2024 19:08:16 +0000 Subject: [PATCH 3/4] Add dedicated array field network_configs test --- mmv1/products/tpuv2/QueuedResource.yaml | 11 +++ ...v2_queued_resource_network_configs.tf.tmpl | 67 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 mmv1/templates/terraform/examples/tpu_v2_queued_resource_network_configs.tf.tmpl diff --git a/mmv1/products/tpuv2/QueuedResource.yaml b/mmv1/products/tpuv2/QueuedResource.yaml index ea6c2351d3fe..f9b8136e132f 100644 --- a/mmv1/products/tpuv2/QueuedResource.yaml +++ b/mmv1/products/tpuv2/QueuedResource.yaml @@ -65,6 +65,17 @@ examples: test_env_vars: project: 'PROJECT_NAME' skip_vcr: true + - name: 'tpu_v2_queued_resource_network_configs' + primary_resource_id: 'qr' + min_version: 'beta' + vars: + qr_name: 'test-qr' + tpu_name: 'test-tpu' + network_name: 'tpu-net' + subnet_name: 'tpu-subnet' + test_env_vars: + project: 'PROJECT_NAME' + skip_vcr: true parameters: - name: 'zone' type: String diff --git a/mmv1/templates/terraform/examples/tpu_v2_queued_resource_network_configs.tf.tmpl b/mmv1/templates/terraform/examples/tpu_v2_queued_resource_network_configs.tf.tmpl new file mode 100644 index 000000000000..8f576dfe68d2 --- /dev/null +++ b/mmv1/templates/terraform/examples/tpu_v2_queued_resource_network_configs.tf.tmpl @@ -0,0 +1,67 @@ +resource "google_tpu_v2_queued_resource" "{{$.PrimaryResourceId}}" { + provider = google-beta + + name = "{{index $.Vars "qr_name"}}" + zone = "us-central1-c" + project = "{{index $.TestEnvVars "project"}}" + + tpu { + node_spec { + parent = "projects/{{index $.TestEnvVars "project"}}/locations/us-central1-c" + node_id = "{{index $.Vars "tpu_name"}}" + node { + runtime_version = "tpu-vm-tf-2.13.0" + accelerator_type = "v2-8" + + network_configs = [ + { + can_ip_forward = true + enable_external_ips = true + network = google_compute_network.network_0.id + subnetwork = google_compute_subnetwork.subnet_0.id + queue_count = 32 + }, + { + can_ip_forward = true + enable_external_ips = true + network = google_compute_network.network_1.id + subnetwork = google_compute_subnetwork.subnet_1.id + queue_count = 32 + } + ] + } + } + } +} + +resource "google_compute_subnetwork" "subnet_0" { + provider = google-beta + + name = "{{index $.Vars "subnet_name"}}-0" + ip_cidr_range = "10.0.0.0/16" + region = "us-central1" + network = google_compute_network.network_0.id +} + +resource "google_compute_network" "network_0" { + provider = google-beta + + name = "{{index $.Vars "network_name"}}-0" + auto_create_subnetworks = false +} + +resource "google_compute_subnetwork" "subnet_1" { + provider = google-beta + + name = "{{index $.Vars "subnet_name"}}-1" + ip_cidr_range = "10.1.0.0/16" + region = "us-central1" + network = google_compute_network.network_1.id +} + +resource "google_compute_network" "network_1" { + provider = google-beta + + name = "{{index $.Vars "network_name"}}-1" + auto_create_subnetworks = false +} From d0f8e46c5297ec42ae861168462a50da30fb5401 Mon Sep 17 00:00:00 2001 From: Zeleena Kearney <12972510+zeleena@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:41:19 -0800 Subject: [PATCH 4/4] Update mmv1/templates/terraform/examples/tpu_v2_queued_resource_network_configs.tf.tmpl Co-authored-by: Stephen Lewis (Burrows) --- .../tpu_v2_queued_resource_network_configs.tf.tmpl | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/mmv1/templates/terraform/examples/tpu_v2_queued_resource_network_configs.tf.tmpl b/mmv1/templates/terraform/examples/tpu_v2_queued_resource_network_configs.tf.tmpl index 8f576dfe68d2..625605e7ac62 100644 --- a/mmv1/templates/terraform/examples/tpu_v2_queued_resource_network_configs.tf.tmpl +++ b/mmv1/templates/terraform/examples/tpu_v2_queued_resource_network_configs.tf.tmpl @@ -13,22 +13,20 @@ resource "google_tpu_v2_queued_resource" "{{$.PrimaryResourceId}}" { runtime_version = "tpu-vm-tf-2.13.0" accelerator_type = "v2-8" - network_configs = [ - { + network_configs { can_ip_forward = true enable_external_ips = true network = google_compute_network.network_0.id subnetwork = google_compute_subnetwork.subnet_0.id queue_count = 32 - }, - { + } + network_configs { can_ip_forward = true enable_external_ips = true network = google_compute_network.network_1.id subnetwork = google_compute_subnetwork.subnet_1.id queue_count = 32 - } - ] + } } } }