Try to match relative magnitude of NNUE eval to classical
authormstembera <MissingEmail@email>
Fri, 14 Aug 2020 11:49:33 +0000 (04:49 -0700)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Fri, 14 Aug 2020 14:39:52 +0000 (16:39 +0200)
The idea is that since we are mixing NNUE and classical evals matching their magnitudes closer allows for better comparisons.

STC https://tests.stockfishchess.org/tests/view/5f35a65411a9b1a1dbf18e2b
LLR: 2.94 (-2.94,2.94) {-0.50,1.50}
Total: 9840 W: 1150 L: 1027 D: 7663
Ptnml(0-2): 49, 772, 3175, 855, 69

LTC https://tests.stockfishchess.org/tests/view/5f35bcbe11a9b1a1dbf18e47
LLR: 2.93 (-2.94,2.94) {0.25,1.75}
Total: 44424 W: 2492 L: 2294 D: 39638
Ptnml(0-2): 42, 2015, 17915, 2183, 57

also corrects the location to clamp the evaluation (non-function on bench).

closes https://github.com/official-stockfish/Stockfish/pull/3003

bench: 3905447

src/evaluate.cpp
src/nnue/evaluate_nnue.cpp

index 00fd2005ed7445008263db7f71c547c72a3ef997..a453fa0f7f4cd871a821fbe38827695f05bfc694 100644 (file)
@@ -941,11 +941,14 @@ Value Eval::evaluate(const Position& pos) {
   bool classical = !Eval::useNNUE
                 ||  abs(eg_value(pos.psq_score())) >= NNUEThreshold;
   Value v = classical ? Evaluation<NO_TRACE>(pos).value()
-                      : NNUE::evaluate(pos) + Tempo;
+                      : NNUE::evaluate(pos) * 5 / 4 + Tempo;
 
   // Damp down the evaluation linearly when shuffling
   v = v * (100 - pos.rule50_count()) / 100;
 
+  // Guarantee evalution outside of TB range
+  v = Utility::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);
+
   return v;
 }
 
index af0894b2f9e6a84cfffcb92aebcc75ccc8285d0c..a6ece8e2427b1fe731e68667dbac1e99720d4e2c 100644 (file)
@@ -159,10 +159,7 @@ namespace Eval::NNUE {
 
   // Evaluation function. Perform differential calculation.
   Value evaluate(const Position& pos) {
-    Value v = ComputeScore(pos, false);
-    v = Utility::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);
-
-    return v;
+    return ComputeScore(pos, false);
   }
 
   // Evaluation function. Perform full calculation.