Skip to content

Commit b87e02f

Browse files
committed
Merge branch 'master' into govcloud
2 parents e9b71a7 + aceb8e0 commit b87e02f

21 files changed

+190
-37
lines changed

CHANGELOG.md

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

3+
## v1.51.0 (2020-03-09)
4+
5+
### Features
6+
7+
* pytorch 1.3.1 eia support
8+
9+
### Documentation Changes
10+
11+
* Update Kubernetes Operator default tag
12+
* improve docstring for tuner.best_estimator()
13+
314
## v1.50.18.post0 (2020-03-05)
415

516
### Documentation Changes

README.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ TensorFlow SageMaker Estimators
176176

177177
By using TensorFlow SageMaker Estimators, you can train and host TensorFlow models on Amazon SageMaker.
178178

179-
Supported versions of TensorFlow: ``1.4.1``, ``1.5.0``, ``1.6.0``, ``1.7.0``, ``1.8.0``, ``1.9.0``, ``1.10.0``, ``1.11.0``, ``1.12.0``, ``1.13.1``, ``1.14.0``, ``1.15.0``, ``2.0.0``.
179+
Supported versions of TensorFlow: ``1.4.1``, ``1.5.0``, ``1.6.0``, ``1.7.0``, ``1.8.0``, ``1.9.0``, ``1.10.0``, ``1.11.0``, ``1.12.0``, ``1.13.1``, ``1.14.0``, ``1.15.0``, ``1.15.2``, ``2.0.0``, ``2.0.1``, ``2.1.0``.
180180

181181
Supported versions of TensorFlow for Elastic Inference: ``1.11.0``, ``1.12.0``, ``1.13.1``, ``1.14.0``.
182182

@@ -208,7 +208,9 @@ PyTorch SageMaker Estimators
208208

209209
With PyTorch SageMaker Estimators, you can train and host PyTorch models on Amazon SageMaker.
210210

211-
Supported versions of PyTorch: ``0.4.0``, ``1.0.0``, ``1.1.0``, ``1.2.0``, ``1.3.1``.
211+
Supported versions of PyTorch: ``0.4.0``, ``1.0.0``, ``1.1.0``, ``1.2.0``, ``1.3.1``, ``1.4.0``.
212+
213+
Supported versions of PyTorch for Elastic Inference: ``1.3.1``.
212214

213215
We recommend that you use the latest supported version, because that's where we focus most of our development efforts.
214216

VERSION

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

doc/amazon_sagemaker_operators_for_kubernetes.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ that directory to your \ ``PATH``.
349349

350350
export os="linux"
351351

352-
wget https://amazon-sagemaker-operator-for-k8s-us-east-1.s3.amazonaws.com/kubectl-smlogs-plugin/latest/${os}.amd64.tar.gz
352+
wget https://amazon-sagemaker-operator-for-k8s-us-east-1.s3.amazonaws.com/kubectl-smlogs-plugin/v1/${os}.amd64.tar.gz
353353
tar xvzf ${os}.amd64.tar.gz
354354

355355
# Move binaries to a directory in your homedir.
@@ -550,11 +550,11 @@ each region.
550550
+-------------+---------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
551551
| Region | Controller Image | Linux SMLogs |
552552
+=============+=============================================================================================+========================================================================================================================+
553-
| us-east-1 | ``957583890962.dkr.ecr.us-east-1.amazonaws.com/amazon-sagemaker-operator-for-k8s:latest`` | https://amazon-sagemaker-operator-for-k8s-us-east-1.s3.amazonaws.com/kubectl-smlogs-plugin/latest/linux.amd64.tar.gz |
553+
| us-east-1 | ``957583890962.dkr.ecr.us-east-1.amazonaws.com/amazon-sagemaker-operator-for-k8s:v1`` | https://amazon-sagemaker-operator-for-k8s-us-east-1.s3.amazonaws.com/kubectl-smlogs-plugin/v1/linux.amd64.tar.gz |
554554
+-------------+---------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
555-
| us-east-2 | ``922499468684.dkr.ecr.us-east-2.amazonaws.com/amazon-sagemaker-operator-for-k8s:latest`` | https://amazon-sagemaker-operator-for-k8s-us-east-2.s3.amazonaws.com/kubectl-smlogs-plugin/latest/linux.amd64.tar.gz |
555+
| us-east-2 | ``922499468684.dkr.ecr.us-east-2.amazonaws.com/amazon-sagemaker-operator-for-k8s:v1`` | https://amazon-sagemaker-operator-for-k8s-us-east-2.s3.amazonaws.com/kubectl-smlogs-plugin/v1/linux.amd64.tar.gz |
556556
+-------------+---------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
557-
| us-west-2 | ``640106867763.dkr.ecr.us-west-2.amazonaws.com/amazon-sagemaker-operator-for-k8s:latest`` | https://amazon-sagemaker-operator-for-k8s-us-west-2.s3.amazonaws.com/kubectl-smlogs-plugin/latest/linux.amd64.tar.gz |
557+
| us-west-2 | ``640106867763.dkr.ecr.us-west-2.amazonaws.com/amazon-sagemaker-operator-for-k8s:v1`` | https://amazon-sagemaker-operator-for-k8s-us-west-2.s3.amazonaws.com/kubectl-smlogs-plugin/v1/linux.amd64.tar.gz |
558558
+-------------+---------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+
559-
| eu-west-1 | ``613661167059.dkr.ecr.eu-west-1.amazonaws.com/amazon-sagemaker-operator-for-k8s:latest`` | https://amazon-sagemaker-operator-for-k8s-eu-west-1.s3.amazonaws.com/kubectl-smlogs-plugin/latest/linux.amd64.tar.gz |
559+
| eu-west-1 | ``613661167059.dkr.ecr.eu-west-1.amazonaws.com/amazon-sagemaker-operator-for-k8s:v1`` | https://amazon-sagemaker-operator-for-k8s-eu-west-1.s3.amazonaws.com/kubectl-smlogs-plugin/v1/linux.amd64.tar.gz |
560560
+-------------+---------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------+

