@@ -190,8 +190,7 @@ def tune_model(
190
190
Learning rate to use in tuning.
191
191
learning_rate_multiplier: Learning rate multiplier to use in tuning.
192
192
tuning_job_location: GCP location where the tuning job should be run.
193
- Only "europe-west4" and "us-central1" locations are supported for now.
194
- tuned_model_location: GCP location where the tuned model should be deployed. Only "us-central1" is supported for now.
193
+ tuned_model_location: GCP location where the tuned model should be deployed.
195
194
model_display_name: Custom display name for the tuned model.
196
195
tuning_evaluation_spec: Specification for the model evaluation during tuning.
197
196
default_context: The context to use for all training samples by default.
@@ -294,8 +293,7 @@ def _tune_model(
294
293
See https://cloud.google.com/vertex-ai/docs/generative-ai/models/tune-models#dataset_format
295
294
tuning_parameters: Tuning pipeline parameter values.
296
295
tuning_job_location: GCP location where the tuning job should be run.
297
- Only "europe-west4" and "us-central1" locations are supported for now.
298
- tuned_model_location: GCP location where the tuned model should be deployed. Only "us-central1" is supported for now.
296
+ tuned_model_location: GCP location where the tuned model should be deployed.
299
297
model_display_name: Custom display name for the tuned model.
300
298
301
299
Returns:
@@ -312,9 +310,10 @@ def _tune_model(
312
310
"Please specify the tuning job location (`tuning_job_location`)."
313
311
f"Tuning is supported in the following locations: { _TUNING_LOCATIONS } "
314
312
)
315
- if tuned_model_location != _TUNED_MODEL_LOCATION :
313
+ if tuned_model_location not in _TUNED_MODEL_LOCATIONS :
316
314
raise ValueError (
317
- f'Model deployment is only supported in the following locations: tuned_model_location="{ _TUNED_MODEL_LOCATION } "'
315
+ "Tuned model deployment is only supported in the following locations: "
316
+ f"{ _TUNED_MODEL_LOCATIONS } "
318
317
)
319
318
model_info = _model_garden_models ._get_model_info (
320
319
model_id = self ._model_id ,
@@ -329,6 +328,7 @@ def _tune_model(
329
328
tuning_parameters = tuning_parameters ,
330
329
model_display_name = model_display_name ,
331
330
tuning_job_location = tuning_job_location ,
331
+ tuned_model_location = tuned_model_location ,
332
332
)
333
333
334
334
job = _LanguageModelTuningJob (
@@ -369,8 +369,7 @@ def tune_model(
369
369
train_steps: Number of training batches to tune on (batch size is 8 samples).
370
370
learning_rate_multiplier: Learning rate multiplier to use in tuning.
371
371
tuning_job_location: GCP location where the tuning job should be run.
372
- Only "europe-west4" and "us-central1" locations are supported for now.
373
- tuned_model_location: GCP location where the tuned model should be deployed. Only "us-central1" is supported for now.
372
+ tuned_model_location: GCP location where the tuned model should be deployed.
374
373
model_display_name: Custom display name for the tuned model.
375
374
tuning_evaluation_spec: Specification for the model evaluation during tuning.
376
375
accelerator_type: Type of accelerator to use. Can be "TPU" or "GPU".
@@ -436,8 +435,7 @@ def tune_model(
436
435
Learning rate to use in tuning.
437
436
learning_rate_multiplier: Learning rate multiplier to use in tuning.
438
437
tuning_job_location: GCP location where the tuning job should be run.
439
- Only "europe-west4" and "us-central1" locations are supported for now.
440
- tuned_model_location: GCP location where the tuned model should be deployed. Only "us-central1" is supported for now.
438
+ tuned_model_location: GCP location where the tuned model should be deployed.
441
439
model_display_name: Custom display name for the tuned model.
442
440
tuning_evaluation_spec: Specification for the model evaluation during tuning.
443
441
accelerator_type: Type of accelerator to use. Can be "TPU" or "GPU".
@@ -503,8 +501,7 @@ def tune_model(
503
501
Learning rate to use in tuning.
504
502
learning_rate_multiplier: Learning rate multiplier to use in tuning.
505
503
tuning_job_location: GCP location where the tuning job should be run.
506
- Only "europe-west4" and "us-central1" locations are supported for now.
507
- tuned_model_location: GCP location where the tuned model should be deployed. Only "us-central1" is supported for now.
504
+ tuned_model_location: GCP location where the tuned model should be deployed.
508
505
model_display_name: Custom display name for the tuned model.
509
506
default_context: The context to use for all training samples by default.
510
507
accelerator_type: Type of accelerator to use. Can be "TPU" or "GPU".
@@ -570,8 +567,7 @@ def tune_model(
570
567
Learning rate to use in tuning.
571
568
learning_rate_multiplier: Learning rate multiplier to use in tuning.
572
569
tuning_job_location: GCP location where the tuning job should be run.
573
- Only "europe-west4" and "us-central1" locations are supported for now.
574
- tuned_model_location: GCP location where the tuned model should be deployed. Only "us-central1" is supported for now.
570
+ tuned_model_location: GCP location where the tuned model should be deployed.
575
571
model_display_name: Custom display name for the tuned model.
576
572
default_context: The context to use for all training samples by default.
577
573
accelerator_type: Type of accelerator to use. Can be "TPU" or "GPU".
@@ -2697,9 +2693,29 @@ class _PreviewCodeGenerationModel(
2697
2693
2698
2694
###### Model tuning
2699
2695
# Currently, tuning can only work in this location
2700
- _TUNING_LOCATIONS = ("europe-west4" , "us-central1" )
2701
- # Currently, deployment can only work in this location
2702
- _TUNED_MODEL_LOCATION = "us-central1"
2696
+
2697
+ _SUPPORTED_LOCATIONS = [
2698
+ # 1
2699
+ "us-central1" ,
2700
+ "europe-west4" ,
2701
+ "asia-southeast1" ,
2702
+ # 2
2703
+ "us-west1" ,
2704
+ "europe-west3" ,
2705
+ "europe-west2" ,
2706
+ "asia-northeast1" ,
2707
+ # 3
2708
+ "us-east4" ,
2709
+ "us-west4" ,
2710
+ "northamerica-northeast1" ,
2711
+ "europe-west9" ,
2712
+ "europe-west1" ,
2713
+ "asia-northeast3" ,
2714
+ ]
2715
+
2716
+ _TUNING_LOCATIONS = _SUPPORTED_LOCATIONS
2717
+ # Currently, deployment can only work in these locations
2718
+ _TUNED_MODEL_LOCATIONS = _SUPPORTED_LOCATIONS
2703
2719
2704
2720
2705
2721
class _LanguageModelTuningJob :
@@ -2771,7 +2787,7 @@ def _list_tuned_model_names(model_id: str) -> List[str]:
2771
2787
tuned_models = aiplatform .Model .list (
2772
2788
filter = f'labels.{ _TUNING_BASE_MODEL_ID_LABEL_KEY } ="{ model_id .replace ("@" , "-" )} "' ,
2773
2789
# TODO(b/275444096): Remove the explicit location once models are deployed to the user's selected location
2774
- location = _TUNED_MODEL_LOCATION ,
2790
+ location = aiplatform_initializer . global_config . location ,
2775
2791
)
2776
2792
model_names = [model .resource_name for model in tuned_models ]
2777
2793
return model_names
@@ -2789,8 +2805,9 @@ def _launch_tuning_job(
2789
2805
model_id : str ,
2790
2806
tuning_pipeline_uri : str ,
2791
2807
tuning_parameters : Dict [str , Any ],
2808
+ tuning_job_location : str ,
2809
+ tuned_model_location : str ,
2792
2810
model_display_name : Optional [str ] = None ,
2793
- tuning_job_location : str = _TUNING_LOCATIONS [0 ],
2794
2811
) -> aiplatform .PipelineJob :
2795
2812
output_dir_uri = _generate_tuned_model_dir_uri (model_id = model_id )
2796
2813
if isinstance (training_data , str ):
@@ -2836,7 +2853,7 @@ def _launch_tuning_job(
2836
2853
"project" : aiplatform_initializer .global_config .project ,
2837
2854
# TODO(b/275444096): Remove the explicit location once tuning can happen in all regions
2838
2855
# "location": aiplatform_initializer.global_config.location,
2839
- "location" : _TUNED_MODEL_LOCATION ,
2856
+ "location" : tuned_model_location ,
2840
2857
"large_model_reference" : model_id ,
2841
2858
"model_display_name" : model_display_name ,
2842
2859
}
0 commit comments