google-cloud-pipeline-components 2.13.1__py3-none-any.whl → 2.14.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of google-cloud-pipeline-components might be problematic. Click here for more details.

Files changed (82) hide show
  1. google_cloud_pipeline_components/__init__.py +5 -6
  2. google_cloud_pipeline_components/_implementation/llm/deployment_graph.py +12 -34
  3. google_cloud_pipeline_components/_implementation/llm/env.py +1 -1
  4. google_cloud_pipeline_components/_implementation/llm/function_based.py +14 -48
  5. google_cloud_pipeline_components/_implementation/llm/generated/refined_image_versions.py +1 -1
  6. google_cloud_pipeline_components/_implementation/llm/infer_preprocessor.py +109 -0
  7. google_cloud_pipeline_components/_implementation/llm/online_evaluation_pairwise.py +8 -0
  8. google_cloud_pipeline_components/_implementation/llm/reinforcement_learning_graph.py +27 -36
  9. google_cloud_pipeline_components/_implementation/llm/reward_model_graph.py +31 -47
  10. google_cloud_pipeline_components/_implementation/llm/rlhf_preprocessor.py +84 -0
  11. google_cloud_pipeline_components/_implementation/llm/validate_pipeline.py +11 -0
  12. google_cloud_pipeline_components/_implementation/model_evaluation/__init__.py +0 -12
  13. google_cloud_pipeline_components/_implementation/model_evaluation/llm_embedding/evaluation_llm_embedding_pipeline.py +2 -1
  14. google_cloud_pipeline_components/_placeholders.py +30 -1
  15. google_cloud_pipeline_components/preview/automl/forecasting/forecasting_ensemble.py +1 -1
  16. google_cloud_pipeline_components/preview/automl/forecasting/forecasting_stage_1_tuner.py +2 -2
  17. google_cloud_pipeline_components/preview/automl/forecasting/forecasting_stage_2_tuner.py +2 -2
  18. google_cloud_pipeline_components/preview/automl/forecasting/learn_to_learn_forecasting_pipeline.yaml +34 -34
  19. google_cloud_pipeline_components/preview/automl/forecasting/sequence_to_sequence_forecasting_pipeline.yaml +34 -34
  20. google_cloud_pipeline_components/preview/automl/forecasting/temporal_fusion_transformer_forecasting_pipeline.yaml +34 -34
  21. google_cloud_pipeline_components/preview/automl/forecasting/time_series_dense_encoder_forecasting_pipeline.yaml +34 -34
  22. google_cloud_pipeline_components/preview/automl/tabular/auto_feature_engineering.py +1 -1
  23. google_cloud_pipeline_components/preview/automl/tabular/automl_tabular_feature_selection_pipeline.yaml +39 -39
  24. google_cloud_pipeline_components/preview/automl/tabular/automl_tabular_v2_pipeline.yaml +41 -41
  25. google_cloud_pipeline_components/preview/automl/tabular/distillation_stage_feature_transform_engine.py +2 -2
  26. google_cloud_pipeline_components/preview/automl/tabular/feature_selection.py +2 -2
  27. google_cloud_pipeline_components/preview/automl/tabular/feature_selection_pipeline.yaml +4 -4
  28. google_cloud_pipeline_components/preview/automl/tabular/feature_transform_engine.py +3 -3
  29. google_cloud_pipeline_components/preview/automl/tabular/tabnet_hyperparameter_tuning_job.py +2 -2
  30. google_cloud_pipeline_components/preview/automl/tabular/tabnet_hyperparameter_tuning_job_pipeline.yaml +17 -17
  31. google_cloud_pipeline_components/preview/automl/tabular/tabnet_trainer.py +2 -2
  32. google_cloud_pipeline_components/preview/automl/tabular/tabnet_trainer_pipeline.yaml +15 -15
  33. google_cloud_pipeline_components/preview/automl/tabular/wide_and_deep_hyperparameter_tuning_job.py +2 -2
  34. google_cloud_pipeline_components/preview/automl/tabular/wide_and_deep_hyperparameter_tuning_job_pipeline.yaml +16 -16
  35. google_cloud_pipeline_components/preview/automl/tabular/wide_and_deep_trainer.py +2 -2
  36. google_cloud_pipeline_components/preview/automl/tabular/wide_and_deep_trainer_pipeline.yaml +15 -15
  37. google_cloud_pipeline_components/preview/automl/tabular/xgboost_hyperparameter_tuning_job_pipeline.yaml +14 -14
  38. google_cloud_pipeline_components/preview/automl/tabular/xgboost_trainer_pipeline.yaml +13 -13
  39. google_cloud_pipeline_components/preview/automl/vision/data_converter.py +3 -1
  40. google_cloud_pipeline_components/preview/custom_job/component.py +2 -2
  41. google_cloud_pipeline_components/preview/custom_job/utils.py +3 -2
  42. google_cloud_pipeline_components/preview/llm/infer/component.py +22 -25
  43. google_cloud_pipeline_components/preview/llm/rlhf/component.py +72 -10
  44. google_cloud_pipeline_components/preview/model_evaluation/__init__.py +5 -2
  45. google_cloud_pipeline_components/preview/model_evaluation/model_evaluation_import_component.py +209 -0
  46. google_cloud_pipeline_components/proto/task_error_pb2.py +33 -0
  47. google_cloud_pipeline_components/proto/template_metadata_pb2.py +22 -15
  48. google_cloud_pipeline_components/v1/automl/forecasting/bqml_arima_predict_pipeline.yaml +10 -10
  49. google_cloud_pipeline_components/v1/automl/forecasting/bqml_arima_train_pipeline.yaml +31 -31
  50. google_cloud_pipeline_components/v1/automl/forecasting/prophet_predict_pipeline.yaml +13 -13
  51. google_cloud_pipeline_components/v1/automl/forecasting/prophet_trainer.py +13 -3
  52. google_cloud_pipeline_components/v1/automl/forecasting/prophet_trainer_pipeline.yaml +18 -15
  53. google_cloud_pipeline_components/v1/automl/tabular/automl_tabular_pipeline.yaml +37 -37
  54. google_cloud_pipeline_components/v1/automl/tabular/cv_trainer.py +2 -2
  55. google_cloud_pipeline_components/v1/automl/tabular/ensemble.py +2 -2
  56. google_cloud_pipeline_components/v1/automl/tabular/finalizer.py +1 -1
  57. google_cloud_pipeline_components/v1/automl/tabular/infra_validator.py +1 -1
  58. google_cloud_pipeline_components/v1/automl/tabular/split_materialized_data.py +1 -1
  59. google_cloud_pipeline_components/v1/automl/tabular/stage_1_tuner.py +2 -2
  60. google_cloud_pipeline_components/v1/automl/tabular/stats_and_example_gen.py +2 -2
  61. google_cloud_pipeline_components/v1/automl/tabular/training_configurator_and_validator.py +1 -1
  62. google_cloud_pipeline_components/v1/automl/tabular/transform.py +2 -2
  63. google_cloud_pipeline_components/v1/model_evaluation/__init__.py +3 -1
  64. google_cloud_pipeline_components/v1/model_evaluation/classification_component.py +2 -2
  65. google_cloud_pipeline_components/v1/model_evaluation/error_analysis_pipeline.py +8 -10
  66. google_cloud_pipeline_components/v1/model_evaluation/evaluated_annotation_pipeline.py +2 -2
  67. google_cloud_pipeline_components/v1/model_evaluation/evaluation_automl_tabular_feature_attribution_pipeline.py +2 -2
  68. google_cloud_pipeline_components/v1/model_evaluation/evaluation_automl_tabular_pipeline.py +2 -2
  69. google_cloud_pipeline_components/v1/model_evaluation/evaluation_automl_unstructure_data_pipeline.py +2 -2
  70. google_cloud_pipeline_components/v1/model_evaluation/evaluation_feature_attribution_pipeline.py +2 -2
  71. google_cloud_pipeline_components/v1/model_evaluation/evaluation_llm_classification_pipeline.py +4 -2
  72. google_cloud_pipeline_components/v1/model_evaluation/evaluation_llm_text_generation_pipeline.py +4 -2
  73. google_cloud_pipeline_components/{preview → v1}/model_evaluation/model_based_llm_evaluation/__init__.py +2 -2
  74. google_cloud_pipeline_components/{preview → v1}/model_evaluation/model_based_llm_evaluation/autosxs/autosxs_pipeline.py +1 -0
  75. google_cloud_pipeline_components/version.py +1 -1
  76. {google_cloud_pipeline_components-2.13.1.dist-info → google_cloud_pipeline_components-2.14.1.dist-info}/METADATA +18 -19
  77. {google_cloud_pipeline_components-2.13.1.dist-info → google_cloud_pipeline_components-2.14.1.dist-info}/RECORD +81 -79
  78. {google_cloud_pipeline_components-2.13.1.dist-info → google_cloud_pipeline_components-2.14.1.dist-info}/WHEEL +1 -1
  79. google_cloud_pipeline_components/proto/preflight_validations_pb2.py +0 -47
  80. /google_cloud_pipeline_components/{preview → v1}/model_evaluation/model_based_llm_evaluation/autosxs/__init__.py +0 -0
  81. {google_cloud_pipeline_components-2.13.1.dist-info → google_cloud_pipeline_components-2.14.1.dist-info}/LICENSE +0 -0
  82. {google_cloud_pipeline_components-2.13.1.dist-info → google_cloud_pipeline_components-2.14.1.dist-info}/top_level.txt +0 -0
