Skip to content

fix: Return ARM XGB/SKLearn tags if image_scope is inference_graviton #3449

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

Merged
merged 1 commit into from
Dec 2, 2022

Conversation

mabunday
Copy link
Contributor

@mabunday mabunday commented Nov 1, 2022

Issue #, if available:

Description of changes:

Return ARM XGB/SKLearn tags if image_scope is inference_graviton.

Old behavior:

In [2]: sagemaker.image_uris.retrieve("sklearn", "us-west-2", version="1.0-1", image_scope="inference_graviton")
Out[2]: '246618743249.dkr.ecr.us-west-2.amazonaws.com/sagemaker-scikit-learn:1.0-1'

New behavior:

In [2]: sagemaker.image_uris.retrieve("sklearn", "us-west-2", version="1.0-1", image_scope="inference_graviton")
Out[2]: '246618743249.dkr.ecr.us-west-2.amazonaws.com/sagemaker-scikit-learn:1.0-1-arm64-cpu-py3'

Also, a validation error is thrown if image_scope is set to inference_graviton with a non-arm instance.

Valid:

In [3]: sagemaker.image_uris.retrieve("sklearn", "us-west-2", version="1.0-1", image_scope="inference_graviton", instance_type="ml.m6g.xlarge")
Out[3]: '246618743249.dkr.ecr.us-west-2.amazonaws.com/sagemaker-scikit-learn:1.0-1-arm64-cpu-py3'

Invalid:

In [4]: sagemaker.image_uris.retrieve("sklearn", "us-west-2", version="1.0-1", image_scope="inference_graviton", instance_type="ml.m5.xlarge")
Out [4]: ValueError: Unsupported instance type: m5. You may need to upgrade your SDK version (pip install -U sagemaker) for newer instance types. Supported instance type(s): m6g, m6gd, c6g, c6gd, c6gn, c7g, r6g, r6gd.

