Skip to content

Commit 42a1a09

Browse files
authored
SageMaker Serverless Inference GA changes (aws#3340)
* SageMaker Serverless Inference GA changes * Update huggingface-text-classification-serverless-inference.ipynb * SageMaker Serverless Inference GA changes * SageMaker Serverless Inference GA changes * SageMaker Serverless Inference GA changes * Update Serverless-Inference-Walkthrough.ipynb * Update Serverless-Inference-Walkthrough.ipynb * Update Serverless-Inference-Walkthrough.ipynb
1 parent f56585e commit 42a1a09

File tree

4 files changed

+15
-44
lines changed

4 files changed

+15
-44
lines changed

sagemaker_processing/fairness_and_explainability/text_explainability_sagemaker_algorithm/container/readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This example shows how to package an algorithm for use with SageMaker.
44

55
SageMaker supports two execution modes: _training_ where the algorithm uses input data to train a new model and _serving_ where the algorithm accepts HTTP requests and uses the previously trained model to do an inference (also called "scoring", "prediction", or "transformation").
66

7-
The algorithm that we have built here supports both training and scoring in SageMaker with the same container image. It is perfectly reasonable to build an algorithm that supports only training _or_ scoring as well as to build an algorithm that has separate container images for training and scoring.
7+
The algorithm that we have built here supports both training and scoring in SageMaker with the same container image. It is perfectly reasonable to build an algorithm that supports only training _or_ scoring as well as to build an algorithm that has separate container images for training and scoring.v
88

99
In order to build a production grade inference server into the container, we use the following stack to make the implementer's job simple:
1010

@@ -16,11 +16,11 @@ In order to build a production grade inference server into the container, we use
1616

1717
The components are as follows:
1818

19-
* __Dockerfile__: The _Dockerfile_ describes how the image is built and what it contains. It is a recipe for your container and gives you tremendous flexibility to construct almost any execution environment you can imagine. Here, we use the Dockerfile to describe a pretty standard python science stack and the simple scripts that we're going to add to it. See the [Dockerfile reference][dockerfile] for what's possible here.
19+
* __Dockerfile__: The _Dockerfile_ describes how the image is built and what it contains. It is a recipe for your container and gives you tremendous flexibility to construct almost any execution environment you can imagine. Here. we use the Dockerfile to describe a pretty standard python science stack and the simple scripts that we're going to add to it. See the [Dockerfile reference][dockerfile] for what's possible here.
2020

2121
* __build\_and\_push.sh__: The script to build the Docker image (using the Dockerfile above) and push it to the [Amazon EC2 Container Registry (ECR)][ecr] so that it can be deployed to SageMaker. Specify the name of the image as the argument to this script. The script will generate a full name for the repository in your account and your configured AWS region. If this ECR repository doesn't exist, the script will create it.
2222

23-
* __blazing_text__: The directory that contains the application to run in the container. See the next section for details about each of the files.
23+
* __blazing_text__: The directory that contains the application to run in the container. See the next session for details about each of the files.
2424

2525
* __local-test__: A directory containing scripts and a setup for running a simple training and inference jobs locally so that you can test that everything is set up correctly. See below for details.
2626

serverless-inference/Serverless-Inference-Walkthrough.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"For this notebook we'll be working with the SageMaker XGBoost Algorithm to train a model and then deploy a serverless endpoint. We will be using the public S3 Abalone regression dataset for this example.\n",
1414
"\n",
1515
"<b>Notebook Setting</b>\n",
16-
"- <b>SageMaker Classic Notebook Instance</b>: ml.m5.xlarge Notebook Instance & conda_python3 Kernel\n",
16+
"- <b>SageMaker Classic Notebook Instance</b>: ml.m5.xlarge Notebook Instance & `conda_python3` Kernel\n",
1717
"- <b>SageMaker Studio</b>: Python 3 (Data Science)\n",
1818
"- <b>Regions Available</b>: SageMaker Serverless Inference is currently available in the following regions: US East (Northern Virginia), US East (Ohio), US West (Oregon), EU (Ireland), Asia Pacific (Tokyo) and Asia Pacific (Sydney)"
1919
]
@@ -49,7 +49,7 @@
4949
"id": "1affea20",
5050
"metadata": {},
5151
"source": [
52-
"Let's start by installing preview wheels of the Python SDK, boto and aws cli"
52+
"Let's start by upgrading the Python SDK, `boto3` and AWS `CLI` (Command Line Interface) packages."
5353
]
5454
},
5555
{
@@ -313,7 +313,7 @@
313313
"source": [
314314
"### Endpoint Configuration Creation\n",
315315
"\n",
316-
"This is where you can adjust the <b>Serverless Configuration</b> for your endpoint. The current max concurrent invocations for a single endpoint, known as <b>MaxConcurrency</b>, can be any value from <b>1 to 50</b>, and <b>MemorySize</b> can be any of the following: <b>1024 MB, 2048 MB, 3072 MB, 4096 MB, 5120 MB, or 6144 MB</b>."
316+
"This is where you can adjust the <b>Serverless Configuration</b> for your endpoint. The current max concurrent invocations for a single endpoint, known as `MaxConcurrency`, can be any value from <b>1 to 200</b>, and `MemorySize` can be any of the following: <b>1024 MB, 2048 MB, 3072 MB, 4096 MB, 5120 MB, or 6144 MB</b>."
317317
]
318318
},
319319
{
@@ -373,7 +373,7 @@
373373
"id": "831d2181",
374374
"metadata": {},
375375
"source": [
376-
"Wait until the endpoint status is InService before invoking the endpoint."
376+
"Wait until the endpoint status is `InService` before invoking the endpoint."
377377
]
378378
},
379379
{

serverless-inference/huggingface-serverless-inference/huggingface-text-classification-serverless-inference.ipynb

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@
8585
"source": [
8686
"import sys\n",
8787
"\n",
88-
"!{sys.executable} -m pip install \"scikit_learn==0.20.0\" \"sagemaker>=2.75.1\" \"transformers==4.6.1\" \"datasets==1.6.2\" \"nltk==3.4.4\""
88+
"!{sys.executable} -m pip install \"scikit_learn==0.20.0\" \"sagemaker>=2.86.1\" \"transformers==4.6.1\" \"datasets==1.6.2\" \"nltk==3.4.4\""
8989
]
9090
},
9191
{
9292
"cell_type": "markdown",
9393
"metadata": {},
9494
"source": [
95-
"Make sure SageMaker version is >= 2.75.1"
95+
"Make sure SageMaker version is >= 2.86.1"
9696
]
9797
},
9898
{
@@ -1097,7 +1097,7 @@
10971097
"\n",
10981098
"#### Concurrent invocations - `max_concurrency`\n",
10991099
" \n",
1100-
"Serverless Inference manages predefined scaling policies and quotas for the capacity of your endpoint. Serverless endpoints have a quota for how many concurrent invocations can be processed at the same time. If the endpoint is invoked before it finishes processing the first request, then it handles the second request concurrently. You can set the maximum concurrency for a <b>single endpoint up to 50</b>, and the total number of serverless endpoint variants you can host in a Region is 50. The total concurrency you can share between all serverless endpoints per Region in your account is 200. The maximum concurrency for an individual endpoint prevents that endpoint from taking up all the invocations allowed for your account, and any endpoint invocations beyond the maximum are throttled."
1100+
"Serverless Inference manages predefined scaling policies and quotas for the capacity of your endpoint. Serverless endpoints have a quota for how many concurrent invocations can be processed at the same time. If the endpoint is invoked before it finishes processing the first request, then it handles the second request concurrently. You can set the maximum concurrency for a <b>single endpoint up to 200</b>, and the total number of serverless endpoint variants you can host in a Region is 50. The total concurrency you can share between all serverless endpoints per Region in your account is 200. The maximum concurrency for an individual endpoint prevents that endpoint from taking up all the invocations allowed for your account, and any endpoint invocations beyond the maximum are throttled."
11011101
]
11021102
},
11031103
{
@@ -1114,33 +1114,6 @@
11141114
")"
11151115
]
11161116
},
1117-
{
1118-
"cell_type": "markdown",
1119-
"metadata": {},
1120-
"source": [
1121-
"### HuggingFace Inference Image `URI`\n",
1122-
"\n",
1123-
"In order to deploy the SageMaker Endpoint with Serverless configuration, we will need to supply the HuggingFace Inference Image URI."
1124-
]
1125-
},
1126-
{
1127-
"cell_type": "code",
1128-
"execution_count": null,
1129-
"metadata": {},
1130-
"outputs": [],
1131-
"source": [
1132-
"image_uri = sagemaker.image_uris.retrieve(\n",
1133-
" framework=\"huggingface\",\n",
1134-
" base_framework_version=\"pytorch1.7\",\n",
1135-
" region=sess.boto_region_name,\n",
1136-
" version=\"4.6\",\n",
1137-
" py_version=\"py36\",\n",
1138-
" instance_type=\"ml.m5.large\",\n",
1139-
" image_scope=\"inference\",\n",
1140-
")\n",
1141-
"image_uri"
1142-
]
1143-
},
11441117
{
11451118
"cell_type": "markdown",
11461119
"metadata": {},
@@ -1157,9 +1130,7 @@
11571130
"source": [
11581131
"%%time\n",
11591132
"\n",
1160-
"predictor = huggingface_estimator.deploy(\n",
1161-
" serverless_inference_config=serverless_config, image_uri=image_uri\n",
1162-
")"
1133+
"predictor = huggingface_estimator.deploy(serverless_inference_config=serverless_config)"
11631134
]
11641135
},
11651136
{

serverless-inference/serverless-model-registry.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"source": [
2121
"Amazon SageMaker Serverless Inference is a purpose-built inference option that makes it easy for customers to deploy and scale ML models. Serverless Inference is ideal for workloads which have idle periods between traffic spurts and can tolerate cold starts. Serverless endpoints also automatically launch compute resources and scale them in and out depending on traffic, eliminating the need to choose instance types or manage scaling policies.\n",
2222
"\n",
23-
"[SageMaker Model Registry](https://docs.aws.amazon.com/sagemaker/latest/dg/model-registry.html) can be used to catalog and manage different model versions. Model Registry now supports deploying registered models to serverless endpoints. For this notebook we will take the existing [XGBoost Serverless example](https://github.com/aws/amazon-sagemaker-examples/blob/main/serverless-inference/Serverless-Inference-Walkthrough.ipynb) and integrate with the Model Registry. From there we will take our trained model and deploy it to a serverless endpoint using the Boto3 Python SDK. Note that there is not Model Registry support for the SageMaker SDK with serverless endpoints at the moment.\n",
23+
"[SageMaker Model Registry](https://docs.aws.amazon.com/sagemaker/latest/dg/model-registry.html) can be used to catalog and manage different model versions. Model Registry now supports deploying registered models to serverless endpoints. For this notebook we will take the existing [XGBoost Serverless example](https://github.com/aws/amazon-sagemaker-examples/blob/main/serverless-inference/Serverless-Inference-Walkthrough.ipynb) and integrate with the Model Registry. From there we will take our trained model and deploy it to a serverless endpoint using the Boto3 Python SDK. Note that there is no support for Model Registry in the SageMaker SDK with serverless endpoints at the moment.\n",
2424
"\n",
2525
"<b>Notebook Setting</b>\n",
2626
"- <b>SageMaker Studio</b>: Python 3 (Data Science)\n",
@@ -351,7 +351,7 @@
351351
"metadata": {},
352352
"source": [
353353
"### Endpoint Configuration Creation\n",
354-
"This is where you can adjust the [Serverless Configuration](https://docs.aws.amazon.com/sagemaker/latest/dg/serverless-endpoints-create.html) for your endpoint. The current max concurrent invocations for a single endpoint, known as MaxConcurrency, can be any value from 1 to 50, and MemorySize can be any of the following: 1024 MB, 2048 MB, 3072 MB, 4096 MB, 5120 MB, or 6144 MB."
354+
"This is where you can adjust the [Serverless Configuration](https://docs.aws.amazon.com/sagemaker/latest/dg/serverless-endpoints-create.html) for your endpoint. The current max concurrent invocations for a single endpoint, known as `MaxConcurrency`, can be any value from 1 to 200, and `MemorySize` can be any of the following: 1024 MB, 2048 MB, 3072 MB, 4096 MB, 5120 MB, or 6144 MB."
355355
]
356356
},
357357
{
@@ -402,7 +402,7 @@
402402
"cell_type": "markdown",
403403
"metadata": {},
404404
"source": [
405-
"Wait until the endpoint status is InService before invoking the endpoint."
405+
"Wait until the endpoint status is `InService` before invoking the endpoint."
406406
]
407407
},
408408
{
@@ -488,4 +488,4 @@
488488
},
489489
"nbformat": 4,
490490
"nbformat_minor": 4
491-
}
491+
}

0 commit comments

Comments
 (0)