@@ -2844,7 +2844,7 @@ deploymentSpec:
2844
2844
  \"encryption_spec\": {\"kms_key_name\":\"", "{{$.inputs.parameters[''encryption_spec_key_name'']}}",
2845
2845
  "\"}, \"job_spec\": {\"worker_pool_specs\": [{\"replica_count\": 1, \"machine_spec\":
2846
2846
  {\"machine_type\": \"n1-standard-8\"}, \"container_spec\": {\"image_uri\":\"",
2847
- "us-docker.pkg.dev/vertex-ai-restricted/automl-tabular/training:20240214_1325", "\",
2847
+ "us-docker.pkg.dev/vertex-ai-restricted/automl-tabular/training:20240419_0625", "\",
2848
2848
  \"args\": [\"cancel_l2l_tuner\", \"--error_file_path=", "{{$.inputs.parameters[''root_dir'']}}",
2849
2849
  "/{{$.pipeline_job_uuid}}/{{$.pipeline_task_uuid}}/error.pb\", \"--cleanup_lro_job_infos=",
2850
2850
  "{{$.inputs.parameters[''root_dir'']}}", "/{{$.pipeline_job_uuid}}/lro\"]}}]}}"]}'
@@ -2875,7 +2875,7 @@ deploymentSpec:
2875
2875
  \ *\n\ndef _bool_identity(value: bool) -> str:\n \"\"\"Returns boolean\
2876
2876
  \ value.\n\n Args:\n value: Boolean value to return\n\n Returns:\n\
2877
2877
  \ Boolean value.\n \"\"\"\n return 'true' if value else 'false'\n\n"
2878
- image: us-docker.pkg.dev/vertex-ai/automl-tabular/kfp-v2-base:20240214_1325
2878
+ image: us-docker.pkg.dev/vertex-ai/automl-tabular/kfp-v2-base:20240419_0625
2879
2879
  exec-feature-transform-engine:
2880
2880
  container:
2881
2881
  args:
@@ -2960,8 +2960,8 @@ deploymentSpec:
2960
2960
  "/{{$.pipeline_job_uuid}}/{{$.pipeline_task_uuid}}/dataflow_tmp"]}'
2961
2961
  - '{"Concat": ["--dataflow_max_num_workers=", "{{$.inputs.parameters[''dataflow_max_num_workers'']}}"]}'
2962
2962
  - '{"Concat": ["--dataflow_machine_type=", "{{$.inputs.parameters[''dataflow_machine_type'']}}"]}'
