Skip to content

Commit 470703d

Browse files
Merge branch 'master' into master
2 parents 2ac737d + 58bdbd0 commit 470703d

File tree

20 files changed

+302
-149
lines changed

20 files changed

+302
-149
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## v2.226.1 (2024-07-17)
4+
5+
## v2.226.0 (2024-07-12)
6+
7+
### Features
8+
9+
* Curated hub improvements
10+
* InferenceSpec support for MMS and testing
11+
12+
### Bug Fixes and Other Changes
13+
14+
* ModelBuilder not passing HF_TOKEN to model.
15+
* update image_uri_configs 07-10-2024 07:18:04 PST
16+
317
## v2.225.0 (2024-07-10)
418

519
### Features

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.225.1.dev0
1+
2.226.2.dev0

src/sagemaker/estimator.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
from sagemaker.interactive_apps import SupportedInteractiveAppTypes
6969
from sagemaker.interactive_apps.tensorboard import TensorBoardApp
7070
from sagemaker.instance_group import InstanceGroup
71+
from sagemaker.model_card.model_card import ModelCard, TrainingDetails
7172
from sagemaker.utils import instance_supports_kms
7273
from sagemaker.job import _Job
7374
from sagemaker.jumpstart.utils import (
@@ -1797,8 +1798,17 @@ def register(
17971798
else:
17981799
if "model_kms_key" not in kwargs:
17991800
kwargs["model_kms_key"] = self.output_kms_key
1800-
model = self.create_model(image_uri=image_uri, **kwargs)
1801+
model = self.create_model(image_uri=image_uri, name=model_name, **kwargs)
18011802
model.name = model_name
1803+
if self.model_data is not None and model_card is None:
1804+
training_details = TrainingDetails.from_model_s3_artifacts(
1805+
model_artifacts=[self.model_data], sagemaker_session=self.sagemaker_session
1806+
)
1807+
model_card = ModelCard(
1808+
name="estimator_card",
1809+
training_details=training_details,
1810+
sagemaker_session=self.sagemaker_session,
1811+
)
18021812
return model.register(
18031813
content_types,
18041814
response_types,

src/sagemaker/image_uri_config/huggingface-llm.json

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"1.2": "1.2.0",
1313
"1.3": "1.3.3",
1414
"1.4": "1.4.5",
15-
"2.0": "2.0.2"
15+
"2.0": "2.2.0"
1616
},
1717
"versions": {
1818
"0.6.0": {
@@ -672,6 +672,53 @@
672672
"container_version": {
673673
"gpu": "cu121-ubuntu22.04"
674674
}
675+
},
676+
"2.2.0": {
677+
"py_versions": [
678+
"py310"
679+
],
680+
"registries": {
681+
"af-south-1": "626614931356",
682+
"il-central-1": "780543022126",
683+
"ap-east-1": "871362719292",
684+
"ap-northeast-1": "763104351884",
685+
"ap-northeast-2": "763104351884",
686+
"ap-northeast-3": "364406365360",
687+
"ap-south-1": "763104351884",
688+
"ap-south-2": "772153158452",
689+
"ap-southeast-1": "763104351884",
690+
"ap-southeast-2": "763104351884",
691+
"ap-southeast-3": "907027046896",
692+
"ap-southeast-4": "457447274322",
693+
"ca-central-1": "763104351884",
694+
"cn-north-1": "727897471807",
695+
"cn-northwest-1": "727897471807",
696+
"eu-central-1": "763104351884",
697+
"eu-central-2": "380420809688",
698+
"eu-north-1": "763104351884",
699+
"eu-west-1": "763104351884",
700+
"eu-west-2": "763104351884",
701+
"eu-west-3": "763104351884",
702+
"eu-south-1": "692866216735",
703+
"eu-south-2": "503227376785",
704+
"me-south-1": "217643126080",
705+
"me-central-1": "914824155844",
706+
"sa-east-1": "763104351884",
707+
"us-east-1": "763104351884",
708+
"us-east-2": "763104351884",
709+
"us-gov-east-1": "446045086412",
710+
"us-gov-west-1": "442386744353",
711+
"us-iso-east-1": "886529160074",
712+
"us-isob-east-1": "094389454867",
713+
"us-west-1": "763104351884",
714+
"us-west-2": "763104351884",
715+
"ca-west-1": "204538143572"
716+
},
717+
"tag_prefix": "2.3.0-tgi2.2.0",
718+
"repository": "huggingface-pytorch-tgi-inference",
719+
"container_version": {
720+
"gpu": "cu121-ubuntu22.04-v2.0"
721+
}
675722
}
676723
}
677724
}

src/sagemaker/image_uri_config/pytorch.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,7 @@
10081008
"us-gov-west-1": "442386744353",
10091009
"us-iso-east-1": "886529160074",
10101010
"us-isob-east-1": "094389454867",
1011+
"us-isof-south-1": "454834333376",
10111012
"us-west-1": "763104351884",
10121013
"us-west-2": "763104351884"
10131014
},
@@ -1051,6 +1052,7 @@
10511052
"us-gov-west-1": "442386744353",
10521053
"us-iso-east-1": "886529160074",
10531054
"us-isob-east-1": "094389454867",
1055+
"us-isof-south-1": "454834333376",
10541056
"us-west-1": "763104351884",
10551057
"us-west-2": "763104351884"
10561058
},
@@ -2329,6 +2331,7 @@
23292331
"us-gov-west-1": "442386744353",
23302332
"us-iso-east-1": "886529160074",
23312333
"us-isob-east-1": "094389454867",
2334+
"us-isof-south-1": "454834333376",
23322335
"us-west-1": "763104351884",
23332336
"us-west-2": "763104351884"
23342337
},
@@ -2372,6 +2375,7 @@
23722375
"us-gov-west-1": "442386744353",
23732376
"us-iso-east-1": "886529160074",
23742377
"us-isob-east-1": "094389454867",
2378+
"us-isof-south-1": "454834333376",
23752379
"us-west-1": "763104351884",
23762380
"us-west-2": "763104351884"
23772381
},
@@ -2415,6 +2419,7 @@
24152419
"us-gov-west-1": "442386744353",
24162420
"us-iso-east-1": "886529160074",
24172421
"us-isob-east-1": "094389454867",
2422+
"us-isof-south-1": "454834333376",
24182423
"us-west-1": "763104351884",
24192424
"us-west-2": "763104351884"
24202425
},

