Skip to content

Commit 71a3b7b

Browse files
ltiaofacebook-github-bot
authored andcommitted
Migrate downstream consumers to multi-metric replay API
Summary: The experiment replay system (`MapDataReplayMetric`, `MapDataReplayRunner`, `replay_experiment`) is hardcoded for single-objective optimization, blocking multi-objective early stopping. This diff series extracts shared state into a `MapDataReplayState` coordinator. This diff (3/3) migrates all downstream consumers of `replay_experiment` and `estimate_hypothetical_early_stopping_savings` from the deprecated `metric=` (singular) kwarg to the new `metrics=` (list) API introduced in D98741816, and removes the backward-compat shim from `experiment_replay.py`. Consumers updated: - `automl/internal/ax/ax_sweep/ax_sweep_orchestrator.py` - `ax/analysis/healthcheck/early_stopping_healthcheck.py` - `fblearner/flow/projects/ae/ess_replay/utils.py` Differential Revision: D98741814
1 parent 546a28b commit 71a3b7b

2 files changed

Lines changed: 5 additions & 35 deletions

File tree

ax/analysis/healthcheck/early_stopping_healthcheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ def _report_early_stopping_nudge(
413413
try:
414414
savings = estimate_hypothetical_early_stopping_savings(
415415
experiment=experiment,
416-
metric=metric,
416+
metrics=[metric],
417417
max_pending_trials=self.max_pending_trials,
418418
)
419419
except Exception as e:

ax/early_stopping/experiment_replay.py

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ def replay_experiment(
4949
historical_experiment: Experiment,
5050
num_samples_per_curve: int,
5151
max_replay_trials: int,
52-
metrics: list[Metric] | None = None,
53-
max_pending_trials: int = MAX_PENDING_TRIALS,
54-
early_stopping_strategy: BaseEarlyStoppingStrategy | None = None,
52+
metrics: list[Metric],
53+
max_pending_trials: int,
54+
early_stopping_strategy: BaseEarlyStoppingStrategy | None,
5555
logging_level: int = logging.ERROR,
56-
# Deprecated backward-compat kwarg
57-
metric: Metric | None = None,
5856
) -> Experiment | None:
5957
"""Replay a historical experiment's data through an Orchestrator.
6058
@@ -73,20 +71,7 @@ def replay_experiment(
7371
replay orchestrator.
7472
early_stopping_strategy: The early stopping strategy to evaluate.
7573
logging_level: Logging level for the orchestrator.
76-
metric: Deprecated. Use ``metrics`` instead.
7774
"""
78-
# Backward compat: accept metric= (singular) and wrap in list
79-
if metric is not None:
80-
warnings.warn(
81-
"The `metric` parameter is deprecated. Use `metrics` instead.",
82-
DeprecationWarning,
83-
stacklevel=2,
84-
)
85-
if metrics is not None:
86-
raise ValueError("Cannot specify both `metric` and `metrics`.")
87-
metrics = [metric]
88-
if metrics is None:
89-
raise ValueError("Must specify `metrics`.")
9075
warnings.warn(
9176
"The `num_samples_per_curve` parameter is deprecated and will be "
9277
"removed in a future release. The `step_size` parameter on "
@@ -195,10 +180,8 @@ def replay_experiment(
195180

196181
def estimate_hypothetical_early_stopping_savings(
197182
experiment: Experiment,
198-
metrics: list[Metric] | None = None,
183+
metrics: list[Metric],
199184
max_pending_trials: int = MAX_PENDING_TRIALS,
200-
# Deprecated backward-compat kwarg
201-
metric: Metric | None = None,
202185
) -> float:
203186
"""Estimate hypothetical early stopping savings using experiment replay.
204187
@@ -211,7 +194,6 @@ def estimate_hypothetical_early_stopping_savings(
211194
metrics: The metrics to use for early stopping replay.
212195
max_pending_trials: Maximum number of pending trials for the replay
213196
orchestrator. Defaults to 5.
214-
metric: Deprecated. Use ``metrics`` instead.
215197
216198
Returns:
217199
Estimated savings as a fraction (0.0 to 1.0).
@@ -224,18 +206,6 @@ def estimate_hypothetical_early_stopping_savings(
224206
- The experiment data does not have progression data for replay
225207
- The experiment replay fails due to invalid experiment state
226208
"""
227-
# Backward compat: accept metric= (singular) and wrap in list
228-
if metric is not None:
229-
warnings.warn(
230-
"The `metric` parameter is deprecated. Use `metrics` instead.",
231-
DeprecationWarning,
232-
stacklevel=2,
233-
)
234-
if metrics is not None:
235-
raise ValueError("Cannot specify both `metric` and `metrics`.")
236-
metrics = [metric]
237-
if metrics is None:
238-
raise ValueError("Must specify `metrics`.")
239209
default_ess = get_default_ess_or_none(experiment=experiment)
240210
if default_ess is None:
241211
raise UnsupportedError(

0 commit comments

Comments
 (0)