Skip to content

Commit da35b69

Browse files
committed
Added interface support for setting time as cutoff_type and setting cutoff_margin per strategy
1 parent 4d2c42b commit da35b69

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

experiment_files/example_visualizations.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"objective_performance_keys": [
2727
"time"
2828
],
29-
"cutoff_type": "fevals",
29+
"cutoff_type": "time",
3030
"plot": {
3131
"plot_x_value_types": [
3232
"fevals",
@@ -44,6 +44,7 @@
4444
"strategy_defaults": {
4545
"repeats": 100,
4646
"minimum_number_of_evaluations": 20,
47+
"cutoff_margin": 1.1,
4748
"stochastic": true,
4849
"record_data": [
4950
"time",

src/autotuning_methodology/experiments.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def execute_experiment(filepath: str, profiling: bool = False) -> tuple[dict, di
139139
assert cutoff_type == "fevals" or cutoff_type == "time", f"cutoff_type must be 'fevals' or 'time', is {cutoff_type}"
140140
curve_segment_factor: float = experiment.get("curve_segment_factor", 0.05)
141141
assert isinstance(curve_segment_factor, float), f"curve_segment_factor is not float, {type(curve_segment_factor)}"
142-
strategies = get_strategies(experiment)
142+
strategies: list[dict] = get_strategies(experiment)
143143

144144
# add the kernel directory to the path to import the module, relative to the experiment file
145145
kernels_path = experiment_folderpath / Path(experiment["kernels_path"])
@@ -179,20 +179,22 @@ def execute_experiment(filepath: str, profiling: bool = False) -> tuple[dict, di
179179
strategy_name: str = strategy["name"]
180180
strategy_display_name: str = strategy["display_name"]
181181
stochastic = strategy["stochastic"]
182+
cutoff_margin = strategy.get(
183+
"cutoff_margin", 1.1
184+
) # +10% margin, to make sure cutoff_point is reached by compensating for potential non-valid evaluations # noqa: E501
182185
print(f" | - | using strategy '{strategy['display_name']}'")
183186

184187
# setup the results description
185188
if "options" not in strategy:
186189
strategy["options"] = dict()
187-
cutoff_margin = 1.1 # +10% margin, to make sure cutoff_point is reached by compensating for potential non-valid evaluations # noqa: E501
188-
189-
# TODO make sure this works correctly
190-
# if cutoff_type == 'time':
191-
# strategy['options']['time_limit'] = cutoff_point_time * cutoff_margin
192-
# else:
193-
strategy["options"]["max_fevals"] = min(
194-
int(ceil(cutoff_point_fevals * cutoff_margin)), searchspace_stats.size
195-
)
190+
191+
# set when to stop
192+
if cutoff_type == "time":
193+
strategy["options"]["time_limit"] = cutoff_point_time * cutoff_margin
194+
else:
195+
strategy["options"]["max_fevals"] = min(
196+
int(ceil(cutoff_point_fevals * cutoff_margin)), searchspace_stats.size
197+
)
196198
results_description = ResultsDescription(
197199
experiment_folder_id,
198200
kernel_name,

0 commit comments

Comments
 (0)