Skip to content

feature: Disable profiler for Trainium instance type #3442

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
Oct 27, 2022
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
5 changes: 4 additions & 1 deletion src/sagemaker/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
UploadedCode,
_region_supports_debugger,
_region_supports_profiler,
_instance_type_supports_profiler,
get_mp_parameters,
tar_and_upload_dir,
validate_source_dir,
Expand Down Expand Up @@ -592,7 +593,9 @@ def __init__(

self.max_retry_attempts = max_retry_attempts

if not _region_supports_profiler(self.sagemaker_session.boto_region_name):
if not _region_supports_profiler(
self.sagemaker_session.boto_region_name
) or _instance_type_supports_profiler(self.instance_type):
self.disable_profiler = True

self.profiler_rule_configs = None
Expand Down
16 changes: 16 additions & 0 deletions src/sagemaker/fw_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,22 @@ def _region_supports_profiler(region_name):
return region_name.lower() not in PROFILER_UNSUPPORTED_REGIONS


def _instance_type_supports_profiler(instance_type):
"""Returns bool indicating whether instance_type supports SageMaker Debugger profiling feature.

Args:
instance_type (str): Name of the instance_type to check against.

Returns:
bool: Whether or not the region supports Amazon SageMaker Debugger profiling feature.
"""
if isinstance(instance_type, str):
match = re.match(r"^ml[\._]([a-z\d]+)\.?\w*$", instance_type)
if match and match[1].startswith("trn"):
return True
return False


def validate_version_or_image_args(framework_version, py_version, image_uri):
"""Checks if version or image arguments are specified.

Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_fw_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,3 +1040,9 @@ def test_validate_unsupported_distributions_trainium_raises():
distribution=smdataparallel_enabled,
instance_type="ml.trn1.32xlarge",
)


def test_instance_type_supports_profiler():
assert fw_utils._instance_type_supports_profiler("ml.trn1.xlarge") is True
assert fw_utils._instance_type_supports_profiler("ml.m4.xlarge") is False
assert fw_utils._instance_type_supports_profiler("local") is False