-
Notifications
You must be signed in to change notification settings - Fork 212
Conversation
@ttheodor can you provide some information on this? I am curious to know how sampling is changing and the effect on performance. thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits for code reusability
src/autotuner/genetic_search.cc
Outdated
@@ -72,9 +74,35 @@ void mutate( | |||
} | |||
} | |||
|
|||
void normalizeVector(std::vector<double>& v) { | |||
double mean(std::vector<double>& v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can these be moved to the utils file https://github.com/facebookresearch/TensorComprehensions/blob/master/src/autotuner/utils/utils.cc
where we already have mathematical functions implemented?
src/autotuner/genetic_search.cc
Outdated
return sum / v.size(); | ||
} | ||
|
||
double stdv(std::vector<double>& v, double mean) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can these be moved to the utils file https://github.com/facebookresearch/TensorComprehensions/blob/master/src/autotuner/utils/utils.cc
where we already have mathematical functions implemented?
src/autotuner/genetic_search.cc
Outdated
return std::sqrt(squareSum / v.size()); | ||
} | ||
|
||
void sigmaScale(std::vector<double>& v) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can these be moved to the utils file https://github.com/facebookresearch/TensorComprehensions/blob/master/src/autotuner/utils/utils.cc
where we already have mathematical functions implemented?
@prigoyal the first commit message includes a motivation. I'll add descriptions to the others. |
@@ -113,6 +115,7 @@ class GeneticSearch { | |||
Population population; | |||
TuningConfiguration lastBestConf; | |||
const size_t kMaxPopulationSize; | |||
const size_t kMatingPoolSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this being exposed as an option to set? like we specify pop_size etc. via flags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now it is not. I'll expose it in a subsequent commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits
src/autotuner/genetic_search.cc
Outdated
@@ -164,6 +193,7 @@ GeneticSearch::GeneticSearch( | |||
: population(), | |||
lastBestConf(confs[0]), | |||
kMaxPopulationSize(n), | |||
kMatingPoolSize(n * 3), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just curious: what is the reason for number 3? can we move the number to header file as a static constexpr int
? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now it is semi-arbitrary: it is the maximum number of candidates that can be used during breeding.
I'll expose it as an option in a subsequent commit.
thanks @ttheodor , can you update PR summary with slight context :) |
@ttheodor I have a hack for you: if you first push only one commit to a branch and create a PR, github will pick up the description from that commit. Once PR is created, pushing more commits does not change the description |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Needs a tuning run though, I will not get to it before coming back from travel.
ba40df5
to
d90a51c
Compare
@caffe2bot retest this please |
795be0e
to
e4cecc3
Compare
de8f30f
to
58fb6c4
Compare
a109131
to
99ec2b3
Compare
@caffe2bot retest this please |
1 similar comment
@caffe2bot retest this please |
8f7bc63
to
eb3c330
Compare
Using an unscaled fitness value for selection is problematic: -Outstanding individuals take over very quickly, this leads to premature convergence. -When fitness values are close together, very litle selection pressure is applied and selection is almost uniformly random. Having slightly better fitness does not improve an individual's survival chances. -Transposing the fitness function (e.g. adding a constant value) changes the selection probabilities even though the location of the optimum (and the "shape" of the fitness) remain unchanged. Scaling the fitness function helps ameliorate those issues. Sigma scaling is used: fitness' = max(fitness - (mean_fitness - 2 * std_fitness), 0)
Stochastic Universal Sampling is an improvement upon the roulette algorithm that was previously used
Previously each generation had mu candidates and generated mu children which all survided. This meant that really bad candidates that were randomly generated would survive across generations. With this change, lambda (typically larger thatn mu) children are generated and the best mu survive. The previous behaviour is a special case in which lambda = mu.
Some candidates survive across across generations. Their runtimes are stored in the options cache. Previously those candidates would be benchmarked everytime they were encountered. Now the runtimes are restored from the caches instead.
Candidates that survive across generations need not be benchmarked again and thus no compilation and gpu jobs have to be created for them.
Each generation includes two evalution phases (marked with *): 1) Benchmarking of candidates * 2) Breeding 3) Benchmarking of new candidates and selection * Except for the first generation usually most of the candidates of step 1) will have been evaluated during step 3) of the previous generation. This commit removed the "Jobs(Compiled,GPU) (0,0)/0" that was printed during step 1) of almost every generation. In theory it is possible not to have enough valid candidates to form a new generation. In those cases step 1) will be run and the progress message will be printed
eb3c330
to
f340b60
Compare
Replaced by #453 |
Use better candidate sampling and make the selection phase more explicit and tunable by command line flags.