191023#45
Open
amchess wants to merge 1529 commits into
Open
Conversation
closes #6523 No functional change
The bestValue can sometimes go down. This happens 2% of the time or so. This fix stops it from decreasing. Failed gainer STC: LLR: -2.94 (-2.94,2.94) <0.00,2.00> Total: 146176 W: 37930 L: 37976 D: 70270 Ptnml(0-2): 480, 17422, 37366, 17304, 516 https://tests.stockfishchess.org/tests/view/6953be19572093c1986da66a Passed Non-regression LTC: LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 257796 W: 65662 L: 65683 D: 126451 Ptnml(0-2): 164, 28247, 72087, 28246, 154 https://tests.stockfishchess.org/tests/view/69554ff0d844c1ce7cc7e333 closes #6520 fixes #6519 Bench: 2477446
Recent changes to the Square enum (reducing it from int32_t to int8_t) now allow the compiler to vectorize loops that were previously too wide for targets below AVX-512. However, this vectorization which Clang performs is not correct and causes a miscompilation. Disable this vectorization. This particular issue was noticable with Clang 15 and Clang 19, on avx2 as well as applie-silicon. Ref: #6063 Original Clang Issue: llvm/llvm-project#80494 First reported by #6528, though misinterpreted. closes #6529 No functional change
Only the one on line 158 is actually required but doesn't hurt to add constexpr where applicable here. Warning was "comparison of unsigned expression in '< 0' is always false" closes #6530 No functional change
Compiles and Runs Stockfish on all supported gcc & clang compilers. Only linux and avx2 currently. closes #6533 No functional change
Although shared history has been successful overall, it led to some speed issues with large numbers of threads. Originally we just split by NUMA node, but on systems with non-unified L3 caches (most AMD workstation and server CPUs, and some Intel E-core based server CPUs), this can still lead to a speed penalty at the default config. Thus, we decided to further subdivide the shared history based on the L3 cache structure. Based on this test, the original SPRTs, and speed experiments, we decided that grouping L3 domains to reach 32 threads per SharedHistories was a reasonable balance for affected systems – but we may revisit this in the future. See the PR for full details. In an extreme case, a single-socket EPYC 9755 configured with 1 numa domain per socket, the nps increases from: Nodes/second : 182827480 to Nodes/second : 229118365 In many cases, when L3 caches are shared between many threads, or when several numa nodes are already configured per socket, this patch does not influence the default. This default setting can adjusted with the existing NumaPolicy option. closes #6526 No functional change.
Passed STC: LLR: 2.97 (-2.94,2.94) <-1.75,0.25> Total: 165792 W: 42849 L: 42768 D: 80175 Ptnml(0-2): 512, 19499, 42800, 19566, 519 https://tests.stockfishchess.org/tests/view/695cdd95912b7ff140de60c2 Passed LTC: LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 80448 W: 20619 L: 20459 D: 39370 Ptnml(0-2): 47, 8693, 22596, 8829, 59 https://tests.stockfishchess.org/tests/view/695f7e84ca95f52e4b852536 closes #6535 bench: 2050811
Speed up by using unsigned enums. Passed STC: LLR: 2.98 (-2.94,2.94) <0.00,2.00> Total: 49248 W: 12894 L: 12568 D: 23786 Ptnml(0-2): 119, 5353, 13397, 5593, 16 https://tests.stockfishchess.org/tests/view/695e3e5002d0182a589fe965 closes #6532 No functional change
Refactor index LUT construction to simplify make_index. Passed STC Non-Regression: LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 62432 W: 16193 L: 16006 D: 30233 Ptnml(0-2): 189, 6950, 16764, 7111, 202 https://tests.stockfishchess.org/tests/view/6959985ad844c1ce7cc7eac8 closes #6522 No functional change.
Windows 10 is missing the GroupMasks and GroupCount members, this breaks compiles on Windows 10. Windows 11 builds, including the official ones, run fine on Windows 10/11. To support developers/testers on Windows 10, fallback conditionally to the Windows 10 struct definition. closes #6538 No functional change
scaledBonus can reach rather large values, which lead to an int overflow as detected anematode using ubsan. (see #6505 (comment)) It can be fixed by scaling nominator and denominator appropriately, which doesn't change the bench, as long as there is no overflow. First overflow/bench change happens at depth 26 closes #6540 Bench: 2050811
avoid munmap of memory when exiting via signal, which avoids side effects such as triggering asserts or (caught) segfaults while the process exists. closes #6542 No functional change
With the current setup, on Linux, SIGILL (and SIGSEGV/SIGBUS etc., in the case of a program bug) lead to no feedback if they occur after the signal handlers are installed, they just exit silently. By invoking the default signal handler, we can still get the appropriate feedback. This is particularly important for feedback if someone downloads the wrong SF binary and runs it on Linux. closes #6554 No functional change
some environment dependent execution (e.g. pid) were being std::hash'ed, and net filenames put in unordered maps. Also uses sprintf instead of std::to_string. Depending on precise content, this could lead to different PGO'ed binaries. This is mitigated by using a basic hash function. This also fixes a potential issue in net filename generation, in cases where std::hash would use invocation dependent salt, which is not the cases today for typical std libraries. Closes #6562 No functional change
fixes github.com//issues/6571 closes #6572 No functional change
Official release version of Stockfish 18 Bench: 2050811 --- Stockfish 18 Today, we have the pleasure of announcing Stockfish 18, a new major release. As always, you can freely download it at [stockfishchess.org/download][1] and use it as a drop-in replacement in the [GUI of your choice][2] to benefit from stronger play and more accurate analysis. Whether you can spare hours or days of CPU time, your help matters for the ongoing development of Stockfish. Find out how you can help at [stockfishchess.org/get-involved][3]. Join our [Discord server][4] to get in touch with the community of developers and users of the project! Quality of chess play In tests against Stockfish 17, this new release brings an Elo gain of up to [46 points][5], and wins [four times as many game pairs][6] as it loses. Quality improved throughout, including in [Fischer Random Chess][7]. Stockfish is stronger than any human, even when running on older or low-end hardware. On the highest-end hardware, where Stockfish can search over [500 million positions per second][8], it continues to [dominate chess engine tournaments][9]. Update highlights Next-Generation Evaluation This release introduces the SFNNv10 network architecture. The network’s input layer has been augmented with 'Threat Inputs' features as part of a massive community effort. These features allow the engine to 'see' which pieces are threatened more naturally, resulting in more accurate evaluations. Hardware and Performance Optimizations A key highlight is the new 'Shared Memory' implementation, which allows different Stockfish processes to share the same memory space for neural network weights. This makes it the most efficient version for cloud analysis and high-concurrency testing. Significant efforts have also been made to utilize hardware more effectively by adapting the code to make use of modern CPU instructions and refining how threads interact during a search. Search Improvements Stockfish 18 features a heavily refined search, utilizing 'Correction History' to dynamically adjust evaluations based on patterns found during the search itself. These and other refinements allow the engine to detect stalemates and evaluate fortresses significantly better than previous versions. A particularly rare issue, involving threefold repetition detection, en passant, and pins, was also fixed. Refactored Training Workflow The training of Stockfish's neural networks has transitioned to an automated and reproducible model. This new framework allows the project to employ standardized recipes to chain complex training stages together. This transition facilitates the training of networks using over 100 billion positions of [Lc0 evaluation data][10]. Thank you In this release in particular, we are deeply grateful to the contributors who shared their research and ideas to help develop the new threat-input network architecture. The Stockfish project builds on a thriving community of enthusiasts (thanks to everybody!) who contribute their expertise, time, and resources to build a free and open-source chess engine that is robust, widely available, and very strong. We would like to express our gratitude for the [14.6k stars][11] that light up our GitHub project. Thank you for your support and encouragement – your recognition means a lot to us. Programmers can contribute to the project either directly to [Stockfish][12] (C++), to [Fishtest][13] (HTML, CSS, JavaScript, and Python), to our trainer [nnue-pytorch][14] (C++ and Python), or to our [website][15] (HTML, CSS/SCSS, and JavaScript). The Stockfish team [1]: https://stockfishchess.org/download [2]: https://official-stockfish.github.io/docs/stockfish-wiki/Download-and-usage.html#download-a-chess-gui [3]: https://stockfishchess.org/get-involved/ [4]: https://discord.gg/GWDRS3kU6R [5]: https://tests.stockfishchess.org/tests/view/696a9e15cec152c6220c1d19 [6]: https://tests.stockfishchess.org/tests/view/696a9e4dcec152c6220c1d1b [7]: https://tests.stockfishchess.org/tests/view/696a9e83cec152c6220c1d1d [8]: https://openbenchmarking.org/test/pts/stockfish [9]: https://en.wikipedia.org/wiki/Stockfish_(chess)#Competition_results [10]: https://lczero.org/blog/2021/06/the-importance-of-open-data/ [11]: https://github.com/official-stockfish/Stockfish/stargazers [12]: https://github.com/official-stockfish/Stockfish [13]: https://github.com/official-stockfish/fishtest [14]: https://github.com/official-stockfish/nnue-pytorch [15]: https://github.com/official-stockfish/stockfish-web
closes #6581 No functional change
also add -flax-vector-conversions=none to the build closes #6587 No functional change
Somehow we forgot to add shm.h & shm_linux.h to the list of headers to be formatted. closes #6591 No functional change
closes #6583 No functional change
Add Move::to_sq_unchecked() that bypasses the is_ok() assertion, for use in branchless code paths where invalid moves are masked out. passed STC: LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 92384 W: 24052 L: 23665 D: 44667 Ptnml(0-2): 265, 10229, 24831, 10588, 279 https://tests.stockfishchess.org/tests/view/6974dfc798dc5fff1dba5b74 closes #6569 No functional change
Make the sf_assume also have an effect with clang and help the compiler proof it's side effect free by comparing against a variable. https://tests.stockfishchess.org/tests/view/6979d14fa2c75f923be1e681 LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 63488 W: 16530 L: 16188 D: 30770 Ptnml(0-2): 167, 6904, 17277, 7212, 184 closes #6573 No functional change
Improve `get_native_properties.sh` with a refreshed implementation. The new version covers all Makefile ARCH variants and keeps the script interface stable while improving portability and CPU feature detection across supported platforms. Drop the asset file name to avoid coupling outputs to a specific artifact naming scheme. Refs: https://github.com/ppigazzini/get-native-properties (includes a testing framework) closes #6552 No functional change.
Looks for the text "Official release version of Stockfish" in the commit message to determine if something is a release. closes #6580 No functional change
Passed STC Non-Regression: https://tests.stockfishchess.org/tests/view/696f1a398b64097dacd231c3 LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 122272 W: 31587 L: 31466 D: 59219 Ptnml(0-2): 301, 13358, 33750, 13373, 354 slight speedup as well: 1 thread bench: sf_base = 2238429 +/- 1221 (95%) sf_test = 2248298 +/- 1371 (95%) diff = 9869 +/- 1571 (95%) speedup = 0.44090% +/- 0.070% (95%) 32 thread speedtest: sf_base = 41016996 +/- 83654 (95%) sf_test = 41185801 +/- 84269 (95%) diff = 168805 +/- 79986 (95%) speedup = 0.41155% +/- 0.195% (95%) closes #6559 No functional change
Passed non-regression STC: LLR: 2.96 (-2.94,2.94) <-1.75,0.25> Total: 119680 W: 31011 L: 30884 D: 57785 Ptnml(0-2): 354, 13231, 32575, 13294, 386 https://tests.stockfishchess.org/tests/view/6973b06c6cd60a8e97ca62e5 closes #6565 No functional change
passed STC: LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 163680 W: 42214 L: 42137 D: 79329 Ptnml(0-2): 454, 18054, 44734, 18157, 441 https://tests.stockfishchess.org/tests/view/697e6f4e5f56030af97b5a3c closes #6588 No functional change
Removes threat features of the form piece -> king, thus saving 13MB of net space and approximately 0.8 threat feature updates per incremental accumulator update. Passed non-regression STC: LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 33664 W: 8864 L: 8636 D: 16164 Ptnml(0-2): 136, 3926, 8501, 4112, 157 https://tests.stockfishchess.org/tests/view/6981dcda4776a4e6e7fef2ac Passed non-regression LTC: LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 46896 W: 12077 L: 11881 D: 22938 Ptnml(0-2): 41, 5118, 12924, 5334, 31 https://tests.stockfishchess.org/tests/view/69827c6beb87369ff4d0c7d5 closes #6593 bench: 2668754
Deduplicating Color-Specific Piece Validation. The validation checks for the number of pawns and additional promoted pieces are duplicated for WHITE and BLACK. We can combine this logic into a single range-based for loop over both colors. closes #6922 No functional change
closes #6926 No functional change
Add `test80-2024-01-jan-2tb7p.min-v2.v6.relabel.binpack` to the distillation fine tuning stage, an additional 3.5B (2.9B non-skipped) positions. nettest PR: vondele/nettest#375 Passed STC (vs #6924): LLR: 2.94 (-2.94,2.94) <0.00,2.00> Total: 57952 W: 15000 L: 14656 D: 28296 Ptnml(0-2): 164, 6651, 15003, 6993, 165 https://tests.stockfishchess.org/tests/view/6a3cca103036e45021aeb6f8 Passed LTC: LLR: 2.95 (-2.94,2.94) <0.50,2.50> Total: 81456 W: 21265 L: 20858 D: 39333 Ptnml(0-2): 52, 8630, 22958, 9035, 53 https://tests.stockfishchess.org/tests/view/6a3dbe203036e45021aeb828 closes #6929 Bench: 2703604
This network is trained by adding the following binpacks, relabeled by @vondele and totaling 74B positions, to the distillation fine-tuning stage: ``` - vondele/from_kaggle_1_relabel/leela96-filt-v2.min.split_0.relabel-BT4-tf13tune.binpack - vondele/from_kaggle_1_relabel/leela96-filt-v2.min.split_1.relabel-BT4-tf13tune.binpack - vondele/from_kaggle_1_relabel/leela96-filt-v2.min.split_2.relabel-BT4-tf13tune.binpack - vondele/from_kaggle_1_relabel/leela96-filt-v2.min.split_3.relabel-BT4-tf13tune.binpack - vondele/from_kaggle_1_relabel/leela96-filt-v2.min.split_4.relabel-BT4-tf13tune.binpack - vondele/from_kaggle_2_relabel/T60T70wIsRightFarseerT60T74T75T76.split_0.relabel-BT4-tf13tune.binpack - vondele/from_kaggle_2_relabel/T60T70wIsRightFarseerT60T74T75T76.split_1.relabel-BT4-tf13tune.binpack - vondele/from_kaggle_2_relabel/T60T70wIsRightFarseerT60T74T75T76.split_2.relabel-BT4-tf13tune.binpack - vondele/from_kaggle_2_relabel/T60T70wIsRightFarseerT60T74T75T76.split_3.relabel-BT4-tf13tune.binpack - vondele/from_kaggle_2_relabel/T60T70wIsRightFarseerT60T74T75T76.split_4.relabel-BT4-tf13tune.binpack ``` The relabeling effort has been completed during the testing of this patch, and a full training run is on the way. Thanks to @vondele, @anematode, @Disservin, @yl25946, and all who've contributed to the process. Passed STC: LLR: 2.95 (-2.94,2.94) <0.00,2.00> Total: 24512 W: 6500 L: 6201 D: 11811 Ptnml(0-2): 69, 2772, 6300, 3021, 94 https://tests.stockfishchess.org/tests/view/6a40b7083036e45021aebbd6 Passed LTC: LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 15708 W: 4232 L: 3960 D: 7516 Ptnml(0-2): 8, 1572, 4420, 1848, 6 https://tests.stockfishchess.org/tests/view/6a413d293036e45021aebc84 nettest PR: vondele/nettest#388 closes #6932 Bench: 2102535 Co-authored-by: Joost VandeVondele <Joost.VandeVondele@gmail.com>
Simplifying the ratio in the eval between the psqt and the positional eval to a basic addition Passed Nonreg STC: https://tests.stockfishchess.org/tests/view/6a3eaac63036e45021aeb937 LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 207392 W: 53521 L: 53489 D: 100382 Ptnml(0-2): 585, 24412, 53748, 24288, 663 Passed Nonreg LTC: https://tests.stockfishchess.org/tests/view/6a423666f97ff95f7879508e LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 27198 W: 7200 L: 6989 D: 13009 Ptnml(0-2): 12, 2794, 7779, 2999, 15 closes #6934 Bench: 2067208
Updating nnue to a new architecture including a newly trained net using recipe vondele/nettest#395 and trainer official-stockfish/nnue-pytorch#480. The recipe contains many small improvements additionally the newly relabled data. Thus this is a combined effort. Passed STC https://tests.stockfishchess.org/tests/view/6a429fd8f97ff95f78795110 ``` LLR: 2.94 (-2.94,2.94) <0.00,2.00> Total: 25312 W: 6725 L: 6422 D: 12165 Ptnml(0-2): 78, 2915, 6397, 3158, 108 ``` Passed LTC https://tests.stockfishchess.org/tests/view/6a434c4cf97ff95f78795235 ``` LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 32814 W: 8655 L: 8345 D: 15814 Ptnml(0-2): 17, 3469, 9132, 3765, 24 ``` closes #6938 Bench: 2639962 Co-authored-by: anematode <anematode@users.noreply.github.com> Co-authored-by: Joost VandeVondele <vondele@users.noreply.github.com> Co-authored-by: xu-shawn <xu-shawn@users.noreply.github.com>
Passed STC: LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 26976 W: 7185 L: 6883 D: 12908 Ptnml(0-2): 89, 3058, 6895, 3354, 92 https://tests.stockfishchess.org/tests/view/6a46dd46f97ff95f78795707 Passed LTC: LLR: 2.95 (-2.94,2.94) <0.50,2.50> Total: 101394 W: 26460 L: 26009 D: 48925 Ptnml(0-2): 74, 10871, 28367, 11300, 85 https://tests.stockfishchess.org/tests/view/6a46eff2f97ff95f7879573b fixes a potential overflow when rescaling network evals. nettest: vondele/nettest#403 closes #6944 Bench: 2752030
Passed STC: LLR: 2.94 (-2.94,2.94) <0.00,2.00> Total: 246400 W: 63981 L: 63391 D: 119028 Ptnml(0-2): 612, 26055, 69299, 26599, 635 https://tests.stockfishchess.org/tests/view/6a3fafbf3036e45021aebaa0 Measured 1% speedup locally on x86-64-avx512icl build (bench 512 1 16, 50 runs): PASSED: speedup = +0.0104, P(speedup > 0) = 1.0000 closes #6936 No functional change
STC: https://tests.stockfishchess.org/tests/view/6a42f773f97ff95f7879518a LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 132992 W: 34679 L: 34248 D: 64065 Ptnml(0-2): 318, 14004, 37436, 14405, 333 No functional change Credit to @anematode for the original PR! closes #6941 No functional change
The depth dependency in best thread selection no longer seems to gain sufficiently and so can be simplified away. Passed non-reg STC SMP: LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 437904 W: 111841 L: 112051 D: 214012 Ptnml(0-2): 485, 49454, 119332, 49148, 533 https://tests.stockfishchess.org/tests/view/6a3158590d5d4b19d08055cd Passed non-reg LTC SMP: LLR: 3.11 (-2.94,2.94) <-1.75,0.25> Total: 484778 W: 123864 L: 124093 D: 236821 Ptnml(0-2): 121, 49237, 143920, 48972, 139 https://tests.stockfishchess.org/tests/view/6a377f3ba4f63d3271af0920 closes #6935 No functional change
The inputs have a different name.. https://github.com/thollander/actions-comment-pull-request#action-inputs closes #6940 No functional change
When compiling for Android (COMP=ndk) on macOS, the build fails because the NDK's LLVM toolchain does not recognize the macOS-specific flags -mdynamic-no-pic and -mmacosx-version-min. This PR wraps these flags with ifneq ($(COMP),ndk) condition to skip them during Android cross-compilation. Please squash and merge this PR. closes #6927 No functional change
Passed STC non-regression on avx512icl (https://tests.stockfishchess.org/tests/view/6a421b46f97ff95f78795061) LLR: 2.96 (-2.94,2.94) <-1.75,0.25> Total: 81632 W: 21240 L: 21075 D: 39317 Ptnml(0-2): 184, 8907, 22464, 9082, 179 Passed STC non-regression on bmi2 (https://tests.stockfishchess.org/tests/view/6a41f6f9f97ff95f7879503e) LLR: 2.93 (-2.94,2.94) <-1.75,0.25> Total: 78112 W: 20411 L: 20245 D: 37456 Ptnml(0-2): 188, 8449, 21632, 8583, 204 After #6845 , pext attacks are slower or equal to parallel-hyperbola attacks which works on all architectures that pext supports. SVE2 supports pext/pdep in vector registers, but it's much slower than the `rbit`-based HQ that we have on ARM, so I don't foresee the code being useful there. Ofc I don't think we should remove the `bmi2` build or anything, because it's nice for people to be able to freely use pext when testing ideas, and I'm sure we'll some day find another use for it! closes #6939 No functional change Co-authored-by: Dubslow <bunslow@gmail.com>
Performance on Spacemit K3, thanks @edolnx for testing master: Total time (ms) : 65200 Nodes searched : 3493826 Nodes/second : 53586 riscv-scalable-port: Total time (ms) : 15834 Nodes searched : 3493826 Nodes/second : 220653 Also thanks to @camel-cdr for guidance on RVV programming, and https://cloud-v.co for supplying an RVV instance to test with passed STC: LLR: 2.81 (-2.94,2.94) <0.00,2.00> Total: 1152 W: 527 L: 108 D: 517 Ptnml(0-2): 0, 17, 167, 348, 44 https://tests.stockfishchess.org/tests/view/6a39895b3036e45021aeb368 ## Summary We've had a `riscv64` target for a while, but haven't really optimized for it, in particular the vector extension (RVV). RVV, like SVE, is based on a scalable vector system where the vector length ranges from 128 to 65536. In practice implementations are between 128 and 2048, and 256 bits is quite common (e.g. the Spacemit K3 system above). Unfortunately this doesn't fit well into the rest of our code which assumes a fixed vector length, so what I've done is bypass the `VECTOR` ifdef (which now basically means "FIXED_LENGTH_VECTOR") and just have RVV-specific paths. The ability to explicitly control `vl` makes the code quite readable, in my opinion. We use LMUL>1 in most places to take advantage of multi-vector instructions. Generally the LMULs were chosen to best support a 256-bit vlen, which is very common, but by virtue of how the vlen control works, the code works with any vlen. In a couple places, i.e., `get_changed_pieces` and `AffineTransformSparseInput::propagate`, we have separate implementations depending on the vlen, because the optimal LMUL varies a lot between implementations. One little wrinkle is that `load_as` is compiled to a sequence of byte loads, because although unaligned loads are legal in RVA23, the spec says that they *may* be extremely slow (even though they usually aren't, in actual hw), so compilers are conservative. Thus I aligned the relevant buffers and made the semantics of `load_as` that the operand is aligned, by adding a runtime assertion. ### Universal binary Adding a universal binary is pretty easy and we can just cross-compile. There are two targets: baseline rv64gc and riscv64-rva23, which is actually a smaller subset of RVA23 that also works on some older processors that don't support the full thing. We use clang because GCC, until recently, has a nasty bug with LTO and RVV. Like the universal ARM and x86 builds, we check all the builds in CI. In this case we run bench with multiple vlens, 128 through 1024. In the meantime I deleted the existing broken and unused riscv64 tests. ### Follow-ups - Optimizations - zvdot4a8i path closes #6920 No functional change
Fixes problems with non-ASCII characters in paths. Fixes #3424. Changes - Bump the minimum supported Clang version to 11 to support std::filesystem - Use std::optional for empty values instead of string sentinels like "None" - Remove the FixedString class - Move the EvalFile network path from the network struct to the engine - Simplify parts of the command-line handling - Remove the old dual-net logic from export_net - And ofc we now support non-ascii paths for windows Behavior Change - Because the EvalFile is no longer part of the network, it won't be included in the hashing, thus the network sharing is no longer dependent on the EvalFile path - As a result, if the binary version and network are the same, changing only the EvalFile location will now reuse the same shared network This also fixes a master bug where: ``` export_net None setoption name EvalFile value None export_net None Failed to export a net ``` would fail on the second export. With this patch, the second export succeeds. Quick Fishtest Check that nets load like normal. https://tests.stockfishchess.org/tests/view/6a455593f97ff95f787954da <img width="833" height="1137" alt="image" src="https://github.com/user-attachments/assets/fffee63b-c63a-4d5e-b13d-87d58bc28c88" /> closes #6937 No functional change Co-authored-by: anematode <timothy.herchen@gmail.com>
GCC 12.2 added `__rbitll` intrinsic to `arm_acle.h`, so we can add a fallback for older versions Clang 10 (our new minimum supported version) is unaffected by all this closes #6949 No functional change
Clang 22 apparently has a codegen regression in capture() and capture_stage() functions. GCC and the other versions of Clang also showed a marginal speedup which however could be due to noise. Combined results of two STC tests: https://tests.stockfishchess.org/tests/view/6a45b104f97ff95f78795570 https://tests.stockfishchess.org/tests/view/6a474aaff97ff95f787957a9 STC (clang++ 22): LLR: 2.811 (-2.944,2.944) <0.00,2.00> Ptnml(0-2): 67, 3094, 7975, 3306, 102 Non-regression STC (g++, clang++ ~21): LLR: 6.617 (-2.944,2.944) <-1.75,0.25> Ptnml(0-2): 428, 22211, 56555, 22553, 429 Local test results (Zen 4, x86-64-avx512icl, bench 512 1 16, 50 runs): Clang (22.1.2): PASSED: speedup = +0.0169, P(speedup > 0) = 1.0000 GCC (15.2.0): FAILED: speedup = +0.0031, P(speedup > 0) = 0.9597 closes #6945 No functional change
this patch simplifies the Value futility multiplier and changes pruning behaviour passed stc: https://tests.stockfishchess.org/tests/view/6a462265f97ff95f78795600 LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 38112 W: 10071 L: 9758 D: 18283 Ptnml(0-2): 88, 4341, 9903, 4618, 106 passed ltc: https://tests.stockfishchess.org/tests/view/6a470bc5f97ff95f7879576a LLR: 2.94 (-2.94,2.94) <0.50,2.50> Total: 67482 W: 17738 L: 17363 D: 32381 Ptnml(0-2): 36, 7061, 19164, 7452, 28 patch rebased to latest master closes #6946 Bench: 2353997
Speedup measured locally with apple-silicon M3 Pro: ``` Result of 50 runs ================== base (./sf_master ) = 1817788 +/- 4388 test (...on_sparse_3c) = 1839826 +/- 5482 diff = +22039 +/- 3215 speedup = +0.0121 P(speedup > 0) = 1.0000 CPU: 11 x arm Hyperthreading: off ``` Passed STC: https://tests.stockfishchess.org/tests/view/6a496a49f97ff95f78795b3d LLR: 2.92 (-2.94,2.94) <0.00,2.00> Total: 44384 W: 11659 L: 11351 D: 21374 Ptnml(0-2): 86, 4673, 12406, 4901, 126 closes #6951 No functional change
In the spirit of previous such PRs, this PR proposes a collection of nonfunctional changes. I am happy to incorporate changes from other devs, and revert some of the proposed changes if the maintainers ask me to. Apart from trivial changes, the proposed changes so far include: * A requested edit to `AUTHORS` and a resorting of all entries, following DIN 5007 for the treatment of any special characters. * Exclude the two recent integer type renaming commits from git blame. * Tightening of some static asserts in `history.h` to avoid overflows. (Note that rounding errors for floating point types could lead to the assert in `operator<<` triggering at run-time.) * Re-instate the 0.5s maximal thinking time in case of a single legal move and reword the comment to make it clear that it should not be tuned. * ~~A small refactoring of the network loading code thanks to @dubslow.~~ * A refactoring of the "dtz is dtm" code, also thanks to @dubslow. closes #6928 No functional change
Reduce the number of *easy* ways to hit UB or an uncaught exception. This builds on Sopel's work on FEN validation. Obviously SF is not and will never be a security boundary, but at least we can reduce the number of reports about uncaught `std::stoi` out of range, etc. I also added a gentle fallback to `NumaConfig` specifically because that's something that (as a dev) I frequently set by hand in the CLI, but happy to revert if that's too annoying of a change. closes #6844 No functional change
Speedup measured locally with apple-silicon M3 Pro: ``` Result of 50 runs ================== base (./sf-master ) = 1570076 +/- 27215 test (...-neon-2chain) = 1578923 +/- 29000 diff = +8847 +/- 5700 speedup = +0.0056 P(speedup > 0) = 0.9988 CPU: 11 x arm Hyperthreading: off ``` Passed STC: https://tests.stockfishchess.org/tests/view/6a49678cf97ff95f78795b38 LLR: 4.43 (-2.94,2.94) <0.00,2.00> Total: 137696 W: 36041 L: 35477 D: 66178 Ptnml(0-2): 289, 14663, 38396, 15195, 305 closes #6956 No functional change
`Skill::pick_best()` assumes the root moves are sorted by score in descending order:
```cpp
Value topScore = rootMoves[0].score;
int delta = std::min(topScore - rootMoves[multiPV - 1].score, int(PawnValue));
```
That does not have to be so with Syzygy tablebases at the root, where the moves are ordered by `tbRank` instead. `rootMoves[0]` is then not the highest score and `delta` can go negative. Since `delta * (rng.rand<unsigned>() % int(weakness))` is evaluated as unsigned, a negative `delta` wraps to a large value and the `int(...)` cast overflows, so the `score + push >= maxScore` check never passes and `best` stays `Move::none()`. The caller
```cpp
std::swap(rootMoves[0],
*std::find(rootMoves.begin(), rootMoves.end(),
skill.best ? skill.best : skill.pick_best(rootMoves, multiPV)));
```
then dereferences `end()`. The result is a crash, or sometimes `bestmove (none)` / an illegal move, in tablebase endgames when `UCI_LimitStrength` is set (or `Skill Level` is below 20).
The fix computes the score range over the candidate moves directly, so `delta` stays non-negative and a valid move is always returned.
**To reproduce**:
```
setoption name UCI_LimitStrength value true
setoption name UCI_Elo value 2900
setoption name SyzygyPath value <syzygy tablebases path>
position fen 8/8/8/4k3/8/8/3BKN2/8 b - - 0 1
go wtime 250 btime 250 winc 100 binc 100
```
You need to call the go command a couple of times before crash, after which is ends with
```
bestmove a1e5 ponder (none)
```
and on the next `go wtime 250 btime 250 winc 100 binc 100` it crashes printing:
```
info string Available processors: 0-31
info string Using 1 thread
info string NNUE evaluation using nn-af1339a6dea3.nnue (106MiB, (83248, 1024, 31, 32, 1))
info string Network replica 1: Shared memory.
```
Bench is unchanged, since this code only runs under `UCI_LimitStrength` / `Skill Level`.
closes #6957
No functional change
Improves calculation of root move score averages by dynamically calculating weight based on effort Passed STC https://tests.stockfishchess.org/tests/view/6a4ada97f97ff95f78795d5a ``` LLR: 2.93 (-2.94,2.94) <0.00,2.00> Total: 157248 W: 41003 L: 40515 D: 75730 Ptnml(0-2): 419, 18320, 40644, 18836, 405 ``` Passed LTC ``` LLR: 3.03 (-2.94,2.94) <0.50,2.50> Total: 197460 W: 51626 L: 50982 D: 94852 Ptnml(0-2): 85, 20849, 56237, 21455, 104 ``` closes #6960 Bench: 2388656
Speedup measured by @anematode ``` Result of 100 runs ================== base (...h.master.exe) = 1504448 +/- 15119 test (./stockfish.exe) = 1519239 +/- 15980 diff = +14791 +/- 4113 speedup = +0.0098 P(speedup > 0) = 1.0000 CPU: Intel Core Ultra 9 285H ``` Passed STC: https://tests.stockfishchess.org/tests/view/6a4dc4c65529b8472df7fd56 LLR: 2.94 (-2.94,2.94) <0.00,2.00> Total: 48256 W: 12746 L: 12420 D: 23090 Ptnml(0-2): 144, 5310, 12913, 5598, 163 closes #6961 No functional change
This patch introduces a dynamic scaling factor for Null Move Pruning (NMP) reductions. By scaling the reduction depth relative to the static evaluation margin against beta, the engine can afford more aggressive reductions in positions that are overwhelmingly favorable, optimizing CPU cycle utilization without compromising search integrity. Passed STC: LLR: 2.94 (-2.94,2.94) <0.00,2.00> Total: 85504 W: 22383 L: 22000 D: 41121 Ptnml(0-2): 225, 9855, 22218, 10220, 234 https://tests.stockfishchess.org/tests/view/6a4793daf97ff95f78795812 Passed LTC: LLR: 2.95 (-2.94,2.94) <0.50,2.50> Total: 205800 W: 53879 L: 53224 D: 98697 Ptnml(0-2): 98, 21747, 58561, 22390, 104 https://tests.stockfishchess.org/tests/view/6a4b864ff97ff95f78795e52 closes #6963 Bench: 2513153
Passed STC non-reg: LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 124864 W: 32270 L: 32151 D: 60443 Ptnml(0-2): 273, 13766, 34278, 13799, 316 https://tests.stockfishchess.org/tests/view/6a44f4d9f97ff95f78795463 Passed LTC non-reg: LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 335544 W: 87272 L: 87369 D: 160903 Ptnml(0-2): 157, 34355, 98852, 34244, 164 https://tests.stockfishchess.org/tests/view/6a46a188f97ff95f787956a1 closes #6964 Bench: 2890786
Use sha and git diff-index status for full version string. closes #6965 No functional change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.