2963
- - --dataflow_worker_container_image=us-docker.pkg.dev/vertex-ai/automl-tabular/dataflow-worker:20240214_1325
2964
- - --feature_transform_engine_docker_uri=us-docker.pkg.dev/vertex-ai/automl-tabular/feature-transform-engine:20240214_1325
2963
+ - --dataflow_worker_container_image=us-docker.pkg.dev/vertex-ai/automl-tabular/dataflow-worker:20240419_0625
2964
+ - --feature_transform_engine_docker_uri=us-docker.pkg.dev/vertex-ai/automl-tabular/feature-transform-engine:20240419_0625
2965
2965
  - '{"Concat": ["--dataflow_disk_size_gb=", "{{$.inputs.parameters[''dataflow_disk_size_gb'']}}"]}'
2966
2966
  - '{"Concat": ["--dataflow_subnetwork_fully_qualified=", "{{$.inputs.parameters[''dataflow_subnetwork'']}}"]}'
2967
2967
  - '{"Concat": ["--dataflow_use_public_ips=", "{{$.inputs.parameters[''dataflow_use_public_ips'']}}"]}'
@@ -2978,7 +2978,7 @@ deploymentSpec:
2978
2978
  - '{"IfPresent": {"InputName": "group_temporal_total_weight", "Then": {"Concat":
2979
2979
  ["--group_temporal_total_weight=", "{{$.inputs.parameters[''group_temporal_total_weight'']}}"]}}}'
2980
2980
  - '{"Concat": ["--encryption_spec_key_name=", "{{$.inputs.parameters[''encryption_spec_key_name'']}}"]}'
2981
- image: us-docker.pkg.dev/vertex-ai/automl-tabular/feature-transform-engine:20240214_1325
2981
+ image: us-docker.pkg.dev/vertex-ai/automl-tabular/feature-transform-engine:20240419_0625
2982
2982
  resources:
2983
2983
  cpuLimit: 8.0
2984
2984
  memoryLimit: 30.0
@@ -3098,10 +3098,10 @@ deploymentSpec:
3098
3098
  \ worker pool specs.\n \"\"\"\n import copy\n import collections\n import\
3099
3099
  \ os\n import re\n\n def get_gcs_path(path):\n return re.sub(r'/gcs/',\
3100
3100
  \ 'gs://', path)\n\n formatted_job_dir = get_gcs_path(job_dir)\n prediction_docker_uri\
3101
- \ = (\n 'us-docker.pkg.dev/vertex-ai/automl-tabular/xgboost-prediction-server:20240214_1325'\n\
3101
+ \ = (\n 'us-docker.pkg.dev/vertex-ai/automl-tabular/xgboost-prediction-server:20240419_0625'\n\
3102
3102
  \ )\n master_worker_pool_spec = {\n 'replica_count': 1,\n 'machine_spec':\
3103
3103
  \ {\n 'machine_type': machine_type,\n },\n 'container_spec':\
3104
- \ {\n 'image_uri': 'us-docker.pkg.dev/vertex-ai-restricted/automl-tabular/xgboost-training:20240214_1325',\n\
3104
+ \ {\n 'image_uri': 'us-docker.pkg.dev/vertex-ai-restricted/automl-tabular/xgboost-training:20240419_0625',\n\
3105
3105
  \ 'args': [\n f'--job_dir={formatted_job_dir}',\n\
3106
3106
  \ f'--target_column={target_column}',\n f'--objective={objective}',\n\
3107
3107
  \ f'--training_data_path={get_gcs_path(materialized_train_split)}',\n\
@@ -3159,7 +3159,7 @@ deploymentSpec:
3159
3159
  \ 'predictionSchemaUri': os.path.join(model_dir, 'prediction_schema.yaml'),\n\
3160
3160
  \ }\n unmanaged_container_model.uri = model_dir\n\n return collections.namedtuple('Outputs',\
3161
3161
  \ ['worker_pool_specs'])(\n worker_pool_specs_lst\n )\n\n"
3162
- image: us-docker.pkg.dev/vertex-ai/automl-tabular/kfp-v2-base:20240214_1325
3162
+ image: us-docker.pkg.dev/vertex-ai/automl-tabular/kfp-v2-base:20240419_0625
3163
3163
  exec-get-model-display-name:
3164
3164
  container:
3165
3165
  args:
@@ -3186,7 +3186,7 @@ deploymentSpec:
3186
3186
  \n return collections.namedtuple(\n 'Outputs',\n [\n \
3187
3187
  \ 'model_display_name',\n ],\n )(\n model_display_name,\n )\n\
3188
3188
  \n"
3189
- image: us-docker.pkg.dev/vertex-ai/automl-tabular/kfp-v2-base:20240214_1325
3189
+ image: us-docker.pkg.dev/vertex-ai/automl-tabular/kfp-v2-base:20240419_0625
3190
3190
  exec-get-prediction-type-for-xgboost:
3191
3191
  container:
3192
3192
  args:
@@ -3215,7 +3215,7 @@ deploymentSpec:
3215
3215
  \ Must be one of'\n ' [reg:squarederror, reg:squaredlogerror, reg:logistic,\
3216
3216
  \ reg:gamma,'\n ' reg:tweedie, reg:pseudohubererror, binary:logistic,'\n\
3217
3217
  \ ' multi:softprob].'\n )\n\n"
3218
- image: us-docker.pkg.dev/vertex-ai/automl-tabular/kfp-v2-base:20240214_1325
3218
+ image: us-docker.pkg.dev/vertex-ai/automl-tabular/kfp-v2-base:20240419_0625
3219
3219
  exec-model-batch-predict:
3220
3220
  container:
3221
3221
  args:
@@ -3407,7 +3407,7 @@ deploymentSpec:
3407
3407
  \ 'data_source_csv_filenames',\n 'data_source_bigquery_table_path',\n\
3408
3408
  \ ],\n )(\n data_source_csv_filenames,\n data_source_bigquery_table_path,\n\
3409
3409
  \ )\n\n"
3410
- image: us-docker.pkg.dev/vertex-ai/automl-tabular/kfp-v2-base:20240214_1325
3410
+ image: us-docker.pkg.dev/vertex-ai/automl-tabular/kfp-v2-base:20240419_0625
3411
3411
  exec-split-materialized-data:
3412
3412
  container:
3413
3413
  args:
@@ -3453,7 +3453,7 @@ deploymentSpec:
3453
3453
  \ 'w') as f:\n f.write(file_patterns[0])\n\n with tf.io.gfile.GFile(materialized_eval_split,\
3454
3454
  \ 'w') as f:\n f.write(file_patterns[1])\n\n with tf.io.gfile.GFile(materialized_test_split,\
3455
3455
  \ 'w') as f:\n f.write(file_patterns[2])\n\n"
3456
- image: us-docker.pkg.dev/vertex-ai/automl-tabular/dataflow-worker:20240214_1325
3456
+ image: us-docker.pkg.dev/vertex-ai/automl-tabular/dataflow-worker:20240419_0625
3457
3457
  exec-training-configurator-and-validator:
3458
3458
  container:
3459
3459
  args:
@@ -3498,7 +3498,7 @@ deploymentSpec:
3498
3498
  ["--temporal_total_weight=", "{{$.inputs.parameters[''temporal_total_weight'']}}"]}}}'
