Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 1d4d67a

Browse files
author
Theodoros Theodoridis
authored
Merge pull request #280 from facebookresearch/expose-option-best
Expose option for saving # best candidates in autotuning
2 parents 40d6b7d + 0c628ff commit 1d4d67a

File tree

5 files changed

+16
-2
lines changed

5 files changed

+16
-2
lines changed

tc/autotuner/genetic_autotuner.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ void GeneticAutotuner::storeCaches(const std::string& filename) {
5757
} else {
5858
std::cout << "Dumping cache to " << filename << ".cuda/options"
5959
<< std::endl;
60-
tc::OptionsCache::getCache()->keepOnlyBestCandidates(10);
60+
tc::OptionsCache::getCache()->keepOnlyBestCandidates(
61+
tc::FLAGS_tuner_save_best_candidates_count);
6162
tc::OptionsCache::dumpCacheToProtobuf(tc::makeOptionsFilename(filename));
6263

6364
tc::OptionsCache::getCache()->keepOnlyBestCandidates(1);

tc/core/flags.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ DEFINE_int64(
105105
random_seed,
106106
-1,
107107
"The number of best candidates to restore from the proto cache");
108+
DEFINE_uint32(
109+
tuner_save_best_candidates_count,
110+
10,
111+
"Number of best candidates to save from autotuning");
108112

109113
uint64_t initRandomSeed() {
110114
static std::mutex mut;

tc/core/flags.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ DECLARE_bool(tuner_gen_restore_from_proto);
5252
DECLARE_uint32(tuner_gen_restore_number);
5353
DECLARE_bool(tuner_gen_log_generations);
5454
DECLARE_uint64(tuner_min_launch_total_threads);
55+
DECLARE_uint32(tuner_save_best_candidates_count);
5556

5657
// Misc
5758
DECLARE_int64(random_seed);

tensor_comprehensions/pybinds/pybind_autotuner.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ PYBIND11_MODULE(autotuner, m) {
110110
tc::FLAGS_tuner_min_launch_total_threads =
111111
tuner_min_launch_total_threads;
112112
})
113+
.def(
114+
"save_best_candidates_count",
115+
[](tc::autotune::GeneticAutotunerATen& instance,
116+
bool save_best_candidates_count) {
117+
tc::FLAGS_tuner_save_best_candidates_count =
118+
save_best_candidates_count;
119+
})
113120
.def(
114121
"tune",
115122
[dlpack](

tensor_comprehensions/tc_unit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def __init__(self, tc_lang, **kwargs):
193193
def set_autotuner_parameters(
194194
self, pop_size=20, crossover_rate=80, mutation_rate=7, generations=10,
195195
number_elites=1, threads=8, gpus="0", restore_from_proto=False,
196-
restore_number=10, log_generations=False,
196+
restore_number=10, log_generations=False, save_best_candidates_count=10,
197197
tuner_min_launch_total_threads=64, **kwargs
198198
):
199199
self.autotuner.pop_size(pop_size)
@@ -206,6 +206,7 @@ def set_autotuner_parameters(
206206
self.autotuner.restore_from_proto(restore_from_proto)
207207
self.autotuner.restore_number(restore_number)
208208
self.autotuner.log_generations(log_generations)
209+
self.autotuner.save_best_candidates_count(save_best_candidates_count)
209210
self.autotuner.tuner_min_launch_total_threads(tuner_min_launch_total_threads)
210211

211212
# We need to pass the inputs so that we can load the correct options from

0 commit comments

Comments
 (0)