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

Allow updating of opt config on completion events #2961

Closed
Closed
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
17 changes: 17 additions & 0 deletions ax/telemetry/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ class ExperimentCompletedRecord:
total_fit_time: int
total_gen_time: int

# OptimizationConfig info which might be updated for human in the
# loop experiments
num_objectives: int
num_tracking_metrics: int
num_outcome_constraints: int # Includes ObjectiveThresholds in MOO

@classmethod
def from_experiment(cls, experiment: Experiment) -> ExperimentCompletedRecord:
trial_count_by_status = {
Expand Down Expand Up @@ -308,4 +314,15 @@ def from_experiment(cls, experiment: Experiment) -> ExperimentCompletedRecord:
num_early_stopped_trials=trial_count_by_status[TrialStatus.EARLY_STOPPED],
total_fit_time=int(fit_time),
total_gen_time=int(gen_time),
num_objectives=(
len(experiment.optimization_config.objective.metrics)
if experiment.optimization_config is not None
else 0
),
num_tracking_metrics=len(experiment.tracking_metrics),
num_outcome_constraints=(
len(experiment.optimization_config.outcome_constraints)
if experiment.optimization_config is not None
else 0
),
)
12 changes: 12 additions & 0 deletions ax/telemetry/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@ class OptimizationCompletedRecord:
estimated_early_stopping_savings: float
estimated_global_stopping_savings: float

# OptimizationConfig info which might be updated for human in the
# loop experiments
num_objectives: int
num_tracking_metrics: int
num_outcome_constraints: int # Includes ObjectiveThresholds in MOO

@classmethod
def from_scheduler(
cls,
Expand Down Expand Up @@ -503,6 +509,9 @@ def from_scheduler(
deployed_job_id=deployed_job_id,
estimated_early_stopping_savings=estimated_early_stopping_savings,
estimated_global_stopping_savings=estimated_global_stopping_savings,
num_objectives=experiment_completed_record.num_objectives,
num_tracking_metrics=experiment_completed_record.num_tracking_metrics,
num_outcome_constraints=experiment_completed_record.num_outcome_constraints,
)

@classmethod
Expand Down Expand Up @@ -541,6 +550,9 @@ def from_ax_client(
deployed_job_id=deployed_job_id,
estimated_early_stopping_savings=estimated_early_stopping_savings,
estimated_global_stopping_savings=estimated_global_stopping_savings,
num_objectives=experiment_completed_record.num_objectives,
num_tracking_metrics=experiment_completed_record.num_tracking_metrics,
num_outcome_constraints=experiment_completed_record.num_outcome_constraints,
# The following are not applicable for AxClient
improvement_over_baseline=float("nan"),
num_metric_fetch_e_encountered=-1,
Expand Down
3 changes: 3 additions & 0 deletions ax/telemetry/tests/test_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def test_experiment_completed_record_from_experiment(self) -> None:
num_early_stopped_trials=0,
total_fit_time=int(fit_time),
total_gen_time=int(gen_time),
num_objectives=1,
num_outcome_constraints=1,
num_tracking_metrics=1,
)
self.assertEqual(record, expected)

Expand Down