mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 12:07:43 +00:00
Verify whether there is a network being used during training.
This commit is contained in:
@@ -1000,7 +1000,7 @@ namespace Learner
|
|||||||
<< " detect_draw_by_insufficient_mating_material = " << detect_draw_by_insufficient_mating_material << endl;
|
<< " detect_draw_by_insufficient_mating_material = " << detect_draw_by_insufficient_mating_material << endl;
|
||||||
|
|
||||||
// Show if the training data generator uses NNUE.
|
// Show if the training data generator uses NNUE.
|
||||||
Eval::NNUE::verify();
|
Eval::NNUE::verify_eval_file_loaded();
|
||||||
|
|
||||||
Threads.main()->ponder = false;
|
Threads.main()->ponder = false;
|
||||||
|
|
||||||
|
|||||||
+24
-22
@@ -1486,6 +1486,27 @@ namespace Learner
|
|||||||
std::cout << "..shuffle_on_memory done." << std::endl;
|
std::cout << "..shuffle_on_memory done." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_learning_search_limits()
|
||||||
|
{
|
||||||
|
// About Search::Limits
|
||||||
|
// Be careful because this member variable is global and affects other threads.
|
||||||
|
auto& limits = Search::Limits;
|
||||||
|
|
||||||
|
limits.startTime = now();
|
||||||
|
|
||||||
|
// Make the search equivalent to the "go infinite" command. (Because it is troublesome if time management is done)
|
||||||
|
limits.infinite = true;
|
||||||
|
|
||||||
|
// Since PV is an obstacle when displayed, erase it.
|
||||||
|
limits.silent = true;
|
||||||
|
|
||||||
|
// If you use this, it will be compared with the accumulated nodes of each thread. Therefore, do not use it.
|
||||||
|
limits.nodes = 0;
|
||||||
|
|
||||||
|
// depth is also processed by the one passed as an argument of Learner::search().
|
||||||
|
limits.depth = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Learning from the generated game record
|
// Learning from the generated game record
|
||||||
void learn(Position&, istringstream& is)
|
void learn(Position&, istringstream& is)
|
||||||
{
|
{
|
||||||
@@ -1837,30 +1858,9 @@ namespace Learner
|
|||||||
|
|
||||||
cout << "init.." << endl;
|
cout << "init.." << endl;
|
||||||
|
|
||||||
// Read evaluation function parameters
|
|
||||||
Eval::NNUE::init();
|
|
||||||
|
|
||||||
Threads.main()->ponder = false;
|
Threads.main()->ponder = false;
|
||||||
|
|
||||||
// About Search::Limits
|
set_learning_search_limits();
|
||||||
// Be careful because this member variable is global and affects other threads.
|
|
||||||
{
|
|
||||||
auto& limits = Search::Limits;
|
|
||||||
|
|
||||||
limits.startTime = now();
|
|
||||||
|
|
||||||
// Make the search equivalent to the "go infinite" command. (Because it is troublesome if time management is done)
|
|
||||||
limits.infinite = true;
|
|
||||||
|
|
||||||
// Since PV is an obstacle when displayed, erase it.
|
|
||||||
limits.silent = true;
|
|
||||||
|
|
||||||
// If you use this, it will be compared with the accumulated nodes of each thread. Therefore, do not use it.
|
|
||||||
limits.nodes = 0;
|
|
||||||
|
|
||||||
// depth is also processed by the one passed as an argument of Learner::search().
|
|
||||||
limits.depth = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cout << "init_training.." << endl;
|
cout << "init_training.." << endl;
|
||||||
Eval::NNUE::InitializeTraining(seed);
|
Eval::NNUE::InitializeTraining(seed);
|
||||||
@@ -1907,6 +1907,8 @@ namespace Learner
|
|||||||
sr.read_validation_set(validation_set_file_name, eval_limit);
|
sr.read_validation_set(validation_set_file_name, eval_limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Eval::NNUE::verify_any_net_loaded();
|
||||||
|
|
||||||
// Calculate rmse once at this point (timing of 0 sfen)
|
// Calculate rmse once at this point (timing of 0 sfen)
|
||||||
// sr.calc_rmse();
|
// sr.calc_rmse();
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,6 @@
|
|||||||
|
|
||||||
void MultiThink::go_think()
|
void MultiThink::go_think()
|
||||||
{
|
{
|
||||||
// Read evaluation function, etc.
|
|
||||||
// In the case of the learn command, the value of the evaluation function may be corrected after reading the evaluation function, so
|
|
||||||
// Skip memory corruption check.
|
|
||||||
Eval::NNUE::init();
|
|
||||||
|
|
||||||
// Call the derived class's init().
|
// Call the derived class's init().
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
|||||||
@@ -235,6 +235,7 @@ namespace Eval::NNUE {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
sync_cout << "info string ERROR: failed to load eval file " << directory + eval_file << sync_endl;
|
sync_cout << "info string ERROR: failed to load eval file " << directory + eval_file << sync_endl;
|
||||||
|
eval_file_loaded.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,7 +244,7 @@ namespace Eval::NNUE {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// NNUE::verify() verifies that the last net used was loaded successfully
|
/// NNUE::verify() verifies that the last net used was loaded successfully
|
||||||
void verify() {
|
void verify_eval_file_loaded() {
|
||||||
|
|
||||||
std::string eval_file = std::string(Options["EvalFile"]);
|
std::string eval_file = std::string(Options["EvalFile"]);
|
||||||
|
|
||||||
@@ -273,4 +274,31 @@ namespace Eval::NNUE {
|
|||||||
sync_cout << "info string classical evaluation enabled" << sync_endl;
|
sync_cout << "info string classical evaluation enabled" << sync_endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// In training we override eval file so this is useful.
|
||||||
|
void verify_any_net_loaded() {
|
||||||
|
|
||||||
|
if (useNNUE != UseNNUEMode::False && eval_file_loaded.empty())
|
||||||
|
{
|
||||||
|
UCI::OptionsMap defaults;
|
||||||
|
UCI::init(defaults);
|
||||||
|
|
||||||
|
std::string msg1 = "If the UCI option \"Use NNUE\" is set to true, network evaluation parameters compatible with the engine must be available.";
|
||||||
|
std::string msg2 = "The option is set to true, but the network file was not loaded successfully.";
|
||||||
|
std::string msg3 = "The UCI option EvalFile might need to specify the full path, including the directory name, to the network file.";
|
||||||
|
std::string msg5 = "The engine will be terminated now.";
|
||||||
|
|
||||||
|
sync_cout << "info string ERROR: " << msg1 << sync_endl;
|
||||||
|
sync_cout << "info string ERROR: " << msg2 << sync_endl;
|
||||||
|
sync_cout << "info string ERROR: " << msg3 << sync_endl;
|
||||||
|
sync_cout << "info string ERROR: " << msg5 << sync_endl;
|
||||||
|
|
||||||
|
std::exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useNNUE != UseNNUEMode::False)
|
||||||
|
sync_cout << "info string NNUE evaluation using " << eval_file_loaded << " enabled" << sync_endl;
|
||||||
|
else
|
||||||
|
sync_cout << "info string classical evaluation enabled" << sync_endl;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Eval::NNUE
|
} // namespace Eval::NNUE
|
||||||
|
|||||||
@@ -96,7 +96,8 @@ namespace Eval::NNUE {
|
|||||||
Value evaluate(const Position& pos);
|
Value evaluate(const Position& pos);
|
||||||
bool load_eval(std::string name, std::istream& stream);
|
bool load_eval(std::string name, std::istream& stream);
|
||||||
void init();
|
void init();
|
||||||
void verify();
|
void verify_eval_file_loaded();
|
||||||
|
void verify_any_net_loaded();
|
||||||
|
|
||||||
} // namespace Eval::NNUE
|
} // namespace Eval::NNUE
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -219,7 +219,7 @@ void MainThread::search() {
|
|||||||
Time.init(Limits, us, rootPos.game_ply());
|
Time.init(Limits, us, rootPos.game_ply());
|
||||||
TT.new_search();
|
TT.new_search();
|
||||||
|
|
||||||
Eval::NNUE::verify();
|
Eval::NNUE::verify_eval_file_loaded();
|
||||||
|
|
||||||
if (rootMoves.empty())
|
if (rootMoves.empty())
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -101,7 +101,7 @@ namespace {
|
|||||||
Position p;
|
Position p;
|
||||||
p.set(pos.fen(), Options["UCI_Chess960"], &states->back(), Threads.main());
|
p.set(pos.fen(), Options["UCI_Chess960"], &states->back(), Threads.main());
|
||||||
|
|
||||||
Eval::NNUE::verify();
|
Eval::NNUE::verify_eval_file_loaded();
|
||||||
|
|
||||||
sync_cout << "\n" << Eval::trace(p) << sync_endl;
|
sync_cout << "\n" << Eval::trace(p) << sync_endl;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user