Skip to content

Commit 7d93855

Browse files
committed
Ensure the time limit is still checked if we also have a fevals budget
1 parent fbb1c19 commit 7d93855

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernel_tuner/util.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,13 @@ def check_stop_criterion(to: dict) -> float:
200200
StopCriterionReached: if the max_fevals is reached or time limit is exceeded.
201201
202202
Returns:
203-
float: fraction of budget spent.
203+
float: fraction of budget spent. If both max_fevals and time_limit are set, it returns the fraction of time.
204204
"""
205205
if "max_fevals" in to:
206206
if len(to.unique_results) >= to.max_fevals:
207207
raise StopCriterionReached(f"max_fevals ({to.max_fevals}) reached")
208-
return len(to.unique_results) / to.max_fevals
208+
if not "time_limit" in to:
209+
return len(to.unique_results) / to.max_fevals
209210
if "time_limit" in to:
210211
time_spent = (time.perf_counter() - to.start_time) + (to.simulated_time * 1e-3) + to.startup_time
211212
if time_spent > to.time_limit:

0 commit comments

Comments
 (0)