Commit Graph
7049 Commits
Author SHA1 Message Date
Timothy HerchenandJoost VandeVondele 229bd1e2e3 check for material key validity in tbprobe
During recent work on threat inputs, there was a hard-to-debug crash in tbprobe
caused by incorrectly computing st->materialKey. This PR adds correctness
checking to pos_is_ok and a faster check in tbprobe that will actually run in
CI (because pos_is_ok checking is disabled even in debug mode, for performance
purposes).

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

No functional change
2025-11-13 22:42:10 +01:00
Torsten HellwigandJoost VandeVondele 3f2405bf4e Print NEON before POPCNT in compilation settings
Normally, Stockfish outputs the compilation settings from advanced to less
advanced, e.g.: `AVX512ICL VNNI AVX512 BMI2 AVX2 SSE41 SSSE3 SSE2 POPCNT`

With NEON, however, POPCNT is printed first, followed by the more advanced NEON
options: `POPCNT NEON_DOTPROD`

This PR places POPCNT behind the NEON options as well.

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

no functional change
2025-11-13 22:36:30 +01:00
Daniel MonroeandJoost VandeVondele 9e38023a8c Simplify threat term in movepick
Passed simplification STC
LLR: 2.97 (-2.94,2.94) <-1.75,0.25>
Total: 71296 W: 18605 L: 18419 D: 34272
Ptnml(0-2): 250, 8374, 18183, 8622, 219
https://tests.stockfishchess.org/tests/view/690454c7ea4b268f1fac1bbe

Passed simplification LTC
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 240552 W: 61870 L: 61874 D: 116808
Ptnml(0-2): 113, 26300, 67460, 26284, 119
https://tests.stockfishchess.org/tests/view/69063956ea4b268f1fac1f66

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

bench 2697501
2025-11-13 22:35:33 +01:00
Didier DurandandJoost VandeVondele 55643baa3f Fix some doc typos
closes https://github.com/official-stockfish/Stockfish/pull/6400

No functional change
2025-11-13 22:32:12 +01:00
Daniel MonroeandJoost VandeVondele 8551f86efc Remove check term in capture movepick
Passed simplification STC
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 248448 W: 64697 L: 64708 D: 119043
Ptnml(0-2): 784, 29393, 63971, 29202, 874
https://tests.stockfishchess.org/tests/view/68fc7afb637acd2a11e72d86

Passed simplification LTC
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 193626 W: 49808 L: 49764 D: 94054
Ptnml(0-2): 162, 21415, 53621, 21447, 168
https://tests.stockfishchess.org/tests/view/6901ad09637acd2a11e73828

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

bench 2920273
2025-11-13 22:31:02 +01:00
Guenther DemetzandJoost VandeVondele 4784ff2b3b Unify do_move & do_null_move workload
While being there also remove and unused assignment.

Tested for non-regression at STC:
https://tests.stockfishchess.org/tests/view/69060d81ea4b268f1fac1f36
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 94496 W: 24570 L: 24421 D: 45505
Ptnml(0-2): 264, 10145, 26275, 10306, 258

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

no functional change
2025-11-13 22:26:35 +01:00
mstemberaandJoost VandeVondele 84148586e5 Fix MSVC compile
broken after Shared Memory patch.

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

No functional change
2025-11-13 22:21:35 +01:00
Timothy HerchenandJoost VandeVondele fa4f05d3ef Don't copy around DirtyThreats
The contents of DirtyThreats gets memcpyed twice for each call to do_move.
(Return value optimization doesn't apply to the do_move function itself because
it constructs a std::pair, so it gets copied; and the calls to reset also
require a copy.) This patch inserts the dirty info in place.

Sometimes the caller of do_move ignores the DirtyThreats info, so we pass in
scratch objects. I found that stack-allocating these scratch objects was bad on
Fishtest, so I begrudgingly put them in the Position struct. Both templating
the do_move function on whether dirty threats are needed and putting a
null-check branch for each use of dirty threats were slowdowns locally. Of
course, nothing prevents a future attempt at cleaning this up.

passed STC
LLR: 2.96 (-2.94,2.94) <0.00,2.00>
Total: 68448 W: 17770 L: 17418 D: 33260
Ptnml(0-2): 198, 7425, 18630, 7769, 202
https://tests.stockfishchess.org/tests/view/6914c01a7ca87818523318ba

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

No functional change
2025-11-13 22:17:03 +01:00
Viren6andJoost VandeVondele 3ae7684714 Improve Threats Speed
Passed STC:
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 23168 W: 6132 L: 5845 D: 11191
Ptnml(0-2): 77, 2405, 6325, 2708, 69
https://tests.stockfishchess.org/tests/view/69148c3c7ca8781852331831

