-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(sagemaker): add support for serverless inference endpoints #35557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pymia
wants to merge
3
commits into
aws:main
Choose a base branch
from
pymia:feature/sagemaker-serverless-variants-23148
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,636
−1,339
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import * as path from 'path'; | ||
import * as ec2 from 'aws-cdk-lib/aws-ec2'; | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { IntegTest } from '@aws-cdk/integ-tests-alpha'; | ||
import * as sagemaker from '../lib'; | ||
|
||
/* | ||
* Stack verification steps: | ||
* aws sagemaker describe-endpoint-config --endpoint-config-name <endpoint config name> | ||
* | ||
* For instance-based endpoint config, the above command will result in the following output: | ||
* { | ||
* "EndpointConfigName": "EndpointConfig...", | ||
* "EndpointConfigArn": "arn:aws:sagemaker:...", | ||
* "ProductionVariants": [ | ||
* { | ||
* "VariantName": "firstVariant", | ||
* "ModelName": "ModelWithArtifactAndVpcModel...", | ||
* "InitialInstanceCount": 1, | ||
* "InstanceType": "ml.m5.large", | ||
* "InitialVariantWeight": 1.0 | ||
* }, | ||
* { | ||
* "VariantName": "secondVariant", | ||
* "ModelName": "ModelWithArtifactAndVpcModel...", | ||
* "InitialInstanceCount": 1, | ||
* "InstanceType": "ml.t2.medium", | ||
* "InitialVariantWeight": 1.0 | ||
* }, | ||
* { | ||
* "VariantName": "thirdVariant", | ||
* "ModelName": "ModelWithoutArtifactAndVpcModel...", | ||
* "InitialInstanceCount": 1, | ||
* "InstanceType": "ml.t2.medium", | ||
* "InitialVariantWeight": 2.0 | ||
* } | ||
* ], | ||
* "CreationTime": "..." | ||
* } | ||
* | ||
* For serverless endpoint config, the command will show: | ||
* { | ||
* "EndpointConfigName": "ServerlessEndpointConfig...", | ||
* "EndpointConfigArn": "arn:aws:sagemaker:...", | ||
* "ProductionVariants": [ | ||
* { | ||
* "VariantName": "serverlessVariant", | ||
* "ModelName": "ModelWithoutArtifactAndVpcModel...", | ||
* "InitialVariantWeight": 1.0, | ||
* "ServerlessConfig": { | ||
* "MaxConcurrency": 10, | ||
* "MemorySizeInMB": 2048, | ||
* "ProvisionedConcurrency": 5 | ||
* } | ||
* } | ||
* ], | ||
* "CreationTime": "..." | ||
* } | ||
*/ | ||
|
||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, 'aws-cdk-sagemaker-endpointconfig'); | ||
|
||
const image = sagemaker.ContainerImage.fromAsset(path.join(__dirname, 'test-image')); | ||
const modelData = sagemaker.ModelData.fromAsset(path.join(__dirname, 'test-artifacts', 'valid-artifact.tar.gz')); | ||
|
||
const modelWithArtifactAndVpc = new sagemaker.Model(stack, 'ModelWithArtifactAndVpc', { | ||
containers: [{ image, modelData }], | ||
vpc: new ec2.Vpc(stack, 'VPC', { restrictDefaultSecurityGroup: false }), | ||
}); | ||
const modelWithoutArtifactAndVpc = new sagemaker.Model(stack, 'ModelWithoutArtifactAndVpc', { | ||
containers: [{ image }], | ||
}); | ||
|
||
// Test instance-based endpoint configuration | ||
const endpointConfig = new sagemaker.EndpointConfig(stack, 'EndpointConfig', { | ||
instanceProductionVariants: [ | ||
{ | ||
model: modelWithArtifactAndVpc, | ||
variantName: 'firstVariant', | ||
instanceType: sagemaker.InstanceType.M5_LARGE, | ||
}, | ||
{ | ||
model: modelWithArtifactAndVpc, | ||
variantName: 'secondVariant', | ||
}, | ||
], | ||
}); | ||
endpointConfig.addInstanceProductionVariant({ | ||
model: modelWithoutArtifactAndVpc, | ||
variantName: 'thirdVariant', | ||
initialVariantWeight: 2.0, | ||
}); | ||
|
||
// Test serverless endpoint configuration with all properties | ||
new sagemaker.EndpointConfig(stack, 'ServerlessEndpointConfig', { | ||
serverlessProductionVariant: { | ||
model: modelWithoutArtifactAndVpc, | ||
variantName: 'serverlessVariant', | ||
maxConcurrency: 10, | ||
memorySizeInMB: 2048, | ||
provisionedConcurrency: 5, | ||
initialVariantWeight: 1.0, | ||
}, | ||
}); | ||
|
||
// Test serverless endpoint configuration with minimal properties | ||
new sagemaker.EndpointConfig(stack, 'MinimalServerlessEndpointConfig', { | ||
serverlessProductionVariant: { | ||
model: modelWithoutArtifactAndVpc, | ||
variantName: 'minimalServerlessVariant', | ||
maxConcurrency: 1, | ||
memorySizeInMB: 1024, | ||
// No provisionedConcurrency - testing optional property | ||
}, | ||
}); | ||
|
||
// Test serverless endpoint configuration with boundary values | ||
new sagemaker.EndpointConfig(stack, 'BoundaryServerlessEndpointConfig', { | ||
serverlessProductionVariant: { | ||
model: modelWithoutArtifactAndVpc, | ||
variantName: 'boundaryServerlessVariant', | ||
maxConcurrency: 200, // Maximum allowed | ||
memorySizeInMB: 6144, // Maximum allowed | ||
provisionedConcurrency: 200, // Maximum allowed (equal to maxConcurrency) | ||
}, | ||
}); | ||
|
||
new IntegTest(app, 'integtest-endpointconfig', { | ||
testCases: [stack], | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can keep the integration test in one file. We have another integration test file
integ.endpoint-config
. We can put all the necessary integration-test related code in that file and remove this one.