Testing done:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

  • I have read the CONTRIBUTING doc
  • I certify that the changes I am introducing will be backward compatible, and I have discussed concerns about this, if any, with the Python SDK team
  • I used the commit message format described in CONTRIBUTING
  • I have passed the region in to all S3 and STS clients that I've initialized as part of this change.
  • I have updated any necessary documentation, including READMEs and API docs (if appropriate)

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added unit and/or integration tests as appropriate to ensure backward compatibility of the changes
  • I have checked that my tests are not configured for a specific region or account (if appropriate)
  • I have used unique_name_from_base to create resource names in integ tests (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

and instance_type_family in GRAVITON_ALLOWED_TARGET_INSTANCE_FAMILY
if framework in (XGBOOST_FRAMEWORK, SKLEARN_FRAMEWORK) and (
instance_type_family in GRAVITON_ALLOWED_TARGET_INSTANCE_FAMILY
or final_image_scope == INFERENCE_GRAVITON
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to leave the "and" statement to make sure that the customer don't accidentally specify a non-Graviton instance(with the scope flag) and get a cryptic error message? We can instead an added condition to check if the scope param was passed and if it is set to INFERENCE_GRAVITON.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good point. I think what we should do then is:

  1. If image_scope == "inference_graviton" and instance_type is None or Graviton instance -> return ARM image
  2. If image_scope == "inference_graviton" and instance_type is x86 instance -> raise ValueError

Let me know if this is what you had in mind and if there are any other conditions to catch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think image_scope should not be the unique identifier for the Customers intentions to invoke Graviton instances. Instead can we have a check for instance_type when belonging to GRAVITON_ALLOWED_TARGET_INSTANCE_FAMILY then invoke the graviton instance and set the scope to INFERENCE_GRAVITON?
This is how it was implemented for PyTorch and Tensorflow frameworks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can circle back and discuss the implementation. With the existing implementation it is confusing for Customer to use these instances differently for each framework type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instance type check that updates the image scope to Graviton inference is already in place for XGB and SKLearn in the same way it is for PyTorch and TensorFlow and this PR doesn't change that behavior.

The rational for this change is that our examples in public documentation (not just for XGB and SKLearn) specifies image_scope when it isn't strictly necessary to get the image URI. Search "image_scope" on this page: https://docs.aws.amazon.com/sagemaker/latest/dg/ecr-us-west-2.html#sklearn-us-west-2.title Various example notebooks also explicitly specify image_scope as a parameter.

Specifying inference_graviton as the image scope and not getting back the graviton image even if the instance type isn't explicitly specified seems like an inconsistency to me.

Copy link
Contributor Author

@mabunday mabunday Nov 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, this is the behavior in this PR. My understanding is that the first two cases are exactly how TF and PT behave as well.

# Graviton instance type specified, ARM image returned
In [1]: sagemaker.image_uris.retrieve("xgboost", "us-west-2", version="1.5-1", instance_type="ml.m6g.xlarge")
Out[1]: '246618743249.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:1.5-1-arm64'

In [2]: sagemaker.image_uris.retrieve("xgboost", "us-west-2", version="1.5-1", instance_type="ml.m6g.xlarge", image_scope="inference")
Out[2]: '246618743249.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:1.5-1-arm64'

In [3]: sagemaker.image_uris.retrieve("xgboost", "us-west-2", version="1.5-1", instance_type="ml.m6g.xlarge", image_scope="graviton_inference")
Out[3]: '246618743249.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:1.5-1-arm64'

# This is new in this PR
In [4]: sagemaker.image_uris.retrieve("xgboost", "us-west-2", version="1.5-1", image_scope="inference_graviton")
Out[4]: '246618743249.dkr.ecr.us-west-2.amazonaws.com/sagemaker-xgboost:1.5-1-arm64'

In [5]: sagemaker.image_uris.retrieve("xgboost", "us-west-2", version="1.5-1", instance_type="ml.m5.xlarge", image_scope="inference_graviton")
ValueError: Unsupported instance type: m5. You may need to upgrade your SDK version (pip install -U sagemaker) for newer instance types. Supported instance type(s): m6g, m6gd, c6g, c6gd, c6gn, c7g, r6g, r6gd.

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 5bdd3a5
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@codecov-commenter
Copy link

codecov-commenter commented Nov 1, 2022

Codecov Report

Merging #3449 (7bfffc8) into master (1fa2377) will decrease coverage by 0.20%.
The diff coverage is 88.34%.

@@            Coverage Diff             @@
##           master    #3449      +/-   ##
==========================================
- Coverage   89.17%   88.96%   -0.21%     
==========================================
  Files         204      212       +8     
  Lines       18979    20441    +1462     
==========================================
+ Hits        16924    18186    +1262     
- Misses       2055     2255     +200     
Impacted Files Coverage Δ
src/sagemaker/feature_store/feature_group.py 76.52% <ø> (ø)
src/sagemaker/huggingface/model.py 89.87% <ø> (ø)
src/sagemaker/pipeline.py 85.33% <ø> (ø)
src/sagemaker/sklearn/model.py 92.98% <ø> (-1.76%) ⬇️
...sagemaker/workflow/monitor_batch_transform_step.py 0.00% <0.00%> (ø)
src/sagemaker/xgboost/model.py 96.36% <ø> (-1.82%) ⬇️
...agemaker/model_monitor/clarify_model_monitoring.py 89.84% <27.58%> (-5.09%) ⬇️
src/sagemaker/training_compiler/config.py 80.43% <60.00%> (-2.90%) ⬇️
src/sagemaker/pytorch/estimator.py 94.73% <63.63%> (-5.27%) ⬇️
src/sagemaker/sklearn/estimator.py 93.93% <63.63%> (-6.07%) ⬇️
... and 49 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: 5bdd3a5
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 5bdd3a5
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: a839f9f
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: a839f9f
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 66d208e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 66d208e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 66d208e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: 66d208e
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 66d208e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mabunday mabunday marked this pull request as ready for review November 2, 2022 03:22
@mabunday
Copy link
Contributor Author

mabunday commented Nov 2, 2022

Failed slow-test passed when I ran it locally with export IGNORE_COVERAGE=- ; tox -e py310 -- -s -vv tests/integ/test_clarify_model_monitor.py::test_run_explainability_monitor;

@mabunday mabunday requested a review from knikure November 2, 2022 03:25
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 32dbaf1
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: 32dbaf1
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 32dbaf1
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 32dbaf1
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 32dbaf1
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@@ -266,6 +269,7 @@ def _get_instance_type_family(instance_type):
def _get_image_tag(
container_version,
distribution,
final_image_scope,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also update the docs in line 79? I'll ping the SDK team on Slack about updating the public docs.

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: f7af490
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: f7af490
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: f7af490
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: f7af490
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@knikure knikure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/bot run pr, slow-tests

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: f7af490
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: f7af490
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mabunday mabunday requested a review from knikure November 2, 2022 21:00
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: f7af490
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@knikure knikure self-assigned this Nov 16, 2022
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: 7bfffc8
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 7bfffc8
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 7bfffc8
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 7bfffc8
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 7bfffc8
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 7bfffc8
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: 7bfffc8
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 7bfffc8
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: 7bfffc8
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@knikure knikure merged commit 75887e9 into aws:master Dec 2, 2022
mizanfiu pushed a commit to mizanfiu/sagemaker-python-sdk that referenced this pull request Dec 13, 2022
JoseJuan98 pushed a commit to JoseJuan98/sagemaker-python-sdk that referenced this pull request Mar 4, 2023
nmadan pushed a commit to nmadan/sagemaker-python-sdk that referenced this pull request Apr 18, 2023
nmadan pushed a commit to nmadan/sagemaker-python-sdk that referenced this pull request Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants