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

Makes the with_stack of the profiler changeable #1497

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions optimum/habana/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ def hpu_deepspeed_checkpointing(function, *checkpoint_args, use_reentrant: Optio
warmup=self.args.profiling_warmup_steps,
active=self.args.profiling_steps,
record_shapes=self.args.profiling_record_shapes,
with_stack=self.args.profiling_with_stack,
)
hb_profiler.start()

Expand Down
5 changes: 5 additions & 0 deletions optimum/habana/transformers/training_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ class GaudiTrainingArguments(TrainingArguments):
default=True,
metadata={"help": ("Record shapes when enabling profiling.")},
)

profiling_with_stack: Optional[bool] = field(
default=False,
metadata={"help": ("record source information (file and line number) for the ops when enabling profiling.")},
)
# Overriding the default value of optim because 'adamw_hf' is deprecated
optim: Optional[Union[OptimizerNames, str]] = field(
default="adamw_torch",
Expand Down
3 changes: 2 additions & 1 deletion optimum/habana/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ def __init__(
warmup: int = 0,
active: int = 0,
record_shapes: bool = True,
with_stack: bool = False,
output_dir: str = "./hpu_profile",
wait: int = 0,
):
Expand All @@ -306,7 +307,7 @@ def noop():
activities=activities,
on_trace_ready=torch.profiler.tensorboard_trace_handler(output_dir),
record_shapes=record_shapes,
with_stack=False,
with_stack=with_stack,
)
self.start = profiler.start
self.stop = profiler.stop
Expand Down