feat(ecs): add support for elastic inference accelerators in ECS task defintions#13950
Conversation
| readonly deviceName?: string; | ||
|
|
||
| /** | ||
| * The Elastic Inference accelerator type to use. |
There was a problem hiding this comment.
It might be helpful to include what values are valid here in the docstring (i.e., eia2.medium, eia2.large, and eia2.xlarge, according to the docs).
Normally, having the different valid values as an enum might be nice so that an IDE can pick up the valid values, but the downside is that we'd have to manually add any new types that get added in the future at the risk of always being behind what's available, so I think a string is fine for now.
| * The type and amount of a resource to assign to a container. | ||
| * @default - No resources assigned. | ||
| */ | ||
| readonly resourceRequirements?: ResourceRequirement[]; |
There was a problem hiding this comment.
I'm wondering if we should have the new field be something that is more specific to EIA, since resourceRequirements in CFN technically encompasses both GPU and EIA. GPU currently is specified through its own field, and it may be confusing for this field to exist when we have GPU specified elsewhere.
There was a problem hiding this comment.
I agree, it might get confusing this way. I will make the required changes.
There was a problem hiding this comment.
I renamed the resourceRequirements prop to inferenceAcceleratorResources (as inferenceAccelerators was already a task definiton prop) and changed the type to be a list of device names (strings).
Updates to documentation and allocation of props in tests Co-authored-by: Hsing-Hui Hsu <hsinghui@amazon.com>
iamhopaul123
left a comment
There was a problem hiding this comment.
Very awesome PR (even without considering it is the first PR that you have) 🎉
Updated docs and sanity check condition Co-authored-by: Penghao He <penghaoh@amazon.com>
iamhopaul123
left a comment
There was a problem hiding this comment.
Looks good just some nits. Just a reminder but make sure every error you throw is covered in the unit test!
| function renderResourceRequirements(gpuCount: number = 0, inferenceAcceleratorResources: string[] = []): | ||
| CfnTaskDefinition.ResourceRequirementProperty[] | undefined { | ||
| if (inferenceAcceleratorResources.length > 0 && gpuCount > 0) { | ||
| throw new Error('Both inference accelerator and gpu count defined in the container definition.'); |
There was a problem hiding this comment.
| throw new Error('Both inference accelerator and gpu count defined in the container definition.'); | |
| throw new Error('Cannot define both inference accelerator and gpu count in the container definition.'); |
We might need to be more specific for the reason why this condition fails https://uxdworld.com/2018/05/30/how-to-write-good-error-messages/
we also need unit test for this.
There was a problem hiding this comment.
Discussed about this offline but posting here for the record, we decided to render both gpuCount and inferenceAcceleratorResources properties and let the validators in other stages handle this check.
Updating error messages Co-authored-by: Penghao He <penghaoh@amazon.com>
iamhopaul123
left a comment
There was a problem hiding this comment.
LGTM with just two nits. Feel free to take off the do-not-merge label once those are addressed!
| function renderResourceRequirements(gpuCount: number = 0, inferenceAcceleratorResources: string[] = []): | ||
| CfnTaskDefinition.ResourceRequirementProperty[] | undefined { | ||
| const ret = []; | ||
| if (inferenceAcceleratorResources.length > 0) { |
There was a problem hiding this comment.
Just a nit but this check might not be required?
Pull request has been modified.
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Pull request has been modified.
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
… defintions (aws#13950) This PR would enable users to attach inference accelerators to their ECS tasks (currently not supported by Fargate). It adds an optional `inferenceAccelerators` property to the EC2 Task Definition. It also adds `resourceRequirement` property to the Container definition to enable containers to refer to the inference accelerators provided in the task definition. Closes aws#12460 *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR would enable users to attach inference accelerators to their ECS tasks (currently not supported by Fargate). It adds an optional
inferenceAcceleratorsproperty to the EC2 Task Definition. It also addsresourceRequirementproperty to the Container definition to enable containers to refer to the inference accelerators provided in the task definition.Closes #12460
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license