-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Use specific images for SMP v2 jobs #4333
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d339269
Add check for smp lib
Teng-xu c9098b4
update syntax
Teng-xu 9dfb234
Remove unused images
Teng-xu 4302c16
Update repo name and regions
Teng-xu e01aeea
Update account number
Teng-xu ecc1301
Update framework name and check for None distribution
Teng-xu b296227
Add unit tests for smp v2 uri
Teng-xu 5342d59
Check enabled
Teng-xu e8edeaa
Remove logging
Teng-xu 42c58eb
Add cuda version in uri
Teng-xu 9d202e6
Update cu121
Teng-xu 3e73f71
Update syntax
Teng-xu 8bffacc
Fix black check
1344b23
Fix black
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,37 @@ | ||
{ | ||
"training": { | ||
"processors": [ | ||
"gpu" | ||
], | ||
"version_aliases": { | ||
"2.0": "2.0.1" | ||
}, | ||
"versions": { | ||
"2.0.1": { | ||
"py_versions": [ | ||
"py310" | ||
], | ||
"registries": { | ||
"ap-northeast-1": "658645717510", | ||
"ap-northeast-2": "658645717510", | ||
"ap-northeast-3": "658645717510", | ||
"ap-south-1": "658645717510", | ||
"ap-southeast-1": "658645717510", | ||
"ap-southeast-2": "658645717510", | ||
"ca-central-1": "658645717510", | ||
"eu-central-1": "658645717510", | ||
"eu-north-1": "658645717510", | ||
"eu-west-1": "658645717510", | ||
"eu-west-2": "658645717510", | ||
"eu-west-3": "658645717510", | ||
"sa-east-1": "658645717510", | ||
"us-east-1": "658645717510", | ||
"us-east-2": "658645717510", | ||
"us-west-1": "658645717510", | ||
"us-west-2": "658645717510" | ||
}, | ||
"repository": "smdistributed-modelparallel" | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -27,7 +27,10 @@ | |
from sagemaker.jumpstart import artifacts | ||
from sagemaker.workflow import is_pipeline_variable | ||
from sagemaker.workflow.utilities import override_pipeline_parameter_var | ||
from sagemaker.fw_utils import GRAVITON_ALLOWED_TARGET_INSTANCE_FAMILY, GRAVITON_ALLOWED_FRAMEWORKS | ||
from sagemaker.fw_utils import ( | ||
GRAVITON_ALLOWED_TARGET_INSTANCE_FAMILY, | ||
GRAVITON_ALLOWED_FRAMEWORKS, | ||
) | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
@@ -343,7 +346,8 @@ def _config_for_framework_and_scope(framework, image_scope, accelerator_type=Non | |
|
||
if image_scope not in ("eia", "inference"): | ||
logger.warning( | ||
"Elastic inference is for inference only. Ignoring image scope: %s.", image_scope | ||
"Elastic inference is for inference only. Ignoring image scope: %s.", | ||
image_scope, | ||
) | ||
image_scope = "eia" | ||
|
||
|
@@ -660,6 +664,17 @@ def get_training_image_uri( | |
container_version = None | ||
base_framework_version = None | ||
|
||
# Check for smp library | ||
if distribution is not None: | ||
if "torch_distributed" in distribution and "smdistributed" in distribution: | ||
if "modelparallel" in distribution["smdistributed"]: | ||
if distribution["smdistributed"]["modelparallel"].get("enabled", True): | ||
framework = "pytorch-smp" | ||
if "p5" in instance_type: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need tests to cover 1) both cases and 2) SMP not enabled case. |
||
container_version = "cu121" | ||
else: | ||
container_version = "cu118" | ||
|
||
return retrieve( | ||
framework, | ||
region, | ||
|
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,53 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"). You | ||
# may not use this file except in compliance with the License. A copy of | ||
# the License is located at | ||
# | ||
# http://aws.amazon.com/apache2.0/ | ||
# | ||
# or in the "license" file accompanying this file. This file is | ||
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific | ||
# language governing permissions and limitations under the License. | ||
from __future__ import absolute_import | ||
|
||
import pytest | ||
from sagemaker import image_uris | ||
from tests.unit.sagemaker.image_uris import expected_uris | ||
|
||
CONTAINER_VERSIONS = {"ml.p4d.24xlarge": "cu118", "ml.p5d.24xlarge": "cu121"} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here it has a typo, I believe it should be |
||
|
||
|
||
@pytest.mark.parametrize("load_config", ["pytorch-smp.json"], indirect=True) | ||
def test_smp_v2(load_config): | ||
VERSIONS = load_config["training"]["versions"] | ||
PROCESSORS = load_config["training"]["processors"] | ||
distribution = { | ||
"torch_distributed": {"enabled": True}, | ||
"smdistributed": {"modelparallel": {"enabled": True}}, | ||
} | ||
for processor in PROCESSORS: | ||
for version in VERSIONS: | ||
ACCOUNTS = load_config["training"]["versions"][version]["registries"] | ||
PY_VERSIONS = load_config["training"]["versions"][version]["py_versions"] | ||
for py_version in PY_VERSIONS: | ||
for region in ACCOUNTS.keys(): | ||
for instance_type in CONTAINER_VERSIONS.keys(): | ||
uri = image_uris.get_training_image_uri( | ||
region, | ||
framework="pytorch", | ||
framework_version=version, | ||
py_version=py_version, | ||
distribution=distribution, | ||
instance_type=instance_type, | ||
) | ||
expected = expected_uris.framework_uri( | ||
repo="smdistributed-modelparallel", | ||
fw_version=version, | ||
py_version=f"{py_version}-{CONTAINER_VERSIONS[instance_type]}", | ||
processor=processor, | ||
region=region, | ||
account=ACCOUNTS[region], | ||
) | ||
assert expected == uri |
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.
nit: Can simplify as