Skip to content

Mix alpha and statScore for reduction #4183

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

Closed
wants to merge 3 commits into from

Conversation

FauziAkram
Copy link
Contributor

The main idea credit goes to @xoto10
I @FauziAkram picked up the idea, and tuned it a little bit, enough to make it pass both STC and LTC tests convincingly:

STC: https://tests.stockfishchess.org/tests/view/6338db6f35f43d649ff60fdc
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 57832 W: 15540 L: 15199 D: 27093
Ptnml(0-2): 207, 6343, 15477, 6680, 209

LTC: https://tests.stockfishchess.org/tests/view/6339777035f43d649ff62686
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 50968 W: 13770 L: 13440 D: 23758
Ptnml(0-2): 25, 4905, 15306, 5211, 37

@ghost
Copy link

ghost commented Oct 3, 2022

I think including both tunes here would also be helpful, as it shows how they converged on reasonably similar values:

https://tests.stockfishchess.org/tests/view/63345725a004bed9a2e47b28

https://tests.stockfishchess.org/tests/view/63345728a004bed9a2e47b2a

@snicolet snicolet closed this in 8bab097 Oct 3, 2022
@snicolet
Copy link
Member

snicolet commented Oct 3, 2022

Merged via 8bab097, congrats :-)

How the alpha effect works is a little bit confusing for me, and I wonder if we could somehow simplify the equation by taking the average of 5 * alpha in line 1182 to get the same effect?

@snicolet snicolet changed the title Alpha in reduction adj Mix alpha and statScore for reduction Oct 4, 2022
@vondele
Copy link
Member

vondele commented Oct 5, 2022

It was noticed that this causes a significant reduction in the mate-finding capability (dropped from 2283 to 1785) in matetrack:
image
this is probably needs fixing. I'll reopen this PR so we can discuss how to proceed

@vondele vondele reopened this Oct 5, 2022
@Disservin
Copy link
Member

As mentioned on discord https://discord.com/channels/435943710472011776/733545871911813221/1027303879928463360
this also affected syzygy for this one user. I think I encountered similar issues today but didnt think much of it.
I would vote for a revert of the patch and wait for a new patch that fixes this bad behaviour.

@vondele
Copy link
Member

vondele commented Oct 5, 2022

yes, I think we should revert, and probably try again with something where this alpha is clamped to a certain range.

@snicolet
Copy link
Member

snicolet commented Oct 5, 2022

We could test, against previous master, a version with a cap of alpha in some reasonable range (say -5000..5000) for the mixing?

      // Decrease/increase reduction for moves with a good/bad history (~30 Elo)
      r -= (ss->statScore + 5 * std::cap(alpha, -5000, 5000)) / 15448;

Direct LTC with Elo gaining bounds against previous master?

@vondele
Copy link
Member

vondele commented Oct 5, 2022

yes (std::clamp) should do the job. Should probably be smaller than 5000 though (this could be tested with a few matetrack runs).

@vondele
Copy link
Member

vondele commented Oct 5, 2022

I'll revert the patch for now.

vondele added a commit that referenced this pull request Oct 5, 2022
This reverts commit 8bab097.

In this form the patch reduces mate finding effectiveness, as the large alpha value has negative influence on the reductions.

see also #4183

Bench: 4114228
@snicolet
Copy link
Member

snicolet commented Oct 5, 2022

yes (std::clamp) should do the job. Should probably be smaller than 5000 though (this could be tested with a few matetrack runs)

Let's optimize the bound for the number of mates found, then test in fishtest :-)

@Disservin
Copy link
Member

Let's optimize the bound for the number of mates found, then test in fishtest :-)

I’d be willing to start that tomorrow. I am probably going to start at +/-1000 and then go up in +/-500 steps. Maybe stoping earlier or using finer bounds depending on what matetrack reports.

@vondele
Copy link
Member

vondele commented Oct 5, 2022

so, I have clamped 5 * alpha as in

