Skip to content

Commit a129ece

Browse files
authored
Merge branch 'master' into f/sm-local-selinux
2 parents ba4fc0f + a3eab05 commit a129ece

File tree

117 files changed

+11993
-2002
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+11993
-2002
lines changed

CHANGELOG.md

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

3+
## v2.154.0 (2023-05-11)
4+
5+
### Features
6+
7+
* Add integ tests for remote_function, auto_capture functionality
8+
* jumpstart model estimator classes
9+
10+
### Bug Fixes and Other Changes
11+
12+
* integs - pytorch transformer deps and add test retry
13+
* adding .lower() so new Pandas dtypes will match the type lookup.
14+
* Pass KMS value to create processing job
15+
16+
## v2.153.0 (2023-05-09)
17+
18+
### Features
19+
20+
* Support npz archives in NumpyDeserializer
21+
* Add FasterTransformer DJL support
22+
* support for Sample Weights for SageMaker Autopilot
23+
24+
### Bug Fixes and Other Changes
25+
26+
* retry is_run assertion
27+
* Avoid 'AttributeError' for endpoint_name, if deploy() is not yet called
28+
* Fix LambdaStep Creation
29+
* Fix error when instance_count>1 in remote_function
30+
* Remove deprecated update_endpoint from deploy() args in TensorFlowModel
31+
* Update DJL deepspeed and fastertransformer DLC image uris
32+
* remote_function python version mismatch issue
33+
34+
## v2.152.0 (2023-05-04)
35+
36+
### Features
37+
38+
* add support for lineage visualization using pyvis
39+
* Expose Experiment class publicly
40+
* PyTorch 1.13 release
41+
42+
### Bug Fixes and Other Changes
43+
44+
* Change data_type argument to dtype to keep consistent with D…
45+
* Skip edge test
46+
* make RemoteExecutor context manager non-blocking on pending futures
47+
* Add inferentia2 DLC images for djl framework
48+
* Fix typo in using_pytorch.rst
49+
* Unable to attach estimator to training job when KeepAlivePeriodInSeconds specified
50+
* update LMI container image
51+
* Update Clarify SHAPConfig baseline to allow JSON structures
52+
53+
### Documentation Changes
54+
55+
* Fix broken link in DJL SageMaker docs
56+
* currency update for the SageMaker data parallelism lib
57+
* SM model parallel library v1.15.0 release note
58+
359
## v2.151.0 (2023-04-27)
460

561
### Features

VERSION

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

doc/frameworks/djl/sagemaker.djl_inference.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ HuggingFaceAccelerateModel
2626
:undoc-members:
2727
:show-inheritance:
2828

29+
FasterTransformerModel
30+
---------------------------
31+
32+
.. autoclass:: sagemaker.djl_inference.model.FasterTransformerModel
33+
:members:
34+
:undoc-members:
35+
:show-inheritance:
36+
2937
DJLPredictor
3038
---------------------------
3139

doc/frameworks/djl/using_djl.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ With the SageMaker Python SDK, you can use DJL Serving to host models that have
2323
These can either be models you have trained/fine-tuned yourself, or models available publicly from the HuggingFace Hub.
2424
DJL Serving in the SageMaker Python SDK supports hosting models for the popular HuggingFace NLP tasks, as well as Stable Diffusion.
2525

26-
You can either deploy your model using DeepSpeed or HuggingFace Accelerate, or let DJL Serving determine the best backend based on your model architecture and configuration.
26+
You can either deploy your model using DeepSpeed, FasterTransformer, or HuggingFace Accelerate, or let DJL Serving determine the best backend based on your model architecture and configuration.
2727

2828
.. code:: python
2929
@@ -63,11 +63,23 @@ If you want to use a specific backend, then you can create an instance of the co
6363
number_of_partitions=2, # number of gpus to partition the model across
6464
)
6565
66+
# Create a model using the FasterTransformer backend
67+
68+
fastertransformer_model = FasterTransformerModel(
69+
"s3://my_bucket/my_saved_model_artifacts/", # This can also be a HuggingFace Hub model id
70+
"my_sagemaker_role",
71+
data_type="fp16",
72+
task="text-generation",
73+
tensor_parallel_degree=2, # number of gpus to partition the model across
74+
)
75+
6676
# Deploy the model to an Amazon SageMaker Endpoint and get a Predictor
6777
deepspeed_predictor = deepspeed_model.deploy("ml.g5.12xlarge",
6878
initial_instance_count=1)
6979
hf_accelerate_predictor = hf_accelerate_model.deploy("ml.g5.12xlarge",
7080
initial_instance_count=1)
81+
fastertransformer_predictor = fastertransformer_model.deploy("ml.g5.12xlarge",
82+
initial_instance_count=1)
7183
7284
Regardless of which way you choose to create your model, a ``Predictor`` object is returned. You can use this ``Predictor``
7385
to do inference on the endpoint hosting your DJLModel.

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>=20.3.0,<23",
51-
"boto3>=1.26.28,<2.0",
51+
"boto3>=1.26.131,<2.0",
5252
"cloudpickle==2.2.1",
5353
"google-pasta",
5454
"numpy>=1.9.0,<2.0",