```
Result of  50 runs
==================
base (./stockfish.master       ) =     985641  +/- 4249
test (./stockfish.patch        ) =    1038567  +/- 5679
diff                             =     +52926  +/- 4473

speedup        = +0.0537
P(speedup > 0) =  1.0000

CPU: 16 x AMD Ryzen 9 3950X 16-Core Processor
Hyperthreading: on
```

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

No functional change
2025-11-13 22:13:47 +01:00
Daniel MonroeandJoost VandeVondele 7ac8e62219 Refine constant in correction history update
Passed STC
LLR: 3.04 (-2.94,2.94) <0.00,2.00>
Total: 250112 W: 65277 L: 64635 D: 120200
Ptnml(0-2): 841, 29326, 64134, 29860, 895
https://tests.stockfishchess.org/tests/view/69096c46ea4b268f1fac2a39

Passed LTC
LLR: 2.96 (-2.94,2.94) <0.50,2.50>
Total: 142908 W: 37141 L: 36604 D: 69163
Ptnml(0-2): 100, 15478, 39742, 16053, 81
https://tests.stockfishchess.org/tests/view/690e7dfbec1d00d2c195c351

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

bench 2613869
2025-11-13 22:10:30 +01:00
+1 8e5392d79a Update NNUE architecture to SFNNv10 with Threat Inputs and net nn-49c1193b131c.nnue
This commit introduces Full Threat Input features, which are a subset of Piece(Square)-Piece(Square) pairs. In any given position, the active features consist of pairs where the second piece’s square lies in the attack set of the first piece. This is an extremely simplified explanation that leaves out many details. The already-used HalfKAv2_hm feature set completes the input features.
Minor quantization changes have also been made.

The net nn-49c1193b131c.nnue was trained by vondele using the following setup: https://github.com/vondele/nettest/blob/7de71238e9b295e3f88ed7c9c5936af632c9b981/threats.yaml

