Skip to content

Conversation

@syzygy1
Copy link
Contributor

@syzygy1 syzygy1 commented Sep 6, 2020

This fixes #3108 and removes some NNUE code that is currently not used.

At the moment, do_null_move() copies the accumulator from the previous state into the new state, which is correct. It then clears the "computed_score" flag because the side to move has changed, and with the other side to move NNUE will return a completely different evaluation (normally with changed sign but also with different NNUE-internal tempo bonus).

The problem is that do_null_move() clears the wrong flag. It clears the computed_score flag of the old state, not of the new state. It turns out that this almost never affects the search. For example, fixing it does not change the current bench (but it does change the previous bench). This is because the search code usually avoids calling evaluate() after a null move.

This PR corrects do_null_move() by removing the computed_score flag altogether. The flag is not needed because nnue_evaluate() is never called twice on a position.

This PR also removes some unnecessary {}s and inserts a few blank lines in the modified NNUE files in line with SF coding style.

Resulf ot STC non-regression test:
LLR: 2.95 (-2.94,2.94) {-1.25,0.25}
Total: 26328 W: 3118 L: 3012 D: 20198
Ptnml(0-2): 126, 2208, 8397, 2300, 133
https://tests.stockfishchess.org/tests/view/5f553ccc2d02727c56b36db1

bench: 4109324

@syzygy1
Copy link
Contributor Author

syzygy1 commented Sep 6, 2020

I could not resist removing some {}s even though those changes are a bit "off topic". If preferred, I can undo those changes.

Let me know if further fishtest runs are needed.

@dorzechowski
Copy link

Looks OK. I would however run the test again just to be on the safe side with this.

@vondele
Copy link
Member

vondele commented Sep 6, 2020

yes, please test again, just to be on the safe side.

@syzygy1
Copy link
Contributor Author

syzygy1 commented Sep 6, 2020

Submitted

@syzygy1
Copy link
Contributor Author

syzygy1 commented Sep 7, 2020

I've updated the comment with the result of the new STC non-regression test.

I will gladly submit an LTC test, but this being very close to non-functional I wonder whether it makes sense to use the resources. Let me know.

@vondele
Copy link
Member

vondele commented Sep 7, 2020

it is fine as is, it is nearly non-functional indeed.

@vondele vondele added the to be merged Will be merged shortly label Sep 8, 2020
@vondele vondele closed this in fc27d15 Sep 8, 2020
lucabrivio pushed a commit to lucabrivio/Stockfish that referenced this pull request Sep 8, 2020
This fixes #3108 and removes some NNUE code that is currently not used.

At the moment, do_null_move() copies the accumulator from the previous
state into the new state, which is correct. It then clears the "computed_score"
flag because the side to move has changed, and with the other side to move
NNUE will return a completely different evaluation (normally with changed
sign but also with different NNUE-internal tempo bonus).

The problem is that do_null_move() clears the wrong flag. It clears the
computed_score flag of the old state, not of the new state. It turns out
that this almost never affects the search. For example, fixing it does not
change the current bench (but it does change the previous bench). This is
because the search code usually avoids calling evaluate() after a null move.

This PR corrects do_null_move() by removing the computed_score flag altogether.
The flag is not needed because nnue_evaluate() is never called twice on a position.

This PR also removes some unnecessary {}s and inserts a few blank lines
in the modified NNUE files in line with SF coding style.

Resulf ot STC non-regression test:
LLR: 2.95 (-2.94,2.94) {-1.25,0.25}
Total: 26328 W: 3118 L: 3012 D: 20198
Ptnml(0-2): 126, 2208, 8397, 2300, 133
https://tests.stockfishchess.org/tests/view/5f553ccc2d02727c56b36db1

closes official-stockfish/Stockfish#3109

bench: 4109324
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

to be merged Will be merged shortly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug and fix in do_null_move

3 participants