Skip to content

Commit 7680368

Browse files
authored
Merge branch 'aws:master' into master
2 parents 5f2bcea + a4ef985 commit 7680368

File tree

11 files changed

+367
-65
lines changed

11 files changed

+367
-65
lines changed

src/sagemaker/image_uri_config/huggingface-llm-neuronx.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,35 @@
6464
"container_version": {
6565
"inf2": "ubuntu22.04"
6666
}
67+
},
68+
"0.0.18": {
69+
"py_versions": [
70+
"py310"
71+
],
72+
"registries": {
73+
"ap-northeast-1": "763104351884",
74+
"ap-south-1": "763104351884",
75+
"ap-south-2": "772153158452",
76+
"ap-southeast-1": "763104351884",
77+
"ap-southeast-2": "763104351884",
78+
"ap-southeast-4": "457447274322",
79+
"eu-central-1": "763104351884",
80+
"eu-central-2": "380420809688",
81+
"eu-south-2": "503227376785",
82+
"eu-west-1": "763104351884",
83+
"eu-west-3": "763104351884",
84+
"il-central-1": "780543022126",
85+
"sa-east-1": "763104351884",
86+
"us-east-1": "763104351884",
87+
"us-east-2": "763104351884",
88+
"us-west-2": "763104351884",
89+
"ca-west-1": "204538143572"
90+
},
91+
"tag_prefix": "1.13.1-optimum0.0.18",
92+
"repository": "huggingface-pytorch-tgi-inference",
93+
"container_version": {
94+
"inf2": "ubuntu22.04"
95+
}
6796
}
6897
}
6998
}

src/sagemaker/image_uri_config/huggingface-llm.json

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"1.1": "1.1.0",
1212
"1.2": "1.2.0",
1313
"1.3": "1.3.3",
14-
"1.4": "1.4.0"
14+
"1.4": "1.4.2"
1515
},
1616
"versions": {
1717
"0.6.0": {
@@ -436,6 +436,53 @@
436436
"container_version": {
437437
"gpu": "cu121-ubuntu20.04"
438438
}
439+
},
440+
"1.4.2": {
441+
"py_versions": [
442+
"py310"
443+
],
444+
"registries": {
445+
"af-south-1": "626614931356",
446+
"il-central-1": "780543022126",
447+
"ap-east-1": "871362719292",
448+
"ap-northeast-1": "763104351884",
449+
"ap-northeast-2": "763104351884",
450+
"ap-northeast-3": "364406365360",
451+
"ap-south-1": "763104351884",
452+
"ap-south-2": "772153158452",
453+
"ap-southeast-1": "763104351884",
454+
"ap-southeast-2": "763104351884",
455+
"ap-southeast-3": "907027046896",
456+
"ap-southeast-4": "457447274322",
457+
"ca-central-1": "763104351884",
458+
"cn-north-1": "727897471807",
459+
"cn-northwest-1": "727897471807",
460+
"eu-central-1": "763104351884",
461+
"eu-central-2": "380420809688",
462+
"eu-north-1": "763104351884",
463+
"eu-west-1": "763104351884",
464+
"eu-west-2": "763104351884",
465+
"eu-west-3": "763104351884",
466+
"eu-south-1": "692866216735",
467+
"eu-south-2": "503227376785",
468+
"me-south-1": "217643126080",
469+
"me-central-1": "914824155844",
470+
"sa-east-1": "763104351884",
471+
"us-east-1": "763104351884",
472+
"us-east-2": "763104351884",
473+
"us-gov-east-1": "446045086412",
474+
"us-gov-west-1": "442386744353",
475+
"us-iso-east-1": "886529160074",
476+
"us-isob-east-1": "094389454867",
477+
"us-west-1": "763104351884",
478+
"us-west-2": "763104351884",
479+
"ca-west-1": "204538143572"
480+
},
481+
"tag_prefix": "2.1.1-tgi1.4.2",
482+
"repository": "huggingface-pytorch-tgi-inference",
483+
"container_version": {
484+
"gpu": "cu121-ubuntu22.04"
485+
}
439486
}
440487
}
441488
}