src/sagemaker/accept_types.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
"""This module is for SageMaker accept types."""
14+
from __future__ import absolute_import
15+
from typing import List, Optional
16+
17+
from sagemaker.jumpstart import artifacts, utils as jumpstart_utils
18+
19+
20+
def retrieve_options(
21+
region: Optional[str] = None,
22+
model_id: Optional[str] = None,
23+
model_version: Optional[str] = None,
24+
tolerate_vulnerable_model: bool = False,
25+
tolerate_deprecated_model: bool = False,
26+
) -> List[str]:
27+
"""Retrieves the supported accept types for the model matching the given arguments.
28+
29+
Args:
30+
region (str): The AWS Region for which to retrieve the supported accept types.
31+
Defaults to ``None``.
32+
model_id (str): The model ID of the model for which to
33+
retrieve the supported accept types. (Default: None).
34+
model_version (str): The version of the model for which to retrieve the
35+
supported accept types. (Default: None).
36+
tolerate_vulnerable_model (bool): True if vulnerable versions of model
37+
specifications should be tolerated (exception not raised). If False, raises an
38+
exception if the script used by this version of the model has dependencies with known
39+
security vulnerabilities. (Default: False).
40+
tolerate_deprecated_model (bool): True if deprecated models should be tolerated
41+
(exception not raised). False if these models should raise an exception.
42+
(Default: False).
43+
Returns:
44+
list: The supported accept types to use for the model.
45+
46+
Raises:
47+
ValueError: If the combination of arguments specified is not supported.
48+
"""
49+
if not jumpstart_utils.is_jumpstart_model_input(model_id, model_version):
50+
raise ValueError(
51+
"Must specify JumpStart `model_id` and `model_version` when retrieving accept types."
52+
)
53+
54+
return artifacts._retrieve_supported_accept_types(
55+
model_id,
56+
model_version,
57+
region,
58+
tolerate_vulnerable_model,
59+
tolerate_deprecated_model,
60+
)
61+
62+
63+
def retrieve_default(
64+
region: Optional[str] = None,
65+
model_id: Optional[str] = None,
66+
model_version: Optional[str] = None,
67+
tolerate_vulnerable_model: bool = False,
68+
tolerate_deprecated_model: bool = False,
69+
) -> str:
70+
"""Retrieves the default accept type for the model matching the given arguments.
71+
72+
Args:
73+
region (str): The AWS Region for which to retrieve the default accept type.
74+
Defaults to ``None``.
75+
model_id (str): The model ID of the model for which to
76+
retrieve the default accept type. (Default: None).
77+
model_version (str): The version of the model for which to retrieve the
78+
default accept type. (Default: None).
79+
tolerate_vulnerable_model (bool): True if vulnerable versions of model
80+
specifications should be tolerated (exception not raised). If False, raises an
81+
exception if the script used by this version of the model has dependencies with known
82+
security vulnerabilities. (Default: False).
83+
tolerate_deprecated_model (bool): True if deprecated models should be tolerated
84+
(exception not raised). False if these models should raise an exception.
85+
(Default: False).
86+
Returns:
87+
str: The default accept type to use for the model.
88+
89+
Raises:
90+
ValueError: If the combination of arguments specified is not supported.
91+
"""
92+
if not jumpstart_utils.is_jumpstart_model_input(model_id, model_version):
93+
raise ValueError(
94+
"Must specify JumpStart `model_id` and `model_version` when retrieving accept types."
95+
)
96+
97+
return artifacts._retrieve_default_accept_type(
98+
model_id,
99+
model_version,
100+
region,
101+
tolerate_vulnerable_model,
102+
tolerate_deprecated_model,
103+
)

