Skip to content

feature: add support for PyTorch 1.9.0 #2653

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 14 commits into from
Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/sagemaker/fw_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
)
SM_DATAPARALLEL_SUPPORTED_FRAMEWORK_VERSIONS = {
"tensorflow": ["2.3", "2.3.1", "2.3.2", "2.4", "2.4.1"],
"pytorch": ["1.6", "1.6.0", "1.7", "1.7.1", "1.8", "1.8.0", "1.8.1"],
"pytorch": ["1.6", "1.6.0", "1.7", "1.7.1", "1.8", "1.8.0", "1.8.1", "1.9", "1.9.0"],
}
SMDISTRIBUTED_SUPPORTED_STRATEGIES = ["dataparallel", "modelparallel"]

Expand Down Expand Up @@ -298,7 +298,7 @@ def framework_name_from_image(image_uri):
(tensorflow|mxnet|chainer|pytorch|scikit-learn|xgboost
|huggingface-tensorflow|huggingface-pytorch)(?:-)?
(scriptmode|training)?
:(.*)-(.*?)-(py2|py3[67]?)(?:.*)$""",
:(.*)-(.*?)-(py2|py3\d*)(?:.*)$""",
re.VERBOSE,
)
name_match = name_pattern.match(sagemaker_match.group(9))
Expand Down Expand Up @@ -329,7 +329,7 @@ def framework_version_from_tag(image_tag):
Returns:
str: The framework version.
"""
tag_pattern = re.compile("^(.*)-(cpu|gpu)-(py2|py3[67]?)$")
tag_pattern = re.compile(r"^(.*)-(cpu|gpu)-(py2|py3\d*)$")
tag_match = tag_pattern.match(image_tag)
return None if tag_match is None else tag_match.group(1)

Expand Down
72 changes: 70 additions & 2 deletions src/sagemaker/image_uri_config/pytorch.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"1.5": "1.5.0",
"1.6": "1.6.0",
"1.7": "1.7.1",
"1.8": "1.8.1"
"1.8": "1.8.1",
"1.9": "1.9.0"
},
"versions": {
"0.4.0": {
Expand Down Expand Up @@ -433,6 +434,39 @@
"us-west-2": "763104351884"
},
"repository": "pytorch-inference"
},
"1.9.0": {
"py_versions": [
"py38"
],
"registries": {
"af-south-1": "626614931356",
"ap-east-1": "871362719292",
"ap-northeast-1": "763104351884",
"ap-northeast-2": "763104351884",
"ap-northeast-3": "364406365360",
"ap-south-1": "763104351884",
"ap-southeast-1": "763104351884",
"ap-southeast-2": "763104351884",
"ca-central-1": "763104351884",
"cn-north-1": "727897471807",
"cn-northwest-1": "727897471807",
"eu-central-1": "763104351884",
"eu-north-1": "763104351884",
"eu-west-1": "763104351884",
"eu-west-2": "763104351884",
"eu-west-3": "763104351884",
"eu-south-1": "692866216735",
"me-south-1": "217643126080",
"sa-east-1": "763104351884",
"us-east-1": "763104351884",
"us-east-2": "763104351884",
"us-gov-west-1": "442386744353",
"us-iso-east-1": "886529160074",
"us-west-1": "763104351884",
"us-west-2": "763104351884"
},
"repository": "pytorch-inference"
}
}
},
Expand All @@ -451,7 +485,8 @@
"1.5": "1.5.0",
"1.6": "1.6.0",
"1.7": "1.7.1",
"1.8": "1.8.1"
"1.8": "1.8.1",
"1.9": "1.9.0"
},
"versions": {
"0.4.0": {
Expand Down Expand Up @@ -823,6 +858,39 @@
"us-west-2": "763104351884"
},
"repository": "pytorch-training"
},
"1.9.0": {
"py_versions": [
"py38"
],
"registries": {
"af-south-1": "626614931356",
"ap-east-1": "871362719292",
"ap-northeast-1": "763104351884",
"ap-northeast-2": "763104351884",
"ap-northeast-3": "364406365360",
"ap-south-1": "763104351884",
"ap-southeast-1": "763104351884",
"ap-southeast-2": "763104351884",
"ca-central-1": "763104351884",
"cn-north-1": "727897471807",
"cn-northwest-1": "727897471807",
"eu-central-1": "763104351884",
"eu-north-1": "763104351884",
"eu-west-1": "763104351884",
"eu-west-2": "763104351884",
"eu-west-3": "763104351884",
"eu-south-1": "692866216735",
"me-south-1": "217643126080",
"sa-east-1": "763104351884",
"us-east-1": "763104351884",
"us-east-2": "763104351884",
"us-gov-west-1": "442386744353",
"us-iso-east-1": "886529160074",
"us-west-1": "763104351884",
"us-west-2": "763104351884"
},
"repository": "pytorch-training"
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def mxnet_eia_latest_py_version():
def pytorch_training_py_version(pytorch_training_version, request):
if Version(pytorch_training_version) < Version("1.5.0"):
return request.param
elif Version(pytorch_training_version) == Version("1.7.1"):
return "py36"
elif Version(pytorch_training_version) >= Version("1.9"):
return "py38"
else:
return "py3"

Expand All @@ -194,8 +194,8 @@ def pytorch_training_py_version(pytorch_training_version, request):
def pytorch_inference_py_version(pytorch_inference_version, request):
if Version(pytorch_inference_version) < Version("1.4.0"):
return request.param
elif Version(pytorch_inference_version) == Version("1.7.1"):
return "py36"
elif Version(pytorch_inference_version) >= Version("1.9"):
return "py38"
else:
return "py3"

Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_fw_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ def test_validate_smdataparallel_args_not_raises():
("ml.p3.16xlarge", "pytorch", "1.8", "py3", smdataparallel_enabled),
("ml.p3.16xlarge", "tensorflow", "2.4.1", "py3", smdataparallel_enabled_custom_mpi),
("ml.p3.16xlarge", "pytorch", "1.8.0", "py3", smdataparallel_enabled_custom_mpi),
("ml.p3.16xlarge", "pytorch", "1.9.0", "py3", smdataparallel_enabled_custom_mpi),
]
for instance_type, framework_name, framework_version, py_version, distribution in good_args:
fw_utils._validate_smdataparallel_args(
Expand Down
20 changes: 15 additions & 5 deletions tests/unit/test_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,20 @@ def test_sklearn_with_all_parameters_via_run_args_called_twice(
@patch("os.path.exists", return_value=True)
@patch("os.path.isfile", return_value=True)
def test_pytorch_processor_with_required_parameters(
exists_mock, isfile_mock, botocore_resolver, sagemaker_session, pytorch_training_version
exists_mock,
isfile_mock,
botocore_resolver,
sagemaker_session,
pytorch_training_version,
pytorch_training_py_version,
):
botocore_resolver.return_value.construct_endpoint.return_value = {"hostname": ECR_HOSTNAME}

processor = PyTorchProcessor(
role=ROLE,
instance_type="ml.m4.xlarge",
framework_version=pytorch_training_version,
py_version=pytorch_training_py_version,
instance_count=1,
sagemaker_session=sagemaker_session,
)
Expand All @@ -302,12 +308,16 @@ def test_pytorch_processor_with_required_parameters(

if version.parse(pytorch_training_version) < version.parse("1.2"):
pytorch_image_uri = (
"520713654638.dkr.ecr.us-west-2.amazonaws.com/sagemaker-pytorch:{}-cpu-py3"
).format(pytorch_training_version)
"520713654638.dkr.ecr.us-west-2.amazonaws.com/sagemaker-pytorch:{}-cpu-{}".format(
pytorch_training_version, pytorch_training_py_version
)
)
else:
pytorch_image_uri = (
"763104351884.dkr.ecr.us-west-2.amazonaws.com/pytorch-training:{}-cpu-py3"
).format(pytorch_training_version)
"763104351884.dkr.ecr.us-west-2.amazonaws.com/pytorch-training:{}-cpu-{}".format(
pytorch_training_version, pytorch_training_py_version
)
)

expected_args["app_specification"]["ImageUri"] = pytorch_image_uri

Expand Down