Commit Graph
7023 Commits
Author SHA1 Message Date
KazAppsandDisservin 74303ca7f9 Update AUTHORS (KazApps)
closes https://github.com/official-stockfish/Stockfish/pull/6454

No functional change
2025-11-30 21:58:35 +01:00
Joost VandeVondeleandDisservin 4fe04a2cc6 Update main network to nn-87a9d7857d88.nnue
trained with https://github.com/vondele/nettest/blob/842d95177f882c0e9b5262247c38d8fcb3e0f3db/threats.yaml

passed STC:
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 114880 W: 30291 L: 29851 D: 54738
Ptnml(0-2): 499, 13547, 28947, 13909, 538
https://tests.stockfishchess.org/tests/view/6923ec4bba083df4ca63dd39

passed LTC:
LLR: 2.97 (-2.94,2.94) <0.50,2.50>
Total: 113268 W: 29115 L: 28634 D: 55519
Ptnml(0-2): 114, 12295, 31340, 12766, 119
https://tests.stockfishchess.org/tests/view/6925cd01b23dfeae38cfe134

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

Bench: 3028457
2025-11-30 21:58:35 +01:00
FauziAkramandDisservin c95386256e Simplify the highBestMoveEffort formula in Time management
Passed STC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 22272 W: 5885 L: 5655 D: 10732
Ptnml(0-2): 76, 2329, 6108, 2535, 88
https://tests.stockfishchess.org/tests/view/69244d07ba083df4ca63e02b

Passed LTC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 48690 W: 12405 L: 12221 D: 24064
Ptnml(0-2): 29, 4755, 14597, 4931, 33
https://tests.stockfishchess.org/tests/view/6924de9aba083df4ca63e327

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

No functional change
2025-11-30 21:58:35 +01:00
Timothy HerchenandDisservin 7c7c574e6b Fix msvc macro
closes https://github.com/official-stockfish/Stockfish/pull/6449

No functional change
2025-11-30 21:58:35 +01:00
Shawn XuandDisservin 45d034fa50 Formatting fixups
closes https://github.com/official-stockfish/Stockfish/pull/6446

