Skip to content

Commit 4acc5b1

Browse files
Merge branch 'master' into master
2 parents 87db488 + ef8dd31 commit 4acc5b1

File tree

35 files changed

+1661
-120
lines changed

35 files changed

+1661
-120
lines changed

CHANGELOG.md

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

3+
## v2.198.0 (2023-11-27)
4+
5+
### Features
6+
7+
* re:Invent 2023 keynote1
8+
39
## v2.197.0 (2023-11-07)
410

511
### Features

VERSION

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

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def read_requirements(filename):
4848
# Declare minimal set for installation
4949
required_packages = [
5050
"attrs>=23.1.0,<24",
51-
"boto3>=1.26.131,<2.0",
51+
"boto3>=1.29.6,<2.0",
5252
"cloudpickle==2.2.1",
5353
"google-pasta",
5454
"numpy>=1.9.0,<2.0",

src/sagemaker/image_uri_config/djl-deepspeed.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
11
{
22
"scope": ["inference"],
33
"versions": {
4+
"0.25.0": {
5+
"registries": {
6+
"af-south-1": "626614931356",
7+
"il-central-1": "780543022126",
8+
"ap-east-1": "871362719292",
9+
"ap-northeast-1": "763104351884",
10+
"ap-northeast-2": "763104351884",
11+
"ap-northeast-3": "364406365360",
12+
"ap-south-1": "763104351884",
13+
"ap-southeast-1": "763104351884",
14+
"ap-southeast-2": "763104351884",
15+
"ap-southeast-3": "907027046896",
16+
"ca-central-1": "763104351884",
17+
"cn-north-1": "727897471807",
18+
"cn-northwest-1": "727897471807",
19+
"eu-central-1": "763104351884",
20+
"eu-north-1": "763104351884",
21+
"eu-west-1": "763104351884",
22+
"eu-west-2": "763104351884",
23+
"eu-west-3": "763104351884",
24+
"eu-south-1": "692866216735",
25+
"me-south-1": "217643126080",
26+
"sa-east-1": "763104351884",
27+
"us-east-1": "763104351884",
28+
"us-east-2": "763104351884",
29+
"us-west-1": "763104351884",
30+
"us-west-2": "763104351884"
31+
},
32+
"repository": "djl-inference",
33+
"tag_prefix": "0.25.0-deepspeed0.11.0-cu118"
34+
},
435
"0.24.0": {
536
"registries": {
637
"af-south-1": "626614931356",

src/sagemaker/image_uri_config/djl-neuronx.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
11
{
22
"scope": ["inference"],
33
"versions": {
4+
"0.25.0": {
5+
"registries": {
6+
"af-south-1": "626614931356",
7+
"il-central-1": "780543022126",
8+
"ap-east-1": "871362719292",
9+
"ap-northeast-1": "763104351884",
10+
"ap-northeast-2": "763104351884",
11+
"ap-northeast-3": "364406365360",
12+
"ap-south-1": "763104351884",
13+
"ap-southeast-1": "763104351884",
14+
"ap-southeast-2": "763104351884",
15+
"ap-southeast-3": "907027046896",
16+
"ca-central-1": "763104351884",
17+
"cn-north-1": "727897471807",
18+
"cn-northwest-1": "727897471807",
19+
"eu-central-1": "763104351884",
20+
"eu-north-1": "763104351884",
21+
"eu-west-1": "763104351884",
22+
"eu-west-2": "763104351884",
23+
"eu-west-3": "763104351884",
24+
"eu-south-1": "692866216735",
25+
"me-south-1": "217643126080",
26+
"sa-east-1": "763104351884",
27+
"us-east-1": "763104351884",
28+
"us-east-2": "763104351884",
29+
"us-west-1": "763104351884",
30+
"us-west-2": "763104351884"
31+
},
32+
"repository": "djl-inference",
33+
"tag_prefix": "0.25.0-neuronx-sdk2.15.0"
34+
},
435
"0.24.0": {
536
"registries": {
637
"af-south-1": "626614931356",
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"scope": ["inference"],
3+
"versions": {
4+
"0.25.0": {
5+
"registries": {
6+
"af-south-1": "626614931356",
7+
"il-central-1": "780543022126",
8+
"ap-east-1": "871362719292",
9+
"ap-northeast-1": "763104351884",
10+
"ap-northeast-2": "763104351884",
11+
"ap-northeast-3": "364406365360",
12+
"ap-south-1": "763104351884",
13+
"ap-southeast-1": "763104351884",
14+
"ap-southeast-2": "763104351884",
15+
"ap-southeast-3": "907027046896",
16+
"ca-central-1": "763104351884",
17+
"cn-north-1": "727897471807",
18+
"cn-northwest-1": "727897471807",
19+
"eu-central-1": "763104351884",
20+
"eu-north-1": "763104351884",
21+
"eu-west-1": "763104351884",
22+
"eu-west-2": "763104351884",
23+
"eu-west-3": "763104351884",
24+
"eu-south-1": "692866216735",
25+
"me-south-1": "217643126080",
26+
"sa-east-1": "763104351884",
27+
"us-east-1": "763104351884",
28+
"us-east-2": "763104351884",
29+
"us-west-1": "763104351884",
30+
"us-west-2": "763104351884"
31+
},
32+
"repository": "djl-inference",
33+
"tag_prefix": "0.25.0-tensorrtllm0.5.0-cu122"
34+
}
35+
}
36+
}

src/sagemaker/jumpstart/artifacts/environment_variables.py

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
from sagemaker.jumpstart.constants import (
1717
DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
1818
JUMPSTART_DEFAULT_REGION_NAME,
19+
SAGEMAKER_GATED_MODEL_S3_URI_TRAINING_ENV_VAR_KEY,
1920
)
2021
from sagemaker.jumpstart.enums import (
2122
JumpStartScriptScope,
2223
)
2324
from sagemaker.jumpstart.utils import (
25+
get_jumpstart_gated_content_bucket,
2426
verify_model_region_and_return_specs,
2527
)
2628
from sagemaker.session import Session
@@ -102,10 +104,89 @@ def _retrieve_default_environment_variables(
102104
elif script == JumpStartScriptScope.TRAINING and getattr(
103105
model_specs, "training_instance_type_variants", None
104106
):
105-
default_environment_variables.update(
106-
model_specs.training_instance_type_variants.get_instance_specific_environment_variables( # noqa E501 # pylint: disable=c0301
107-
instance_type
108-
)
107+
instance_specific_environment_variables = model_specs.training_instance_type_variants.get_instance_specific_environment_variables( # noqa E501 # pylint: disable=c0301
108+
instance_type
109109
)
110110

111+
default_environment_variables.update(instance_specific_environment_variables)
112+
113+
gated_model_env_var: Optional[str] = _retrieve_gated_model_uri_env_var_value(
114+
model_id=model_id,
115+
model_version=model_version,
116+
region=region,
117+
tolerate_vulnerable_model=tolerate_vulnerable_model,
118+
tolerate_deprecated_model=tolerate_deprecated_model,
119+
sagemaker_session=sagemaker_session,
120+
instance_type=instance_type,
121+
)
122+
123+
if gated_model_env_var is not None:
124+
default_environment_variables.update(
125+
{SAGEMAKER_GATED_MODEL_S3_URI_TRAINING_ENV_VAR_KEY: gated_model_env_var}
126+
)
127+
111128
return default_environment_variables
129+
130+
131+
def _retrieve_gated_model_uri_env_var_value(
132+
model_id: str,
133+
model_version: str,
134+
region: Optional[str] = None,
135+
tolerate_vulnerable_model: bool = False,
136+
tolerate_deprecated_model: bool = False,
137+
sagemaker_session: Session = DEFAULT_JUMPSTART_SAGEMAKER_SESSION,
138+
instance_type: Optional[str] = None,
139+
) -> Optional[str]:
140+
"""Retrieves the gated model env var URI matching the given arguments.
141+
142+
Args:
143+
model_id (str): JumpStart model ID of the JumpStart model for which to
144+
retrieve the gated model env var URI.
145+
model_version (str): Version of the JumpStart model for which to retrieve the
146+
gated model env var URI.
147+
region (Optional[str]): Region for which to retrieve the gated model env var URI.
148+
(Default: None).
149+
tolerate_vulnerable_model (bool): True if vulnerable versions of model
150+
specifications should be tolerated (exception not raised). If False, raises an
151+
exception if the script used by this version of the model has dependencies with known
152+
security vulnerabilities. (Default: False).
153+
tolerate_deprecated_model (bool): True if deprecated versions of model
154+
specifications should be tolerated (exception not raised). If False, raises
155+
an exception if the version of the model is deprecated. (Default: False).
156+
sagemaker_session (sagemaker.session.Session): A SageMaker Session
157+
object, used for SageMaker interactions. If not
158+
specified, one is created using the default AWS configuration
159+
chain. (Default: sagemaker.jumpstart.constants.DEFAULT_JUMPSTART_SAGEMAKER_SESSION).
160+
instance_type (str): An instance type to optionally supply in order to get
161+
environment variables specific for the instance type.
162+
163+
Returns:
164+
Optional[str]: the s3 URI to use for the environment variable, or None if the model does not
165+
have gated training artifacts.
166+
167+
Raises:
168+
ValueError: If the model specs specified are invalid.
169+
"""
170+
171+
if region is None:
172+
region = JUMPSTART_DEFAULT_REGION_NAME
173+
174+
model_specs = verify_model_region_and_return_specs(
175+
model_id=model_id,
176+
version=model_version,
177+
scope=JumpStartScriptScope.TRAINING,
178+
region=region,
179+
tolerate_vulnerable_model=tolerate_vulnerable_model,
180+
tolerate_deprecated_model=tolerate_deprecated_model,
181+
sagemaker_session=sagemaker_session,
182+
)
183+
184+
s3_key: Optional[
185+
str
186+
] = model_specs.training_instance_type_variants.get_instance_specific_gated_model_key_env_var_value( # noqa E501 # pylint: disable=c0301
187+
instance_type
188+
)
189+
if s3_key is None:
190+
return None
191+
192+
return f"s3://{get_jumpstart_gated_content_bucket(region)}/{s3_key}"

src/sagemaker/jumpstart/cache.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
ENV_VARIABLE_JUMPSTART_SPECS_LOCAL_ROOT_DIR_OVERRIDE,
2727
JUMPSTART_DEFAULT_MANIFEST_FILE_S3_KEY,
2828
JUMPSTART_DEFAULT_REGION_NAME,
29+
JUMPSTART_LOGGER,
2930
MODEL_ID_LIST_WEB_URL,
3031
)
32+
from sagemaker.jumpstart.exceptions import get_wildcard_model_version_msg
3133
from sagemaker.jumpstart.parameters import (
3234
JUMPSTART_DEFAULT_MAX_S3_CACHE_ITEMS,
3335
JUMPSTART_DEFAULT_MAX_SEMANTIC_VERSION_CACHE_ITEMS,
@@ -172,7 +174,7 @@ def _get_manifest_key_from_model_id_semantic_version(
172174

173175
manifest = self._s3_cache.get(
174176
JumpStartCachedS3ContentKey(JumpStartS3FileType.MANIFEST, self._manifest_file_s3_key)
175-
).formatted_content
177+
)[0].formatted_content
176178

177179
sm_version = utils.get_sagemaker_version()
178180

@@ -330,7 +332,7 @@ def _retrieval_function(
330332
if file_type == JumpStartS3FileType.SPECS:
331333
formatted_body, _ = self._get_json_file(s3_key, file_type)
332334
model_specs = JumpStartModelSpecs(formatted_body)
333-
utils.emit_logs_based_on_model_specs(model_specs, self.get_region())
335+
utils.emit_logs_based_on_model_specs(model_specs, self.get_region(), self._s3_client)
334336
return JumpStartCachedS3ContentValue(
335337
formatted_content=model_specs
336338
)
@@ -343,7 +345,7 @@ def get_manifest(self) -> List[JumpStartModelHeader]:
343345

344346
manifest_dict = self._s3_cache.get(
345347
JumpStartCachedS3ContentKey(JumpStartS3FileType.MANIFEST, self._manifest_file_s3_key)
346-
).formatted_content
348+
)[0].formatted_content
347349
manifest = list(manifest_dict.values()) # type: ignore
348350
return manifest
349351

@@ -403,10 +405,11 @@ def _get_header_impl(
403405

404406
versioned_model_id = self._model_id_semantic_version_manifest_key_cache.get(
405407
JumpStartVersionedModelId(model_id, semantic_version_str)
406-
)
408+
)[0]
409+
407410
manifest = self._s3_cache.get(
408411
JumpStartCachedS3ContentKey(JumpStartS3FileType.MANIFEST, self._manifest_file_s3_key)
409-
).formatted_content
412+
)[0].formatted_content
410413
try:
411414
header = manifest[versioned_model_id] # type: ignore
412415
return header
@@ -427,10 +430,18 @@ def get_specs(self, model_id: str, semantic_version_str: str) -> JumpStartModelS
427430

428431
header = self.get_header(model_id, semantic_version_str)
429432
spec_key = header.spec_key
430-
specs = self._s3_cache.get(
433+
specs, cache_hit = self._s3_cache.get(
431434
JumpStartCachedS3ContentKey(JumpStartS3FileType.SPECS, spec_key)
432-
).formatted_content
433-
return specs # type: ignore
435+
)
436+
if not cache_hit and "*" in semantic_version_str:
437+
JUMPSTART_LOGGER.warning(
438+
get_wildcard_model_version_msg(
439+
header.model_id,
440+
semantic_version_str,
441+
header.version
442+
)
443+
)
444+
return specs.formatted_content
434445

435446
def clear(self) -> None:
436447
"""Clears the model ID/version and s3 cache."""

src/sagemaker/jumpstart/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
SUPPORTED_JUMPSTART_SCOPES = set(scope.value for scope in JumpStartScriptScope)
169169

170170
ENV_VARIABLE_JUMPSTART_CONTENT_BUCKET_OVERRIDE = "AWS_JUMPSTART_CONTENT_BUCKET_OVERRIDE"
171+
ENV_VARIABLE_JUMPSTART_GATED_CONTENT_BUCKET_OVERRIDE = "AWS_JUMPSTART_GATED_CONTENT_BUCKET_OVERRIDE"
171172
ENV_VARIABLE_JUMPSTART_MODEL_ARTIFACT_BUCKET_OVERRIDE = "AWS_JUMPSTART_MODEL_BUCKET_OVERRIDE"
172173
ENV_VARIABLE_JUMPSTART_SCRIPT_ARTIFACT_BUCKET_OVERRIDE = "AWS_JUMPSTART_SCRIPT_BUCKET_OVERRIDE"
173174
ENV_VARIABLE_JUMPSTART_MANIFEST_LOCAL_ROOT_DIR_OVERRIDE = (

src/sagemaker/jumpstart/exceptions.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,35 @@
3030
)
3131

3232

33+
_MAJOR_VERSION_WARNING_MSG = (
34+
"Note that models may have different input/output signatures after a major version upgrade."
35+
)
36+
37+
38+
def get_wildcard_model_version_msg(
39+
model_id: str, wildcard_model_version: str, full_model_version: str
40+
) -> str:
41+
"""Returns customer-facing message for using a model version with a wildcard character."""
42+
43+
return (
44+
f"Using model '{model_id}' with wildcard version identifier '{wildcard_model_version}'. "
45+
f"You can pin to version '{full_model_version}' "
46+
f"for more stable results. {_MAJOR_VERSION_WARNING_MSG}"
47+
)
48+
49+
50+
def get_old_model_version_msg(
51+
model_id: str, current_model_version: str, latest_model_version: str
52+
) -> str:
53+
"""Returns customer-facing message associated with using an old model version."""
54+
55+
return (
56+
f"Using model '{model_id}' with version '{current_model_version}'. "
57+
f"You can upgrade to version '{latest_model_version}' to get the latest model "
58+
f"specifications. {_MAJOR_VERSION_WARNING_MSG}"
59+
)
60+
61+
3362
class JumpStartHyperparametersError(ValueError):
3463
"""Exception raised for bad hyperparameters of a JumpStart model."""
3564

0 commit comments

Comments
 (0)