Skip to content

Commit

Permalink
Add _maybe_clear_multiplexer method to deal with memory leaks (#2642)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #2642

Adds _maybe_clear_multiplexer method, which is a no-op on base TensorboardMetric, to be implemented on its children where more is known about the multiplexer used.

Reviewed By: mpolson64

Differential Revision: D60935886
  • Loading branch information
Bernie Beckerman authored and facebook-github-bot committed Aug 8, 2024
1 parent 6afa678 commit 9ec85c6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ax/metrics/tensorboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ def bulk_fetch_trial_data(
"the curve empty in the TensorBoard UI?"
)

self._maybe_clear_multiplexer(mul)

df = (
pd.DataFrame(records)
# If a metric has multiple records for the same arm, metric, and
Expand Down Expand Up @@ -222,6 +224,15 @@ def _get_event_multiplexer_for_trial(

return mul

def _maybe_clear_multiplexer(
self, mul: event_multiplexer.EventMultiplexer
) -> None:
"""Clear the multiplexer to avoid memory leaks. This is a no-op on the base
class, to be implemented on child classes where more is known about the
multiplexer.
"""
pass

except ImportError:
logger.warning(
"tensorboard package not found. If you would like to use "
Expand Down

0 comments on commit 9ec85c6

Please sign in to comment.