Skip to content

Commit

Permalink
Use min trials, not arbitrary 0 (#2148)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #2148

I think this must have been a mistake

Reviewed By: esantorella

Differential Revision: D52847552

fbshipit-source-id: 3da6dbd2d45128f0bd5d748f10295c86991e7a84
  • Loading branch information
Daniel Cohen authored and facebook-github-bot committed Jan 24, 2024
1 parent f9cb349 commit 80d346b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 6 additions & 2 deletions ax/global_stopping/strategies/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ def should_stop_optimization(
message = "There are pending trials in the experiment."
return False, message

if len(experiment.trials_by_status[TrialStatus.COMPLETED]) == 0:
message = "There are no completed trials yet."
num_completed_trials = len(experiment.trials_by_status[TrialStatus.COMPLETED])
if num_completed_trials < self.min_trials:
message = (
f"There are only {num_completed_trials} completed trials, "
f"but {self} has a minumum of {self.min_trials}."
)
return False, message

return self._should_stop_optimization(experiment, **kwargs)
7 changes: 3 additions & 4 deletions ax/global_stopping/tests/tests_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_base_cases(self) -> None:
self.assertFalse(stop)
self.assertEqual(
message,
"There are no completed trials yet.",
f"There are only 0 completed trials, but {gss_2} has a minumum of 2.",
)

# Insufficient trials to stop.
Expand All @@ -60,8 +60,7 @@ def test_base_cases(self) -> None:
self.assertFalse(stop)
self.assertEqual(
message,
"There are not enough completed trials to "
"make a stopping decision (completed: 1, required: 3).",
f"There are only 1 completed trials, but {gss} has a minumum of 2.",
)

# Check that we properly count completed trials.
Expand Down Expand Up @@ -358,7 +357,7 @@ def test_safety_check(self) -> None:
self.assertFalse(stop)
self.assertEqual(
message,
"There are no completed trials yet.",
f"There are only 0 completed trials, but {gss} has a minumum of 2.",
)

def test_constraint_satisfaction(self) -> None:
Expand Down

0 comments on commit 80d346b

Please sign in to comment.