Skip to content

Commit 95dceca

Browse files
Daniel Cohenfacebook-github-bot
Daniel Cohen
authored andcommitted
Allow updating of opt config on completion events (#2961)
Summary: Pull Request resolved: #2961 This will allow for accuracy in human in the loop experiments where metrics change through the lifecycle of experiments. Reviewed By: mgarrard Differential Revision: D61996011 fbshipit-source-id: d9ea911aae64624ec5bb0b010adc78ad052b5126
1 parent 3aaca44 commit 95dceca

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

ax/telemetry/experiment.py

+17
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,12 @@ class ExperimentCompletedRecord:
263263
total_fit_time: int
264264
total_gen_time: int
265265

266+
# OptimizationConfig info which might be updated for human in the
267+
# loop experiments
268+
num_objectives: int
269+
num_tracking_metrics: int
270+
num_outcome_constraints: int # Includes ObjectiveThresholds in MOO
271+
266272
@classmethod
267273
def from_experiment(cls, experiment: Experiment) -> ExperimentCompletedRecord:
268274
trial_count_by_status = {
@@ -308,4 +314,15 @@ def from_experiment(cls, experiment: Experiment) -> ExperimentCompletedRecord:
308314
num_early_stopped_trials=trial_count_by_status[TrialStatus.EARLY_STOPPED],
309315
total_fit_time=int(fit_time),
310316
total_gen_time=int(gen_time),
317+
num_objectives=(
318+
len(experiment.optimization_config.objective.metrics)
319+
if experiment.optimization_config is not None
320+
else 0
321+
),
322+
num_tracking_metrics=len(experiment.tracking_metrics),
323+
num_outcome_constraints=(
324+
len(experiment.optimization_config.outcome_constraints)
325+
if experiment.optimization_config is not None
326+
else 0
327+
),
311328
)

ax/telemetry/optimization.py

+12
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,12 @@ class OptimizationCompletedRecord:
458458
estimated_early_stopping_savings: float
459459
estimated_global_stopping_savings: float
460460

461+
# OptimizationConfig info which might be updated for human in the
462+
# loop experiments
463+
num_objectives: int
464+
num_tracking_metrics: int
465+
num_outcome_constraints: int # Includes ObjectiveThresholds in MOO
466+
461467
@classmethod
462468
def from_scheduler(
463469
cls,
@@ -503,6 +509,9 @@ def from_scheduler(
503509
deployed_job_id=deployed_job_id,
504510
estimated_early_stopping_savings=estimated_early_stopping_savings,
505511
estimated_global_stopping_savings=estimated_global_stopping_savings,
512+
num_objectives=experiment_completed_record.num_objectives,
513+
num_tracking_metrics=experiment_completed_record.num_tracking_metrics,
514+
num_outcome_constraints=experiment_completed_record.num_outcome_constraints,
506515
)
507516

508517
@classmethod
@@ -541,6 +550,9 @@ def from_ax_client(
541550
deployed_job_id=deployed_job_id,
542551
estimated_early_stopping_savings=estimated_early_stopping_savings,
543552
estimated_global_stopping_savings=estimated_global_stopping_savings,
553+
num_objectives=experiment_completed_record.num_objectives,
554+
num_tracking_metrics=experiment_completed_record.num_tracking_metrics,
555+
num_outcome_constraints=experiment_completed_record.num_outcome_constraints,
544556
# The following are not applicable for AxClient
545557
improvement_over_baseline=float("nan"),
546558
num_metric_fetch_e_encountered=-1,

ax/telemetry/tests/test_experiment.py

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def test_experiment_completed_record_from_experiment(self) -> None:
6666
num_early_stopped_trials=0,
6767
total_fit_time=int(fit_time),
6868
total_gen_time=int(gen_time),
69+
num_objectives=1,
70+
num_outcome_constraints=1,
71+
num_tracking_metrics=1,
6972
)
7073
self.assertEqual(record, expected)
7174

0 commit comments

Comments
 (0)