Skip to content

feature: Support profiler config in the pipeline training job step #2183

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 6 commits into from
Mar 4, 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
3 changes: 0 additions & 3 deletions src/sagemaker/workflow/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ def arguments(self) -> RequestType:
NOTE: The CreateTrainingJob request is not quite the args list that workflow needs.
The TrainingJobName and ExperimentConfig attributes cannot be included.
"""
self.estimator.disable_profiler = True
self.estimator.profiler_config = None
self.estimator.profiler_rules = None
Comment on lines -163 to -165
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any edge cases that can arise by having it enabled by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. We enable the profiler by default if a user launch a training job directly by doing estimator.fit(). We could do the same for pipeline users.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add an integ test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Updated the existing test to verify the profiler config.

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome! Does this work in every region?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Profiler config is not available in CN, or GovCloud, pipeline is not available in those regions either.


self.estimator._prepare_for_training()
train_args = _TrainingJob._get_train_args(
Expand Down
5 changes: 4 additions & 1 deletion tests/integ/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def test_conditional_pytorch_training_model_registration(
pass


def test_training_job_with_debugger(
def test_training_job_with_debugger_and_profiler(
sagemaker_session,
pipeline_name,
role,
Expand Down Expand Up @@ -535,6 +535,9 @@ def test_training_job_with_debugger(
config["RuleParameters"]["rule_to_invoke"] == rule.rule_parameters["rule_to_invoke"]
)
assert job_description["DebugHookConfig"] == debugger_hook_config._to_request_dict()

assert job_description["ProfilingStatus"] == "Enabled"
assert job_description["ProfilerConfig"]["ProfilingIntervalInMilliseconds"] == 500
finally:
try:
pipeline.delete()
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/sagemaker/workflow/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
PropertyMock,
)

from sagemaker.debugger import ProfilerConfig
from sagemaker.estimator import Estimator
from sagemaker.inputs import TrainingInput, TransformInput, CreateModelInput
from sagemaker.model import Model
Expand Down Expand Up @@ -112,6 +113,8 @@ def test_training_step(sagemaker_session):
role=ROLE,
instance_count=1,
instance_type="c4.4xlarge",
profiler_config=ProfilerConfig(system_monitor_interval_millis=500),
rules=[],
sagemaker_session=sagemaker_session,
)
inputs = TrainingInput(f"s3://{BUCKET}/train_manifest")
Expand Down Expand Up @@ -144,6 +147,10 @@ def test_training_step(sagemaker_session):
},
"RoleArn": ROLE,
"StoppingCondition": {"MaxRuntimeInSeconds": 86400},
"ProfilerConfig": {
"ProfilingIntervalInMilliseconds": 500,
"S3OutputPath": f"s3://{BUCKET}/",
},
},
"CacheConfig": {"Enabled": True, "ExpireAfter": "PT1H"},
}
Expand Down