Skip to content

Commit 7b724dc

Browse files
billdoorsEC2 Default UsershreyapanditQingwei LiEC2 Default User
committed
updated shadow_variants with Alwin's work (aws#225)
* initial commit * minor fix * minor fixes * add inference experiment notebook add inference experiment notebook * Add shadow endpoint notebook (aws#215) * initial commit * add inference experiment notebook add inference experiment notebook Co-authored-by: Qingwei Li<[email protected]> Co-authored-by: Shreya Pandit <[email protected]> Co-authored-by: Qingwei Li <[email protected]> * Revert "Add shadow endpoint notebook (aws#215)" (aws#218) This reverts commit b6d2fd203f7f85670478556e902ad2bb86a1a882. * reformat * reviewer's comments addressed * clear output * fix and reformat nb * reformat nb * remove notebook * markdown change * Alwin's edit add edits from Alwin * reformat * change folder name Co-authored-by: EC2 Default User <[email protected]> Co-authored-by: Shreya Pandit <[email protected]> Co-authored-by: Qingwei Li <[email protected]> Co-authored-by: EC2 Default User <[email protected]> Co-authored-by: atqy <[email protected]> Co-authored-by: atqy <[email protected]>
1 parent e1e062c commit 7b724dc

File tree

1 file changed

+50
-10
lines changed

1 file changed

+50
-10
lines changed

sagemaker-shadow-variant/Shadow_variant.ipynb

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,13 @@
273273
" \"InitialVariantWeight\": 1,\n",
274274
" }\n",
275275
" ],\n",
276-
" ShadowProductionVariants=[ # Type: Array of ProductionVariant (https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_ProductionVariant.html) objects\n",
276+
" ShadowProductionVariants=[\n",
277277
" {\n",
278278
" \"VariantName\": shadow_variant_name,\n",
279279
" \"ModelName\": model_name2,\n",
280-
" \"InitialInstanceCount\": 3,\n",
281-
" \"InitialVariantWeight\": 0.5,\n",
282280
" \"InstanceType\": \"ml.m5.xlarge\",\n",
281+
" \"InitialInstanceCount\": 1,\n",
282+
" \"InitialVariantWeight\": 0.5,\n",
283283
" }\n",
284284
" ],\n",
285285
")\n",
@@ -536,7 +536,7 @@
536536
"tags": []
537537
},
538538
"source": [
539-
"Finally, let us review the 4xx and 5xx returned by the model. "
539+
"Finally, let us review the 4xx, 5xx and total model errors returned by the model serving container. "
540540
]
541541
},
542542
{
@@ -546,7 +546,10 @@
546546
"outputs": [],
547547
"source": [
548548
"Invocation4xxErrors = plot_endpoint_invocation_metrics(endpoint_name, \"Invocation4XXErrors\", \"Sum\")\n",
549-
"Invocation5xxErrors = plot_endpoint_invocation_metrics(endpoint_name, \"Invocation5XXErrors\", \"Sum\")"
549+
"Invocation5xxErrors = plot_endpoint_invocation_metrics(endpoint_name, \"Invocation5XXErrors\", \"Sum\")\n",
550+
"Invocation5xxErrors = plot_endpoint_invocation_metrics(\n",
551+
" endpoint_name, \"InvocationModelErrors\", \"Sum\"\n",
552+
")"
550553
]
551554
},
552555
{
@@ -557,10 +560,30 @@
557560
"source": [
558561
"We can consider promoting the shadow model if we do not see any differences in 4xx and 5xx errors between the production shadow variants. \n",
559562
"\n",
560-
"To promote the shadow model to production, create a new endpoint configuration with current ShadowProductionVariant as the new ProductionVariant and removing the ShadowProductionVariant. This will remove the current ProductionVariant and promote the shadow variant to become the new production variant. As always, all SageMaker updates are orchestrated as blue/green deployments under the hood and there is no loss of availability while performing the update. Optionally, you can leverage [Deployment Guardrails](https://docs.aws.amazon.com/sagemaker/latest/dg/deployment-guardrails.html) if you want to use linear and canary traffic shifting modes and auto rollbacks during your update\n",
561-
"\n",
563+
"To promote the shadow model to production, create a new endpoint configuration with current ShadowProductionVariant as the new ProductionVariant and removing the ShadowProductionVariant. This will remove the current ProductionVariant and promote the shadow variant to become the new production variant. As always, all SageMaker updates are orchestrated as blue/green deployments under the hood and there is no loss of availability while performing the update. Optionally, you can leverage [Deployment Guardrails](https://docs.aws.amazon.com/sagemaker/latest/dg/deployment-guardrails.html) if you want to use all-at-once traffic shifting and auto rollbacks during your update."
564+
]
565+
},
566+
{
567+
"cell_type": "code",
568+
"execution_count": null,
569+
"metadata": {},
570+
"outputs": [],
571+
"source": [
572+
"promote_ep_config_name = f\"PromoteShadow-EpConfig-{datetime.now():%Y-%m-%d-%H-%M-%S}\"\n",
562573
"\n",
563-
"If you do not want to create multiple endpoint configurations and want SageMaker to manage the end to end workflow of creating, managing, and acting on the results of the shadow tests, consider using the SageMaker Inference Experiement APIs/Console experience. As stated earlier, they enable you to setup shadow tests for a predefined duration of time, monitor the progress through a live dashboard, presents clean up options upon completion, and act on the results. To get started, please navigate to the 'Shadow Tests' section of the SageMaker Inference console. "
574+
"create_endpoint_config_response = sm.create_endpoint_config(\n",
575+
" EndpointConfigName=promote_ep_config_name,\n",
576+
" ProductionVariants=[\n",
577+
" {\n",
578+
" \"VariantName\": shadow_variant_name,\n",
579+
" \"ModelName\": model_name2,\n",
580+
" \"InstanceType\": \"ml.m5.xlarge\",\n",
581+
" \"InitialInstanceCount\": 2,\n",
582+
" \"InitialVariantWeight\": 1.0,\n",
583+
" }\n",
584+
" ],\n",
585+
")\n",
586+
"print(f\"Created EndpointConfig: {create_endpoint_config_response['EndpointConfigArn']}\")"
564587
]
565588
},
566589
{
@@ -569,7 +592,21 @@
569592
"metadata": {},
570593
"outputs": [],
571594
"source": [
572-
"plot_endpoint_invocation_metrics(endpoint_name, \"CPUUtilization\", \"Average\")"
595+
"update_endpoint_api_response = sm.update_endpoint(\n",
596+
" EndpointName=endpoint_name,\n",
597+
" EndpointConfigName=promote_ep_config_name,\n",
598+
")\n",
599+
"\n",
600+
"wait_for_endpoint_in_service(endpoint_name)\n",
601+
"\n",
602+
"sm.describe_endpoint(EndpointName=endpoint_name)"
603+
]
604+
},
605+
{
606+
"cell_type": "markdown",
607+
"metadata": {},
608+
"source": [
609+
"If you do not want to create multiple endpoint configurations and want SageMaker to manage the end to end workflow of creating, managing, and acting on the results of the shadow tests, consider using the SageMaker Inference Experiement APIs/Console experience. As stated earlier, they enable you to setup shadow tests for a predefined duration of time, monitor the progress through a live dashboard, presents clean up options upon completion, and act on the results. To get started, please navigate to the 'Shadow Tests' section of the SageMaker Inference console. "
573610
]
574611
},
575612
{
@@ -593,7 +630,10 @@
593630
"outputs": [],
594631
"source": [
595632
"sm.delete_endpoint(EndpointName=endpoint_name)\n",
596-
"sm.delete_endpoint_config(EndpointConfigName=ep_config_name)"
633+
"sm.delete_endpoint_config(EndpointConfigName=ep_config_name)\n",
634+
"sm.delete_endpoint_config(EndpointConfigName=promote_ep_config_name)\n",
635+
"sm.delete_model(ModelName=model_name)\n",
636+
"sm.delete_model(ModelName=model_name2)"
597637
]
598638
}
599639
],

0 commit comments

Comments
 (0)