Skip to content
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

enable profiler for specific ranks #451

Merged
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: 6 additions & 0 deletions megatron/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -1570,5 +1570,11 @@ def _add_profiler_args(parser):
type=str,
default='2,3',
help="Which steps to profile. Format: <start step>,<end step>")

group.add_argument("--profile-ranks",
type=int,
nargs='+',
default=None,
help="Which ranks to profile. Format: 0 1 2 3")

return parser
4 changes: 3 additions & 1 deletion megatron/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def is_end_step():
def is_capture_step():
return cur_step >= start_step and cur_step <= end_step

if args.profile.startswith('pt'):
if args.profile.startswith('pt') and (
args.profile_ranks is None or torch.distributed.get_rank() in args.profile_ranks
):
schedule = torch.profiler.schedule(wait=0, warmup=0, active=active_steps, repeat=1)
activities = [torch.profiler.ProfilerActivity.CPU]
activities.extend([torch.profiler.ProfilerActivity.HPU] if device.startswith("hpu") else [])
Expand Down