this will be the merge of a lifetime : SF 80 Elo+

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: this will be the merge of a lifetime : SF 80 Elo+

Post by MikeB »

Deberger wrote: Wed Aug 19, 2020 2:15 am
schack wrote: Tue Aug 18, 2020 9:47 pm @deberger - what value should I use for NNUEThreshold2 in the updated code after today's "fallback to NNUE" push? 0? Infinite?
src/evaluate.cpp:

Code: Select all

-  constexpr Value NNUEThreshold1  =   Value(550);
+  constexpr Value NNUEThreshold1  =   VALUE_INFINITE;
There's no need to touch NNUEThreshold2 because the logical subexpression (classical && Eval::useNNUE) will always be false

Code: Select all

if (classical && Eval::useNNUE && abs(v) * 16 < NNUEThreshold2 * (16 + pos.rule50_count()))
please explain ..."There's no need to touch NNUEThreshold2 because the logical subexpression (classical && Eval::useNNUE) will always be false"

in light of the code preceding it ...

Code: Select all

Value Eval::evaluate(const Position& pos) {

  bool classical = !Eval::useNNUE
                ||  abs(eg_value(pos.psq_score())) * 16 > NNUEThreshold1 * (16 + pos.rule50_count());
  Value v = classical ? Evaluation<NO_TRACE>(pos).value()
                      : NNUE::evaluate(pos) * 5 / 4 + Tempo;

  if (classical && Eval::useNNUE && abs(v) * 16 < NNUEThreshold2 * (16 + pos.rule50_count()))
      v = 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;
}
Image
User avatar
Deberger
Posts: 91
Joined: Sat Nov 02, 2019 6:42 pm
Full name: ɹǝƃɹǝqǝᗡ ǝɔnɹꓭ

Re: this will be the merge of a lifetime : SF 80 Elo+

Post by Deberger »

MikeB wrote: Wed Aug 19, 2020 5:16 am
Deberger wrote: Wed Aug 19, 2020 2:15 am
schack wrote: Tue Aug 18, 2020 9:47 pm @deberger - what value should I use for NNUEThreshold2 in the updated code after today's "fallback to NNUE" push? 0? Infinite?
There's no need to touch NNUEThreshold2 because the logical subexpression (classical && Eval::useNNUE) will always be false

Code: Select all

if (classical && Eval::useNNUE && abs(v) * 16 < NNUEThreshold2 * (16 + pos.rule50_count()))
please explain ..."There's no need to touch NNUEThreshold2 because the logical subexpression (classical && Eval::useNNUE) will always be false"
User schack was looking for a patch which uses NNUE without reverting to the classical evaluation.
Deberger wrote: Sun Aug 09, 2020 2:10 am With a trivial change to the source code, you can build your own executable which always uses NNUE.
schack wrote: Sun Aug 09, 2020 3:39 am Ok. What's the trivial change to the source code?
And this is the trivial change:

src/evaluate.cpp:

Code: Select all

-  constexpr Value NNUEThreshold1  =   Value(550);
+  constexpr Value NNUEThreshold1  =   VALUE_INFINITE;
If (NNUEThreshold1 == VALUE_INFINITE) then (classical == !Eval::useNNUE) and therefore (classical && Eval::useNNUE == false)


MikeB wrote: Wed Aug 19, 2020 5:16 am
in light of the code preceding it ...

Code: Select all

Value Eval::evaluate(const Position& pos) {

  bool classical = !Eval::useNNUE
                ||  abs(eg_value(pos.psq_score())) * 16 > NNUEThreshold1 * (16 + pos.rule50_count());
  Value v = classical ? Evaluation<NO_TRACE>(pos).value()
                      : NNUE::evaluate(pos) * 5 / 4 + Tempo;

  if (classical && Eval::useNNUE && abs(v) * 16 < NNUEThreshold2 * (16 + pos.rule50_count()))
      v = 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;
}