Skip to content

fix: Update neo multiversion support to include edge devices #3875

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
Jun 2, 2023
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
14 changes: 14 additions & 0 deletions src/sagemaker/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@

NEO_IOC_TARGET_DEVICES = ["ml_c4", "ml_c5", "ml_m4", "ml_m5", "ml_p2", "ml_p3", "ml_g4dn"]

NEO_MULTIVERSION_UNSUPPORTED = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious which edge targets do we want to support?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"imx8mplus",
"jacinto_tda4vm",
"coreml",
"sitara_am57x",
"amba_cv2",
"amba_cv22",
"amba_cv25",
"lambda",
]


class ModelBase(abc.ABC):
"""An object that encapsulates a trained model.
Expand Down Expand Up @@ -836,11 +847,14 @@ def multi_version_compilation_supported(
multi_version_frameworks_support_mapping = {
"inferentia": ["pytorch", "tensorflow", "mxnet"],
"neo_ioc_targets": ["pytorch", "tensorflow"],
"neo_edge_targets": ["pytorch", "tensorflow"],
}
if target_instance_type in NEO_IOC_TARGET_DEVICES:
return framework in multi_version_frameworks_support_mapping["neo_ioc_targets"]
if target_instance_type == "ml_inf1":
Copy link
Contributor

@HappyAmazonian HappyAmazonian Jun 1, 2023

Choose a reason for hiding this comment

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

Will trainium and inferentia2 support multi version too? It probably doesn't matter now. We may want to change it after they get released

return framework in multi_version_frameworks_support_mapping["inferentia"]
if target_instance_type not in NEO_MULTIVERSION_UNSUPPORTED:
return framework in multi_version_frameworks_support_mapping["neo_edge_targets"]
return False

if multi_version_compilation_supported(target_instance_type, framework, framework_version):
Expand Down
36 changes: 36 additions & 0 deletions tests/unit/sagemaker/model/test_neo.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,39 @@ def test_compile_validates_framework_version(sagemaker_session):
)

assert model.image_uri is None

sagemaker_session.wait_for_compilation_job = Mock(
return_value={
"CompilationJobStatus": "Completed",
"ModelArtifacts": {"S3ModelArtifacts": "s3://output-path/model.tar.gz"},
"InferenceImage": None,
}
)

config = model._compilation_job_config(
"rasp3b",
{"data": [1, 3, 1024, 1024]},
"s3://output",
"role",
900,
"compile-model",
"pytorch",
None,
framework_version="1.6.1",
)

assert config["input_model_config"]["FrameworkVersion"] == "1.6"

config = model._compilation_job_config(
"amba_cv2",
{"data": [1, 3, 1024, 1024]},
"s3://output",
"role",
900,
"compile-model",
"pytorch",
None,
framework_version="1.6.1",
)

assert config["input_model_config"].get("FrameworkVersion", None) is None