Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix:invalid component error with new metadata #4634

Merged
merged 7 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/sagemaker/jumpstart/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions src/sagemaker/jumpstart/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions tests/integ/sagemaker/jumpstart/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "4.*" # model artifacts retrieved from jumpstart-private-cache-* buckets

estimator = JumpStartEstimator(
model_id=model_id,
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/sagemaker/jumpstart/estimator/test_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
)

Expand Down Expand Up @@ -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,
},
)

Expand Down
8 changes: 8 additions & 0 deletions tests/unit/sagemaker/jumpstart/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 be ignored
}
specs1 = JumpStartModelSpecs(spec)


def test_set_inference_configs():
spec = {**BASE_SPEC, **INFERENCE_CONFIGS, **INFERENCE_CONFIG_RANKINGS}
Expand Down