A graphical version of an earlier scheme (with less refinement) that illustrates the core concepts can be found attached.
[NewInputs.pdf](https://github.com/user-attachments/files/23478441/NewInputs.pdf)

Further information, as well as a brief description of the history of development, can be found attached.
[Stockfish threat inputs PR summary.pdf](https://github.com/user-attachments/files/23478634/Stockfish.threat.inputs.PR.summary.pdf)

This has been a huge effort spanning over half a year, with the original [discussion thread](https://discord.com/channels/435943710472011776/1336647760388034610) reaching over 11k messages. Thanks to everyone who has contributed.

Monty PRs:
https://github.com/official-monty/Monty/pull/87 (Initial threat input PR)
https://github.com/official-monty/Monty/pull/114 (Fixed threat indexing to take into account colour correctly)
https://github.com/official-monty/Monty/pull/116 (i8 quantisation of weights whilst keeping calculations in i16)

Yukari commit:
https://github.com/yukarichess/yukari/commit/2d482c64a79cec03cf4987d5289334b9cdc737bc (Threat inputs merged)

Plentychess PRs:
https://github.com/Yoshie2000/PlentyChess/pull/400 (Threat inputs merged)
https://github.com/Yoshie2000/PlentyChess/pull/411 (Threat input weights quantised to i8)

Passed STC:
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 63424 W: 16956 L: 16591 D: 29877
Ptnml(0-2): 276, 7522, 15797, 7795, 322
https://tests.stockfishchess.org/tests/view/69105b3dec1d00d2c195c569

Passed LTC:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 27876 W: 7417 L: 7110 D: 13349
Ptnml(0-2): 23, 3033, 7530, 3318, 34
https://tests.stockfishchess.org/tests/view/6910d817ec1d00d2c195c66e

Passed VVLTC (Hash accidentally set to 1/2 normal value for both sides):
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 12458 W: 3353 L: 3102 D: 6003
Ptnml(0-2): 0, 1106, 3767, 1355, 1
https://tests.stockfishchess.org/tests/view/69115a26ec1d00d2c195c7cd

This version has also passed non-regression LTC against the originally passed version:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 51144 W: 13086 L: 12903 D: 25155
Ptnml(0-2): 22, 5167, 15018, 5336, 29
https://tests.stockfishchess.org/tests/view/69138a317ca87818523314bf

LTC elo estimate on ARM:
1 patch     :    13.9    1.9  38296.5   73728    52
2 master    :     0.0   ----  35431.5   73728    48

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

bench: 2626086

Co-authored-by: Shawn Xu <xu107288696@gmail.com>
Co-authored-by: Timothy Herchen <timothy.herchen@gmail.com>
Co-authored-by: Viren6 <94880762+Viren6@users.noreply.github.com>
Co-authored-by: Yoshie2000 <patrick.leonhardt@gmx.net>
Co-authored-by: Joost Vandevondele <Joost.VandeVondele@gmail.com>
Co-authored-by: rn5f107s2 <clemens.lerchl@gmail.com>
Co-authored-by: cj5716 <125858804+cj5716@users.noreply.github.com>
Co-authored-by: AliceRoselia <63040919+AliceRoselia@users.noreply.github.com>
Co-authored-by: Linmiao Xu <linmiao.xu@gmail.com>
Co-authored-by: Disservin <disservin.social@gmail.com>
2025-11-12 10:49:39 +01:00
69a01b88f3 Use shared memory for network weights
This enables different Stockfish processes that use the same weights to use the
same memory. The approach establishes equivalence by memory content, and is
compatible with NUMA replication.  The benefit of sharing is reduced memory usage
and a speedup thanks to improved (inter-process) caching of the network in the
CPUs cache, and thus reduced bandwidth usage to main memory. Even though this
change doesn't benefit a user running a single process, this helps on fishtest
or e.g.  for Lichess, when multiple games run concurrently, or multiple
positions are analyzed in parallel.

This concept was probably first introduced in the Monty engine
(https://github.com/official-monty/Monty/pull/62), after a discussion in
https://github.com/official-stockfish/fishtest/issues/2077 on the issue of
memory pressure. Measurements based on Torch
(https://github.com/user-attachments/files/21386224/verbatim.pdf) further
suggested that large gains were possible. Multiple other engines have
adopted this 'verbatim' format as well.

The implementation here adds the flexibility needed for SF, for example, retains
the ability to bundle compressed networks with the binary, to load nets by uci
option, and to distribute the shared nets to the proper NUMA region. This
flexibility comes with a fair amount of complexity in the implementation, such
as OS specific code, and fallback code.

For most users this should be transparent. However, for example, those running
docker containers should ensure the `--ipc` flag is set correctly, and
`--shm-size` is sufficiently large.

The benefits of this patch significantly depend on hardware, with systems with
many cores and a large (O(150MB), the net size) L3 cache benefitting typically
most.  On such systems SF speedups (as measured via nps playing games with
large concurrency but just 1 thread) can be 38%, which results in master vs.
patch Elo which gains about 25 Elo.

```
   # PLAYER             :  RATING  ERROR   POINTS  PLAYED   (%)
   1 shared_memoryPR    :    24.8    1.9  39432.0   73728    53
   2 master             :     0.0   ----  34296.0   73728    47
```

In a multithreaded setup, where weights are already shared, that benefit is smaller,
for example on the same HW as above, but with 8t for each side.
```
   # PLAYER             :  RATING  ERROR  POINTS  PLAYED   (%)
   1 shared_memoryPR    :     5.2    3.5  9351.0   18432    51
   2 master             :     0.0   ----  9081.0   18432    49
```

On fishtest with a typical hardware mix of our contributors, the following was measured:

STC, 60k games
https://tests.stockfishchess.org/tests/view/69074a49ea4b268f1fac236c
Elo: 4.69 ± 1.4 (95%) LOS: 100.0%
Total: 60000 W: 16085 L: 15275 D: 28640
Ptnml(0-2): 154, 6440, 16053, 7148, 205
nElo: 9.38 ± 2.8 (95%) PairsRatio: 1.12

To verify correctness with a single process on a NUMA architecture,
speedtest was used, confirming near equivalence:
```
master:        Average (over 10):  296236186
shared_memory: Average (over 10):  295769332
```
Currently, using large pages for the shared network weights is not always possible,
which can lead to a small slowdown (1-2%), in case a single process is run.

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

No functional change

Co-authored-by: disservin <disservin.social@gmail.com>
Co-authored-by: Joost VandeVondele <Joost.VandeVondele@gmail.com>
2025-11-02 16:04:09 +01:00
FauziAkramandJoost VandeVondele bc9f08731f Simplify Futility pruning formula
Passed STC:
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 170112 W: 44266 L: 44193 D: 81653
Ptnml(0-2): 599, 20062, 43611, 20235, 549
https://tests.stockfishchess.org/tests/view/68f50b94637acd2a11e721ad

Passed LTC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 164658 W: 42393 L: 42318 D: 79947
Ptnml(0-2): 120, 18127, 45747, 18228, 107
https://tests.stockfishchess.org/tests/view/68fa6683637acd2a11e72ac3

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

bench: 2351426
2025-11-01 11:39:00 +01:00
Shawn XuandJoost VandeVondele cd7880c030 Simplify Corrhist Bonus
Passed Non-regression STC:
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 187776 W: 48687 L: 48631 D: 90458
Ptnml(0-2): 570, 22327, 48090, 22279, 622
https://tests.stockfishchess.org/tests/view/68f58019637acd2a11e72233

Passed Non-regression LTC:
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 159378 W: 41027 L: 40946 D: 77405
Ptnml(0-2): 122, 17645, 44078, 17718, 126
https://tests.stockfishchess.org/tests/view/68fe7492637acd2a11e73090

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

Bench: 2458738
2025-11-01 11:36:33 +01:00
Carlos EsparzaandJoost VandeVondele e9674a7888 simplify make_index()
passed non-regression STC: https://tests.stockfishchess.org/tests/view/68fdb409637acd2a11e72f11
LLR: 3.08 (-2.94,2.94) <-1.75,0.25>
Total: 95008 W: 24837 L: 24677 D: 45494
Ptnml(0-2): 268, 10024, 26775, 10154, 283

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

no functional change
2025-11-01 11:34:54 +01:00
Shawn XuandJoost VandeVondele 0351652995 Simplify Pawn History Bonus
Passed Non-regression STC:
LLR: 2.98 (-2.94,2.94) <-1.75,0.25>
Total: 122016 W: 31655 L: 31525 D: 58836
Ptnml(0-2): 388, 14317, 31474, 14435, 394
https://tests.stockfishchess.org/tests/view/68f57e66637acd2a11e7221d

Passed Non-regression LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 81348 W: 21016 L: 20858 D: 39474
Ptnml(0-2): 45, 8793, 22841, 8949, 46
https://tests.stockfishchess.org/tests/view/68f9e2d9637acd2a11e72997

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

Bench: 2370893
2025-11-01 11:32:53 +01:00
Daniel MonroeandJoost VandeVondele c9a2aff485 Simplify correction update condition
Passed non-regression STC
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 95136 W: 24722 L: 24564 D: 45850
Ptnml(0-2): 307, 11139, 24522, 11289, 311
https://tests.stockfishchess.org/tests/view/68e5034ea017f472e763dc5a

Passed non-regression LTC
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 256440 W: 65854 L: 65873 D: 124713
Ptnml(0-2): 144, 28287, 71375, 28272, 142
https://tests.stockfishchess.org/tests/view/68e71ae4a017f472e763e291

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

bench 2216361
2025-11-01 11:29:47 +01:00
Daniel MonroeandJoost VandeVondele 013d42914f Simplify static eval bonus
Passed non-regression STC
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 176896 W: 45998 L: 45933 D: 84965
Ptnml(0-2): 609, 20845, 45451, 20958, 585
https://tests.stockfishchess.org/tests/view/68e5e48ba017f472e763dd21

Passed non-regression LTC
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 77682 W: 20046 L: 19884 D: 37752
Ptnml(0-2): 41, 8404, 21786, 8572, 38
https://tests.stockfishchess.org/tests/view/68ee71e328e6d77fcff9fd68

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

bench 2101654
2025-11-01 11:27:27 +01:00
Daniel MonroeandJoost VandeVondele fd3c563f57 Simplify r50 condition in cutoff
Passed non-regression STC
LLR: 3.11 (-2.94,2.94) <-1.75,0.25>
Total: 114560 W: 29832 L: 29689 D: 55039
Ptnml(0-2): 332, 12302, 31869, 12445, 332
https://tests.stockfishchess.org/tests/view/68e38587fa806e2e8393d4a9

Passed non-regression LTC
LLR: 2.99 (-2.94,2.94) <-1.75,0.25>
Total: 256272 W: 65817 L: 65832 D: 124623
Ptnml(0-2): 137, 25528, 76817, 25521, 133
https://tests.stockfishchess.org/tests/view/68e69b47a017f472e763e065

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

Bench: 2438327
2025-11-01 11:20:23 +01:00
Daniel MonroeandJoost VandeVondele 9e071f3561 Simplify best move effort
Passed non-regression STC
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 44224 W: 11614 L: 11403 D: 21207
Ptnml(0-2): 147, 4936, 11726, 5165, 138
https://tests.stockfishchess.org/tests/view/68e9410ed323fd15c04e3a87

Passed non-regression LTC
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 109788 W: 28223 L: 28096 D: 53469
Ptnml(0-2): 60, 11493, 31657, 11628, 56
https://tests.stockfishchess.org/tests/view/68eb5ac0a23744016c14af1d

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

No functional change
2025-11-01 11:18:00 +01:00
Carlos EsparzaandJoost VandeVondele 11ab4cde07 Avoid unnecessary allocations in AccumulatorStack
replacing the vector with an array resulted in a .45+-.10 % speedup.

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

no functional change
2025-11-01 11:12:03 +01:00
pb00067andJoost VandeVondele fa3b4ef5af Improve retrograde analisys and matefinding capability
fixes https://github.com/official-stockfish/Stockfish/issues/6328

Before calling search(depth), the patch ensures that depth is at least 1
whenever we encounter a decisive score in the transposition table (TT). This
prevents search(depth) from being executed by qsearch, which would otherwise
ignore that information.  Typically, decisive TT hits occur when analyzing a
mating sequence backward. Due to the nature of Iterative Deepening (IID), such
scores are usually first found at depth 0. Without this patch, valuable
information can be lost because qsearch may overwrite the TT entry by replacing
the value with a static evaluation, even though the node was already processed
at a higher depth. This is also why the engine sometimes loses track of an
already discovered mate.

Using ..\sf\patch.exe on matetrack.epd with --nodes 1000000
Engine ID:     Stockfish dev-20251015-nogit
Total FENs:    6554
Found mates:   3437
Best mates:    2438

Using ..\sf\master.exe on matetrack.epd with --nodes 1000000
Engine ID:     Stockfish dev-20251015-nogit
Total FENs:    6554
Found mates:   3337
Best mates:    2407

Passed STC
https://tests.stockfishchess.org/tests/view/68fa3fa7637acd2a11e72a79
LLR: 3.55 (-2.94,2.94) <0.00,2.00>
Total: 134144 W: 34960 L: 34471 D: 64713
Ptnml(0-2): 376, 14199, 37459, 14636, 402

Failed LTC
https://tests.stockfishchess.org/tests/view/68ffc1b5637acd2a11e73377
LLR: -3.10 (-2.94,2.94) <0.50,2.50>
Total: 75360 W: 19423 L: 19519 D: 36418
Ptnml(0-2): 38, 7553, 22605, 7435, 49

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

bench: 2530552
2025-11-01 11:02:00 +01:00
shaowyxandJoost VandeVondele a49b52cf69 Revert malus and associated coefficient parameters resulting from using only quiet moves
Following #6226 and #6256, this patch ultimately corresponds to the revert of #6200.
Parameters were tuned on 60k LTC games.

STC (10+0.1 th1) was accepted:
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 167488 W: 43573 L: 43063 D: 80852
Ptnml(0-2): 506, 19644, 43004, 20014, 576
https://tests.stockfishchess.org/tests/view/68f526a4637acd2a11e721c2

LTC (60+0.6 th1) was accepted:
LLR: 2.99 (-2.94,2.94) <0.50,2.50>
Total: 61068 W: 15882 L: 15510 D: 29676
Ptnml(0-2): 31, 6578, 16949, 6940, 36
https://tests.stockfishchess.org/tests/view/68fa1968637acd2a11e72a0a

Non-regression VLTC (180+1.8 th1) was accepted:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 50380 W: 13087 L: 12905 D: 24388
Ptnml(0-2): 5, 5018, 14962, 5200, 5
https://tests.stockfishchess.org/tests/view/68fdc6e5637acd2a11e72f33

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

Bench: 2530552
2025-11-01 10:48:40 +01:00
Timothy HerchenandJoost VandeVondele 6764561916 Improve index generation
The speedup seems to vary by machine.  The indexing function can be changed w/o needing to understand intrinsics.

Result of 100 runs
==================
base (...ish_baseline) =    1719637  +/- 3233
test (./stockfish    ) =    1734245  +/- 3534
diff                   =     +14608  +/- 4868

speedup        = +0.0085
P(speedup > 0) =  1.0000

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

No functional change
2025-11-01 10:42:42 +01:00
Timothy HerchenandJoost VandeVondele 3bb01ce7a9 prefetch earlier if checKEP is false
Only a modest amount of work happens between the transposition table prefetch
and the probe, so the probe still often stalls waiting for DRAM. The vast
majority of the time (in particular, if !checkEP), the key is known much
earlier in the do_move function and the latency can be better hidden.

passed STC SMP
https://tests.stockfishchess.org/tests/view/68f337c528e6d77fcffa066a
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 65256 W: 16806 L: 16462 D: 31988
Ptnml(0-2): 76, 7386, 17362, 7726, 78

but failed to gain STC
https://tests.stockfishchess.org/tests/view/68f3378328e6d77fcffa0665
LLR: -2.94 (-2.94,2.94) <0.00,2.00>
Total: 109824 W: 28523 L: 28618 D: 52683
Ptnml(0-2): 311, 11799, 30788, 11702, 312

In local tests, the speedup grows with thread count

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

No functional change
2025-11-01 10:40:23 +01:00
Shawn XuandJoost VandeVondele f434cc2918 Allow AccumulatorStack::size to point to one past the end
this is guaranteed to be correct since we access the last element with `size - 1`

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

fixes https://github.com/official-stockfish/Stockfish/issues/6367

no functional change
2025-11-01 10:34:44 +01:00
Taras VukandJoost VandeVondele b9e3e7921b Increase NMP reduction when improving
Passed STC:
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 52896 W: 13904 L: 13565 D: 25427
Ptnml(0-2): 186, 6022, 13706, 6335, 199
https://tests.stockfishchess.org/tests/view/68e67d02a017f472e763dfaf

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 168354 W: 43750 L: 43163 D: 81441
Ptnml(0-2): 81, 18284, 46882, 18827, 103
https://tests.stockfishchess.org/tests/view/68e79d7ba017f472e763e352

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

bench: 2537382
2025-11-01 10:28:02 +01:00
Kieren PearsonandJoost VandeVondele 75edbee01e Use huge pages for worker data
As the worker data is quite large (28MB after #6350) we can make use of huge pages as a speedup.

prior to #6350

STC passed elo gaining bounds:
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 166272 W: 43479 L: 42993 D: 79800
Ptnml(0-2): 540, 17598, 46365, 18102, 531
https://tests.stockfishchess.org/tests/view/68e9f3c0d323fd15c04e3ba4

Tested the speedup on a large machine with speedtest:
==== master ====
Average (over 20):  288644510
==== largePageWorker ====
Average (over 20):  292082422

Test after #6350:
==== rustam-cpp-testPR ====
Average (over 20):  291035351
==== rustam-cpp-testPR-pages ====
Average (over 20):  291937367

https://github.com/official-stockfish/Stockfish/pull/6359

No functional change
2025-10-14 17:46:13 +02:00
Robert Nurnberg @ elitebookandJoost VandeVondele 315f8ba4bf let CI check for mate scores outside the valid range
closes https://github.com/official-stockfish/Stockfish/pull/6358

No functional change
2025-10-14 17:34:17 +02:00
Daniel MonroeandJoost VandeVondele e7a4708ad5 Remove condition in qsearch
Instead of skipping non-captures when pawn history is exceptionally high, skip all non-captures

Passed non-regression STC
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 38016 W: 10018 L: 9795 D: 18203
Ptnml(0-2): 155, 4346, 9755, 4625, 127
https://tests.stockfishchess.org/tests/view/68e43d4aa017f472e763db2e

Passed rebased non-regression LTC
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 96048 W: 24854 L: 24710 D: 46484
Ptnml(0-2): 47, 10504, 26780, 10644, 49
https://tests.stockfishchess.org/tests/view/68e59352a017f472e763dcf9

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

bench 2343840
2025-10-14 17:32:32 +02:00
rustam-cppandJoost VandeVondele 63d449d1d9 bigger PAWN_HISTORY_SIZE
STC (10+0.1 th1) was accepted:
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 75712 W: 19701 L: 19326 D: 36685
Ptnml(0-2): 254, 8738, 19513, 9081, 270
https://tests.stockfishchess.org/tests/view/68e286d5fa806e2e8393d160

LTC (60+0.6 th1) was accepted:
LLR: 2.96 (-2.94,2.94) <0.50,2.50>
Total: 108492 W: 28068 L: 27604 D: 52820
Ptnml(0-2): 60, 11639, 30390, 12091, 66
https://tests.stockfishchess.org/tests/view/68e3e564a017f472e763dac0

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

bench 2128316
2025-10-14 17:27:42 +02:00
mstemberaandJoost VandeVondele c956df4cbb Split accumulator 3-way for avxvnni
This does the same thing for x86-64-avxvnni as #6336, #6339.

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

No functional change
2025-10-14 17:25:48 +02:00
dav1312andJoost VandeVondele fc5d296f9d Update get_native_properties.sh for AVXVNNI
Update get_native_properties.sh to detect and report 'x86-64-avxvnni' when the CPU supports it.

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

No functional change
2025-10-14 17:22:30 +02:00
Daniel SamekandJoost VandeVondele e18ed795f2 Introduce 4-ply continuation correction history
Passed STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 113984 W: 29752 L: 29323 D: 54909
Ptnml(0-2): 376, 13191, 29435, 13608, 382
https://tests.stockfishchess.org/tests/view/68dc3576fa806e2e8393bd93

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 80154 W: 20823 L: 20417 D: 38914
Ptnml(0-2): 47, 8600, 22383, 8994, 53
https://tests.stockfishchess.org/tests/view/68df83e0fa806e2e8393cbe8

Passed non-regression VLTC (rebased):
LLR: 2.98 (-2.94,2.94) <-1.75,0.25>
Total: 38158 W: 9992 L: 9805 D: 18361
Ptnml(0-2): 3, 3406, 12075, 3591, 4
https://tests.stockfishchess.org/tests/view/68e22f2afa806e2e8393d0ed

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

bench 2169281
2025-10-07 11:50:51 +02:00
Daniel MonroeandJoost VandeVondele feb17e5acf Make sure we don't move a nonexistent piece in SEE
added assert.

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

No functional change
2025-10-07 11:49:00 +02:00
mstemberaandJoost VandeVondele ee243f0fdc Remove x86-64-vnni256 target
When vnni256 was first introduced #3038 it was very slightly faster than vnni512
on some machines. We have since sped up vnni512 significantly (#4796 over 10%
alone, #6139, and probably others I'm forgetting). Since any machine that can
run vnni256 can run vnni512 this arch is no longer useful.

Note, x86-64-avxvnni still covers targets that don't have AVX512 but do have
VNNI on 128- and 256-bit vectors.

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

No functional change
2025-10-05 09:38:44 +02:00
Shawn XuandJoost VandeVondele e5c2dc5edd remove clang-format workaround
closes https://github.com/official-stockfish/Stockfish/pull/6332

No functional change
2025-10-05 09:33:42 +02:00
b09339a420 Split accumulator 3-Way
Squeeze a tiny bit more juice from the original idea in #6336 which this is on top of.

https://tests.stockfishchess.org/tests/view/68dddd85fa806e2e8393c0b9
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 156320 W: 40925 L: 40447 D: 74948
Ptnml(0-2): 427, 17330, 42172, 17800, 431

4-way doesn't look to be better than this.
https://tests.stockfishchess.org/tests/view/68dde19efa806e2e8393c0c1

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

No functional change

Co-authored-by: M Stembera <m_stembera@yahoo.com>
2025-10-05 09:33:23 +02:00
FauziAkramandJoost VandeVondele 7a7c033a86 Tweak Correction History Bonus Asymmetrically
Refine the correction history update by applying an asymmetric bonus based on the type of evaluation error. It differentiates between negative corrections and positive corrections.

Passed STC:
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 165184 W: 43314 L: 42807 D: 79063
Ptnml(0-2): 551, 19391, 42261, 19778, 611
https://tests.stockfishchess.org/tests/view/68cae49902c43c969fe7f008

Passed LTC:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 243234 W: 62765 L: 62029 D: 118440
Ptnml(0-2): 163, 25996, 68551, 26756, 151
https://tests.stockfishchess.org/tests/view/68d1c50dfa806e2e8393aa1f

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

Bench: 2746404
2025-10-05 09:25:44 +02:00
nicolasduhamelandJoost VandeVondele 5c93616a3f Adjust aspiration window
Narrow the aspiration window after fail high.

Passed STC:
LLR: 2.98 (-2.94,2.94) <0.00,2.00>
Total: 51296 W: 13550 L: 13207 D: 24539
Ptnml(0-2): 165, 5971, 13052, 6276, 184
https://tests.stockfishchess.org/tests/view/68d99afffa806e2e8393b7ae

Passed LTC;
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 87780 W: 22795 L: 22375 D: 42610
Ptnml(0-2): 52, 9340, 24694, 9744, 60
https://tests.stockfishchess.org/tests/view/68dae0a6fa806e2e8393baad

See the comments in #6293 discussing the mechanisms leading to issue #6296

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

Bench: 2336606
2025-10-05 09:23:02 +02:00
Shawn XuandJoost VandeVondele 5895f47dab Further simplify low ply history in evasions
Passed Non-regression STC (vs #6308):
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 174208 W: 45414 L: 45343 D: 83451
Ptnml(0-2): 633, 20324, 45095, 20443, 609
https://tests.stockfishchess.org/tests/view/68c24be359efc3c96b611487

Passed Non-regression LTC (vs #6308):
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 110070 W: 28099 L: 27969 D: 54002
Ptnml(0-2): 56, 11919, 30962, 12035, 63
https://tests.stockfishchess.org/tests/view/68c4efa559efc3c96b611dfc

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

Bench: 2151873
2025-10-05 09:18:16 +02:00
Shawn XuandJoost VandeVondele 3073d82ccf Simplify use of low-ply history in evasions
Passed Non-regression STC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 65024 W: 16991 L: 16804 D: 31229
Ptnml(0-2): 182, 7423, 17119, 7602, 186
https://tests.stockfishchess.org/tests/view/68c23f5459efc3c96b6113df

Passed Non-regression LTC:
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 207312 W: 53126 L: 53095 D: 101091
Ptnml(0-2): 126, 21986, 59389, 22041, 114
https://tests.stockfishchess.org/tests/view/68c241e359efc3c96b6113ef

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

Bench: 2515619
2025-09-28 21:21:57 +02:00
Shawn XuandJoost VandeVondele c62e71e78f Simplify a separate term in low ply history bonus formula
Passed Non-regression STC:
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 211200 W: 54887 L: 54860 D: 101453
Ptnml(0-2): 719, 24894, 54296, 25023, 668
https://tests.stockfishchess.org/tests/view/68c21e7f59efc3c96b6112c8

Passed Non-regression LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 217842 W: 55587 L: 55568 D: 106687
Ptnml(0-2): 130, 23651, 61313, 23724, 103
https://tests.stockfishchess.org/tests/view/68c230ec59efc3c96b61135a

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

Bench: 2070860
2025-09-28 21:19:22 +02:00
FauziAkramandJoost VandeVondele 40aeb5a411 Simplify away conthist 0
While at it, I also added the scaler note to the Lmrdepth/history formula.

Passed STC:
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 25376 W: 6660 L: 6423 D: 12293
Ptnml(0-2): 77, 2947, 6403, 3184, 77
https://tests.stockfishchess.org/tests/view/68c1ccf759efc3c96b610deb

Passed LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 208464 W: 53371 L: 53342 D: 101751
Ptnml(0-2): 110, 22776, 58426, 22815, 105
https://tests.stockfishchess.org/tests/view/68c1d04b59efc3c96b610e13

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

Bench: 2029296
2025-09-28 21:14:28 +02:00
Shawn XuandJoost VandeVondele 415a1ad426 Simplify Probcut Clamp Further
Passed Non-regression STC:
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 157984 W: 41116 L: 41030 D: 75838
Ptnml(0-2): 568, 18570, 40601, 18714, 539
https://tests.stockfishchess.org/tests/view/68b750518f94a4e5a7fe76cd

Passed Non-regression LTC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 335232 W: 85443 L: 85543 D: 164246
Ptnml(0-2): 177, 36616, 94137, 36502, 184
https://tests.stockfishchess.org/tests/view/68bc767259efc3c96b61076b

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

Bench: 2213844
2025-09-28 21:12:01 +02:00
7a36c0e95f Remove quiet move streak
Passed Non-regression STC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 67712 W: 17744 L: 17555 D: 32413
Ptnml(0-2): 204, 8030, 17274, 8069, 279
https://tests.stockfishchess.org/tests/view/68b784628f94a4e5a7fe7706

Passed Non-regression LTC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 196050 W: 50270 L: 50228 D: 95552
Ptnml(0-2): 122, 21465, 54813, 21499, 126
https://tests.stockfishchess.org/tests/view/68ba119d8f94a4e5a7fe7941

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

Bench: 2238789

Co-authored-by: Daniel Monroe <github.com@danielmonroe.net>
2025-09-28 21:08:58 +02:00
Timothy HerchenandJoost VandeVondele 9b164d9520 Shave some instructions off a hot loop in affine transform
On x86, GCC generates highly suboptimal code for this loop in its old form,
about 2x as many instructions as necessary. This decreases throughput
especially in an SMT setting. Clang does a better job but this change still has
some improvement. Note that the std::ptrdiff_t type is not optional; using an
unsigned type brings back the bad assembly. (Not sure why, but it seems
reliable on all the GCC versions I tested.)

passed STC:
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 44672 W: 11841 L: 11527 D: 21304
Ptnml(0-2): 165, 4625, 12415, 4993, 138
https://tests.stockfishchess.org/tests/view/68d8111efa806e2e8393b10e

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

No functional change
2025-09-28 21:04:29 +02:00
Michael ChalyandJoost VandeVondele 4f4f78f86e Extend nodes pre qsearch only with deep enough tt entries
Modification of current pre qsearch extensions - allowing it only for deep enough tt entries.

Passed STC:
https://tests.stockfishchess.org/tests/view/68c954d302c43c969fe7eea5
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 35872 W: 9548 L: 9236 D: 17088
Ptnml(0-2): 101, 4075, 9295, 4341, 124

Passed LTC:
https://tests.stockfishchess.org/tests/view/68ca4e4f02c43c969fe7ef5f
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 107754 W: 27784 L: 27324 D: 52646
Ptnml(0-2): 47, 11528, 30300, 11922, 80

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

bench: 2462792
2025-09-28 20:56:36 +02:00
Nonlinear2andJoost VandeVondele 6fa42d9724 Simplify RFP return value
Passed non-regression STC:
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 220800 W: 57351 L: 57332 D: 106117
Ptnml(0-2): 726, 26200, 56548, 26181, 745
https://tests.stockfishchess.org/tests/view/68b1db6e6217b8721dca9c67

Passed gainer LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 257820 W: 66286 L: 65523 D: 126011
Ptnml(0-2): 118, 27586, 72779, 28269, 158
https://tests.stockfishchess.org/tests/view/68c1d40859efc3c96b610e3d

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

bench: 2364596
2025-09-28 20:53:47 +02:00
FauziAkramandJoost VandeVondele bbad001a49 Double PawnHistory size and update formula
Doubling PAWN_HISTORY_SIZE to 1024. So with that, we can apply a stronger learning signal.
The bonus/malus multipliers in the update_quiet_histories function have been increased accordingly.

Passed STC:
LLR: 2.97 (-2.94,2.94) <0.00,2.00>
Total: 111008 W: 29136 L: 28708 D: 53164
Ptnml(0-2): 367, 12870, 28609, 13284, 374
https://tests.stockfishchess.org/tests/view/68c201d659efc3c96b61117e

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 117210 W: 30142 L: 29664 D: 57404
Ptnml(0-2): 49, 12532, 32970, 13000, 54
https://tests.stockfishchess.org/tests/view/68c20a6259efc3c96b6111ef

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

Bench: 2788334
2025-09-28 20:51:34 +02:00