Commit Graph
6885 Commits
Author SHA1 Message Date
ppigazziniandDisservin d92e6b458a chore(ci): bump runner to macos-15
closes https://github.com/official-stockfish/Stockfish/pull/6475

No functional change
2025-12-21 15:43:32 +01:00
Pieter te BrakeandDisservin 955c927265 Removed redundant board updates
Contrary to what the comment says, `remove_piece` does in fact set the
relevant `board` elements to `NO_PIECE`.

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

No functional change
2025-12-21 15:43:32 +01:00
Timothy HerchenandDisservin e0e6fdf094 Tweak nnue_accumulator indexing
```
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 92736 W: 24149 L: 23764 D: 44823
Ptnml(0-2): 280, 10056, 25334, 10395, 303
```

The use of `IndexType` in the loops is suboptimal because it requires
truncation to 32 bits, and thereby defeats some optimizations. Using
`size_t` for the loop body works nicely, and a signed index into the
index lists allows the compiler to assume the case `added.size() ==
UINT_MAX`, which would be an infinite loop, to not happen.

Passed STC
https://tests.stockfishchess.org/tests/live_elo/692fd98ab23dfeae38d01d98

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

No functional change
2025-12-21 15:43:32 +01:00
mstemberaandDisservin e1c919fd7e Fix one error and all warnings on MSVC 2026
The error is "C1001: Internal compiler error." in uci.cpp on line 370 of
master.  For some reason the compiler can't handle the
std::size(hashfullAges) inside the lambda.  Older MSVC versions had no
problem.

Most of the warnings are due to implicit type conversions "conversion
from type A to type B, possible loss of data"
many of which have been present for a while.

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

No functional change
2025-12-21 15:43:32 +01:00
Daniel MonroeandDisservin 8449e5eb9d Remove non-functional term in isShuffling
closes https://github.com/official-stockfish/Stockfish/pull/6462

No functional change
2025-12-21 15:43:32 +01:00
Timothy HerchenandDisservin a98c3f6878 Small threat-related cleanups
Remove a couple unused things, mark `noRaysContaining` as
`[[maybe_unused]]` (suggested by Viz) to silence a warning on GCC 10,
update a comment, and replace inline constants

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

No functional change
2025-12-21 15:43:32 +01:00
FauziAkramandDisservin 863c0ec6d0 Simplify piece threat calculation
Passed STC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 105984 W: 27206 L: 27067 D: 51711
Ptnml(0-2): 260, 11556, 29245, 11647, 284
https://tests.stockfishchess.org/tests/view/6914798e7ca87818523317cf

Passed LTC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 53028 W: 13635 L: 13456 D: 25937
Ptnml(0-2): 28, 5184, 15908, 5369, 25
https://tests.stockfishchess.org/tests/view/6918c5fc7ca8781852332312

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

No functional change
2025-12-21 15:43:25 +01:00
FauziAkramandDisservin 5edfabd070 Fix Typo
closes https://github.com/official-stockfish/Stockfish/pull/6436

No functional change
2025-12-21 15:22:06 +01:00
Timothy HerchenandJoost VandeVondele c109a88ebe fix missing condition
Fixes a bug in https://github.com/official-stockfish/Stockfish/pull/6453
https://github.com/official-stockfish/Stockfish/commit/abd835dcbc3a28481224f6253b00b7420d062513
The modifications to the DirtyThreats bitboards should only happen if PutPiece is true.
This somehow didn't affect bench at the default parameters.

Reference AVX2:
./stockfish.killdeer-fix.avx2 bench 64 1 23
Nodes searched  : 178140156
Nodes/second    : 1503152

before patch:
./stockfish.master.avx512icl  bench 64 1 23
Nodes searched  : 218349728
Nodes/second    : 1743450

after patch:
./stockfish.killdeer-fix.avx512icl bench 64 1 23
Nodes searched  : 178140156
Nodes/second    : 1727520

passed STC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 39328 W: 10293 L: 10080 D: 18955
Ptnml(0-2): 113, 4306, 10629, 4487, 129
https://tests.stockfishchess.org/tests/view/692fb2d8b23dfeae38d01c81

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

Bench: 2912398
2025-12-03 12:32:29 +01:00
Daniel MonroeandJoost VandeVondele 5297ba0a1a Move hindsight reductions above cutoffs
Passed STC
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 52640 W: 13701 L: 13361 D: 25578
Ptnml(0-2): 168, 6143, 13356, 6487, 166
https://tests.stockfishchess.org/tests/view/6918dc407ca8781852332339

Passed LTC
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 207690 W: 53187 L: 52520 D: 101983
Ptnml(0-2): 93, 22515, 57994, 23118, 125
https://tests.stockfishchess.org/tests/view/6919dd307ca87818523324c7

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

Bench: 2912398
2025-12-01 17:35:34 +01:00
Timothy HerchenandJoost VandeVondele abd835dcbc Improve update_piece_threats
passed on avx512ICL:
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 30240 W: 8026 L: 7726 D: 14488
Ptnml(0-2): 95, 3235, 8171, 3513, 106
https://tests.stockfishchess.org/tests/view/69281d9ab23dfeae38cfeeb8

passed on generic architectures:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 73184 W: 19183 L: 18821 D: 35180
Ptnml(0-2): 258, 7988, 19744, 8338, 264
https://tests.stockfishchess.org/tests/view/6928ba11b23dfeae38cff276

subsequent cleanups tested as:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 72480 W: 18678 L: 18502 D: 35300
Ptnml(0-2): 242, 7925, 19718, 8125, 230
https://tests.stockfishchess.org/tests/view/692a26adb23dfeae38cff566

We add an argument noRaysContaining, which skips all discoveries which contain
all bits in the argument; if the argument is from | to, then this will
eliminate the discovery. Separately, on AVX512ICL we can speed up the
computation of DirtyThreats by moving from a pop_lsb loop to a vector
extraction with vpcompressb. See PR for details.

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

No functional change
2025-12-01 17:26:50 +01:00
Joost VandeVondeleandDisservin 9e2ee13e77 Update main network to nn-2962dca31855.nnue
trained with https://github.com/vondele/nettest/blob/dd921672bd4ad8eb09fa45248078450857e81884/threats.yaml

on top off and tested against https://github.com/official-stockfish/Stockfish/pull/6452

passed STC
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 130720 W: 34028 L: 33570 D: 63122
Ptnml(0-2): 435, 15348, 33384, 15710, 483
https://tests.stockfishchess.org/tests/view/69294539b23dfeae38cff3ad

passed LTC
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 51144 W: 13140 L: 12794 D: 25210
Ptnml(0-2): 38, 5370, 14408, 5720, 36
https://tests.stockfishchess.org/tests/view/692a9c37b23dfeae38cffa4f

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

Bench: 2823033
2025-11-30 21:58:35 +01:00
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