src/sagemaker/image_uri_config/tensorflow.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,7 @@
21402140
"us-gov-west-1": "442386744353",
21412141
"us-iso-east-1": "886529160074",
21422142
"us-isob-east-1": "094389454867",
2143+
"us-isof-south-1": "454834333376",
21432144
"us-west-1": "763104351884",
21442145
"us-west-2": "763104351884"
21452146
},
@@ -2180,6 +2181,7 @@
21802181
"us-gov-west-1": "442386744353",
21812182
"us-iso-east-1": "886529160074",
21822183
"us-isob-east-1": "094389454867",
2184+
"us-isof-south-1": "454834333376",
21832185
"us-west-1": "763104351884",
21842186
"us-west-2": "763104351884"
21852187
},
@@ -4352,6 +4354,7 @@
43524354
"us-gov-west-1": "442386744353",
43534355
"us-iso-east-1": "886529160074",
43544356
"us-isob-east-1": "094389454867",
4357+
"us-isof-south-1": "454834333376",
43554358
"us-west-1": "763104351884",
43564359
"us-west-2": "763104351884"
43574360
},
@@ -4395,6 +4398,7 @@
43954398
"us-gov-west-1": "442386744353",
43964399
"us-iso-east-1": "886529160074",
43974400
"us-isob-east-1": "094389454867",
4401+
"us-isof-south-1": "454834333376",
43984402
"us-west-1": "763104351884",
43994403
"us-west-2": "763104351884"
44004404
},