diff --git a/src/search.cpp b/src/search.cpp
index 46463b327..d992fa9cb 100644
--- a/src/search.cpp
+++ b/src/search.cpp
@@ -1179,7 +1179,7 @@ moves_loop: // When in check, search starts here
                          - 4433;
 
           // Decrease/increase reduction for moves with a good/bad history (~30 Elo)
-          r -= (ss->statScore + 5 * alpha) / 15448;
+          r -= (ss->statScore + std::clamp(5 * int(alpha), -500, 500)) / 15448;
 
           // In general we want to cap the LMR depth search at newDepth, but when
           // reduction is negative, we allow this move a limited search extension
limit mates
500 2282
1000 2314
5000 2323
20000 2330
100000 1946

So doesn't look like this is very sensitive even up to large values that probably don't matter much (i.e. values of alpha that imply a win/loss already).

@vondele
Copy link
Member

vondele commented Oct 5, 2022

so if somebody can start the LTC test for e.g. 5000 as a limit, that would be nice.

@xoto10
Copy link
Contributor

xoto10 commented Oct 5, 2022

Another idea to try could be to add beta and alpha, taking the average. Maybe this will avoid the extreme values enough?

diff --git a/src/search.cpp b/src/search.cpp
index 46463b32..a8241c88 100644
-- a/src/search.cpp
+++ b/src/search.cpp
@@ -1179,7 +1179,7 @@ moves_loop: // When in check, search starts here
                          - 4433;

           // Decrease/increase reduction for moves with a good/bad history (~30 Elo)
-          r -= (ss->statScore + 5 * alpha) / 15448;
+          r -= (ss->statScore + 5 * (alpha + beta) / 2) / 15448;                                                                       
           // In general we want to cap the LMR depth search at newDepth, but when
           // reduction is negative, we allow this move a limited search extension

To be honest I like the clamp, we are sure of the min/max values then, but I guess we can try one or two different things?

xoto10 pushed a commit to xoto10/stockfish-xoto10 that referenced this pull request Oct 5, 2022
@snicolet
Copy link
Member

snicolet commented Oct 5, 2022

Suggestion: add the mate tracker script in the distro, in the test folder

@locutus2
Copy link
Member

locutus2 commented Oct 6, 2022

I try here also a limited version of my beta-alpha variant which is capped at one ply: https://tests.stockfishchess.org/tests/view/633e5918fb7ccb2ea9bd8176

The reasons i liked and tried the beta-alpha idea:

  • it can only decrease reducton
  • the effect is limited to PV nodes (at non PV nodes beta-alpha = 1 which should be have nearly no effect)
  • if the search window becomes bigger we search more careful, which seems good. This are in the case of repeating researches at the root (so more researches => less reduction. The only odd case are the first three iterations where this becomes 'infinity'. Here in effect no reductions are done at PV nodes.

snicolet referenced this pull request in OfekShochat/Stockfish Oct 6, 2022
@xoto10
Copy link
Contributor

xoto10 commented Oct 7, 2022

so if somebody can start the LTC test for e.g. 5000 as a limit, that would be nice.

I created https://tests.stockfishchess.org/tests/view/633e1139fb7ccb2ea9bd77be for this. It is still running, but after 57k games it's not looking hopeful, currently:

LLR: -1.50 (-2.94,2.94) <0.50,2.50>
Total: 57656 W: 15348 L: 15353 D: 26955
Ptnml(0-2): 31, 5751, 17267, 5750, 29

Perhaps the branches implied by the clamp slow it down too much?

It could be worth testing the -20000,+20000 clamp as that would use the actual value in alpha more often? (and it had the best mate track figure in vondele's list) I'll leave that for others to try ...

@vondele
Copy link
Member

vondele commented Oct 19, 2022

clamping with 20k failed yellow here https://tests.stockfishchess.org/tests/view/634c00644bc7650f0755528a

I'll close this PR, but would encourage some more experimentation in this direction.

@vondele vondele closed this Oct 19, 2022
MinetaS added a commit to MinetaS/Stockfish that referenced this pull request Mar 15, 2023
MinetaS added a commit to MinetaS/Stockfish that referenced this pull request Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants