From 0f3c8edc77728a188a45d88718d2a8f25b30d7ae Mon Sep 17 00:00:00 2001 From: Haotian An Date: Mon, 29 Apr 2024 20:24:00 +0000 Subject: [PATCH 1/6] fix: invalid component name --- src/sagemaker/jumpstart/types.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/sagemaker/jumpstart/types.py b/src/sagemaker/jumpstart/types.py index dae879494e..05c38da266 100644 --- a/src/sagemaker/jumpstart/types.py +++ b/src/sagemaker/jumpstart/types.py @@ -1064,9 +1064,8 @@ def from_json(self, json_obj: Dict[str, Any]) -> None: Dictionary representation of the config component. """ for field in json_obj.keys(): - if field not in self.__slots__: - raise ValueError(f"Invalid component field: {field}") - setattr(self, field, json_obj[field]) + if field in self.__slots__: + setattr(self, field, json_obj[field]) class JumpStartMetadataConfig(JumpStartDataHolderType): From 7d04be8f161c0154e3df4a6a1c6a9ea5074d881a Mon Sep 17 00:00:00 2001 From: Haotian An Date: Mon, 29 Apr 2024 20:27:47 +0000 Subject: [PATCH 2/6] tests --- tests/unit/sagemaker/jumpstart/test_types.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/unit/sagemaker/jumpstart/test_types.py b/tests/unit/sagemaker/jumpstart/test_types.py index 5ca01c3c52..8e0d6bac44 100644 --- a/tests/unit/sagemaker/jumpstart/test_types.py +++ b/tests/unit/sagemaker/jumpstart/test_types.py @@ -1052,6 +1052,14 @@ def test_inference_configs_parsing(): ) assert list(config.config_components.keys()) == ["neuron-inference"] + spec = { + **BASE_SPEC, + **INFERENCE_CONFIGS, + **INFERENCE_CONFIG_RANKINGS, + "unrecognized-field": "blah", # New fields in base metadata fields should not break + } + specs1 = JumpStartModelSpecs(spec) + def test_set_inference_configs(): spec = {**BASE_SPEC, **INFERENCE_CONFIGS, **INFERENCE_CONFIG_RANKINGS} From a2c9b9b58d9de793378e099bcf825bfdca290e89 Mon Sep 17 00:00:00 2001 From: Haotian An Date: Tue, 30 Apr 2024 15:04:32 +0000 Subject: [PATCH 3/6] format --- tests/unit/sagemaker/jumpstart/test_types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/sagemaker/jumpstart/test_types.py b/tests/unit/sagemaker/jumpstart/test_types.py index 8e0d6bac44..b2758c73ef 100644 --- a/tests/unit/sagemaker/jumpstart/test_types.py +++ b/tests/unit/sagemaker/jumpstart/test_types.py @@ -1056,7 +1056,7 @@ def test_inference_configs_parsing(): **BASE_SPEC, **INFERENCE_CONFIGS, **INFERENCE_CONFIG_RANKINGS, - "unrecognized-field": "blah", # New fields in base metadata fields should not break + "unrecognized-field": "blah", # New fields in base metadata fields should be ignored } specs1 = JumpStartModelSpecs(spec) From fbd25d1abb75aebc38abf409c8e4e11429380d25 Mon Sep 17 00:00:00 2001 From: Haotian An Date: Tue, 30 Apr 2024 19:02:06 +0000 Subject: [PATCH 4/6] fix vulnerable model integ tests llama 2 --- src/sagemaker/jumpstart/estimator.py | 7 ++++++- .../jumpstart/estimator/test_jumpstart_estimator.py | 3 ++- tests/unit/sagemaker/jumpstart/estimator/test_estimator.py | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/sagemaker/jumpstart/estimator.py b/src/sagemaker/jumpstart/estimator.py index bade834cc6..f53d109dc8 100644 --- a/src/sagemaker/jumpstart/estimator.py +++ b/src/sagemaker/jumpstart/estimator.py @@ -734,7 +734,12 @@ def attach( model_version = model_version or "*" - additional_kwargs = {"model_id": model_id, "model_version": model_version} + additional_kwargs = { + "model_id": model_id, + "model_version": model_version, + "tolerate_vulnerable_model": True, # model is already trained + "tolerate_deprecated_model": True, # model is already trained + } model_specs = verify_model_region_and_return_specs( model_id=model_id, diff --git a/tests/integ/sagemaker/jumpstart/estimator/test_jumpstart_estimator.py b/tests/integ/sagemaker/jumpstart/estimator/test_jumpstart_estimator.py index a839a293c5..033e5dc53b 100644 --- a/tests/integ/sagemaker/jumpstart/estimator/test_jumpstart_estimator.py +++ b/tests/integ/sagemaker/jumpstart/estimator/test_jumpstart_estimator.py @@ -140,7 +140,7 @@ def test_gated_model_training_v1(setup): def test_gated_model_training_v2(setup): model_id = "meta-textgeneration-llama-2-7b" - model_version = "3.*" # model artifacts retrieved from jumpstart-private-cache-* buckets + model_version = "*" # model artifacts retrieved from jumpstart-private-cache-* buckets estimator = JumpStartEstimator( model_id=model_id, @@ -150,6 +150,7 @@ def test_gated_model_training_v2(setup): tags=[{"Key": JUMPSTART_TAG, "Value": os.environ[ENV_VAR_JUMPSTART_SDK_TEST_SUITE_ID]}], environment={"accept_eula": "true"}, max_run=259200, # avoid exceeding resource limits + tolerate_vulnerable_model=True, # tolerate old version of model ) # uses ml.g5.12xlarge instance diff --git a/tests/unit/sagemaker/jumpstart/estimator/test_estimator.py b/tests/unit/sagemaker/jumpstart/estimator/test_estimator.py index ce5f15b287..36d8b11fab 100644 --- a/tests/unit/sagemaker/jumpstart/estimator/test_estimator.py +++ b/tests/unit/sagemaker/jumpstart/estimator/test_estimator.py @@ -1010,6 +1010,8 @@ def test_jumpstart_estimator_attach_eula_model( "model_id": "gemma-model", "model_version": "*", "environment": {"accept_eula": "true"}, + "tolerate_vulnerable_model": True, + "tolerate_deprecated_model": True, }, ) @@ -1053,6 +1055,8 @@ def test_jumpstart_estimator_attach_no_model_id_happy_case( additional_kwargs={ "model_id": "js-trainable-model-prepacked", "model_version": "1.0.0", + "tolerate_vulnerable_model": True, + "tolerate_deprecated_model": True, }, ) From b7b180ee8cc24bb0bafd3a886ffcb81e6ccf8d6e Mon Sep 17 00:00:00 2001 From: Haotian An Date: Tue, 30 Apr 2024 19:03:09 +0000 Subject: [PATCH 5/6] updated --- .../sagemaker/jumpstart/estimator/test_jumpstart_estimator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integ/sagemaker/jumpstart/estimator/test_jumpstart_estimator.py b/tests/integ/sagemaker/jumpstart/estimator/test_jumpstart_estimator.py index 033e5dc53b..0da64ecf05 100644 --- a/tests/integ/sagemaker/jumpstart/estimator/test_jumpstart_estimator.py +++ b/tests/integ/sagemaker/jumpstart/estimator/test_jumpstart_estimator.py @@ -140,7 +140,7 @@ def test_gated_model_training_v1(setup): def test_gated_model_training_v2(setup): model_id = "meta-textgeneration-llama-2-7b" - model_version = "*" # model artifacts retrieved from jumpstart-private-cache-* buckets + model_version = "4.*" # model artifacts retrieved from jumpstart-private-cache-* buckets estimator = JumpStartEstimator( model_id=model_id, From 3d5ba91086e1d91da83b3f6fab0931507e8cb6cb Mon Sep 17 00:00:00 2001 From: Haotian An Date: Tue, 30 Apr 2024 19:58:55 +0000 Subject: [PATCH 6/6] fix: training dataset location --- tests/integ/sagemaker/jumpstart/constants.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integ/sagemaker/jumpstart/constants.py b/tests/integ/sagemaker/jumpstart/constants.py index f5ffbf7a3a..b839866b1f 100644 --- a/tests/integ/sagemaker/jumpstart/constants.py +++ b/tests/integ/sagemaker/jumpstart/constants.py @@ -48,6 +48,7 @@ def _to_s3_path(filename: str, s3_prefix: Optional[str]) -> str: ("meta-textgeneration-llama-2-7b", "*"): ("training-datasets/sec_amazon/"), ("meta-textgeneration-llama-2-7b", "2.*"): ("training-datasets/sec_amazon/"), ("meta-textgeneration-llama-2-7b", "3.*"): ("training-datasets/sec_amazon/"), + ("meta-textgeneration-llama-2-7b", "4.*"): ("training-datasets/sec_amazon/"), ("meta-textgenerationneuron-llama-2-7b", "*"): ("training-datasets/sec_amazon/"), }