src/sagemaker/jumpstart/hub/hub.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def list_sagemaker_public_hub_models(
233233
f"arn:{info.partition}:"
234234
f"sagemaker:{info.region}:"
235235
f"aws:hub-content/{info.hub_name}/"
236-
f"{HubContentType.MODEL}/{model[0]}"
236+
f"{HubContentType.MODEL.value}/{model[0]}"
237237
)
238238
hub_content_summary = {
239239
"hub_content_name": model[0],

src/sagemaker/model.py

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,10 @@ def register(
549549
model_package_group_name = utils.base_name_from_image(
550550
self.image_uri, default_base_name=ModelPackage.__name__
551551
)
552-
if model_package_group_name is not None:
552+
if (
553+
model_package_group_name is not None
554+
and model_type is not JumpStartModelType.PROPRIETARY
555+
):
553556
container_def = self.prepare_container_def(accept_eula=accept_eula)
554557
container_def = update_container_with_inference_params(
555558
framework=framework,
@@ -2466,32 +2469,55 @@ def update_model_card(self, model_card: Union[ModelCard, ModelPackageModelCard])
24662469
desc_model_package = sagemaker_session.sagemaker_client.describe_model_package(
24672470
ModelPackageName=self.model_package_arn
24682471
)
2472+
if hasattr(model_card, "model_package_details"):
2473+
model_card.model_package_details = None
24692474
update_model_card_req = model_card._create_request_args()
2470-
if update_model_card_req["ModelCardStatus"] is not None:
2471-
if (
2472-
desc_model_package["ModelCard"]["ModelCardStatus"]
2473-
== update_model_card_req["ModelCardStatus"]
2474-
):
2475-
del update_model_card_req["ModelCardStatus"]
2476-
24772475
if update_model_card_req.get("ModelCardName") is not None:
24782476
del update_model_card_req["ModelCardName"]
2479-
if update_model_card_req.get("Content") is not None:
2480-
previous_content_hash = _hash_content_str(
2481-
desc_model_package["ModelCard"]["ModelCardContent"]
2482-
)
2483-
current_content_hash = _hash_content_str(update_model_card_req["Content"])
2484-
if (
2485-
previous_content_hash == current_content_hash
2486-
or update_model_card_req.get("Content") == "{}"
2487-
or update_model_card_req.get("Content") == "null"
2488-
):
2489-
del update_model_card_req["Content"]
2490-
else:
2491-
update_model_card_req["ModelCardContent"] = update_model_card_req["Content"]
2492-
del update_model_card_req["Content"]
2493-
update_model_package_args = {
2494-
"ModelPackageArn": self.model_package_arn,
2495-
"ModelCard": update_model_card_req,
2496-
}
2497-
sagemaker_session.sagemaker_client.update_model_package(**update_model_package_args)
2477+
if update_model_card_req["Content"] is not None:
2478+
if "model_package_details" in update_model_card_req["Content"]:
2479+
update_model_card_req["Content"].pop("model_package_details", None)
2480+
update_model_card_req["ModelCardContent"] = update_model_card_req["Content"]
2481+
del update_model_card_req["Content"]
2482+
2483+
if "ModelCard" in desc_model_package:
2484+
if update_model_card_req["ModelCardStatus"] is not None:
2485+
if (
2486+
desc_model_package["ModelCard"]["ModelCardStatus"]
2487+
!= update_model_card_req["ModelCardStatus"]
2488+
):
2489+
new_mc_mp_req = update_model_card_req
2490+
del new_mc_mp_req["ModelCardContent"]
2491+
update_model_package_args = {
2492+
"ModelPackageArn": self.model_package_arn,
2493+
"ModelCard": new_mc_mp_req,
2494+
}
2495+
sagemaker_session.sagemaker_client.update_model_package(
2496+
**update_model_package_args
2497+
)
2498+
2499+
if update_model_card_req.get("ModelCardContent") is not None:
2500+
previous_content_hash = _hash_content_str(
2501+
desc_model_package["ModelCard"]["ModelCardContent"]
2502+
)
2503+
current_content_hash = _hash_content_str(update_model_card_req["ModelCardContent"])
2504+
if not (
2505+
previous_content_hash == current_content_hash
2506+
or update_model_card_req.get("ModelCardContent") == "{}"
2507+
or update_model_card_req.get("ModelCardContent") == "null"
2508+
):
2509+
new_mc_mp_req = update_model_card_req
2510+
del new_mc_mp_req["ModelCardStatus"]
2511+
update_model_package_args = {
2512+
"ModelPackageArn": self.model_package_arn,
2513+
"ModelCard": new_mc_mp_req,
2514+
}
2515+
sagemaker_session.sagemaker_client.update_model_package(
2516+
**update_model_package_args
2517+
)
2518+
else:
2519+
update_model_package_args = {
2520+
"ModelPackageArn": self.model_package_arn,
2521+
"ModelCard": update_model_card_req,
2522+
}
2523+
sagemaker_session.sagemaker_client.update_model_package(**update_model_package_args)

src/sagemaker/model_card/helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,12 @@ def _read_s3_json(session: Session, bucket: str, key: str):
503503
raise
504504

505505
result = {}
506-
if data["ContentType"] == "application/json" or data["ContentType"] == "binary/octet-stream":
506+
content_types = ["application/json", "binary/octet-stream", "application/octet-stream"]
507+
if data["ContentType"] in content_types:
507508
result = json.loads(data["Body"].read().decode("utf-8"))
508509
else:
509510
logger.warning(
510-
"Invalid file type %s. application/json or binary/octet-stream is expected.",
511-
data["ContentType"],
511+
"Invalid file type %s. %s is expected.", data["ContentType"], ", ".join(content_types)
512512
)
513513

514514
return result

src/sagemaker/serve/builder/jumpstart_builder.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,6 @@ def _optimize_for_jumpstart(
669669
self,
670670
output_path: Optional[str] = None,
671671
instance_type: Optional[str] = None,
672-
role_arn: Optional[str] = None,
673672
tags: Optional[Tags] = None,
674673
job_name: Optional[str] = None,
675674
accept_eula: Optional[bool] = None,
@@ -685,9 +684,7 @@ def _optimize_for_jumpstart(
685684
686685
Args:
687686
output_path (Optional[str]): Specifies where to store the compiled/quantized model.
688-
instance_type (Optional[str]): Target deployment instance type that
689-
the model is optimized for.
690-
role_arn (Optional[str]): Execution role. Defaults to ``None``.
687+
instance_type (str): Target deployment instance type that the model is optimized for.
691688
tags (Optional[Tags]): Tags for labeling a model optimization job. Defaults to ``None``.
692689
job_name (Optional[str]): The name of the model optimization job. Defaults to ``None``.
693690
accept_eula (bool): For models that require a Model Access Config, specify True or
@@ -715,7 +712,7 @@ def _optimize_for_jumpstart(
715712
f"Model '{self.model}' requires accepting end-user license agreement (EULA)."
716713
)
717714

718-
is_compilation = (quantization_config is None) and (
715+
is_compilation = (not quantization_config) and (
719716
(compilation_config is not None) or _is_inferentia_or_trainium(instance_type)
720717
)
721718

@@ -758,7 +755,6 @@ def _optimize_for_jumpstart(
758755
else None
759756
)
760757
self.instance_type = instance_type or deployment_config_instance_type or _get_nb_instance()
761-
self.role_arn = role_arn or self.role_arn
762758

763759
create_optimization_job_args = {
764760
"OptimizationJobName": job_name,
@@ -787,10 +783,10 @@ def _optimize_for_jumpstart(
787783
"AcceptEula": True
788784
}
789785

786+
optimization_env_vars = _update_environment_variables(optimization_env_vars, override_env)
787+
if optimization_env_vars:
788+
self.pysdk_model.env.update(optimization_env_vars)
790789
if quantization_config or is_compilation:
791-
self.pysdk_model.env = _update_environment_variables(
792-
optimization_env_vars, override_env
793-
)
794790
return create_optimization_job_args
795791
return None
796792

0 commit comments

Comments
 (0)