feature: Add Granular Target Description support for compilation (Neo)#1752
feature: Add Granular Target Description support for compilation (Neo)#1752laurenyu merged 1 commit intoaws:masterfrom
Conversation
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
src/sagemaker/model.py
Outdated
| assert target_platform_os is not None and target_platform_arch is not None, ( | ||
| "target_instance_type or (target_platform_os and target_platform_arch) " | ||
| "should be provided" | ||
| ) |
There was a problem hiding this comment.
it's better practice to avoid using asserts in source code, and instead raise a ValueError in this case
https://stackoverflow.com/a/945135
https://stackoverflow.com/a/1838411
There was a problem hiding this comment.
Replaced with ValueError
src/sagemaker/model.py
Outdated
| run your model after compilation, for example: ml_c5. For allowed | ||
| strings see | ||
| https://docs.aws.amazon.com/sagemaker/latest/dg/API_OutputConfig.html. | ||
| Alternatively, you can select OS, Arch and Accelerator using Target Platform |
There was a problem hiding this comment.
| Alternatively, you can select OS, Arch and Accelerator using Target Platform | |
| Alternatively, you can select an OS, Architecture, and Accelerator using | |
| ``target_platform_os``, ``target_platform_arch``, and ``target_platform_accelerator``. |
There was a problem hiding this comment.
fixed as suggested
src/sagemaker/model.py
Outdated
| target_platform_os (str): Target Platform OS. Allowed values: 'LINUX', 'ANDROID'. | ||
| It can be used instead of target_instance_family. | ||
| target_platform_arch (str): Target Platform Architecture. Allowed values: 'X86_64', | ||
| 'X86', 'ARM64', 'ARM_EABIHF', 'ARM_EABI'. | ||
| It can be used instead of target_instance_family. | ||
| target_platform_accelerator (str): Target Platform Accelerator. Allowed values: | ||
| 'INTEL_GRAPHICS', 'MALI', 'NVIDIA'. Optional. |
There was a problem hiding this comment.
can you instead link to docs that list the allowed versions? I assume they might change in the future, and if that happens, this docstring will inevitably be forgotten.
There was a problem hiding this comment.
The API reference is updated:
OutputConfig API
TargetPlatform API
It would be good to provide these links as well.
There was a problem hiding this comment.
I left one example value and added link to allowed values.
src/sagemaker/model.py
Outdated
| It can be used instead of target_instance_family. | ||
| target_platform_accelerator (str): Target Platform Accelerator. Allowed values: | ||
| 'INTEL_GRAPHICS', 'MALI', 'NVIDIA'. Optional. | ||
| compiler_options (str): Additional parameters for compiler (Optional, in JSON format). |
There was a problem hiding this comment.
if it needs to be in JSON, would it make more sense to accept a dict, and then let the Python SDK call json.dumps?
There was a problem hiding this comment.
Fixed, now it support both dict and string. Similar to DataInputConfig
src/sagemaker/model.py
Outdated
| "Devices described by Target Platform Os, Arch and Accelerator are not supported" | ||
| "to deploy via SageMaker, please deploy the model manually." |
There was a problem hiding this comment.
| "Devices described by Target Platform Os, Arch and Accelerator are not supported" | |
| "to deploy via SageMaker, please deploy the model manually." | |
| "Deploying devices described by Target Platform OS, Architecture, and Accelerator " | |
| "is not supported via SageMaker. Please deploy the model manually." |
There was a problem hiding this comment.
Can we keep old comment? I like it better.
There was a problem hiding this comment.
"not supported to deploy" is the part that was bothering me. maybe "not supported for deployment"?
There was a problem hiding this comment.
ok, changed to not supported for deployment.
src/sagemaker/model.py
Outdated
| "The instance type %s is not supported to deploy via SageMaker," | ||
| "please deploy the model manually.", | ||
| target_instance_family, |
There was a problem hiding this comment.
(I know this isn't your change, but while you're here...)
| "The instance type %s is not supported to deploy via SageMaker," | |
| "please deploy the model manually.", | |
| target_instance_family, | |
| "Deploying instance type %s is not supported via SageMaker." | |
| "Please deploy the model manually.", | |
| target_instance_family, |
There was a problem hiding this comment.
Can we keep old comment? I like it better.
There was a problem hiding this comment.
changed to not supported for deployment
| model = _create_model(sagemaker_session) | ||
| model.compile( | ||
| target_instance_family=None, | ||
| input_shape={"data": [1, 3, 1024, 1024]}, |
There was a problem hiding this comment.
input_shape={'data': [1, 3, 1024, 1024]}
^ suggesting to use single-quote (based on what we discussed earlier)
There was a problem hiding this comment.
because of black-check python code style check we have to use double-quotes here
| model = _create_model(sagemaker_session) | ||
| model.compile( | ||
| target_instance_family=None, | ||
| input_shape={"data": [1, 3, 1024, 1024]}, |
There was a problem hiding this comment.
input_shape={'data': [1, 3, 1024, 1024]}
^ suggesting to use single-quote (based on what we discussed earlier)
There was a problem hiding this comment.
This is not JSON-like String which we use in Console UI or AWS CLI.
This is Python code. In Python SDK we use Dictionary {...} instead of JSON-string "{...}".
Technically we can use single quotes here. However, This project automatic build runs Python code style check (black-check) and it requires all strings to use double-quoutes for Strings in Python code.
src/sagemaker/model.py
Outdated
| It can be used instead of target_instance_family. | ||
| target_platform_accelerator (str): Target Platform Accelerator. Allowed values: | ||
| 'INTEL_GRAPHICS', 'MALI', 'NVIDIA'. Optional. | ||
| compiler_options (str): Additional parameters for compiler (Optional, in JSON format). |
There was a problem hiding this comment.
We may need to point out here as well that target_instance_family and target_platform_* are not usable together?
There was a problem hiding this comment.
For each target_platform_* field documentation I added - It can be used instead of target_instance_family.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
src/sagemaker/model.py
Outdated
| compiler_options | ||
| if not isinstance(compiler_options, dict) | ||
| else json.dumps(compiler_options) |
There was a problem hiding this comment.
let's flip this around to put the positive condition first, i.e. json.dumps(compiler_options) if isinstance(compiler_options, dict) else compiler_options
There was a problem hiding this comment.
fixed here and for DataInputConfig as well.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Description
Add Granular Target Description support for DL model compilation.
Example:
Tests
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.