doc/using_pytorch.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ With PyTorch Estimators and Models, you can train and host PyTorch models on Ama
66

77
Supported versions of PyTorch: ``0.4.0``, ``1.0.0``, ``1.1.0``, ``1.2.0``, ``1.3.1``.
88

9+
Supported versions of PyTorch for Elastic Inference: ``1.3.1``.
10+
911
We recommend that you use the latest supported version, because that's where we focus most of our development efforts.
1012

1113
You can visit the PyTorch repository at https://github.com/pytorch/pytorch.
@@ -250,6 +252,14 @@ You use the SageMaker PyTorch model server to host your PyTorch model when you c
250252
Estimator. The model server runs inside a SageMaker Endpoint, which your call to ``deploy`` creates.
251253
You can access the name of the Endpoint by the ``name`` property on the returned ``Predictor``.
252254

255+
PyTorch on Amazon SageMaker has support for `Elastic Inference <https://docs.aws.amazon.com/sagemaker/latest/dg/ei.html>`_, which allows for inference acceleration to a hosted endpoint for a fraction of the cost of using a full GPU instance.
256+
In order to attach an Elastic Inference accelerator to your endpoint provide the accelerator type to ``accelerator_type`` to your ``deploy`` call.
257+
258+
.. code:: python
259+
260+
predictor = pytorch_estimator.deploy(instance_type='ml.m4.xlarge',
261+
initial_instance_count=1,
262+
accelerator_type='ml.eia2.medium')
253263
254264
The SageMaker PyTorch Model Server
255265
==================================
@@ -291,6 +301,11 @@ It loads the model parameters from a ``model.pth`` file in the SageMaker model d
291301
model.load_state_dict(torch.load(f))
292302
return model
293303
304+
However, if you are using PyTorch Elastic Inference, you do not have to provide a ``model_fn`` since the PyTorch serving
305+
container has a default one for you. But please note that if you are utilizing the default ``model_fn``, please save
306+
yor parameter file as ``model.pt`` instead of ``model.pth``. For more information on inference script, please refer to:
307+
`SageMaker PyTorch Default Inference Handler <https://github.com/aws/sagemaker-pytorch-serving-container/blob/master/src/sagemaker_pytorch_serving_container/default_inference_handler.py>`_.
308+
294309
Serve a PyTorch Model
295310
---------------------
296311

