Skip to content

Commit ec30052

Browse files
fix budget overshoot issue for sequential tuning
1 parent 35e61fb commit ec30052

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

kernel_tuner/runners/sequential.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,7 @@ def run(self, parameter_space, tuning_options):
132132

133133
# all visited configurations are added to results to provide a trace for optimization strategies
134134
results.append(params)
135+
if x_int not in tuning_options.unique_results:
136+
tuning_options.unique_results[x_int] = result
135137

136138
return results

kernel_tuner/runners/simulation.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def run(self, parameter_space, tuning_options):
136136
result["framework_time"] = total_time
137137

138138
results.append(result)
139+
if x_int not in tuning_options.unique_results:
140+
tuning_options.unique_results[x_int] = result
139141
continue
140142

141143
# if the configuration is not in the cache and not within restrictions, simulate an InvalidConfig with warning

kernel_tuner/strategies/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ def _run_configs(self, xs, check_restrictions=True):
188188
self.tuning_options.unique_results[x_int] = result
189189

190190
# check again for stop condition
191+
# this check is necessary because some strategies cannot handle partially completed requests
192+
# for example when only half of the configs in a population have been evaluated
191193
self.budget_spent_fraction = util.check_stop_criterion(self.tuning_options)
192194

193195
# upon returning from this function control will be given back to the strategy, so reset the start time

test/test_runners.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ def test_runner(env):
287287
device_options = Options([(k, opts.get(k, None))
288288
for k in _device_options.keys()])
289289
tuning_options.cachefile = None
290+
tuning_options.unique_results = {}
290291

291292
# create runner
292293
runner = SequentialRunner(kernelsource,

0 commit comments

Comments
 (0)