No functional change
2025-11-30 21:58:35 +01:00
pb00067andDisservin c73f21df97 Fix for SF getting stuck during search (issue #5023)
Among several passed similar versions this is the simpliest one.

Passed STC non-regression
https://tests.stockfishchess.org/tests/view/691f3b4aacb6dbdf23d07d11
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 126368 W: 32607 L: 32489 D: 61272
Ptnml(0-2): 408, 13974, 34298, 14100, 404

Passed LTC non-regression
https://tests.stockfishchess.org/tests/view/69209712acb6dbdf23d0836a
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 114786 W: 29097 L: 28976 D: 56713
Ptnml(0-2): 53, 11841, 33488, 11954, 57

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

Bench: 2941767
2025-11-30 21:58:34 +01:00
Carlos EsparzaandDisservin f4244e13e4 Some more work on FullThreats::make_index
[Passed STC](https://tests.stockfishchess.org/tests/live_elo/691fc321acb6dbdf23d07e4b):

```
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 215360 W: 55651 L: 55108 D: 104601
Ptnml(0-2): 520, 22399, 61290, 22960, 511
```

This PR is on top of ces42's work so I'll rebase if that PR changes.
Essentially, it comprises my adjustments to `make_index` that remained
unmerged before threat inputs was finalized.

The unsigned intermediate variables let us skip a bunch of useless sign
extensions (because Square and Piece inherit from `int8_t`, and C/C++
semantics require narrow integers to be promoted to `int` before doing
arithmetic on them). Additionally, by removing the special usage of
`offsets[][64]` and `[65]` the indexing becomes more efficient. (This
usage was a temporary hack from sscg anyway, so I think he'll like that
it's gone.) Finally, the `sf_assume` condition was fixed so that it
actually makes a difference to the compiler.

The speedup is fairly nice locally (combining both ces42's and these changes):

```
Result of 100 runs
==================
base (...kfish.master) =    1691982  +/- 1907
test (./stockfish    ) =    1714349  +/- 1789
diff                   =     +22367  +/- 2465

speedup        = +0.0132
P(speedup > 0) =  1.0000
```

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

No functional change
2025-11-30 21:45:14 +01:00
Shawn XuandDisservin 93f2d14d95 Simplify Incremental Updates
Passed Non-regression STC:
LLR: 3.03 (-2.94,2.94) <-1.75,0.25>
Total: 277856 W: 71575 L: 71611 D: 134670
Ptnml(0-2): 842, 30719, 75836, 30695, 836
https://tests.stockfishchess.org/tests/view/69169dc17ca8781852331d76

Supersedes #6430

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

No functional change
2025-11-30 21:43:54 +01:00
Shawn XuandDisservin 1132d893e0 Simplify Accumulator Updates
Passed Non-regression STC:
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 146848 W: 37915 L: 37820 D: 71113
Ptnml(0-2): 415, 16159, 40186, 16244, 420
https://tests.stockfishchess.org/tests/view/691772217ca878185233202b

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

No functional change
2025-11-30 21:41:51 +01:00
Daniel MonroeandJoost VandeVondele d9fd516547 Post-NNUEv10 tune
Tune search parameters after the switch to NNUEv10.

The change is neutral at STC but increases with the TC. The main changes are more aggressive corrections, futility pruning, and extensions.

Failed STC
LLR: -2.96 (-2.94,2.94) <0.00,2.00>
Total: 108320 W: 27616 L: 27719 D: 52985
Ptnml(0-2): 332, 12833, 27884, 12828, 283
https://tests.stockfishchess.org/tests/view/69212e623b03dd3a060e6114

Passed LTC
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 43272 W: 11117 L: 10788 D: 21367
Ptnml(0-2): 20, 4543, 12180, 4874, 19
https://tests.stockfishchess.org/tests/view/692130813b03dd3a060e6123

Passed VLTC
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 22714 W: 5840 L: 5581 D: 11293
Ptnml(0-2): 2, 2152, 6795, 2401, 7
https://tests.stockfishchess.org/tests/view/6921387b3b03dd3a060e6191

Passed VLTC SMP
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 11868 W: 3142 L: 2896 D: 5830
Ptnml(0-2): 0, 1007, 3676, 1249, 2
https://tests.stockfishchess.org/tests/view/69212e953b03dd3a060e611b

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

bench 2907929
2025-11-22 07:56:47 +01:00
Shawn XuandJoost VandeVondele 035cb146d4 Do more futility pruning
closes https://github.com/official-stockfish/Stockfish/pull/6433

Bench: 2469519
2025-11-17 14:03:02 +01:00
Joost VandeVondele 61149ac9ee Update main net to nn-c0ae49f08b40.nnue
Trained using the recipe https://github.com/vondele/nettest/blob/d39f72420504e474a716b9977c1380541a7b482e/threats.yaml

fix CI check for negative evals.

fix format

passed STC:
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 84032 W: 21876 L: 21490 D: 40666
Ptnml(0-2): 239, 9821, 21553, 10121, 282
https://tests.stockfishchess.org/tests/view/6914b81e7ca87818523318aa

passed LTC:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 126420 W: 32429 L: 31927 D: 62064
Ptnml(0-2): 56, 13748, 35118, 14214, 74
https://tests.stockfishchess.org/tests/view/6916c1277ca8781852331dd8

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

Bench: 2513286
2025-11-17 14:00:33 +01:00
Joost VandeVondele a27fcd6274 Fix format
No functional change
2025-11-17 13:57:53 +01:00
Andreas MatthiesandJoost VandeVondele 563b4a9c4d Cleanup benchmark
Avoid unnecessary consecutive ucinewgame commands in benchmark setup.
Remove measuring time and nodes in speedtest warmup.

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

No functional change
2025-11-17 13:37:55 +01:00
Joost VandeVondele 4b8fffe3b3 Silence warning
for systems without shared memory support

Fixes https://github.com/official-stockfish/Stockfish/issues/6425

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

No functional change
2025-11-17 13:36:11 +01:00
Carlos EsparzaandJoost VandeVondele 2084d94266 inline make_index() and avoid templating perspective
combination of two patches.

pass perspective as argument
passed STC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 52832 W: 13725 L: 13528 D: 25579
Ptnml(0-2): 154, 5756, 14412, 5927, 167
https://tests.stockfishchess.org/tests/view/69162e307ca8781852331c6a

inline make_index
passed STC:
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 68768 W: 17786 L: 17607 D: 33375
Ptnml(0-2): 187, 7591, 18694, 7680, 232
https://tests.stockfishchess.org/tests/view/6916859e7ca8781852331d36

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

No functional change
2025-11-17 13:34:45 +01:00
Timothy HerchenandJoost VandeVondele b083049fe0 Use non-locking operations for nodes count and tbHits
fetch_add and friends must produce a locking instruction because they guarantee
consistency in the presence of multiple writers. Because only one thread ever
writes to nodes and tbHits, we may use relaxed load and store to emit regular
loads and stores (on both x86-64 and arm64), while avoiding undefined behavior
and miscounting nodes.

Credit must go to Arseniy Surkov of Reckless (codedeliveryservice) for
uncovering this performance gotcha.

failed yellow as a gainer on fishtest:
LLR: -2.95 (-2.94,2.94) <0.00,2.00>
Total: 219616 W: 57165 L: 57105 D: 105346
Ptnml(0-2): 732, 24277, 59720, 24357, 722
https://tests.stockfishchess.org/tests/view/69086abfea4b268f1fac2809

potential small speedup on large core system:
```
==== master ====
1 Nodes/second : 294269736
2 Nodes/second : 295217629
Average (over 2):  294743682
==== patch ====
1 Nodes/second : 299003603
2 Nodes/second : 298111320
Average (over 2):  298557461
```

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

No functional change
2025-11-17 13:24:32 +01:00
Shawn XuandJoost VandeVondele 1d504b927f Fix undefined behavior
C++ standard does not define `uint8_t` as an allowed pointer alias type. Despite
`uint8_t` being `unsigned char` on most platforms, this is not enforced by the standard.

https://eel.is/c++draft/basic.lval#11
https://stackoverflow.com/a/16138470

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

No functional change
2025-11-14 17:43:44 +01:00
Robert NurnbergandJoost VandeVondele 4b71d8e202 Allow time checking after each DTZ probe
This PR allows for time checking within Tablebases::rank_root_moves(). The
principal application for now is syzygy_extend_pv().

In the past, Stockfish suffered some time losses at e.g. TCEC when the HDD with
the DTZ tables was too slow for the chosen move overhead setting, see #5894.

```
> ./fastchess -engine name="patch" cmd=./stockfish.patch -engine name="master" cmd=./stockfish.master -each tc=10+0.1 option.SyzygyPath=/disk1/syzygy/3-4-5-6/WDL:/disk2/syzygy/3-4-5-6/DTZ -draw movenumber=34 movecount=8 score=20 -openings file=UHO_Lichess_4852_v1.epd format=epd -rounds 50 -repeat -concurrency 16
...
Results of patch vs master (10+0.1, 1t, 16MB, UHO_Lichess_4852_v1.epd):
Elo: 59.64 +/- 35.35, nElo: 117.61 +/- 68.10
LOS: 99.96 %, DrawRatio: 56.00 %, PairsRatio: 4.50
Games: 100, Wins: 34, Losses: 17, Draws: 49, Points: 58.5 (58.50 %)
Ptnml(0-2): [0, 4, 28, 15, 3], WL/DD Ratio: 0.87
--------------------------------------------------

Player: master
  Timeouts: 19
  Crashed: 0

Finished match
```

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

No functional change
2025-11-14 17:38:55 +01:00
Shawn XuandJoost VandeVondele db824e26be Pass accumulator caches by reference
closes https://github.com/official-stockfish/Stockfish/pull/6416

No functional change
2025-11-14 17:32:17 +01:00
Daniel MonroeandJoost VandeVondele a191791f46 Clean up code and comments
closes https://github.com/official-stockfish/Stockfish/pull/6416

No functional change
2025-11-14 17:30:55 +01:00
Shawn XuandJoost VandeVondele bd82b9e01f Cleanup, fix style issues
use naming convention for variables, functions, constants

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

no functional change
2025-11-14 17:29:01 +01:00
AliceRoseliaandJoost VandeVondele 7b7a9485d6 Simplify indexing
Removes 1 function (from_to) from the Move type, change them to simpler raw.
Remove the "and" use in the correction history structure calculation. Adjust
the indexing.

Passed simplification STC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 42880 W: 11327 L: 11113 D: 20440
Ptnml(0-2): 161, 4852, 11212, 5042, 173
https://tests.stockfishchess.org/tests/view/690593b8ea4b268f1fac1e8a

Passed simplification LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 43560 W: 11276 L: 11079 D: 21205
Ptnml(0-2): 17, 4679, 12197, 4864, 23
https://tests.stockfishchess.org/tests/view/6906f819ea4b268f1fac216b

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

Bench: 2523092
2025-11-14 17:28:17 +01:00
FauziAkramandJoost VandeVondele df88db16c6 Simplify NMP reduction formula
Passed STC:
LLR: 2.97 (-2.94,2.94) <-1.75,0.25>
Total: 178912 W: 46625 L: 46559 D: 85728
Ptnml(0-2): 540, 21167, 45975, 21235, 539
https://tests.stockfishchess.org/tests/view/69060677ea4b268f1fac1f25

Passed LTC:
LLR: 2.99 (-2.94,2.94) <-1.75,0.25>
Total: 140988 W: 36278 L: 36176 D: 68534
Ptnml(0-2): 82, 15520, 39215, 15568, 109
https://tests.stockfishchess.org/tests/view/6908bc32ea4b268f1fac288f

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

bench: 2959834
2025-11-14 17:24:16 +01:00
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