Skip to content

Commit f3f3316

Browse files
author
Googler
committed
fix: Dynamically set default boot disk type in CustomJob component for Vertex Pipelines for machines which cannot use the current default (pd-ssd)
Signed-off-by: Googler <nobody@google.com> PiperOrigin-RevId: 916175540
1 parent 3004f97 commit f3f3316

2 files changed

Lines changed: 32 additions & 7 deletions

File tree

components/google-cloud/RELEASE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Upcoming release
22

33
* Remove deprecated Wide and Deep Tabular Workflow pipeline.
4+
* Dynamically set default boot disk type in CustomJob component for Vertex Pipelines based on machine type.
45

56
## Release 2.22.0
67

components/google-cloud/google_cloud_pipeline_components/v1/custom_job/utils.py

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,28 @@ def _replace_executor_placeholder(
4848
]
4949

5050

51+
def _get_default_boot_disk_type(machine_type: str) -> str:
52+
"""Get default boot disk type for a given machine type.
53+
54+
Args:
55+
machine_type: The machine type to get the default boot disk type for.
56+
57+
Returns:
58+
The default boot disk type for the given machine type.
59+
"""
60+
if (
61+
machine_type.startswith('a3-ultragpu-')
62+
or machine_type.startswith('a4-highgpu')
63+
or machine_type.startswith('a4x-highgpu')
64+
or machine_type.startswith('g4-standard')
65+
or machine_type.startswith('ct6e-')
66+
or machine_type.startswith('tpu7x')
67+
or machine_type.startswith('n4-')
68+
):
69+
return 'hyperdisk-balanced'
70+
return 'pd-ssd'
71+
72+
5173
# keep identical to CustomTrainingJobOp
5274
def create_custom_training_job_from_component(
5375
component_spec: Callable,
@@ -56,7 +78,7 @@ def create_custom_training_job_from_component(
5678
machine_type: str = 'n1-standard-4',
5779
accelerator_type: str = '',
5880
accelerator_count: int = 1,
59-
boot_disk_type: str = 'pd-ssd',
81+
boot_disk_type: str = '',
6082
boot_disk_size_gb: int = 100,
6183
timeout: str = '604800s',
6284
restart_job_on_worker_restart: bool = False,
@@ -92,7 +114,7 @@ def create_custom_training_job_from_component(
92114
machine_type: The type of the machine to run the CustomJob. The default value is "n1-standard-4". See [more information](https://cloud.google.com/vertex-ai/docs/training/configure-compute#machine-types).
93115
accelerator_type: The type of accelerator(s) that may be attached to the machine per `accelerator_count`. See [more information](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/MachineSpec#acceleratortype).
94116
accelerator_count: The number of accelerators to attach to the machine. Defaults to 1 if `accelerator_type` is set.
95-
boot_disk_type: Type of the boot disk (default is "pd-ssd"). Valid values: "pd-ssd" (Persistent Disk Solid State Drive) or "pd-standard" (Persistent Disk Hard Disk Drive). boot_disk_type is set as a static value and cannot be changed as a pipeline parameter.
117+
boot_disk_type: Type of the boot disk (default is "pd-ssd" unless the machine type requires a different default, e.g. N4 machine types require "hyperdisk-balanced"). Valid values: "pd-ssd" (Persistent Disk Solid State Drive), "pd-standard" (Persistent Disk Hard Disk Drive), or "hyperdisk-balanced" (Hyperdisk Balanced). boot_disk_type is set as a static value and cannot be changed as a pipeline parameter.
96118
boot_disk_size_gb: Size in GB of the boot disk (default is 100GB). `boot_disk_size_gb` is set as a static value and cannot be changed as a pipeline parameter.
97119
timeout: The maximum job running time. The default is 7 days. A duration in seconds with up to nine fractional digits, terminated by 's', for example: "3.5s".
98120
restart_job_on_worker_restart: Restarts the entire CustomJob if a worker gets restarted. This feature can be used by distributed training jobs that are not resilient to workers leaving and joining a job.
@@ -197,11 +219,13 @@ def create_custom_training_job_from_component(
197219
'values'
198220
] = reservation_affinity_values
199221

200-
if boot_disk_type:
201-
worker_pool_spec['disk_spec'] = {
202-
'boot_disk_type': boot_disk_type,
203-
'boot_disk_size_gb': boot_disk_size_gb,
204-
}
222+
if not boot_disk_type:
223+
boot_disk_type = _get_default_boot_disk_type(machine_type)
224+
worker_pool_spec['disk_spec'] = {
225+
'boot_disk_type': boot_disk_type,
226+
'boot_disk_size_gb': boot_disk_size_gb,
227+
}
228+
205229
if nfs_mounts:
206230
worker_pool_spec['nfs_mounts'] = nfs_mounts
207231

0 commit comments

Comments
 (0)