src/sagemaker/automl/automl.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def __init__(
4949
channel_type=None,
5050
content_type=None,
5151
s3_data_type=None,
52+
sample_weight_attribute_name=None,
5253
):
5354
"""Convert an S3 Uri or a list of S3 Uri to an AutoMLInput object.
5455
@@ -67,13 +68,16 @@ def __init__(
6768
The content type of the data from the input source.
6869
s3_data_type (str, PipelineVariable): The data type for S3 data source.
6970
Valid values: ManifestFile or S3Prefix.
71+
sample_weight_attribute_name (str, PipelineVariable):
72+
the name of the dataset column representing sample weights
7073
"""
7174
self.inputs = inputs
7275
self.target_attribute_name = target_attribute_name
7376
self.compression = compression
7477
self.channel_type = channel_type
7578
self.content_type = content_type
7679
self.s3_data_type = s3_data_type
80+
self.sample_weight_attribute_name = sample_weight_attribute_name
7781

7882
def to_request_dict(self):
7983
"""Generates a request dictionary using the parameters provided to the class."""
@@ -96,6 +100,8 @@ def to_request_dict(self):
96100
input_entry["ContentType"] = self.content_type
97101
if self.s3_data_type is not None:
98102
input_entry["DataSource"]["S3DataSource"]["S3DataType"] = self.s3_data_type
103+
if self.sample_weight_attribute_name is not None:
104+
input_entry["SampleWeightAttributeName"] = self.sample_weight_attribute_name
99105
auto_ml_input.append(input_entry)
100106
return auto_ml_input
101107

@@ -129,6 +135,7 @@ def __init__(
129135
mode: Optional[str] = None,
130136
auto_generate_endpoint_name: Optional[bool] = None,
131137
endpoint_name: Optional[str] = None,
138+
sample_weight_attribute_name: str = None,
132139
):
133140
"""Initialize the an AutoML object.
134141
@@ -179,6 +186,8 @@ def __init__(
179186
model deployment if the endpoint name is not generated automatically.
180187
Specify the endpoint_name if and only if
181188
auto_generate_endpoint_name is set to False
189+
sample_weight_attribute_name (str): The name of dataset column representing
190+
sample weights.
182191
183192
Returns:
184193
AutoML object.
@@ -234,6 +243,7 @@ def __init__(
234243
)
235244

236245
self._check_problem_type_and_job_objective(self.problem_type, self.job_objective)
246+
self.sample_weight_attribute_name = sample_weight_attribute_name
237247

238248
@runnable_by_pipeline
239249
def fit(self, inputs=None, wait=True, logs=True, job_name=None):
@@ -342,6 +352,9 @@ def attach(cls, auto_ml_job_name, sagemaker_session=None):
342352
"AutoGenerateEndpointName", False
343353
),
344354
endpoint_name=auto_ml_job_desc.get("ModelDeployConfig", {}).get("EndpointName"),
355+
sample_weight_attribute_name=auto_ml_job_desc["InputDataConfig"][0].get(
356+
"SampleWeightAttributeName", None
357+
),
345358
)
346359
amlj.current_job_name = auto_ml_job_name
347360
amlj.latest_auto_ml_job = auto_ml_job_name # pylint: disable=W0201
@@ -867,6 +880,7 @@ def _load_config(cls, inputs, auto_ml, expand_role=True, validate_uri=True):
867880
auto_ml.target_attribute_name,
868881
auto_ml.content_type,
869882
auto_ml.s3_data_type,
883+
auto_ml.sample_weight_attribute_name,
870884
)
871885
output_config = _Job._prepare_output_config(auto_ml.output_path, auto_ml.output_kms_key)
872886

@@ -932,6 +946,7 @@ def _format_inputs_to_input_config(
932946
target_attribute_name=None,
933947
content_type=None,
934948
s3_data_type=None,
949+
sample_weight_attribute_name=None,
935950
):
936951
"""Convert inputs to AutoML InputDataConfig.
937952
@@ -961,6 +976,8 @@ def _format_inputs_to_input_config(
961976
channel["ContentType"] = content_type
962977
if s3_data_type is not None:
963978
channel["DataSource"]["S3DataSource"]["S3DataType"] = s3_data_type
979+
if sample_weight_attribute_name is not None:
980+
channel["SampleWeightAttributeName"] = sample_weight_attribute_name
964981
channels.append(channel)
965982
elif isinstance(inputs, list):
966983
for input_entry in inputs:
@@ -974,6 +991,8 @@ def _format_inputs_to_input_config(
974991
channel["ContentType"] = content_type
975992
if s3_data_type is not None:
976993
channel["DataSource"]["S3DataSource"]["S3DataType"] = s3_data_type
994+
if sample_weight_attribute_name is not None:
995+
channel["SampleWeightAttributeName"] = sample_weight_attribute_name
977996
channels.append(channel)
978997
else:
979998
msg = (

0 commit comments

Comments
 (0)