src/sagemaker/image_uri_config/huggingface-neuronx.json

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"trn"
55
],
66
"version_aliases": {
7-
"4.28": "4.28.1"
7+
"4.28": "4.28.1",
8+
"4.34": "4.34.1"
89
},
910
"versions": {
1011
"4.28.1": {
@@ -86,7 +87,9 @@
8687
"inf"
8788
],
8889
"version_aliases": {
89-
"4.28": "4.28.1"
90+
"4.28": "4.28.1",
91+
"4.34": "4.34.1",
92+
"4.36": "4.36.2"
9093
},
9194
"versions": {
9295
"4.28.1": {
@@ -192,6 +195,58 @@
192195
"sdk2.15.0"
193196
]
194197
}
198+
},
199+
"4.36.2": {
200+
"version_aliases": {
201+
"pytorch1.13": "pytorch1.13.1"
202+
},
203+
"pytorch1.13.1": {
204+
"py_versions": [
205+
"py310"
206+
],
207+
"repository": "huggingface-pytorch-inference-neuronx",
208+
"registries": {
209+
"af-south-1": "626614931356",
210+
"il-central-1": "780543022126",
211+
"ap-east-1": "871362719292",
212+
"ap-northeast-1": "763104351884",
213+
"ap-northeast-2": "763104351884",
214+
"ap-northeast-3": "364406365360",
215+
"ap-south-1": "763104351884",
216+
"ap-south-2": "772153158452",
217+
"ap-southeast-1": "763104351884",
218+
"ap-southeast-2": "763104351884",
219+
"ap-southeast-4": "457447274322",
220+
"ca-central-1": "763104351884",
221+
"cn-north-1": "727897471807",
222+
"cn-northwest-1": "727897471807",
223+
"eu-central-1": "763104351884",
224+
"eu-central-2": "380420809688",
225+
"eu-north-1": "763104351884",
226+
"eu-west-1": "763104351884",
227+
"eu-west-2": "763104351884",
228+
"eu-west-3": "763104351884",
229+
"eu-south-1": "692866216735",
230+
"eu-south-2": "503227376785",
231+
"me-south-1": "217643126080",
232+
"sa-east-1": "763104351884",
233+
"us-east-1": "763104351884",
234+
"us-east-2": "763104351884",
235+
"us-gov-east-1": "446045086412",
236+
"us-gov-west-1": "442386744353",
237+
"us-iso-east-1": "886529160074",
238+
"us-isob-east-1": "094389454867",
239+
"us-west-1": "763104351884",
240+
"us-west-2": "763104351884",
241+
"ca-west-1": "204538143572"
242+
},
243+
"container_version": {
244+
"inf": "ubuntu20.04"
245+
},
246+
"sdk_versions": [
247+
"sdk2.16.1"
248+
]
249+
}
195250
}
196251
}
197252
}

