Skip to content

Commit 2418097

Browse files
committed
Fix random_sample incorrectly sampling too many configurations
1 parent 40a956e commit 2418097

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

kernel_tuner/interface.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,9 @@ def tune_kernel(
630630
if "searchspace_construction_options" in strategy_options:
631631
searchspace_construction_options = strategy_options["searchspace_construction_options"]
632632

633+
tuning_options["time_limit"] = time_limit # TODO: Is this used?
634+
tuning_options["max_fevals"] = max_fevals # TODO: Is this used?
635+
633636
# log the user inputs
634637
logging.debug("tune_kernel called")
635638
logging.debug("kernel_options: %s", util.get_config_string(kernel_options))
@@ -720,11 +723,8 @@ def preprocess_cache(filepath):
720723
logging.info(f"evaluation limit has been adjusted from {max_fevals} to {searchspace.size} (search space size)")
721724
max_fevals = searchspace.size
722725

723-
# Create the budget. Add the time spent on startup to the budget
724-
budget = util.TuningBudget(time_limit, max_fevals)
725-
tuning_options["time_limit"] = time_limit # TODO: Is this used?
726-
tuning_options["max_fevals"] = max_fevals # TODO: Is this used?
727-
tuning_options["budget"] = budget
726+
# Create the budget
727+
tuning_options["budget"] = util.TuningBudget(time_limit, max_fevals)
728728

729729

730730
# call the strategy to execute the tuning process

test/strategies/test_common.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from kernel_tuner.searchspace import Searchspace
88
from kernel_tuner.strategies import common
99
from kernel_tuner.strategies.common import CostFunc
10-
from kernel_tuner.util import StopCriterionReached
10+
from kernel_tuner.util import StopCriterionReached, TuningBudget
1111

1212
try:
1313
from mock import Mock
@@ -30,7 +30,7 @@ def fake_runner():
3030

3131
def test_cost_func():
3232
x = [1, 4]
33-
tuning_options = Options(scaling=False, snap=False, tune_params=tune_params,
33+
tuning_options = Options(tune_params=tune_params, budget=TuningBudget(),
3434
restrictions=None, strategy_options={}, cache={}, unique_results={},
3535
objective="time", objective_higher_is_better=False, metrics=None)
3636
runner = fake_runner()
@@ -41,7 +41,7 @@ def test_cost_func():
4141
# check if restrictions are properly handled
4242
def restrictions(x, y):
4343
return False
44-
tuning_options = Options(scaling=False, snap=False, tune_params=tune_params,
44+
tuning_options = Options(tune_params=tune_params, budget=TuningBudget(),
4545
restrictions=restrictions, strategy_options={},
4646
verbose=True, cache={}, unique_results={},
4747
objective="time", objective_higher_is_better=False, metrics=None)

0 commit comments

Comments
 (0)