-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix greater than TB scores in null move pruning. #4715
Fix greater than TB scores in null move pruning. #4715
Conversation
Sorry, I don't manage to parse the previous sentence :-) Can you describe your scenario for the bug in master with steps like this: step 1 : thanks :-) |
Scenario 1:Step 1: if the depth is equal or lesser than 0 and we are on a pv-node we fall into a PV qSearch Step 2: if the node is a new node that does not exist in TT we assign the eval to be the static evaluation Step 3: if the evaluation function returns the maximum static evaluation and this score is > beta we save that node score in TT and return bestValue on that pv-node so the score gets updated from x.xx to 96.05 on rootNode. Step 4: we have little time to refute the rootScore if the static evaluation turned out to evaluate the position wrongly. Scenario 2:Step 1: A non-PV qSearch is called on a position that does not exist in TT. Step 2: We evaluate the position (before or after making a move, that's irrelevant) and the evaluation return the maximum static evaluation (96.05). Step 3: We save that position in TT with a lower bound and break with that score. Step 4: We got to that same node later by a transposition, and to our luck the search is not normal PV Search but rather a PV-qSearch and we extract the ttValue for that same position and break with that score which gets propagated to the root. Step 5: we have no time to refute the root score if the static evaluation was wrong. Scenario 3:Step 1: Razoring in current master is done on RootNodes, PvNodes, and nonPv nodes leading to the same scenario with one step. Scenario 4:on moves that does not exist in TT, If the previous move is a Null Move we flip the static evaluation of the position which is prone to zugzwang and the same steps happens from above. TLDR; the meaning of my statement is that we can still theoretically report a 96.05 and still be wrong about it and the only blame then would only be the static evaluation of such position and not something dangerous in search in the first 3 scenarios. The 4th scenario I consider actually dangerous but evaluating instead of flipping the sign has been tried many times and loses Elo. Conclusion:Notice that there is a crucial difference between a PV Search and PV qSearch that makes these scenarios not possible in PvSearch: PV (normal )search has probing TB's for such positions but qSearch does not. |
Now to actually explain what the issue this PR fixes in steps: Step 1: We do null move search on non-PV nodes and an extra move to opponent could actually make the position winning for us instead of a draw (wrong zugzwang). Step 2: The position turned out to really be a proven loss for opponent Step 3: We flip the score obtained and prune with that score with a downgraded value (96.05) for us Step 4: The position and score is saved in TT Step 5: The wrong evaluation could be then used in Pv qSearch that updates the root score or Razoring Step 6: We have very little time to refute the score. |
Is this ready for merge? |
For debugging reference see https://discord.com/channels/435943710472011776/813919248455827515/1139314949278154783 I edited the commit message removing the reference for other cases that this PR don't touch since in them it's non-reproducible for me. Yes it is ready for merge. |
drafted for now because master could find mate here after a minute of a pause with
info depth 43 seldepth 68 multipv 1 score mate 41 nodes 364713757 but the patch stuck in a GHI instead reporting a TB win without TB... |
Increasing the hash solved the strange GHI issue with 20000
|
This patch is a simplification and a fix to dealing with null moves scores that returns proven mates or TB scores by preventing 'null move pruning' if the nullvalue is in that range. Current solution downgrades nullValues on the non-PV node but the value can be used in a transposed PV-node to the same position afterwards (Triangulation), the later is prone to propagate a wrong score (96.05) to root that will not be refuted unless we search further. Score of (96.05) can be obtained be two methods, maxim static-eval returned on Pv update (mostly qSearch) this downgrade (clamp) in NMP and theoretically can happen with or without TBs but the second scenario is more dangerous than the first. This fixes the reproducible case in very common scenarios with TBs as shown in the debugging at discord. Fixes: #4699 Passed STC: https://tests.stockfishchess.org/tests/view/64c1eca8dc56e1650abba6f9 LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 670048 W: 171132 L: 171600 D: 327316 Ptnml(0-2): 2134, 75687, 179820, 75279, 2104 Passed LTC: https://tests.stockfishchess.org/tests/view/64c5e130dc56e1650abc0438 LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 92868 W: 23642 L: 23499 D: 45727 Ptnml(0-2): 52, 9509, 27171, 9648, 54 Bench: 1603079
It seems that after removing classical, I cannot reproduce the staticEval hitting TB range with bench (d50), leaving only the cases of NMP. |
referring to this // Guarantee evaluation does not hit the tablebase range
+ Value oldV = v;
v = std::clamp(v, VALUE_TB_LOSS_IN_MAX_PLY + 1, VALUE_TB_WIN_IN_MAX_PLY - 1);
+ dbg_hit_on(v != oldV); |
@peregrineshahin is there a testcase and a sequence of uci commands I can use to see before / after behavior? |
Yes. Here is the difference in behavior. Before:
After:
|
Worth noting that a 9605 score is not a correct downgrade to a null search mate score unless the same position can be reached via Triangulation. |
This patch is a simplification and a fix to dealing with null moves scores that returns proven mates or TB scores by preventing 'null move pruning' if the nullvalue is in that range.
Current solution downgrades nullValues on the non-PV node but the value can be used in a transposed PV-node to the same position afterwards (Triangulation), the later is prone to propagate a wrong score (96.05) to root that will not be refuted unless we search further.
Score of (96.05) can be obtained be two methods,
and theoretically can happen with or without TBs but the second scenario is more dangerous than the first.
This fixes the reproducible case in very common scenarios with TBs as shown in the debugging at discord.
Fixes: #4699
Passed STC:
https://tests.stockfishchess.org/tests/view/64c1eca8dc56e1650abba6f9
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 670048 W: 171132 L: 171600 D: 327316
Ptnml(0-2): 2134, 75687, 179820, 75279, 2104
Passed LTC:
https://tests.stockfishchess.org/tests/view/64c5e130dc56e1650abc0438
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 92868 W: 23642 L: 23499 D: 45727
Ptnml(0-2): 52, 9509, 27171, 9648, 54
Bench: 1573024