Skip to content

Tunable constrained optimization algorithms #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 286 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
286 commits
Select commit Hold shift + click to select a range
eba03f8
Refactored BO BOTorch into class structure
fjwillemsen Nov 5, 2024
c6b243a
Switched to newer fit function, more efficient model initialization b…
fjwillemsen Nov 6, 2024
1581840
Added option to return invalid configurations in CostFunc
fjwillemsen Nov 6, 2024
620ee60
Added the handling of invalid configurations, training data is direct…
fjwillemsen Nov 6, 2024
009cf01
Setup structure for Tensorspace in Searchspace
fjwillemsen Nov 6, 2024
33983f7
Implemented mappings and conversions to and from tensor to parameter …
fjwillemsen Nov 7, 2024
f3fc81b
Improved efficiency of acquisition function by removing evaluated con…
fjwillemsen Nov 7, 2024
a5a0471
Removed Ax, added BOTorch as dependency
fjwillemsen Nov 7, 2024
9429539
Convenience script for benchmarking BO
fjwillemsen Nov 7, 2024
176b8f5
Added objective, tuning direction and hyperparameter tuning language …
fjwillemsen Nov 7, 2024
196af62
Completed implementation of mixed-type handling and handling of inval…
fjwillemsen Nov 8, 2024
55a5c1a
Added docstrings, improved formatting
fjwillemsen Nov 8, 2024
d64f783
Extended strategies test to test for ability to handle non-numeric an…
fjwillemsen Nov 8, 2024
e95ab30
Mixed-type parameters are not converted to numeric constraints
fjwillemsen Nov 8, 2024
10a6a5c
CostFunc can now encode and decode non-numeric configurations for str…
fjwillemsen Nov 8, 2024
6ae3ba6
Fixed logging statements, improved formatting
fjwillemsen Nov 8, 2024
4873a20
Improved the performance of get_bounds
fjwillemsen Nov 8, 2024
bae7e96
Applied non-numeric encoding in differential evolution to handle non-…
fjwillemsen Nov 8, 2024
7eb7ef7
Implemented automatic conversion to multiple types for encoded tensor…
fjwillemsen Nov 8, 2024
91d3ce4
Added tests for Searchspace tensor encoding and conversion
fjwillemsen Nov 8, 2024
80d514e
Seperated strategies and runners test cache file
fjwillemsen Nov 8, 2024
a489252
Implemented handling of categorical parameters
fjwillemsen Nov 8, 2024
68aee14
Implemented variational GP and likelihood
fjwillemsen Nov 8, 2024
b9c012d
Using LogExpectedImprovement to avoid stability issues
fjwillemsen Nov 8, 2024
41ce663
Implemented tensor space bounds in searchspace
fjwillemsen Nov 9, 2024
07ef1d4
Implemented normalization for input features
fjwillemsen Nov 9, 2024
721d072
Tensorspace is reduced by removing inconsequential parameters
fjwillemsen Nov 9, 2024
2434b3b
Extended strategies tests to include single parameter value
fjwillemsen Nov 9, 2024
1679751
Fixed an indexing error for tensorspace bounds
fjwillemsen Nov 9, 2024
2b816a6
Extended searchspace tests to include single parameter value
fjwillemsen Nov 9, 2024
c417585
Implemented additional acquisition functions, reduced number of reini…
fjwillemsen Nov 10, 2024
3d53b29
Implemented division of tensorspace into chunks for faster optimization
fjwillemsen Nov 10, 2024
3ed43a6
Switch to fit_gpytorch_mll_torch for faster fitting, use approximate …
fjwillemsen Nov 12, 2024
559813f
Implemented running BO on GPU / Apple Silicon, settable precision
fjwillemsen Nov 12, 2024
c391428
Removed Apple Silicon MPS support as cholesky operation is not yet im…
fjwillemsen Nov 12, 2024
07925c5
Implemented discrete local search for cases where the tensorspace isn…
fjwillemsen Nov 12, 2024
4113513
Implemented standardization of output
fjwillemsen Nov 12, 2024
ed12b5a
Implemented unified optimization direction
fjwillemsen Nov 12, 2024
d62c941
Updated outcome standardization
fjwillemsen Nov 12, 2024
1c015cb
Using extra information from variance in BO for better fits
fjwillemsen Nov 13, 2024
cad10f8
Implemented gradual cooldown on multi-feval depending on number of fe…
fjwillemsen Nov 13, 2024
1ed0352
Adjusted the calculation of number of optimization spaces to be more …
fjwillemsen Nov 19, 2024
38f084c
Two different kernels as test files for BO
fjwillemsen Nov 19, 2024
c447dc2
Setup structure for BOTorch transfer learning strategy as separate st…
fjwillemsen Nov 21, 2024
7c2fd51
Implemented Rank-Weighted GP Ensemble for transferlearning
fjwillemsen Nov 21, 2024
fec0e65
Avoided import of whole util submodule
fjwillemsen Nov 21, 2024
091ef47
Simplified BO transfer run loop
fjwillemsen Nov 21, 2024
ee11757
Implemented transfer learning caches in interface to be read and pass…
fjwillemsen Nov 21, 2024
1162ece
Added BO transfer learning strategy
fjwillemsen Nov 22, 2024
62fa135
Implemented optionally constructing a searchspace from a cache dictio…
fjwillemsen Nov 22, 2024
57a262f
Implemented construction of Searchspaces from caches
fjwillemsen Nov 22, 2024
964a6ee
Transfer learning inputs and outcomes are represented in Tensors
fjwillemsen Nov 22, 2024
24c6767
More general approach to model and likelihood initialization to make …
fjwillemsen Nov 22, 2024
dc4b4c7
Fitting a model for each base transfer learning task
fjwillemsen Nov 22, 2024
e21a605
Account for invalid configurations in base task caches
fjwillemsen Nov 22, 2024
e3cfe91
Implement main RGPE BO loop
fjwillemsen Nov 22, 2024
2334214
Improved the efficiency of taking initial sample
fjwillemsen Nov 22, 2024
c78a18c
Use of state dictionary is made optional
fjwillemsen Nov 22, 2024
8416098
Renamed RGPE strategy
fjwillemsen Nov 22, 2024
dc000b7
Implemented new transfer learning strategy with multiple independent GPs
fjwillemsen Nov 22, 2024
aa30ec2
Removed redundant min/max results adjustment
fjwillemsen Nov 23, 2024
fd6f95e
Result registration must be optimization direction dependent
fjwillemsen Nov 26, 2024
6963feb
Transfer learning by direct transfer of best configurations
fjwillemsen Nov 26, 2024
a08953e
BO update
fjwillemsen Mar 5, 2025
ecd7802
Improved conversion of tunable parameter
fjwillemsen Mar 5, 2025
b7cda36
Extended and improved conversion of T1 arguments, improved error repo…
fjwillemsen Mar 6, 2025
8836ce2
Improved selection of transfer learning caches
fjwillemsen Mar 7, 2025
539aed3
Fixed an error with quotes in an f-string
fjwillemsen Mar 7, 2025
435b56b
Fixed torch import error due to Tensor type hint
fjwillemsen Mar 7, 2025
3c48b49
Fixed torch import error due to Tensor type hint
fjwillemsen Mar 7, 2025
388f325
Fixed torch import error due to Tensor type hint
fjwillemsen Mar 7, 2025
373782f
Fixed torch import error due to Tensor type hint
fjwillemsen Mar 7, 2025
874c390
Merge with searchspace_experiments
fjwillemsen Mar 7, 2025
db3abb3
Merge with searchspace_experiments
fjwillemsen Mar 7, 2025
c692ba6
Loosened required positional arguments
fjwillemsen Mar 7, 2025
fe113e6
Changed benchmarks location for hypertuner
fjwillemsen Mar 7, 2025
5e65abd
Used hip-python-fork package as hip-python is not available
fjwillemsen Mar 7, 2025
0ba00a0
Removed transfer learning references
fjwillemsen Mar 7, 2025
1517565
add support for user-defined optimization algorithms
benvanwerkhoven Mar 7, 2025
6633bed
Updated pyproject
fjwillemsen Mar 7, 2025
23f557f
Merge branch 'searchspace_experiments' into hyperparametertuning
fjwillemsen Mar 7, 2025
c39ac5a
Adjusted hyper.py for paper
fjwillemsen Mar 7, 2025
cc19515
Extended hypertuner with additional kernels, adjusted for benchmark_hub
fjwillemsen Mar 7, 2025
1433930
Merge branch 'hyperparametertuning' of https://github.com/benvanwerkh…
fjwillemsen Mar 7, 2025
638d216
Implemented passing strategy to hyperparametertune by CLI argument
fjwillemsen Mar 8, 2025
d36adb5
Extended hyperparmeter tuning with 4 more strategies
fjwillemsen Mar 8, 2025
4e46459
Generate a unique filename for generated experiment files to avoid co…
fjwillemsen Mar 8, 2025
5760ea0
Merge branch 'master' of github.com:KernelTuner/kernel_tuner into cus…
benvanwerkhoven Mar 10, 2025
1c57201
add test for the optimization algorithm wrapper
benvanwerkhoven Mar 10, 2025
d28fdbe
Adjusted the test / train sets and number of repeats
fjwillemsen Mar 10, 2025
49fa92f
Added simulated_annealing to hyperparameter tuning, adjusted greedy_i…
fjwillemsen Mar 10, 2025
1056269
Updated hyperparameters
fjwillemsen Mar 13, 2025
7ce2234
Updated search spaces used in hyperparameter tuning and number of rep…
fjwillemsen Mar 13, 2025
1ed1893
Added bayes_opt to hyperparamtuning
fjwillemsen Mar 15, 2025
1e2532f
Fixed link with hyperparameter tuning attributes
fjwillemsen Mar 17, 2025
7b7bd8b
Merge branch 'hyperparametertuning' of https://github.com/benvanwerkh…
fjwillemsen Mar 17, 2025
afbf83e
Added support for evaluating T1 strings as a type
fjwillemsen Mar 17, 2025
84a2b1f
Added automatic scaling of random sample size if necessary
fjwillemsen Mar 17, 2025
9e80479
Formatting
fjwillemsen Mar 17, 2025
ce552d0
Minor update to hyperparameter tuning
fjwillemsen Mar 18, 2025
5da8845
Merge branch 'hyperparametertuning' of https://github.com/benvanwerkh…
fjwillemsen Mar 18, 2025
2714c28
Set new default hyperparameters for PSO, dual annealing and simulated…
fjwillemsen Mar 18, 2025
25d5202
Set new default hyperparameters for Genetic Algorithm and Differentia…
fjwillemsen Mar 18, 2025
651c42c
Avoid requesting more random samples than the searchspace size
fjwillemsen Mar 20, 2025
b953a69
Clearer message when exceeding the stop criterion
fjwillemsen Mar 20, 2025
a401008
Add soft maximum function evaluations limit to dual annealing
fjwillemsen Mar 20, 2025
425b4f4
Improved rounding of encoded parameter values
fjwillemsen Mar 20, 2025
0b7ec15
Merge of doc requirements files
fjwillemsen Mar 20, 2025
3bba923
Updated pyproject and requirements files
fjwillemsen Mar 20, 2025
64dfd95
Improved assertion error message
fjwillemsen Mar 20, 2025
5a83d36
Added logging in case default block size restriction is added
fjwillemsen Mar 20, 2025
5e3512b
Adjusted path to benchmarking kernels
fjwillemsen Mar 20, 2025
bff6d7b
Automatically adjust genetic algorithm popsize for smaller search spaces
fjwillemsen Mar 20, 2025
8ddce18
Updated poetry configuration fields to project configuration fields, …
fjwillemsen Mar 20, 2025
19470e4
Removed not yet fully implemented bayesian optimization references, m…
fjwillemsen Mar 20, 2025
d2bb76a
Avoid import of whole util module
fjwillemsen Mar 20, 2025
58f147f
Avoid import of whole util module
fjwillemsen Mar 20, 2025
a48394a
Avoid import of whole util module
fjwillemsen Mar 20, 2025
5dd3e4c
Updated dependencies, required python version and bumped version
fjwillemsen Mar 25, 2025
02833f3
Updated dependencies, required python version and bumped version
fjwillemsen Mar 25, 2025
b820419
Updated documentation dependencies
fjwillemsen Mar 25, 2025
11b378f
Added python version classifiers
fjwillemsen Mar 26, 2025
6550916
Improved code quality based on sonarcloud issues
fjwillemsen Mar 26, 2025
6770d3c
Removed PythonFunctions approach to hyperparameter tuning that is no …
fjwillemsen Mar 26, 2025
3dbe379
Removed bayes_opt_old as a strategy
fjwillemsen Mar 26, 2025
dcd102b
Report last HIP error on error
fjwillemsen Mar 26, 2025
1f935a1
Merge branch 'hyperparametertuning' of https://github.com/KernelTuner…
fjwillemsen Mar 26, 2025
290a860
Added docstring to ScoreObserver class
fjwillemsen Mar 26, 2025
496af94
Reduced cognitive complexity
fjwillemsen Mar 26, 2025
063fe97
Merge branch 'hyperparametertuning' of https://github.com/KernelTuner…
fjwillemsen Mar 26, 2025
c1c3a71
Improved development environment creation specification
fjwillemsen Mar 26, 2025
26914be
Merge with recent additions to searchspace_experiments
fjwillemsen Apr 3, 2025
54010b4
introduced repair technique in genetic algorithm
benvanwerkhoven Apr 30, 2025
71e3de8
added non-constraint-aware initialization and mutation for comparison
benvanwerkhoven Apr 30, 2025
67a5070
fix test_mutate
benvanwerkhoven May 1, 2025
939ea19
constraint-aware variants for pso, firefly, and sa
benvanwerkhoven May 12, 2025
b358265
remove unused variable
benvanwerkhoven May 12, 2025
2d24ae9
Added objective performance keys
fjwillemsen May 12, 2025
77676c8
Support for time-based cutoff with T1 format
fjwillemsen May 13, 2025
2e718f4
Merge with constrained_optimization
fjwillemsen May 13, 2025
9196266
Improvements to constraint-aware strategies
fjwillemsen May 13, 2025
83df948
Implemented passing settings to hyperparameter tuner, improved hyperp…
fjwillemsen May 13, 2025
f6811ab
Added firefly to hyperparameter tuning, various minor improvements
fjwillemsen May 14, 2025
e4af9f7
Added explicit restrictions definition to hyperparameter tuning
fjwillemsen May 15, 2025
5f3b6fc
Updated tune_kernel_T1 to be more broadly applicable
fjwillemsen May 16, 2025
7f3a4a3
Updated hyperparameters to newly tuned defaults
fjwillemsen May 24, 2025
80a5b62
Set default arguments if not provided
fjwillemsen May 28, 2025
79fe080
Merge with master branch
fjwillemsen May 28, 2025
e9797e2
Made Hypertuner backend compatible with changes to Backend ABC
fjwillemsen May 28, 2025
1a4c439
Adjusted GA popsize to only be adjusted when necessary
fjwillemsen May 28, 2025
8afc3d6
Merge remote-tracking branch 'origin/master' into custom_strategies
fjwillemsen May 30, 2025
04baf7d
Merge branch 'custom_strategies' into hyperparametertuning_custom_str…
fjwillemsen May 30, 2025
b8a9902
Implemented utility method to dynamically import class from file
fjwillemsen Jun 2, 2025
8f3744d
Implemented passing custom search method path and options usng T1 format
fjwillemsen Jun 2, 2025
72b615b
Implemented passing arguments to costfunc from optimizer in OptAlgWra…
fjwillemsen Jun 4, 2025
83ab888
Merge remote-tracking branch 'origin/master' into custom_strategies
fjwillemsen Jun 4, 2025
5ce2495
Implemented abstract base class for custom optimization algorithm str…
fjwillemsen Jun 4, 2025
22a6e0e
returns the fraction of the budget that has been spent
fjwillemsen Jun 4, 2025
a4a69ae
Adjusted CostFunc and tests to use budget_spent_fraction
fjwillemsen Jun 4, 2025
dbcb89d
Completed merge with updated custom_strategies
fjwillemsen Jun 4, 2025
e8ff6e7
Improved dynamic import of modules for custom strategies
fjwillemsen Jun 5, 2025
160d4b7
Expanded custom optimizer test to T1 input format
fjwillemsen Jun 5, 2025
d121da6
Merge remote-tracking branch 'origin/master' into hyperparametertunin…
fjwillemsen Jun 12, 2025
f52d573
Improve GA constraint-awareness differentiation
fjwillemsen Jun 12, 2025
fbb1c19
Implemented simulation of configurations outside the restrictions for…
fjwillemsen Jun 12, 2025
7d93855
Ensure the time limit is still checked if we also have a fevals budget
fjwillemsen Jun 16, 2025
3c293a1
If the optimizer has a constraint_aware attribute, set it in the stra…
fjwillemsen Jun 16, 2025
268bf67
Initial version of using external package strategies
fjwillemsen Jun 17, 2025
20ea709
Implemented the pyatf_strategies, which enables using the pyATF strat…
fjwillemsen Jun 19, 2025
c2c9458
Improvements to the stop criterion and cost function return values
fjwillemsen Jun 20, 2025
62d98df
Various improvements to the handling of budget and return values in p…
fjwillemsen Jun 20, 2025
30de03e
Added deepcopy of unmodified restrictions for reconstructing Searchsp…
fjwillemsen Jun 20, 2025
49e786d
Search space construction can be deffered to a later time, split pyAT…
fjwillemsen Jun 20, 2025
36208d1
Implemented pyATF search space lookup of configs
fjwillemsen Jun 20, 2025
934be28
Implemented caching of PyATF searchspace object, both storage and ret…
fjwillemsen Jun 21, 2025
1d916bd
Implemented passing whether or not to use the searchspace cache as a …
fjwillemsen Jun 23, 2025
ebe872d
merged
benvanwerkhoven Jun 25, 2025
08a1029
changed SA to act similar with or without constraint awareness
benvanwerkhoven Jun 25, 2025
3d12130
Completed merge with recent changes to searchspace
fjwillemsen Jun 25, 2025
4394d13
Amended strategy tests to account for pyATF limitations
fjwillemsen Jun 25, 2025
e3980e2
Implemented context for pyATF tests to be skipped if not installed
fjwillemsen Jun 25, 2025
ecf7218
Lowered the cutoff percentile to have a faster test
fjwillemsen Jun 25, 2025
5c94c78
Basic implementation to use Searchspace in Bayesian Optimization
fjwillemsen Jun 25, 2025
6cd8029
Changed pyATF strategies to use invalid configs
fjwillemsen Jun 25, 2025
9821156
Merge remote-tracking branch 'origin/searchspace_experiments' into co…
fjwillemsen Jun 25, 2025
ec51b0a
Changed to cached neighbor lookup now multiple methods are cached sim…
fjwillemsen Jun 25, 2025
f2902b5
Implemented a fix for the non-constrained version of GA
fjwillemsen Jun 26, 2025
27226a9
Improvements to Simulated Annealing regarding invalid and error confi…
fjwillemsen Jun 26, 2025
5ec2d60
Merge remote-tracking branch 'origin/hyperparametertuning_custom_stra…
fjwillemsen Jun 26, 2025
8954a46
Implemented building multiple neighbor index caches, optional paramet…
fjwillemsen Jun 27, 2025
e2924e0
Improvements for Numpy 2.0 compatibility
fjwillemsen Jul 3, 2025
0d9b90b
Completed merge with master
fjwillemsen Jul 3, 2025
c39b87e
replace differential evolution strategy
benvanwerkhoven Jul 3, 2025
a81765a
formatted with black
benvanwerkhoven Jul 4, 2025
655fcc0
fix parsing diff_evo method argument
benvanwerkhoven Jul 4, 2025
2fdee80
add test for parse method
benvanwerkhoven Jul 4, 2025
539735c
add support for x0 starting point
benvanwerkhoven Jul 4, 2025
baf628d
add constraint-awareness
benvanwerkhoven Jul 4, 2025
962e5f9
merged master into custom_diff_evo
benvanwerkhoven Jul 4, 2025
5798286
Merge with custom_diff_evo
fjwillemsen Jul 4, 2025
7d3861d
Improved bounds check to deal with non-numericals, other improvements
fjwillemsen Jul 4, 2025
958f8bd
Replaced undefined references to self
fjwillemsen Jul 4, 2025
ea7a69d
LHS sampling, enforce trial population diversity, avoid getting stuck
benvanwerkhoven Jul 4, 2025
fd96b81
Moved cache_filename reference to top-level for import elsewhere
fjwillemsen Jul 4, 2025
26c8127
code quality improvements
benvanwerkhoven Jul 4, 2025
05caa5f
Merge with latest changed from diff_evo
fjwillemsen Jul 7, 2025
7b5cd29
Improved passing of restrictions
fjwillemsen Jul 10, 2025
e0aaf24
Improvements to how non-numeric configurations are handled
fjwillemsen Jul 10, 2025
2d41660
string values compatible
benvanwerkhoven Jul 10, 2025
7e4f38c
Improvements to how non-numeric configurations are handled
fjwillemsen Jul 10, 2025
8da11a7
Searchspace object improvements in checking for tensorspace and error…
fjwillemsen Jul 10, 2025
28a149e
Improved tests using restrictions and extended parameters where neces…
fjwillemsen Jul 10, 2025
cfb67ae
Merge remote-tracking branch 'origin/custom_diff_evo' into constraine…
fjwillemsen Jul 10, 2025
b170eef
string values compatible, for real this time
benvanwerkhoven Jul 10, 2025
7be2d86
Merge remote-tracking branch 'origin/custom_diff_evo' into constraine…
fjwillemsen Jul 10, 2025
19d5127
further reducing use of numpy arrays for representing configs
benvanwerkhoven Jul 11, 2025
ac87d79
Merge remote-tracking branch 'origin/custom_diff_evo' into constraine…
fjwillemsen Jul 11, 2025
214865f
Removed encoding of non-numeric parameters in favour of index-based
fjwillemsen Jul 11, 2025
c6917bd
Implemented get_random_neighbor and helper functions in Searchspace, …
fjwillemsen Jul 11, 2025
d1d653e
Implemented a test for the new get_random_neighbor method
fjwillemsen Jul 11, 2025
7fcfacb
Various improvements to random neighbor performance
fjwillemsen Jul 11, 2025
6e61fd6
Implemented getting a random neighbor over the full list where applic…
fjwillemsen Jul 11, 2025
83c4043
Adjusted costfunc_kwargs defaults
fjwillemsen Jul 11, 2025
623eca4
Implemented partial neighbor caching, adding more information to the …
fjwillemsen Jul 11, 2025
f671c0e
Fix to add neighbor method as argument
fjwillemsen Jul 11, 2025
b45f880
Extended differential evolution hyperparameters to fit new algorithm …
fjwillemsen Jul 17, 2025
ff64ae3
Merged the changes to valid param config checking and checking matchi…
fjwillemsen Jul 17, 2025
f31f67c
Implemented retrieving the true tunable parameters (those that are no…
fjwillemsen Jul 17, 2025
bb152f2
Implemented number of dimensions-dependent population size in diff_evo
fjwillemsen Jul 17, 2025
b7e779e
If there is a problem loading the cache, the path of the cachefile is…
fjwillemsen Jul 17, 2025
a89af66
Implemented passing keyword arguments like meta strategy and time lim…
fjwillemsen Jul 17, 2025
8bd5991
Improved matching problem size check
fjwillemsen Jul 18, 2025
89891a8
Implemented a discrete version of Latin Hypercube sampling that is (s…
fjwillemsen Jul 19, 2025
b91a650
Implemented efficiently representing the full search space as the ind…
fjwillemsen Jul 19, 2025
fa293cf
Implemented getting the numpy array as numerical values, where non-nu…
fjwillemsen Jul 21, 2025
0812b2b
Implemented retrieving the true parameter configuration from a mixed …
fjwillemsen Jul 21, 2025
21d63bc
Implemented parameter index-, numeric- and mixed- 2D views of the sea…
fjwillemsen Jul 21, 2025
66f3f69
Created additional tests for new and improved numpy views of the sear…
fjwillemsen Jul 21, 2025
3b1aeed
Implemented a fast distributed random sample technique suitable for t…
fjwillemsen Jul 22, 2025
ce55392
Various improvements to and other searchspace functions
fjwillemsen Jul 23, 2025
5ab83f8
Performance improvement to __get_random_neighbor_adjacent
fjwillemsen Jul 23, 2025
3a38865
Implemented test for get_distributed_random_sample_indices
fjwillemsen Jul 23, 2025
c43634b
Implemented a new neighbor method for getting the neighbors clostest …
fjwillemsen Jul 23, 2025
0fe2ea5
Wrote test for closest param indices neighbor method
fjwillemsen Jul 24, 2025
d0a5ba6
Implemented a LHS sampler, automatic adjustement to smaller integer s…
fjwillemsen Jul 24, 2025
ce29740
Implemented tests for the LHS sampler and the true index bounds
fjwillemsen Jul 24, 2025
16c8245
Using LHS and closest-param-indices in new diff_evo for much better p…
fjwillemsen Jul 24, 2025
c044ef8
Disabled full validate on load for hyperparameter tuning
fjwillemsen Jul 25, 2025
cde7823
Extended hyperparameters for optimization algorithms in paper
fjwillemsen Jul 25, 2025
f56c1fd
Updated required python-constraint version
fjwillemsen Jul 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
poetry.lock
noxenv.txt
noxsettings.toml
hyperparamtuning/
hyperparamtuning*/*
*.prof

### Python ###
Expand All @@ -20,13 +20,15 @@ push_to_pypi.sh
*.json
!kernel_tuner/schema/T1/1.0.0/input-schema.json
!test/test_T1_input.json
!test_cache_file*.json
*.csv
.cache
*.ipynb_checkpoints
examples/cuda/output
deploy_key
*.mod
temp_*.*
.DS_Store
.python-version
.nox

Expand All @@ -41,4 +43,4 @@ temp_*.*
.LSOverride

.vscode
.idea
.idea
518 changes: 272 additions & 246 deletions doc/requirements_test.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion doc/source/dev-environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Steps without :bash:`sudo` access (e.g. on a cluster):
* Verify that your development environment has no missing installs or updates with :bash:`poetry install --sync --dry-run --with test`.
#. Check if the environment is setup correctly by running :bash:`pytest`. All tests should pass, except if you're not on a GPU node, or one or more extras has been left out in the previous step, then these tests will skip gracefully.
#. Set Nox to use the correct backend and location:
* Run :bash:`conda -- create-settings-file` to automatically create a settings file.
* Run :bash:`nox -- create-settings-file` to automatically create a settings file.
* In this settings file :bash:`noxsettings.toml`, change the :bash:`venvbackend`:
* If you used Mamba in step 2, to :bash:`mamba`.
* If you used Miniconda or Anaconda in step 2, to :bash:`conda`.
Expand Down
Empty file modified examples/c/vector_add.py
100755 → 100644
Empty file.
Empty file modified examples/cuda-c++/vector_add.py
100755 → 100644
Empty file.
Empty file modified examples/cuda-c++/vector_add_blocksize.py
100755 → 100644
Empty file.
Empty file modified examples/cuda-c++/vector_add_cupy.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/convolution.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/convolution_correct.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/convolution_streams.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/expdist.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/matmul.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/pnpoly.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/python_kernel.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/reduction.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/sepconv.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/spmv.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/stencil.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/test_vector_add.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/test_vector_add_parameterized.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/vector_add.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/vector_add_codegen.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/vector_add_cupy.py
100755 → 100644
Empty file.
44 changes: 44 additions & 0 deletions examples/cuda/vector_add_custom_strategy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python
"""This is the minimal example from the README"""

import numpy
import kernel_tuner
from kernel_tuner import tune_kernel
from kernel_tuner.file_utils import store_output_file, store_metadata_file

def tune():

kernel_string = """
__global__ void vector_add(float *c, float *a, float *b, int n) {
int i = blockIdx.x * block_size_x + threadIdx.x;
if (i<n) {
c[i] = a[i] + b[i];
}
}
"""

size = 10000000

a = numpy.random.randn(size).astype(numpy.float32)
b = numpy.random.randn(size).astype(numpy.float32)
c = numpy.zeros_like(b)
n = numpy.int32(size)

args = [c, a, b, n]

tune_params = dict()
tune_params["block_size_x"] = [128+64*i for i in range(15)]

results, env = tune_kernel("vector_add", kernel_string, size, args, tune_params, strategy=kernel_tuner.strategies.minimize, verbose=True)

# Store the tuning results in an output file
store_output_file("vector_add.json", results, tune_params)

# Store the metadata of this run
store_metadata_file("vector_add-metadata.json")

return results


if __name__ == "__main__":
tune()
Empty file modified examples/cuda/vector_add_jinja.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/vector_add_metric.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/vector_add_observers.py
100755 → 100644
Empty file.
Empty file modified examples/cuda/zeromeanfilter.py
100755 → 100644
Empty file.
Empty file modified examples/fortran/vector_add.py
100755 → 100644
Empty file.
Empty file modified examples/opencl/convolution.py
100755 → 100644
Empty file.
Empty file modified examples/opencl/convolution_correct.py
100755 → 100644
Empty file.
Empty file modified examples/opencl/matmul.py
100755 → 100644
Empty file.
Empty file modified examples/opencl/reduction.py
100755 → 100644
Empty file.
Empty file modified examples/opencl/sepconv.py
100755 → 100644
Empty file.
Empty file modified examples/opencl/stencil.py
100755 → 100644
Empty file.
Empty file modified examples/opencl/vector_add.py
100755 → 100644
Empty file.
Empty file modified examples/opencl/vector_add_codegen.py
100755 → 100644
Empty file.
Empty file modified examples/opencl/vector_add_observers.py
100755 → 100644
Empty file.
1 change: 0 additions & 1 deletion kernel_tuner/backends/cupy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""This module contains all Cupy specific kernel_tuner functions."""
from __future__ import print_function
from warnings import warn

import numpy as np

Expand Down
109 changes: 82 additions & 27 deletions kernel_tuner/backends/hypertuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@


class ScoreObserver(BenchmarkObserver):
"""BenchmarkObserver subclass for registering the hyperparameter tuning score."""

def __init__(self, dev):
self.dev = dev
self.scores = []
Expand All @@ -33,13 +35,70 @@ class HypertunerFunctions(Backend):
"""Class for executing hyperparameter tuning."""
units = {}

def __init__(self, iterations):
def __init__(self, iterations, compiler_options=None):
self.iterations = iterations
self.compiler_options = compiler_options
self.observers = [ScoreObserver(self)]
self.name = platform.processor()
self.max_threads = 1024
self.last_score = None

# set the defaults
self.gpus = ["A100", "A4000", "MI250X"]
folder = "../autotuning_methodology/benchmark_hub/kernels"
self.applications = [
{
"name": "dedispersion_milo",
"folder": folder,
"input_file": "dedispersion_milo.json",
"objective_performance_keys": ["time"]
},
{
"name": "hotspot_milo",
"folder": folder,
"input_file": "hotspot_milo.json",
"objective_performance_keys": ["GFLOP/s"]
},
{
"name": "convolution_milo",
"folder": folder,
"input_file": "convolution_milo.json",
"objective_performance_keys": ["time"]
},
{
"name": "gemm_milo",
"folder": folder,
"input_file": "gemm_milo.json",
"objective_performance_keys": ["time"]
}
]
# any additional settings
self.override = {
"experimental_groups_defaults": {
"repeats": 25,
"samples": self.iterations,
"minimum_fraction_of_budget_valid": 0.1,
"minimum_number_of_valid_search_iterations": 5,
},
"statistics_settings": {
"cutoff_percentile": 0.95,
"cutoff_percentile_start": 0.01,
"cutoff_type": "time",
"objective_time_keys": [
"all"
]
}
}

# override the defaults with compiler options if provided
if self.compiler_options is not None:
if "gpus" in self.compiler_options:
self.gpus = self.compiler_options["gpus"]
if "applications" in self.compiler_options:
self.applications = self.compiler_options["applications"]
if "override" in self.compiler_options:
self.override = self.compiler_options["override"]

# set the environment options
env = dict()
env["iterations"] = self.iterations
Expand All @@ -60,22 +119,6 @@ def compile(self, kernel_instance):
path = Path(__file__).parent.parent.parent / "hyperparamtuning"
path.mkdir(exist_ok=True)

# TODO get applications & GPUs args from benchmark
gpus = ["RTX_3090", "RTX_2080_Ti"]
applications = None
# applications = [
# {
# "name": "convolution",
# "folder": "./cached_data_used/kernels",
# "input_file": "convolution.json"
# },
# {
# "name": "pnpoly",
# "folder": "./cached_data_used/kernels",
# "input_file": "pnpoly.json"
# }
# ]

# strategy settings
strategy: str = kernel_instance.arguments[0]
hyperparams = [{'name': k, 'value': v} for k, v in kernel_instance.params.items()]
Expand All @@ -88,16 +131,9 @@ def compile(self, kernel_instance):
'search_method_hyperparameters': hyperparams
}]

# any additional settings
override = {
"experimental_groups_defaults": {
"samples": self.iterations
}
}

name = kernel_instance.name if len(kernel_instance.name) > 0 else kernel_instance.kernel_source.kernel_name
experiments_filepath = generate_experiment_file(name, path, searchspace_strategies, applications, gpus,
override=override, overwrite_existing_file=True)
experiments_filepath = generate_experiment_file(name, path, searchspace_strategies, self.applications, self.gpus,
override=self.override, generate_unique_file=True, overwrite_existing_file=True)
return str(experiments_filepath)

def start_event(self):
Expand All @@ -114,12 +150,27 @@ def synchronize(self):
return super().synchronize()

def run_kernel(self, func, gpu_args=None, threads=None, grid=None, stream=None):
# from cProfile import Profile

# # generate the experiments file
# experiments_filepath = Path(func)

# # run the methodology to get a fitness score for this configuration
# with Profile() as pr:
# scores = get_strategy_scores(str(experiments_filepath), full_validate_on_load=False)
# pr.dump_stats('diff_evo_hypertune_hotspot.prof')
# self.last_score = scores[list(scores.keys())[0]]['score']
# raise ValueError(scores)

# generate the experiments file
experiments_filepath = Path(func)

# run the methodology to get a fitness score for this configuration
scores = get_strategy_scores(str(experiments_filepath))
scores = get_strategy_scores(str(experiments_filepath), full_validate_on_load=False)
self.last_score = scores[list(scores.keys())[0]]['score']

# remove the experiments file
experiments_filepath.unlink()

def memset(self, allocation, value, size):
return super().memset(allocation, value, size)
Expand All @@ -129,3 +180,7 @@ def memcpy_dtoh(self, dest, src):

def memcpy_htod(self, dest, src):
return super().memcpy_htod(dest, src)

def refresh_memory(self, device_memory, host_arguments, should_sync):
"""This is a no-op for the hypertuner backend, as it does not manage memory directly."""
pass
7 changes: 5 additions & 2 deletions kernel_tuner/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,13 @@ def __init__(
observers=observers,
)
elif lang.upper() == "HYPERTUNER":
dev = HypertunerFunctions(iterations=iterations)
dev = HypertunerFunctions(
iterations=iterations,
compiler_options=compiler_options
)
self.requires_warmup = False
else:
raise ValueError(
raise NotImplementedError(
"Sorry, support for languages other than CUDA, OpenCL, HIP, C, and Fortran is not implemented yet"
)
self.dev = dev
Expand Down
25 changes: 24 additions & 1 deletion kernel_tuner/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import subprocess
from importlib.metadata import PackageNotFoundError, requires, version
from importlib.util import spec_from_file_location, module_from_spec
from pathlib import Path
from sys import platform

Expand Down Expand Up @@ -152,7 +153,7 @@ def get_t4_results(results, tune_params, objective="time"):

# write output_data to a JSON file
version, _ = output_file_schema("results")
output_json = dict(results=output_data, schema_version=version, metadata={'timeunit': 'miliseconds'})
output_json = dict(results=output_data, schema_version=version, metadata={'timeunit': 'milliseconds'})
return output_json

def store_output_file(output_filename: str, results, tune_params, objective="time"):
Expand Down Expand Up @@ -302,3 +303,25 @@ def store_metadata_file(metadata_filename: str):
with open(metadata_filenamepath, "w+") as fh:
json.dump(metadata_json, fh, indent=" ")

def import_class_from_file(file_path: Path, class_name):
"""Import a class from a file."""

def load_module(module_name):
spec = spec_from_file_location(module_name, file_path)
if spec is None:
raise ImportError(f"Could not load spec from {file_path}")

# create a module from the spec and execute it
module = module_from_spec(spec)
spec.loader.exec_module(module)
if not hasattr(module, class_name):
raise ImportError(f"Module '{module_name}' has no class '{class_name}'")
return module

try:
module = load_module(file_path.stem)
except ImportError:
module = load_module(f"{file_path.parent.stem}.{file_path.stem}")

# return the class from the module
return getattr(module, class_name)
Loading