Skip to content

feature: support PyTorch 1.7.1 training, inference and data parallel #2185

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 9 commits into from
Mar 3, 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
2 changes: 1 addition & 1 deletion 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.0", "2.3.1"],
"pytorch": ["1.6.0"],
"pytorch": ["1.6.0", "1.7.1"],
}
SMDISTRIBUTED_SUPPORTED_STRATEGIES = ["dataparallel", "modelparallel"]

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 @@ -54,7 +54,8 @@
"1.3": "1.3.1",
"1.4": "1.4.0",
"1.5": "1.5.0",
"1.6": "1.6.0"
"1.6": "1.6.0",
"1.7": "1.7.1"
},
"versions": {
"0.4.0": {
Expand Down Expand Up @@ -318,6 +319,39 @@
"us-west-2": "763104351884"
},
"repository": "pytorch-inference"
},
"1.7.1": {
"py_versions": [
"py3",
"py36"
],
"registries": {
"af-south-1": "626614931356",
"ap-east-1": "871362719292",
"ap-northeast-1": "763104351884",
"ap-northeast-2": "763104351884",
"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 @@ -334,7 +368,8 @@
"1.3": "1.3.1",
"1.4": "1.4.0",
"1.5": "1.5.0",
"1.6": "1.6.0"
"1.6": "1.6.0",
"1.7": "1.7.1"
},
"versions": {
"0.4.0": {
Expand Down Expand Up @@ -599,6 +634,39 @@
"us-west-2": "763104351884"
},
"repository": "pytorch-training"
},
"1.7.1": {
"py_versions": [
"py3",
"py36"
],
"registries": {
"af-south-1": "626614931356",
"ap-east-1": "871362719292",
"ap-northeast-1": "763104351884",
"ap-northeast-2": "763104351884",
"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
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,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"
else:
return "py3"

Expand All @@ -181,6 +183,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"
else:
return "py3"

Expand Down
7 changes: 4 additions & 3 deletions tests/data/smdistributed_dataparallel/mnist_pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from __future__ import print_function

import argparse
import os
import time
import torch
import torch.nn as nn
Expand Down Expand Up @@ -150,8 +151,8 @@ def main():
parser.add_argument(
"--data-path",
type=str,
default="/tmp/data",
help="Path for downloading " "the MNIST dataset",
default=os.environ["SM_CHANNEL_TRAINING"],
help="Path for downloading the MNIST dataset",
)

args = parser.parse_args()
Expand Down Expand Up @@ -186,7 +187,7 @@ def main():
train_dataset = datasets.MNIST(
data_path,
train=True,
download=True,
download=False, # True sets a dependency on an external site for our tests.
transform=transforms.Compose(
[transforms.ToTensor(), transforms.Normalize((0.1307,), (0.3081,))]
),
Expand Down
4 changes: 2 additions & 2 deletions tests/integ/test_smdataparallel_pt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from sagemaker.pytorch import PyTorch
from tests.integ import timeout

from tests.integ.test_pytorch import _upload_training_data

smdataparallel_dir = os.path.join(
os.path.dirname(__file__), "..", "data", "smdistributed_dataparallel"
Expand Down Expand Up @@ -51,4 +51,4 @@ def test_smdataparallel_pt_mnist(
)

with timeout.timeout(minutes=integ.TRAINING_DEFAULT_TIMEOUT_MINUTES):
estimator.fit(job_name=job_name)
estimator.fit({"training": _upload_training_data(estimator)}, job_name=job_name)
1 change: 1 addition & 0 deletions tests/unit/test_fw_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ def test_validate_smdataparallel_args_not_raises():
(None, None, None, None, smdataparallel_disabled),
("ml.p3.16xlarge", "tensorflow", "2.3.1", "py3", smdataparallel_enabled),
("ml.p3.16xlarge", "pytorch", "1.6.0", "py3", smdataparallel_enabled),
("ml.p3.16xlarge", "pytorch", "1.7.1", "py3", smdataparallel_enabled),
]
for instance_type, framework_name, framework_version, py_version, distribution in good_args:
fw_utils._validate_smdataparallel_args(
Expand Down