@@ -176,6 +176,11 @@ def create_ray_cluster(
176
176
"[Ray on Vertex AI]: For head_node_type, "
177
177
+ "Resources.node_count must be 1."
178
178
)
179
+ if head_node_type .autoscaling_spec is not None :
180
+ raise ValueError (
181
+ "[Ray on Vertex AI]: For head_node_type, "
182
+ + "Resources.autoscaling_spec must be None."
183
+ )
179
184
if (
180
185
head_node_type .accelerator_type is None
181
186
and head_node_type .accelerator_count > 0
@@ -225,18 +230,38 @@ def create_ray_cluster(
225
230
"[Ray on Vertex]: accelerator_type must be specified when"
226
231
+ " accelerator_count is set to a value other than 0."
227
232
)
228
- # Worker and head share the same MachineSpec, merge them into the
229
- # same ResourcePool
230
233
additional_replica_count = resources ._check_machine_spec_identical (
231
234
head_node_type , worker_node_type
232
235
)
233
- resource_pool_0 .replica_count = (
234
- resource_pool_0 .replica_count + additional_replica_count
235
- )
236
+ if worker_node_type .autoscaling_spec is None :
237
+ # Worker and head share the same MachineSpec, merge them into the
238
+ # same ResourcePool
239
+ resource_pool_0 .replica_count = (
240
+ resource_pool_0 .replica_count + additional_replica_count
241
+ )
242
+ else :
243
+ if additional_replica_count > 0 :
244
+ # Autoscaling for single ResourcePool (homogeneous cluster).
245
+ resource_pool_0 .replica_count = None
246
+ resource_pool_0 .autoscaling_spec .min_replica_count = (
247
+ worker_node_type .autoscaling_spec .min_replica_count
248
+ )
249
+ resource_pool_0 .autoscaling_spec .max_replica_count = (
250
+ worker_node_type .autoscaling_spec .max_replica_count
251
+ )
236
252
if additional_replica_count == 0 :
237
253
resource_pool = ResourcePool ()
238
254
resource_pool .id = f"worker-pool{ i + 1 } "
239
- resource_pool .replica_count = worker_node_type .node_count
255
+ if worker_node_type .autoscaling_spec is None :
256
+ resource_pool .replica_count = worker_node_type .node_count
257
+ else :
258
+ # Autoscaling for worker ResourcePool.
259
+ resource_pool .autoscaling_spec .min_replica_count = (
260
+ worker_node_type .autoscaling_spec .min_replica_count
261
+ )
262
+ resource_pool .autoscaling_spec .max_replica_count = (
263
+ worker_node_type .autoscaling_spec .max_replica_count
264
+ )
240
265
resource_pool .machine_spec .machine_type = worker_node_type .machine_type
241
266
resource_pool .machine_spec .accelerator_count = (
242
267
worker_node_type .accelerator_count
0 commit comments