@@ -15,7 +15,7 @@ def tune(searchspace: Searchspace, runner, tuning_options):
15
15
from pyatf .search_techniques .search_technique import SearchTechnique
16
16
17
17
# setup the Kernel Tuner functionalities
18
- cost_func = CostFunc (searchspace , tuning_options , runner , scaling = True , snap = True )
18
+ cost_func = CostFunc (searchspace , tuning_options , runner , scaling = True , snap = True , return_invalid = True )
19
19
# using this instead of get_bounds because scaling is used
20
20
bounds , _ , eps = cost_func .get_bounds_x0_eps ()
21
21
@@ -39,10 +39,11 @@ def tune(searchspace: Searchspace, runner, tuning_options):
39
39
get_next_coordinates_or_indices = search_technique .get_next_coordinates
40
40
coordinates_or_indices = set () # Set[Union[Coordinates, Index]]
41
41
costs = {} # Dict[Union[Coordinates, Index], Cost]
42
+ eval_count = 0
42
43
43
44
try :
44
45
# optimization loop (KT-compatible re-implementation of `make_step` from TuningRun)
45
- while True :
46
+ while eval_count < searchspace . size :
46
47
47
48
# get new coordinates
48
49
if not coordinates_or_indices :
@@ -62,13 +63,14 @@ def tune(searchspace: Searchspace, runner, tuning_options):
62
63
coords_or_index = tuple (b [0 ]+ c * (b [1 ]- b [0 ]) for c , b in zip (coords_or_index , bounds ) if c is not None )
63
64
64
65
# evaluate the configuration
65
- opt_result = cost_func (coords_or_index )
66
+ opt_result = cost_func (coords_or_index )
66
67
67
68
# adjust opt_result to expected PyATF output in cost and valid
68
69
if not isinstance (opt_result , (int , float )):
69
70
valid = False
70
71
else :
71
72
cost = opt_result
73
+ eval_count += 1
72
74
73
75
# record the evaluation
74
76
costs [coords_or_index ] = cost
0 commit comments