3499
3499
  - '{"IfPresent": {"InputName": "group_temporal_total_weight", "Then": {"Concat":
3500
3500
  ["--group_temporal_total_weight=", "{{$.inputs.parameters[''group_temporal_total_weight'']}}"]}}}'
3501
- image: us-docker.pkg.dev/vertex-ai/automl-tabular/feature-transform-engine:20240214_1325
3501
+ image: us-docker.pkg.dev/vertex-ai/automl-tabular/feature-transform-engine:20240419_0625
3502
3502
  exec-xgboost-trainer:
3503
3503
  container:
3504
3504
  args:
@@ -22,6 +22,7 @@ from google_cloud_pipeline_components.preview.automl.vision.json_utils import Co
22
22
  from kfp import dsl
23
23
 
24
24
 
25
+ # pylint: disable=singleton-comparison
25
26
  # pylint: disable=g-doc-args
26
27
  @dsl.container_component
27
28
  def data_converter(
@@ -31,6 +32,7 @@ def data_converter(
31
32
  objective: str,
32
33
  output_dir: dsl.Output[dsl.Artifact],
33
34
  gcp_resources: dsl.OutputPath(str),
35
+ enable_input_validation: bool = True,
34
36
  location: str = 'us-central1',
35
37
  timeout: str = '604800s',
36
38
  service_account: Optional[str] = None,
@@ -75,7 +77,7 @@ def data_converter(
75
77
  'image_uri': 'us-docker.pkg.dev/vertex-ai/vertex-vision-model-garden-dockers/data-converter',
76
78
  'args': [
77
79
  '--enable_input_validation',
78
- 'true',
80
+ str(enable_input_validation),
79
81
  '--input_file_path',
80
82
  input_file_path,
81
83
  '--input_file_type',
@@ -37,7 +37,7 @@ def custom_training_job(
37
37
  base_output_directory: str = '',
38
38
  labels: Dict[str, str] = {},
39
39
  encryption_spec_key_name: str = '',
40
- persistent_resource_id: str = '',
40
+ persistent_resource_id: str = _placeholders.PERSISTENT_RESOURCE_ID_PLACEHOLDER,
41
41
  project: str = _placeholders.PROJECT_ID_PLACEHOLDER,
42
42
  ):
43
43
  # fmt: off
@@ -57,7 +57,7 @@ def custom_training_job(
57
57
  base_output_directory: The Cloud Storage location to store the output of this CustomJob or HyperparameterTuningJob. See [more information ](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/GcsDestination).
58
58
  labels: The labels with user-defined metadata to organize the CustomJob. See [more information](https://goo.gl/xmQnxf).
59
59
  encryption_spec_key_name: Customer-managed encryption key options for the CustomJob. If this is set, then all resources created by the CustomJob will be encrypted with the provided encryption key.
60
- persistent_resource_id: The ID of the PersistentResource in the same Project and Location which to run. If this is specified, the job will be run on existing machines held by the PersistentResource instead of on-demand short-live machines. The network and CMEK configs on the job should be consistent with those on the PersistentResource, otherwise, the job will be rejected. (This is a Preview feature not yet recommended for production workloads.)
60
+ persistent_resource_id: The ID of the PersistentResource in the same Project and Location which to run. The default value is a placeholder that will be resolved to the PipelineJob [RuntimeConfig](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.pipelineJobs#PipelineJob.RuntimeConfig)'s persistent resource id at runtime. However, if the PipelineJob doesn't set Persistent Resource as the job level runtime, the placedholder will be resolved to an empty string and the custom job will be run on demand. If the value is set explicitly, the custom job will runs in the specified persistent resource, in this case, please note the network and CMEK configs on the job should be consistent with those on the PersistentResource, otherwise, the job will be rejected. (This is a Preview feature not yet recommended for production workloads.)
61
61
  project: Project to create the custom training job in. Defaults to the project in which the PipelineJob is run.
62
62
  Returns:
63
63
  gcp_resources: Serialized JSON of `gcp_resources` [proto](https://github.com/kubeflow/pipelines/tree/master/components/google-cloud/google_cloud_pipeline_components/proto) which tracks the CustomJob.
@@ -18,6 +18,7 @@ import textwrap
18
18
  from typing import Callable, Dict, List, Optional
19
19
  import warnings
20
20
 
21
+ from google_cloud_pipeline_components import _placeholders
21
22
  from google_cloud_pipeline_components.preview.custom_job import component
22
23
  from kfp import components
23
24
  import yaml
@@ -68,7 +69,7 @@ def create_custom_training_job_from_component(
68
69
  nfs_mounts: Optional[List[Dict[str, str]]] = None,
69
70
  base_output_directory: str = '',
70
71
  labels: Optional[Dict[str, str]] = None,
71
- persistent_resource_id: str = '',
72
+ persistent_resource_id: str = _placeholders.PERSISTENT_RESOURCE_ID_PLACEHOLDER,
72
73
  env: Optional[List[Dict[str, str]]] = None,
73
74
  ) -> Callable:
74
75
  # fmt: off
@@ -96,7 +97,7 @@ def create_custom_training_job_from_component(
96
97
  nfs_mounts: A list of [NfsMount](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/CustomJobSpec#NfsMount) resource specs in Json dict format. For more details about mounting NFS for CustomJob, see [Mount an NFS share for custom training](https://cloud.google.com/vertex-ai/docs/training/train-nfs-share).
97
98
  base_output_directory: The Cloud Storage location to store the output of this CustomJob or HyperparameterTuningJob. See [more information](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/GcsDestination).
98
99
  labels: The labels with user-defined metadata to organize the CustomJob. See [more information](https://goo.gl/xmQnxf).
99
- persistent_resource_id: The ID of the PersistentResource in the same Project and Location which to run. If this is specified, the job will be run on existing machines held by the PersistentResource instead of on-demand short-live machines. The network and CMEK configs on the job should be consistent with those on the PersistentResource, otherwise, the job will be rejected. (This is a Preview feature not yet recommended for production workloads.)
100
+ persistent_resource_id: The ID of the PersistentResource in the same Project and Location which to run. The default value is a placeholder that will be resolved to the PipelineJob [RuntimeConfig](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.pipelineJobs#PipelineJob.RuntimeConfig)'s persistent resource id at runtime. However, if the PipelineJob doesn't set Persistent Resource as the job level runtime, the placedholder will be resolved to an empty string and the custom job will be run on demand. If the value is set explicitly, the custom job will runs in the specified persistent resource, in this case, please note the network and CMEK configs on the job should be consistent with those on the PersistentResource, otherwise, the job will be rejected. (This is a Preview feature not yet recommended for production workloads.)
100
101
  env: Environment variables to be passed to the container. Takes the form `[{'name': '...', 'value': '...'}]`. Maximum limit is 100.
101
102
 
102
103
  Returns:
@@ -18,7 +18,7 @@ from typing import NamedTuple, Optional
18
18
  from google_cloud_pipeline_components import _placeholders
19
19
  from google_cloud_pipeline_components._implementation.llm import bulk_inferrer
20
20
  from google_cloud_pipeline_components._implementation.llm import env
21
- from google_cloud_pipeline_components._implementation.llm import function_based
21
+ from google_cloud_pipeline_components._implementation.llm import infer_preprocessor
22
22
  from google_cloud_pipeline_components._implementation.llm import preprocess_chat_dataset
23
23
  from google_cloud_pipeline_components._implementation.llm import private_text_importer
24
24
  import kfp
@@ -66,14 +66,16 @@ def infer_pipeline(
66
66
  """
67
67
  # fmt: on
68
68
  prompt_column = 'input_text'
69
- machine_spec = function_based.resolve_machine_spec(
69
+ preprocess_metadata = infer_preprocessor.infer_preprocessor(
70
+ large_model_reference=large_model_reference,
70
71
  accelerator_type=accelerator_type,
71
72
  use_test_spec=env.get_use_test_machine_spec(),
72
- ).set_display_name('Resolve Machine Spec')
73
- reference_model_metadata = function_based.resolve_reference_model_metadata(
74
- large_model_reference=large_model_reference,
75
- reference_model_path=model_checkpoint,
76
- ).set_display_name('Resolve Model Metadata')
73
+ project=env.PRIVATE_ARTIFACT_REGISTRY_PROJECT,
74
+ location=env.PRIVATE_ARTIFACT_REGISTRY_LOCATION,
75
+ artifact_registry=env.PRIVATE_ARTIFACT_REGISTRY,
76
+ tag=env.get_private_image_tag(),
77
+ instruction=instruction,
78
+ ).set_display_name('Preprocess Inputs')
77
79
 
78
80
  processed_dataset = preprocess_chat_dataset.preprocess_chat_dataset(
79
81
  large_model_reference=large_model_reference,
@@ -82,10 +84,6 @@ def infer_pipeline(
82
84
  dataset_type='prompt',
83
85
  ).set_display_name('Preprocess Dataset')
84
86
 
85
- resolved_text_instruction = function_based.resolve_instruction(
86
- large_model_reference=large_model_reference,
87
- instruction=instruction,
88
- ).set_display_name('Resolve Instruction')
89
87
  prompt_dataset_importer = (
90
88
  private_text_importer.private_text_importer(
91
89
  project=project,
@@ -94,35 +92,34 @@ def infer_pipeline(
94
92
  inputs_field_name=prompt_column,
95
93
  targets_field_name='', # ignore targets_field_name
96
94
  output_split_name=env.TRAIN_SPLIT,
97
- large_model_reference=reference_model_metadata.outputs[
98
- 'large_model_reference'
95
+ large_model_reference=preprocess_metadata.outputs[
96
+ 'metadata_large_model_reference'
99
97
  ],
100
- instruction=resolved_text_instruction.output,
98
+ instruction=preprocess_metadata.outputs['metadata_instruction'],
101
99
  encryption_spec_key_name=encryption_spec_key_name,
102
100
  )
103
101
  .set_display_name('Import Prompt Dataset')
104
102
  .set_caching_options(False)
105
103
  )
106
104
 
107
- bulk_inferrer_image_uri = function_based.resolve_private_refined_image_uri(
108
- accelerator_type=machine_spec.outputs['accelerator_type'],
109
- ).set_display_name('Resolve Bulk Inferrer Image URI')
110
105
  bulk_inference = bulk_inferrer.bulk_inferrer(
111
106
  project=project,
112
- location=machine_spec.outputs['tuning_location'],
113
- input_model=reference_model_metadata.outputs['reference_model_path'],
107
+ location=preprocess_metadata.outputs['metadata_tuning_location'],
108
+ input_model=preprocess_metadata.outputs['metadata_reference_model_path'],
114
109
  input_dataset_path=prompt_dataset_importer.outputs['imported_data_path'],
115
110
  dataset_split=env.TRAIN_SPLIT,
116
111
  inputs_sequence_length=prompt_sequence_length,
117
112
  targets_sequence_length=target_sequence_length,
118
- large_model_reference=reference_model_metadata.outputs[
119
- 'large_model_reference'
113
+ large_model_reference=preprocess_metadata.outputs[
114
+ 'metadata_large_model_reference'
120
115
  ],
121
116
  sampling_strategy=sampling_strategy,
122
- accelerator_type=machine_spec.outputs['accelerator_type'],
123
- accelerator_count=machine_spec.outputs['accelerator_count'],
124
- machine_type=machine_spec.outputs['machine_type'],
125
- image_uri=bulk_inferrer_image_uri.output,
117
+ accelerator_type=preprocess_metadata.outputs['metadata_accelerator_type'],
118
+ accelerator_count=preprocess_metadata.outputs[
119
+ 'metadata_accelerator_count'
120
+ ],
121
+ machine_type=preprocess_metadata.outputs['metadata_machine_type'],
122
+ image_uri=preprocess_metadata.outputs['metadata_refined_image_uri'],
126
123
  encryption_spec_key_name=encryption_spec_key_name,
127
124
  ).set_display_name('Bulk Inferrer')
128
125
 
@@ -21,6 +21,8 @@ from google_cloud_pipeline_components._implementation.llm import env
21
21
  from google_cloud_pipeline_components._implementation.llm import function_based
22
22
  from google_cloud_pipeline_components._implementation.llm import reinforcement_learning_graph
23
23
  from google_cloud_pipeline_components._implementation.llm import reward_model_graph
24
+ from google_cloud_pipeline_components._implementation.llm import rlhf_preprocessor
25
+ from google_cloud_pipeline_components._implementation.llm import utils
24
26
  from google_cloud_pipeline_components._implementation.llm import validate_pipeline
25
27
  from google_cloud_pipeline_components.preview.llm.infer import component
26
28
  import kfp
@@ -94,11 +96,49 @@ def rlhf_pipeline(
94
96
  eval_dataset=eval_dataset,
95
97
  ).set_display_name('Validate Inputs')
96
98
 
99
+ preprocess_metadata = rlhf_preprocessor.rlhf_preprocessor(
100
+ large_model_reference=large_model_reference,
101
+ accelerator_type=accelerator_type,
102
+ use_test_spec=env.get_use_test_machine_spec(),
103
+ project=env.PRIVATE_ARTIFACT_REGISTRY_PROJECT,
104
+ location=env.PRIVATE_ARTIFACT_REGISTRY_LOCATION,
105
+ artifact_registry=env.PRIVATE_ARTIFACT_REGISTRY,
106
+ tag=env.get_private_image_tag(),
107
+ evaluation_dataset=eval_dataset,
108
+ tensorboard_resource_id=tensorboard_resource_id,
109
+ upload_location=location,
110
+ model_display_name=model_display_name,
111
+ deploy_model=deploy_model,
112
+ ).set_display_name('Preprocess Inputs')
113
+ num_microbatches = preprocess_metadata.outputs['metadata_num_microbatches']
114
+
97
115
  reward_model_pipeline = (
98
116
  (
99
117
  reward_model_graph.pipeline(
100
118
  preference_dataset=preference_dataset,
101
119
  large_model_reference=large_model_reference,
120
+ reward_model_reference=preprocess_metadata.outputs[
121
+ 'metadata_reward_model_reference'
122
+ ],
123
+ reward_model_path=preprocess_metadata.outputs[
124
+ 'metadata_reward_model_path'
125
+ ],
126
+ machine_type=preprocess_metadata.outputs['metadata_machine_type'],
127
+ tuning_location=preprocess_metadata.outputs[
128
+ 'metadata_tuning_location'
129
+ ],
130
+ accelerator_type=preprocess_metadata.outputs[
131
+ 'metadata_accelerator_type'
132
+ ],
133
+ accelerator_count=preprocess_metadata.outputs[
134
+ 'metadata_accelerator_count'
135
+ ],
136
+ reward_model_image_uri=preprocess_metadata.outputs[
137
+ 'metadata_refined_image_uri'
138
+ ],
139
+ comma_separated_candidates_field_names=preprocess_metadata.outputs[
140
+ 'metadata_candidate_columns_string'
141
+ ],
102
142
  prompt_sequence_length=prompt_sequence_length,
103
143
  target_sequence_length=target_sequence_length,
104
144
  eval_dataset=validate_pipeline_task.outputs[
@@ -110,9 +150,9 @@ def rlhf_pipeline(
110
150
  lora_dim=reward_lora_dim,
111
151
  project=project,
112
152
  location=location,
113
- accelerator_type=accelerator_type,
114
153
  tensorboard_resource_id=tensorboard_resource_id,
115
154
  encryption_spec_key_name=encryption_spec_key_name,
155
+ num_microbatches=num_microbatches,
116
156
  )
117
157
  )
118
158
  .set_display_name('Train Reward Model')
@@ -120,8 +160,8 @@ def rlhf_pipeline(
120
160
  )
121
161
  rl_model_pipeline = reinforcement_learning_graph.pipeline(
122
162
  prompt_dataset=prompt_dataset,
123
- input_reward_model_path=reward_model_pipeline.outputs[
124
- 'reward_model_base_path'
163
+ input_reward_model_path=preprocess_metadata.outputs[
164
+ 'metadata_reward_model_path'
125
165
  ],
126
166
  input_reward_adapter_path=reward_model_pipeline.outputs[
127
167
  'reward_model_adapter_path'
@@ -130,6 +170,22 @@ def rlhf_pipeline(
130
170
  'reward_dataset_path'
131
171
  ],
132
172
  large_model_reference=large_model_reference,
173
+ reward_model_reference=preprocess_metadata.outputs[
174
+ 'metadata_reward_model_reference'
175
+ ],
176
+ policy_model_reference=preprocess_metadata.outputs[
177
+ 'metadata_large_model_reference'
178
+ ],
179
+ policy_model_path=preprocess_metadata.outputs[
180
+ 'metadata_reference_model_path'
181
+ ],
182
+ machine_type=preprocess_metadata.outputs['metadata_machine_type'],
183
+ tuning_location=preprocess_metadata.outputs['metadata_tuning_location'],
184
+ accelerator_type=preprocess_metadata.outputs['metadata_accelerator_type'],
185
+ accelerator_count=preprocess_metadata.outputs[
186
+ 'metadata_accelerator_count'
187
+ ],
188
+ rl_image_uri=preprocess_metadata.outputs['metadata_refined_image_uri'],
133
189
  prompt_sequence_length=prompt_sequence_length,
134
190
  target_sequence_length=target_sequence_length,
135
191
  reinforcement_learning_rate_multiplier=reinforcement_learning_rate_multiplier,
@@ -138,17 +194,16 @@ def rlhf_pipeline(
138
194
  instruction=instruction,
139
195
  reward_lora_dim=reward_lora_dim,
140
196
  project=project,
141
- accelerator_type=accelerator_type,
142
197
  location=location,
143
198
  tensorboard_resource_id=tensorboard_resource_id,
144
199
  encryption_spec_key_name=encryption_spec_key_name,
200
+ num_microbatches=num_microbatches,
145
201
  ).set_display_name('Reinforcement Learning')
146
202
 
147
- has_inference_dataset = function_based.value_exists(
148
- value=eval_dataset
149
- ).set_display_name('Resolve Inference Dataset')
203
+ has_inference_dataset = preprocess_metadata.outputs['has_inference_dataset']
204
+
150
205
  with kfp.dsl.Condition(
151
- has_inference_dataset.output == True, # pylint: disable=singleton-comparison
206
+ has_inference_dataset == True, # pylint: disable=singleton-comparison
152
207
  name='Perform Inference',
153
208
  ):
154
209
  has_model_checkpoint = function_based.value_exists(
@@ -174,10 +229,17 @@ def rlhf_pipeline(
174
229
  llm_model_handler = deployment_graph.pipeline(
175
230
  output_adapter_path=rl_model_pipeline.outputs['output_adapter_path'],
176
231
  large_model_reference=large_model_reference,
177
- model_display_name=model_display_name,
178
- deploy_model=deploy_model,
232
+ policy_model_reference=preprocess_metadata.outputs[
233
+ 'metadata_large_model_reference'
234
+ ],
235
+ model_display_name=preprocess_metadata.outputs[
236
+ 'metadata_model_display_name'
237
+ ],
238
+ deploy_model=preprocess_metadata.outputs['metadata_deploy_model'],
239
+ upload_model=preprocess_metadata.outputs['metadata_upload_model'],
179
240
  encryption_spec_key_name=encryption_spec_key_name,
180
241
  upload_location=location,
242
+ regional_endpoint=preprocess_metadata.outputs['metadata_upload_location'],
181
243
  ).set_display_name('Upload and Deploy Tuned Model')
182
244
 
183
245
  return PipelineOutput(
@@ -1,4 +1,4 @@
1
- # Copyright 2021 The Kubeflow Authors. All Rights Reserved.
1
+ # Copyright 2024 The Kubeflow Authors. All Rights Reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -16,10 +16,12 @@
16
16
  from google_cloud_pipeline_components.preview.model_evaluation.data_bias_component import detect_data_bias as DetectDataBiasOp
17
17
  from google_cloud_pipeline_components.preview.model_evaluation.feature_attribution_component import feature_attribution as ModelEvaluationFeatureAttributionOp
18
18
  from google_cloud_pipeline_components.preview.model_evaluation.feature_attribution_graph_component import feature_attribution_graph_component as FeatureAttributionGraphComponentOp
19
- from google_cloud_pipeline_components.preview.model_evaluation.model_based_llm_evaluation.autosxs.autosxs_pipeline import autosxs_pipeline
20
19
  from google_cloud_pipeline_components.preview.model_evaluation.model_bias_component import detect_model_bias as DetectModelBiasOp
20
+ from google_cloud_pipeline_components.preview.model_evaluation.model_evaluation_import_component import model_evaluation_import as ModelImportEvaluationOp
21
21
  from google_cloud_pipeline_components.v1.model_evaluation.evaluation_llm_classification_pipeline import evaluation_llm_classification_pipeline
22
22
  from google_cloud_pipeline_components.v1.model_evaluation.evaluation_llm_text_generation_pipeline import evaluation_llm_text_generation_pipeline
23
+ from google_cloud_pipeline_components.v1.model_evaluation.model_based_llm_evaluation.autosxs.autosxs_pipeline import autosxs_pipeline
24
+
23
25
 
24
26
  __all__ = [
25
27
  'autosxs_pipeline',
@@ -29,4 +31,5 @@ __all__ = [
29
31
  'FeatureAttributionGraphComponentOp',
30
32
  'DetectModelBiasOp',
31
33
  'DetectDataBiasOp',
34
+ 'ModelImportEvaluationOp',
32
35
  ]
@@ -0,0 +1,209 @@
1
+ # Copyright 2024 The Kubeflow Authors. All Rights Reserved.
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
+
16
+ from typing import List, Optional
17
+
18
+ from google_cloud_pipeline_components import _image
19
+ from google_cloud_pipeline_components.types.artifact_types import ClassificationMetrics
20
+ from google_cloud_pipeline_components.types.artifact_types import ForecastingMetrics
21
+ from google_cloud_pipeline_components.types.artifact_types import RegressionMetrics
22
+ from google_cloud_pipeline_components.types.artifact_types import VertexModel
23
+ from kfp import dsl
24
+ from kfp.dsl import Input
25
+ from kfp.dsl import Metrics
26
+
27
+
28
+ @dsl.container_component
29
+ def model_evaluation_import(
30
+ model: Input[VertexModel],
31
+ gcp_resources: dsl.OutputPath(str),
32
+ evaluation_resource_name: dsl.OutputPath(str),
33
+ metrics: Optional[Input[Metrics]] = None,
34
+ row_based_metrics: Optional[Input[Metrics]] = None,
35
+ problem_type: Optional[str] = None,
36
+ classification_metrics: Optional[Input[ClassificationMetrics]] = None,
37
+ forecasting_metrics: Optional[Input[ForecastingMetrics]] = None,
38
+ regression_metrics: Optional[Input[RegressionMetrics]] = None,
39
+ text_generation_metrics: Optional[Input[Metrics]] = None,
40
+ question_answering_metrics: Optional[Input[Metrics]] = None,
41
+ summarization_metrics: Optional[Input[Metrics]] = None,
42
+ explanation: Optional[Input[Metrics]] = None,
43
+ feature_attributions: Optional[Input[Metrics]] = None,
44
+ embedding_metrics: Optional[Input[Metrics]] = None,
45
+ display_name: str = "",
46
+ dataset_path: str = "",
47
+ dataset_paths: List[str] = [],
48
+ dataset_type: str = "",
49
+ ):
50
+ # fmt: off
51
+ """Imports a model evaluation artifact to an existing Vertex model with
52
+ ModelService.ImportModelEvaluation.
53
+
54
+ For more details, see
55
+ https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.models.evaluations
56
+ One of the metrics inputs must be provided, metrics & problem_type,
57
+ classification_metrics, regression_metrics, or forecasting_metrics, text_generation_metrics,
58
+ question_answering_metrics, summarization_metrics, embedding_metrics.
59
+
60
+ Args:
61
+ model: Vertex model resource that will be the parent resource of the
62
+ uploaded evaluation.
63
+ metrics: Path of metrics generated from an evaluation component.
64
+ row_based_metrics:
65
+ Path of row_based_metrics generated from an evaluation component.
66
+ problem_type: The problem type of the metrics being imported to the
67
+ VertexModel. `classification`, `regression`, `forecasting`,
68
+ `text-generation`, `question-answering`, and `summarization` are the
69
+ currently supported problem types. Must be provided when `metrics` is
70
+ provided.
71
+ classification_metrics: google.ClassificationMetrics artifact generated from
72
+ the ModelEvaluationClassificationOp component.
73
+ forecasting_metrics: google.ForecastingMetrics artifact generated from
74
+ the ModelEvaluationForecastingOp component.
75
+ regression_metrics: google.ClassificationMetrics artifact generated from
76
+ the ModelEvaluationRegressionOp component.
77
+ text_generation_metrics: system.Metrics artifact generated from
78
+ the LLMEvaluationTextGenerationOp component. Subject to change to
79
+ google.TextGenerationMetrics.
80
+ question_answering_metrics: system.Metrics artifact generated from
81
+ the LLMEvaluationTextGenerationOp component. Subject to change to
82
+ google.QuestionAnsweringMetrics.
83
+ summarization_metrics: system.Metrics artifact generated from
84
+ the LLMEvaluationTextGenerationOp component. Subject to change to
85
+ google.SummarizationMetrics.
86
+ explanation: Path for model explanation metrics generated from an evaluation
87
+ component.
88
+ feature_attributions: The feature attributions metrics artifact generated
89
+ from the feature attribution component.
90
+ embedding_metrics: The embedding metrics artifact generated from the
91
+ embedding retrieval metrics component.
92
+ display_name: The display name for the uploaded model evaluation resource.
93
+ """
94
+ # fmt: on
95
+ return dsl.ContainerSpec(
96
+ image=_image.GCPC_IMAGE_TAG,
97
+ command=[
98
+ "python3",
99
+ "-u",
100
+ "-m",
101
+ "google_cloud_pipeline_components.container._implementation.model_evaluation.import_model_evaluation",
102
+ ],
103
+ args=[
104
+ dsl.IfPresentPlaceholder(
105
+ input_name="metrics",
106
+ then=[
107
+ "--metrics",
108
+ metrics.uri,
109
+ "--metrics_explanation",
110
+ metrics.metadata["explanation_gcs_path"],
111
+ ],
112
+ ),
113
+ dsl.IfPresentPlaceholder(
114
+ input_name="row_based_metrics",
115
+ then=[
116
+ "--row_based_metrics",
117
+ row_based_metrics.uri,
118
+ ],
119
+ ),
120
+ dsl.IfPresentPlaceholder(
121
+ input_name="explanation",
122
+ then=[
123
+ "--explanation",
124
+ explanation.metadata["explanation_gcs_path"],
125
+ ],
126
+ ),
127
+ dsl.IfPresentPlaceholder(
128
+ input_name="classification_metrics",
129
+ then=[
130
+ "--classification_metrics",
131
+ classification_metrics.uri,
132
+ ],
133
+ ),
134
+ dsl.IfPresentPlaceholder(
135
+ input_name="forecasting_metrics",
136
+ then=[
137
+ "--forecasting_metrics",
138
+ forecasting_metrics.uri,
139
+ ],
140
+ ),
141
+ dsl.IfPresentPlaceholder(
142
+ input_name="regression_metrics",
143
+ then=[
144
+ "--regression_metrics",
145
+ regression_metrics.uri,
146
+ ],
147
+ ),
148
+ dsl.IfPresentPlaceholder(
149
+ input_name="text_generation_metrics",
150
+ then=[
151
+ "--text_generation_metrics",
152
+ text_generation_metrics.uri,
153
+ ],
154
+ ),
155
+ dsl.IfPresentPlaceholder(
156
+ input_name="question_answering_metrics",
157
+ then=[
158
+ "--question_answering_metrics",
159
+ question_answering_metrics.uri,
160
+ ],
161
+ ),
162
+ dsl.IfPresentPlaceholder(
163
+ input_name="summarization_metrics",
164
+ then=[
165
+ "--summarization_metrics",
166
+ summarization_metrics.uri,
167
+ ],
168
+ ),
169
+ dsl.IfPresentPlaceholder(
170
+ input_name="feature_attributions",
171
+ then=[
172
+ "--feature_attributions",
173
+ feature_attributions.uri,
174
+ ],
175
+ ),
176
+ dsl.IfPresentPlaceholder(
177
+ input_name="embedding_metrics",
178
+ then=[
179
+ "--embedding_metrics",
180
+ embedding_metrics.uri,
181
+ ],
182
+ ),
183
+ dsl.IfPresentPlaceholder(
184
+ input_name="problem_type",
185
+ then=[
186
+ "--problem_type",
187
+ problem_type,
188
+ ],
189
+ ),
190
+ "--display_name",
191
+ display_name,
192
+ "--dataset_path",
193
+ dataset_path,
194
+ "--dataset_paths",
195
+ dataset_paths,
196
+ "--dataset_type",
197
+ dataset_type,
198
+ "--pipeline_job_id",
199
+ dsl.PIPELINE_JOB_ID_PLACEHOLDER,
200
+ "--pipeline_job_resource_name",
201
+ dsl.PIPELINE_JOB_RESOURCE_NAME_PLACEHOLDER,
202
+ "--model_name",
203
+ model.metadata["resourceName"],
204
+ "--gcp_resources",
205
+ gcp_resources,
206
+ "--evaluation_resource_name",
207
+ evaluation_resource_name,
208
+ ],
209
+ )