src/sagemaker/image_uri_config/pytorch.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,6 +1958,7 @@
19581958
"ap-northeast-2": "763104351884",
19591959
"ap-northeast-3": "364406365360",
19601960
"ap-south-1": "763104351884",
1961+
"ap-south-2": "772153158452",
19611962
"ap-southeast-1": "763104351884",
19621963
"ap-southeast-2": "763104351884",
19631964
"ap-southeast-3": "907027046896",
@@ -1966,11 +1967,13 @@
19661967
"cn-north-1": "727897471807",
19671968
"cn-northwest-1": "727897471807",
19681969
"eu-central-1": "763104351884",
1970+
"eu-central-2": "380420809688",
19691971
"eu-north-1": "763104351884",
19701972
"eu-west-1": "763104351884",
19711973
"eu-west-2": "763104351884",
19721974
"eu-west-3": "763104351884",
19731975
"eu-south-1": "692866216735",
1976+
"eu-south-2": "503227376785",
19741977
"me-south-1": "217643126080",
19751978
"sa-east-1": "763104351884",
19761979
"us-east-1": "763104351884",
@@ -1997,6 +2000,7 @@
19972000
"ap-northeast-2": "763104351884",
19982001
"ap-northeast-3": "364406365360",
19992002
"ap-south-1": "763104351884",
2003+
"ap-south-2": "772153158452",
20002004
"ap-southeast-1": "763104351884",
20012005
"ap-southeast-2": "763104351884",
20022006
"ap-southeast-3": "907027046896",
@@ -2005,11 +2009,13 @@
20052009
"cn-north-1": "727897471807",
20062010
"cn-northwest-1": "727897471807",
20072011
"eu-central-1": "763104351884",
2012+
"eu-central-2": "380420809688",
20082013
"eu-north-1": "763104351884",
20092014
"eu-west-1": "763104351884",
20102015
"eu-west-2": "763104351884",
20112016
"eu-west-3": "763104351884",
20122017
"eu-south-1": "692866216735",
2018+
"eu-south-2": "503227376785",
20132019
"me-south-1": "217643126080",
20142020
"sa-east-1": "763104351884",
20152021
"us-east-1": "763104351884",
@@ -2036,6 +2042,7 @@
20362042
"ap-northeast-2": "763104351884",
20372043
"ap-northeast-3": "364406365360",
20382044
"ap-south-1": "763104351884",
2045+
"ap-south-2": "772153158452",
20392046
"ap-southeast-1": "763104351884",
20402047
"ap-southeast-2": "763104351884",
20412048
"ap-southeast-3": "907027046896",
@@ -2044,11 +2051,13 @@
20442051
"cn-north-1": "727897471807",
20452052
"cn-northwest-1": "727897471807",
20462053
"eu-central-1": "763104351884",
2054+
"eu-central-2": "380420809688",
20472055
"eu-north-1": "763104351884",
20482056
"eu-west-1": "763104351884",
20492057
"eu-west-2": "763104351884",
20502058
"eu-west-3": "763104351884",
20512059
"eu-south-1": "692866216735",
2060+
"eu-south-2": "503227376785",
20522061
"me-south-1": "217643126080",
20532062
"sa-east-1": "763104351884",
20542063
"us-east-1": "763104351884",
@@ -2075,6 +2084,7 @@
20752084
"ap-northeast-2": "763104351884",
20762085
"ap-northeast-3": "364406365360",
20772086
"ap-south-1": "763104351884",
2087+
"ap-south-2": "772153158452",
20782088
"ap-southeast-1": "763104351884",
20792089
"ap-southeast-2": "763104351884",
20802090
"ap-southeast-3": "907027046896",
@@ -2083,11 +2093,13 @@
20832093
"cn-north-1": "727897471807",
20842094
"cn-northwest-1": "727897471807",
20852095
"eu-central-1": "763104351884",
2096+
"eu-central-2": "380420809688",
20862097
"eu-north-1": "763104351884",
20872098
"eu-west-1": "763104351884",
20882099
"eu-west-2": "763104351884",
20892100
"eu-west-3": "763104351884",
20902101
"eu-south-1": "692866216735",
2102+
"eu-south-2": "503227376785",
20912103
"me-south-1": "217643126080",
20922104
"sa-east-1": "763104351884",
20932105
"us-east-1": "763104351884",

src/sagemaker/user_agent.py

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,18 @@
1515

1616
import platform
1717
import sys
18+
import json
19+
import os
1820

1921
import importlib_metadata
2022

23+
SDK_PREFIX = "AWS-SageMaker-Python-SDK"
24+
STUDIO_PREFIX = "AWS-SageMaker-Studio"
25+
NOTEBOOK_PREFIX = "AWS-SageMaker-Notebook-Instance"
26+
27+
NOTEBOOK_METADATA_FILE = "/etc/opt/ml/sagemaker-notebook-instance-version.txt"
28+
STUDIO_METADATA_FILE = "/opt/ml/metadata/resource-metadata.json"
29+
2130
SDK_VERSION = importlib_metadata.version("sagemaker")
2231
OS_NAME = platform.system() or "UnresolvedOS"
2332
OS_VERSION = platform.release() or "UnresolvedOSVersion"
@@ -27,30 +36,69 @@
2736
)
2837

2938