src/sagemaker/algorithm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@ def transformer(
328328
instance_type (str): Type of EC2 instance to use, for example,
329329
'ml.c4.xlarge'.
330330
strategy (str): The strategy used to decide how to batch records in
331-
a single request (default: None). Valid values: 'MULTI_RECORD'
332-
and 'SINGLE_RECORD'.
331+
a single request (default: None). Valid values: 'MultiRecord'
332+
and 'SingleRecord'.
333333
assemble_with (str): How the output is assembled (default: None).
334334
Valid values: 'Line' or 'None'.
335335
output_path (str): S3 location for saving the transform result. If

src/sagemaker/estimator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,8 +823,8 @@ def transformer(
823823
instance_type (str): Type of EC2 instance to use, for example,
824824
'ml.c4.xlarge'.
825825
strategy (str): The strategy used to decide how to batch records in
826-
a single request (default: None). Valid values: 'MULTI_RECORD'
827-
and 'SINGLE_RECORD'.
826+
a single request (default: None). Valid values: 'MultiRecord'
827+
and 'SingleRecord'.
828828
assemble_with (str): How the output is assembled (default: None).
829829
Valid values: 'Line' or 'None'.
830830
output_path (str): S3 location for saving the transform result. If
@@ -1895,8 +1895,8 @@ def transformer(
18951895
instance_type (str): Type of EC2 instance to use, for example,
18961896
'ml.c4.xlarge'.
18971897
strategy (str): The strategy used to decide how to batch records in
1898-
a single request (default: None). Valid values: 'MULTI_RECORD'
1899-
and 'SINGLE_RECORD'.
1898+
a single request (default: None). Valid values: 'MultiRecord'
1899+
and 'SingleRecord'.
19001900
assemble_with (str): How the output is assembled (default: None).
19011901
Valid values: 'Line' or 'None'.
19021902
output_path (str): S3 location for saving the transform result. If

src/sagemaker/fw_utils.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,14 @@
5353
)
5454

5555
VALID_PY_VERSIONS = ["py2", "py3"]
56-
VALID_EIA_FRAMEWORKS = ["tensorflow", "tensorflow-serving", "mxnet", "mxnet-serving"]
56+
VALID_EIA_FRAMEWORKS = [
57+
"tensorflow",
58+
"tensorflow-serving",
59+
"mxnet",
60+
"mxnet-serving",
61+
"pytorch-serving",
62+
]
63+
PY2_RESTRICTED_EIA_FRAMEWORKS = ["pytorch-serving"]
5764
VALID_ACCOUNTS_BY_REGION = {"us-gov-west-1": "246785580436", "us-iso-east-1": "744548109606"}
5865
ASIMOV_VALID_ACCOUNTS_BY_REGION = {"us-gov-west-1": "442386744353", "us-iso-east-1": "886529160074"}
5966
OPT_IN_ACCOUNTS_BY_REGION = {"ap-east-1": "057415533634", "me-south-1": "724002660598"}
@@ -71,6 +78,7 @@
7178
"mxnet-serving-eia": "mxnet-inference-eia",
7279
"pytorch": "pytorch-training",
7380
"pytorch-serving": "pytorch-inference",
81+
"pytorch-serving-eia": "pytorch-inference-eia",
7482
}
7583

7684
MERGED_FRAMEWORKS_LOWEST_VERSIONS = {
@@ -82,6 +90,7 @@
8290
"mxnet-serving-eia": [1, 4, 1],
8391
"pytorch": [1, 2, 0],
8492
"pytorch-serving": [1, 2, 0],
93+
"pytorch-serving-eia": [1, 3, 1],
8594
}
8695

8796
DEBUGGER_UNSUPPORTED_REGIONS = ["us-gov-west-1", "us-iso-east-1"]
@@ -188,6 +197,7 @@ def create_image_uri(
188197

189198
if _accelerator_type_valid_for_framework(
190199
framework=framework,
200+
py_version=py_version,
191201
accelerator_type=accelerator_type,
192202
optimized_families=optimized_families,
193203
):
@@ -240,21 +250,27 @@ def create_image_uri(
240250

241251

242252
def _accelerator_type_valid_for_framework(
243-
framework, accelerator_type=None, optimized_families=None
253+
framework, py_version, accelerator_type=None, optimized_families=None
244254
):
245255
"""
246256
Args:
247257
framework:
258+
py_version:
248259
accelerator_type:
249260
optimized_families:
250261
"""
251262
if accelerator_type is None:
252263
return False
253264

265+
if py_version == "py2" and framework in PY2_RESTRICTED_EIA_FRAMEWORKS:
266+
raise ValueError(
267+
"{} is not supported with Amazon Elastic Inference in Python 2.".format(framework)
268+
)
269+
254270
if framework not in VALID_EIA_FRAMEWORKS:
255271
raise ValueError(
256272
"{} is not supported with Amazon Elastic Inference. Currently only "
257-
"Python-based TensorFlow and MXNet are supported.".format(framework)
273+
"Python-based TensorFlow, MXNet, PyTorch are supported.".format(framework)
258274
)
259275

260276
if optimized_families:

src/sagemaker/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,8 @@ def transformer(
504504
instance_type (str): Type of EC2 instance to use, for example,
505505
'ml.c4.xlarge'.
506506
strategy (str): The strategy used to decide how to batch records in
507-
a single request (default: None). Valid values: 'MULTI_RECORD'
508-
and 'SINGLE_RECORD'.
507+
a single request (default: None). Valid values: 'MultiRecord'
508+
and 'SingleRecord'.
509509
assemble_with (str): How the output is assembled (default: None).
510510
Valid values: 'Line' or 'None'.
511511
output_path (str): S3 location for saving the transform result. If

src/sagemaker/pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ def transformer(
215215
instance_type (str): Type of EC2 instance to use, for example,
216216
'ml.c4.xlarge'.
217217
strategy (str): The strategy used to decide how to batch records in
218-
a single request (default: None). Valid values: 'MULTI_RECORD'
219-
and 'SINGLE_RECORD'.
218+
a single request (default: None). Valid values: 'MultiRecord'
219+
and 'SingleRecord'.
220220
assemble_with (str): How the output is assembled (default: None).
221221
Valid values: 'Line' or 'None'.
222222
output_path (str): S3 location for saving the transform result. If

src/sagemaker/pytorch/README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ With PyTorch Estimators and Models, you can train and host PyTorch models on Ama
66

77
Supported versions of PyTorch: ``0.4.0``, ``1.0.0``, ``1.1.0``, ``1.2.0``, ``1.3.1``, ``1.4.0``.
88

9+
Supported versions of PyTorch for Elastic Inference: ``1.3.1``.
10+
911
We recommend that you use the latest supported version, because that's where we focus most of our development efforts.
1012

1113
You can visit the PyTorch repository at https://github.com/pytorch/pytorch.

src/sagemaker/pytorch/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def prepare_container_def(self, instance_type, accelerator_type=None):
136136
For example, 'ml.p2.xlarge'.
137137
accelerator_type (str): The Elastic Inference accelerator type to
138138
deploy to the instance for loading and making inferences to the
139-
model. Currently unsupported with PyTorch.
139+
model.
140140
141141
Returns:
142142
dict[str, str]: A container definition object usable with the
@@ -169,7 +169,7 @@ def serving_image_uri(self, region_name, instance_type, accelerator_type=None):
169169
(cpu/gpu/family-specific optimized).
170170
accelerator_type (str): The Elastic Inference accelerator type to
171171
deploy to the instance for loading and making inferences to the
172-
model. Currently unsupported with PyTorch.
172+
model.
173173
174174
Returns:
175175
str: The appropriate image URI based on the given parameters.

src/sagemaker/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1968,7 +1968,7 @@ def transform(
19681968
job_name (str): Name of the transform job being created.
19691969
model_name (str): Name of the SageMaker model being used for the transform job.
19701970
strategy (str): The strategy used to decide how to batch records in a single request.
1971-
Possible values are 'MULTI_RECORD' and 'SINGLE_RECORD'.
1971+
Possible values are 'MultiRecord' and 'SingleRecord'.
19721972
max_concurrent_transforms (int): The maximum number of HTTP requests to be made to
19731973
each individual transform container at one time.
19741974
max_payload (int): Maximum size of the payload in a single HTTP request to the

src/sagemaker/tensorflow/estimator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ def transformer(
772772
instance_count (int): Number of EC2 instances to use.
773773
instance_type (str): Type of EC2 instance to use, for example, 'ml.c4.xlarge'.
774774
strategy (str): The strategy used to decide how to batch records in a single request
775-
(default: None). Valid values: 'MULTI_RECORD' and 'SINGLE_RECORD'.
775+
(default: None). Valid values: 'MultiRecord' and 'SingleRecord'.
776776
assemble_with (str): How the output is assembled (default: None). Valid values: 'Line'
777777
or 'None'.
778778
output_path (str): S3 location for saving the transform result. If not specified,

src/sagemaker/tuner.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,23 @@ def best_estimator(self, best_training_job=None):
760760
be deployed to an Amazon SageMaker endpoint and return a ``sagemaker.RealTimePredictor``
761761
object.
762762
763+
Args:
764+
best_training_job (dict): Dictionary containing "TrainingJobName" and
765+
"TrainingJobDefinitionName".
766+
767+
Example:
768+
769+
.. code:: python
770+
771+
{
772+
"TrainingJobName": "my_training_job_name",
773+
"TrainingJobDefinitionName": "my_training_job_definition_name"
774+
}
775+
776+
Returns:
777+
sagemaker.estimator.EstimatorBase: The estimator that has the best training job
778+
attached.
779+
763780
Raises:
764781
Exception: If there is no best training job available for the hyperparameter tuning job.
765782
"""

src/sagemaker/workflow/airflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,8 @@ def transform_config_from_estimator(
802802
model_name (str): model name (default: None). If not specified, one will
803803
be generated.
804804
strategy (str): The strategy used to decide how to batch records in a
805-
single request (default: None). Valid values: 'MULTI_RECORD' and
806-
'SINGLE_RECORD'.
805+
single request (default: None). Valid values: 'MultiRecord' and
806+
'SingleRecord'.
807807
assemble_with (str): How the output is assembled (default: None). Valid
808808
values: 'Line' or 'None'.
809809
output_path (str): S3 location for saving the transform result. If not
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2020 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 file is intentionally left blank to invoke default model_fn and predict_fn
129 KB
Binary file not shown.

0 commit comments

Comments
 (0)