Skip to content

Commit

Permalink
bugfix: autotune bucket size manually set
Browse files Browse the repository at this point in the history
Summary: The bucket part of the matrix is needed only when we compute subwords or when we want to take into account the word-ngrams. Otherwise the bucket size is set to 0. However, when the autotune is activated, the decision to set the bucket size to 0 should be let to autotune strategy.

Reviewed By: EdouardGrave

Differential Revision: D17629756

fbshipit-source-id: f259b7aad562fdd10a813af368171dee57a4a569
  • Loading branch information
Celebio authored and facebook-github-bot committed Dec 23, 2019
1 parent 0c6db7c commit 1b11e96
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ void Args::parseArgs(const std::vector<std::string>& args) {
printHelp();
exit(EXIT_FAILURE);
}
if (wordNgrams <= 1 && maxn == 0) {
if (wordNgrams <= 1 && maxn == 0 && !hasAutotune()) {
bucket = 0;
}
}
Expand Down
18 changes: 10 additions & 8 deletions src/autotune.cc
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ AutotuneStrategy::AutotuneStrategy(
trials_(0),
bestMinnIndex_(0),
bestDsubExponent_(1),
bestNonzeroBucket_(2000000) {
bestNonzeroBucket_(2000000),
originalBucket_(originalArgs.bucket) {
minnChoices_ = {0, 2, 3};
updateBest(originalArgs);
}
Expand Down Expand Up @@ -167,13 +168,14 @@ Args AutotuneStrategy::ask(double elapsed) {
}
}
if (!args.isManual("bucket")) {
if (args.wordNgrams <= 1 && args.maxn == 0) {
args.bucket = 0;
} else {
int nonZeroBucket = updateArgGauss(
bestNonzeroBucket_, 10000, 10000000, 2.0, 1.5, t, false, rng_);
args.bucket = nonZeroBucket;
}
int nonZeroBucket = updateArgGauss(
bestNonzeroBucket_, 10000, 10000000, 2.0, 1.5, t, false, rng_);
args.bucket = nonZeroBucket;
} else {
args.bucket = originalBucket_;
}
if (args.wordNgrams <= 1 && args.maxn == 0) {
args.bucket = 0;
}
if (!args.isManual("loss")) {
args.loss = loss_name::softmax;
Expand Down
1 change: 1 addition & 0 deletions src/autotune.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class AutotuneStrategy {
int bestMinnIndex_;
int bestDsubExponent_;
int bestNonzeroBucket_;
int originalBucket_;
std::vector<int> minnChoices_;
int getIndex(int val, const std::vector<int>& choices);

Expand Down

0 comments on commit 1b11e96

Please sign in to comment.