Skip to content

Commit

Permalink
Implemented number of iterations per strategy, allowing automatic sup…
Browse files Browse the repository at this point in the history
…plementation of missing runtimes
  • Loading branch information
fjwillemsen committed Apr 25, 2024
1 parent 3e96270 commit 3af11c4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions experiment_files/methodology_paper_evaluation.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"compare_split_times": false
},
"strategy_defaults": {
"iterations": 32,
"repeats": 100,
"minimum_number_of_evaluations": 20,
"stochastic": true,
Expand Down
19 changes: 19 additions & 0 deletions src/autotuning_methodology/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ def tune_with_kerneltuner():
metadata, results = get_results_and_metadata(
filename_results=kernel.file_path_results, filename_metadata=kernel.file_path_metadata
)
# check that the number of iterations is correct
if "iterations" in strategy:
for result in results:
if "runtime" in result:
num_iters = len(results[0]["runtimes"])
assert (
strategy["iterations"] == num_iters
), f"Specified {strategy['iterations']=} not equal to actual number of iterations ({num_iters})"
break
if "max_fevals" in strategy["options"]:
max_fevals = strategy["options"]["max_fevals"]
if len(results) < max_fevals * 0.1:
Expand Down Expand Up @@ -250,6 +259,16 @@ def import_from_KTT(use_param_mapping=True, use_bruteforce_objective=True):
duration = searchspace_stats.get_value_in_config(config_string_key, "time")
else:
duration = np.mean(times_runtimes)
assert (
"iterations" in strategy
), "For imported KTT runs, the number of iterations must be specified in the strategy in the experiments file"

Check failure on line 264 in src/autotuning_methodology/runner.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Ruff (E501)

src/autotuning_methodology/runner.py:264:121: E501 Line too long (126 > 120)

Check failure on line 264 in src/autotuning_methodology/runner.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Ruff (E501)

src/autotuning_methodology/runner.py:264:121: E501 Line too long (126 > 120)

Check failure on line 264 in src/autotuning_methodology/runner.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Ruff (E501)

src/autotuning_methodology/runner.py:264:121: E501 Line too long (126 > 120)
if strategy["iterations"] != len(times_runtimes):
times_runtimes = [np.mean(times_runtimes)] * strategy["iterations"]
warnings.warn(
f"The specified number of iterations ({strategy['iterations']}) did not equal"
+ f"the actual number of iterations ({len(times_runtimes)}). "
+ "The average has been used."
)
times_search_algorithm = timemapper(config_attempt.get("SearcherOverhead", 0))
times_validation = timemapper(config_attempt.get("ValidationOverhead", 0))
times_framework = timemapper(config_attempt.get("DataMovementOverhead", 0))
Expand Down

0 comments on commit 3af11c4

Please sign in to comment.