Skip to content

Commit

Permalink
Better warnings against setting useless human sl profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
lightvector committed Jul 13, 2024
1 parent c780e7f commit 67a82af
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 12 deletions.
6 changes: 5 additions & 1 deletion cpp/command/analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ int MainCmds::analysis(const vector<string>& args) {

//Check for unused config keys
cfg.warnUnusedKeys(cerr,&logger);
Setup::maybeWarnHumanSLParams(defaultParams,nnEval,humanEval,cerr,logger);
Setup::maybeWarnHumanSLParams(defaultParams,nnEval,humanEval,cerr,&logger);

logger.write("Loaded config "+ cfg.getFileName());
logger.write("Loaded model "+ modelFile);
Expand Down Expand Up @@ -916,6 +916,10 @@ int MainCmds::analysis(const vector<string>& args) {
if(unusedKeys.size() > 0) {
reportWarningForId(rbase.id, "overrideSettings", string("Unknown config params: ") + Global::concat(unusedKeys,","));
}
ostringstream out;
if(Setup::maybeWarnHumanSLParams(rbase.params,nnEval,humanEval,out,NULL)) {
throw StringError(out.str());
}
}
catch(const StringError& exception) {
reportErrorForId(rbase.id, "overrideSettings", string("Could not set settings: ") + exception.what());
Expand Down
2 changes: 1 addition & 1 deletion cpp/command/evalsgf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ int MainCmds::evalsgf(const vector<string>& args) {

//Check for unused config keys
cfg.warnUnusedKeys(cerr,&logger);
Setup::maybeWarnHumanSLParams(params,nnEval,NULL,cerr,logger);
Setup::maybeWarnHumanSLParams(params,nnEval,NULL,cerr,&logger);

if(rawNN) {
NNResultBuf buf;
Expand Down
2 changes: 1 addition & 1 deletion cpp/command/genbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ int MainCmds::genbook(const vector<string>& args) {

// Check for unused config keys
cfg.warnUnusedKeys(cerr,&logger);
Setup::maybeWarnHumanSLParams(params,nnEval,NULL,cerr,logger);
Setup::maybeWarnHumanSLParams(params,nnEval,NULL,cerr,&logger);

if(htmlDir != "")
MakeDir::make(htmlDir);
Expand Down
6 changes: 5 additions & 1 deletion cpp/command/gtp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,7 @@ int MainCmds::gtp(const vector<string>& args) {

//Check for unused config keys
cfg.warnUnusedKeys(cerr,&logger);
Setup::maybeWarnHumanSLParams(initialGenmoveParams,engine->nnEval,engine->humanEval,cerr,logger);
Setup::maybeWarnHumanSLParams(initialGenmoveParams,engine->nnEval,engine->humanEval,cerr,&logger);

logger.write("Loaded config " + cfg.getFileName());
logger.write("Loaded model " + nnModelFile);
Expand Down Expand Up @@ -2591,6 +2591,10 @@ int MainCmds::gtp(const vector<string>& args) {
for(const string& unused: unusedKeys) {
throw StringError("Unrecognized or non-overridable parameter in kata-set-params: " + unused);
}
ostringstream out;
if(Setup::maybeWarnHumanSLParams(buf1,engine->nnEval,engine->humanEval,out,NULL)) {
throw StringError(out.str());
}
}

//Ignore any unused keys in the original config so far
Expand Down
2 changes: 1 addition & 1 deletion cpp/command/match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ int MainCmds::match(const vector<string>& args) {
for(int i = 0; i<numBots; i++) {
if(!botIsUsed[i])
continue;
Setup::maybeWarnHumanSLParams(paramss[i],nnEvalsByBot[i],NULL,cerr,logger);
Setup::maybeWarnHumanSLParams(paramss[i],nnEvalsByBot[i],NULL,cerr,&logger);
}

//Done loading!
Expand Down
4 changes: 2 additions & 2 deletions cpp/command/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ int MainCmds::demoplay(const vector<string>& args) {

//Check for unused config keys
cfg.warnUnusedKeys(cerr,&logger);
Setup::maybeWarnHumanSLParams(params,nnEval,NULL,cerr,logger);
Setup::maybeWarnHumanSLParams(params,nnEval,NULL,cerr,&logger);

AsyncBot* bot = new AsyncBot(params, nnEval, &logger, searchRandSeed);
bot->setAlwaysIncludeOwnerMap(true);
Expand Down Expand Up @@ -1523,7 +1523,7 @@ int MainCmds::dataminesgfs(const vector<string>& args) {

GameInitializer* gameInit = new GameInitializer(cfg,logger);
cfg.warnUnusedKeys(cerr,&logger);
Setup::maybeWarnHumanSLParams(params,nnEval,NULL,cerr,logger);
Setup::maybeWarnHumanSLParams(params,nnEval,NULL,cerr,&logger);

vector<string> sgfFiles;
FileHelpers::collectSgfsFromDirsOrFiles(sgfDirs,sgfFiles);
Expand Down
9 changes: 6 additions & 3 deletions cpp/program/setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,12 @@ vector<SearchParams> Setup::loadParams(
}


void Setup::maybeWarnHumanSLParams(
bool Setup::maybeWarnHumanSLParams(
const SearchParams& params,
const NNEvaluator* nnEval,
const NNEvaluator* humanEval,
std::ostream& out,
Logger& logger
Logger* logger
) {
if(params.humanSLProfile.initialized) {
bool hasAnySGFMetaUse =
Expand All @@ -840,10 +840,13 @@ void Setup::maybeWarnHumanSLParams(
modelNames += " and ";
modelNames += humanEval->getModelName();
}
logger.write("WARNING: humanSLProfile is specified as config param but model(s) don't use it: " + modelNames);
if(logger != NULL)
logger->write("WARNING: humanSLProfile is specified as config param but model(s) don't use it: " + modelNames);
out << "WARNING: humanSLProfile is specified as config param but model(s) don't use it: " << modelNames << endl;
return true;
}
}
return false;
}


Expand Down
4 changes: 2 additions & 2 deletions cpp/program/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ namespace Setup {
bool loadSingleConfigOnly
);

void maybeWarnHumanSLParams(
bool maybeWarnHumanSLParams(
const SearchParams& params,
const NNEvaluator* nnEval,
const NNEvaluator* humanEval,
std::ostream& out,
Logger& logger
Logger* logger
);

Player parseReportAnalysisWinrates(
Expand Down
1 change: 1 addition & 0 deletions cpp/tests/gtp/misc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ get_komi

version
kata-get-models
kata-set-param humanSLProfile rank_10k
3 changes: 3 additions & 0 deletions cpp/tests/results/gtp/misc.txt.log
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,8 @@ trtUseFP16 = false
: = 1.14.1+g170-b6c96-s175M
: Controller: kata-get-models
: = [{"internalName":"g170-b6c96-s175395328-d26788732","maxBatchSize":8,"name":"tests/models/g170-b6c96-s175395328-d26788732.bin.gz","usesHumanSLProfile":false,"usingFP16":"false","version":8}]
: Controller: kata-set-param humanSLProfile rank_10k
: ? Could not set params: WARNING: humanSLProfile is specified as config param but model(s) don't use it: tests/models/g170-b6c96-s175395328-d26788732.bin.gz

: GPU -1 finishing, processed 0 rows 0 batches
: All cleaned up, quitting
3 changes: 3 additions & 0 deletions cpp/tests/results/gtp/misc.txt.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@

= [{"internalName":"g170-b6c96-s175395328-d26788732","maxBatchSize":8,"name":"tests/models/g170-b6c96-s175395328-d26788732.bin.gz","usesHumanSLProfile":false,"usingFP16":"false","version":8}]

? Could not set params: WARNING: humanSLProfile is specified as config param but model(s) don't use it: tests/models/g170-b6c96-s175395328-d26788732.bin.gz


0 comments on commit 67a82af

Please sign in to comment.