Skip to content

Commit

Permalink
Allow running profiler on specific steps.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 662014698
  • Loading branch information
CLU Authors authored and copybara-github committed Aug 12, 2024
1 parent b64aa29 commit 7c22ddf
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions clu/periodic_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def __init__(
first_profile: int = 10,
every_steps: Optional[int] = None,
every_secs: Optional[float] = 3600.0,
on_steps: Optional[Iterable[int]] = None,
artifact_name: str = "[{step}] Profile",
):
"""Initializes a new periodic profiler action.
Expand All @@ -322,12 +323,15 @@ def __init__(
first_profile: First step at which a profile is started.
every_steps: See `PeriodicAction.__init__()`.
every_secs: See `PeriodicAction.__init__()`.
on_steps: See `PeriodicAction.__init__()`.
artifact_name: Name of the artifact to record.
"""
if not num_profile_steps and not profile_duration_ms:
raise ValueError(
"Must specify num_profile_steps and/or profile_duration_ms.")
super().__init__(every_steps=every_steps, every_secs=every_secs)
super().__init__(
every_steps=every_steps, every_secs=every_secs, on_steps=on_steps
)
self._num_profile_steps = num_profile_steps
self._first_profile = first_profile
self._profile_duration_ms = profile_duration_ms
Expand Down Expand Up @@ -383,7 +387,8 @@ def __init__(self,
profile_duration_ms: int = 3_000,
first_profile: int = 10,
every_steps: Optional[int] = None,
every_secs: Optional[float] = 3600.0):
every_secs: Optional[float] = 3600.0,
on_steps: Optional[Iterable[int]] = None):
"""Initializes a new periodic profiler action.
Args:
Expand All @@ -394,8 +399,11 @@ def __init__(self,
first_profile: First step at which a profile is started.
every_steps: See `PeriodicAction.__init__()`.
every_secs: See `PeriodicAction.__init__()`.
on_steps: See `PeriodicAction.__init__()`.
"""
super().__init__(every_steps=every_steps, every_secs=every_secs)
super().__init__(
every_steps=every_steps, every_secs=every_secs, on_steps=on_steps
)
self._hosts = hosts
self._first_profile = first_profile
self._profile_duration_ms = profile_duration_ms
Expand Down

0 comments on commit 7c22ddf

Please sign in to comment.