39+
def process_notebook_metadata_file():
40+
"""Check if the platform is SageMaker Notebook, if yes, return the InstanceType
41+
42+
Returns:
43+
str: The InstanceType of the SageMaker Notebook if it exists, otherwise None
44+
"""
45+
if os.path.exists(NOTEBOOK_METADATA_FILE):
46+
with open(NOTEBOOK_METADATA_FILE, "r") as sagemaker_nbi_file:
47+
return sagemaker_nbi_file.read().strip()
48+
49+
return None
50+
51+
52+
def process_studio_metadata_file():
53+
"""Check if the platform is SageMaker Studio, if yes, return the AppType
54+
55+
Returns:
56+
str: The AppType of the SageMaker Studio if it exists, otherwise None
57+
"""
58+
if os.path.exists(STUDIO_METADATA_FILE):
59+
with open(STUDIO_METADATA_FILE, "r") as sagemaker_studio_file:
60+
metadata = json.load(sagemaker_studio_file)
61+
return metadata.get("AppType")
62+
63+
return None
64+
65+
3066
def determine_prefix(user_agent=""):
31-
"""Placeholder docstring"""
32-
prefix = "AWS-SageMaker-Python-SDK/{}".format(SDK_VERSION)
67+
"""Determines the prefix for the user agent string.
68+
69+
Args:
70+
user_agent (str): The user agent string to prepend the prefix to.
71+
72+
Returns:
73+
str: The user agent string with the prefix prepended.
74+
"""
75+
prefix = "{}/{}".format(SDK_PREFIX, SDK_VERSION)
3376

3477
if PYTHON_VERSION not in user_agent:
3578
prefix = "{} {}".format(prefix, PYTHON_VERSION)
3679

3780
if OS_NAME_VERSION not in user_agent:
3881
prefix = "{} {}".format(prefix, OS_NAME_VERSION)
3982

40-
try:
41-
with open("/etc/opt/ml/sagemaker-notebook-instance-version.txt") as sagemaker_nbi_file:
42-
prefix = "{} AWS-SageMaker-Notebook-Instance/{}".format(
43-
prefix, sagemaker_nbi_file.read().strip()
44-
)
45-
except IOError:
46-
# This file isn't expected to always exist, and we DO want to silently ignore failures.
47-
pass
83+
# Get the notebook instance type and prepend it to the user agent string if exists
84+
notebook_instance_type = process_notebook_metadata_file()
85+
if notebook_instance_type:
86+
prefix = "{} {}/{}".format(prefix, NOTEBOOK_PREFIX, notebook_instance_type)
87+
88+
# Get the studio app type and prepend it to the user agent string if exists
89+
studio_app_type = process_studio_metadata_file()
90+
if studio_app_type:
91+
prefix = "{} {}/{}".format(prefix, STUDIO_PREFIX, studio_app_type)
4892

4993
return prefix
5094

5195

5296
def prepend_user_agent(client):
53-
"""Placeholder docstring"""
97+
"""Prepends the user agent string with the SageMaker Python SDK version.
98+
99+
Args:
100+
client (botocore.client.BaseClient): The client to prepend the user agent string for.
101+
"""
54102
prefix = determine_prefix(client._client_config.user_agent)
55103

56104
if client._client_config.user_agent is None:

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def huggingface_neuron_latest_inference_transformer_version():
441441

442442
@pytest.fixture(scope="module")
443443
def huggingface_neuronx_latest_inference_transformer_version():
444-
return "4.34.1"
444+
return "4.36.2"
445445

446446

447447
@pytest.fixture(scope="module")

tests/integ/sagemaker/jumpstart/estimator/test_jumpstart_estimator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def test_gated_model_training_v1(setup):
108108
tags=[{"Key": JUMPSTART_TAG, "Value": os.environ[ENV_VAR_JUMPSTART_SDK_TEST_SUITE_ID]}],
109109
environment={"accept_eula": "true"},
110110
max_run=259200, # avoid exceeding resource limits
111+
tolerate_vulnerable_model=True,
111112
)
112113

113114
# uses ml.g5.12xlarge instance

tests/unit/sagemaker/image_uris/test_huggingface_llm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@
2929
"1.3.1": "2.1.1-tgi1.3.1-gpu-py310-cu121-ubuntu20.04",
3030
"1.3.3": "2.1.1-tgi1.3.3-gpu-py310-cu121-ubuntu20.04",
3131
"1.4.0": "2.1.1-tgi1.4.0-gpu-py310-cu121-ubuntu20.04",
32+
"1.4.2": "2.1.1-tgi1.4.2-gpu-py310-cu121-ubuntu22.04",
3233
},
3334
"inf2": {
3435
"0.0.16": "1.13.1-optimum0.0.16-neuronx-py310-ubuntu22.04",
3536
"0.0.17": "1.13.1-optimum0.0.17-neuronx-py310-ubuntu22.04",
37+
"0.0.18": "1.13.1-optimum0.0.18-neuronx-py310-ubuntu22.04",
3638
},
3739
}
3840

0 commit comments

Comments
 (0)