From 49f321304ac1176b982d35f2bee1ddfa3383eae1 Mon Sep 17 00:00:00 2001 From: Lemmy <10430540+TierynnB@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:48:13 +1000 Subject: [PATCH] Squashed commit of the following: commit 524083a3d5f910c247c28c643ee619394b231bab Merge: 8a0206f0 4a5ba40f Author: Tierynn Byrnes Date: Fri Feb 23 08:42:30 2024 +1000 Merge branch 'TM_Change_2' of https://github.com/TierynnB/Stockfish into TM_Change_2 commit 8a0206f009ee428b7c8f1f4d0d2ff4ab0155394d Author: Tierynn Byrnes Date: Mon Feb 19 07:13:26 2024 +1000 use current time instead of '1' for timeLeft formula. make timeLeft a double, timepoint seemed unecessary since it was always casting back to double anyway. fixed comments Squashed commits commit 4a5ba40f9ef67d6b143bddb4733245e306dcd3f9 Merge: ce952bf7 676a1d71 Author: Tierynn Byrnes Date: Fri Feb 23 08:01:21 2024 +1000 Merge branch 'TM_Change_2' of https://github.com/TierynnB/Stockfish into TM_Change_2 commit ce952bf7fa2f1d56cb69c96c4a078ec2845aa125 Author: cj5716 <125858804+cj5716@users.noreply.github.com> Date: Tue Feb 13 17:46:37 2024 +0800 Simplify PV node reduction Reduce less on PV nodes even with an upperbound TT entry. Passed STC: https://tests.stockfishchess.org/tests/view/65cb3a861d8e83c78bfd0497 LLR: 2.96 (-2.94,2.94) <-1.75,0.25> Total: 118752 W: 30441 L: 30307 D: 58004 Ptnml(0-2): 476, 14179, 29921, 14335, 465 Passed LTC: https://tests.stockfishchess.org/tests/view/65cd3b951d8e83c78bfd2b0d LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 155058 W: 38549 L: 38464 D: 78045 Ptnml(0-2): 85, 17521, 42219, 17632, 72 closes https://github.com/official-stockfish/Stockfish/pull/5057 Bench: 1303971 commit 4acf8106f36f376ffe474afcd24784dd2c81faf1 Author: Linmiao Xu Date: Tue Feb 6 11:21:15 2024 -0500 Update default main net to nn-b1a57edbea57.nnue Created by retraining the previous main net `nn-baff1edbea57.nnue` with: - some of the same options as before: ranger21, more WDL skipping - the addition of T80 nov+dec 2023 data - increasing loss by 15% when prediction is too high, up from 10% - use of torch.compile to speed up training by over 25% ```yaml experiment-name: 2560--S9-514G-T80-augtodec2023-more-wdl-skip-15p-more-loss-high-q-sk28 training-dataset: # https://github.com/official-stockfish/Stockfish/pull/4782 - /data/S6-514G-1ee1aba5ed.binpack - /data/test80-aug2023-2tb7p.v6.min.binpack - /data/test80-sep2023-2tb7p.binpack - /data/test80-oct2023-2tb7p.binpack - /data/test80-nov2023-2tb7p.binpack - /data/test80-dec2023-2tb7p.binpack early-fen-skipping: 28 start-from-engine-test-net: True nnue-pytorch-branch: linrock/nnue-pytorch/r21-more-wdl-skip-15p-more-loss-high-q-torch-compile num-epochs: 1000 lr: 4.375e-4 gamma: 0.995 start-lambda: 1.0 end-lambda: 0.7 ``` Epoch 819 trained with the above config led to this PR. Use of torch.compile decorators in nnue-pytorch model.py was found to speed up training by at least 25% on Ampere gpus when using recent pytorch compiled with cuda 12: https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch See recent main net PRs for more info on - ranger21 and more WDL skipping: https://github.com/official-stockfish/Stockfish/pull/4942 - increasing loss when Q is too high: https://github.com/official-stockfish/Stockfish/pull/4972 Training data can be found at: https://robotmoon.com/nnue-training-data/ Passed STC: https://tests.stockfishchess.org/tests/view/65cd76151d8e83c78bfd2f52 LLR: 2.98 (-2.94,2.94) <0.00,2.00> Total: 78336 W: 20504 L: 20115 D: 37717 Ptnml(0-2): 317, 9225, 19721, 9562, 343 Passed LTC: https://tests.stockfishchess.org/tests/view/65ce5be61d8e83c78bfd43e9 LLR: 2.95 (-2.94,2.94) <0.50,2.50> Total: 41016 W: 10492 L: 10159 D: 20365 Ptnml(0-2): 22, 4533, 11071, 4854, 28 closes https://github.com/official-stockfish/Stockfish/pull/5056 Bench: 1351997 commit 40c6cdfdca97530088dbc4b2141e5d2f198b8f54 Author: cj5716 <125858804+cj5716@users.noreply.github.com> Date: Tue Feb 13 17:50:16 2024 +0800 Simplify TT PV reduction This also removes some incorrect fail-high logic. Passed STC: https://tests.stockfishchess.org/tests/view/65cb3b641d8e83c78bfd04a9 LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 87968 W: 22634 L: 22468 D: 42866 Ptnml(0-2): 315, 10436, 22323, 10588, 322 Passed LTC: https://tests.stockfishchess.org/tests/view/65cccee21d8e83c78bfd222c LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 70794 W: 17846 L: 17672 D: 35276 Ptnml(0-2): 44, 7980, 19189, 8126, 58 closes https://github.com/official-stockfish/Stockfish/pull/5055 Bench: 1474424 commit 9299d0144b3e96aeaaf07fc3efdf559b351fd63e Author: Gahtan Nahdi <155860115+gahtan-syarif@users.noreply.github.com> Date: Sat Feb 10 03:51:05 2024 +0700 Remove penalty for quiet ttMove that fails low Passed STC non-reg: https://tests.stockfishchess.org/tests/view/65c691a7c865510db0286e6e LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 234336 W: 60258 L: 60255 D: 113823 Ptnml(0-2): 966, 28141, 58918, 28210, 933 Passed LTC non-reg: https://tests.stockfishchess.org/tests/view/65c8d0d31d8e83c78bfcd4a6 LLR: 2.95 (-2.94,2.94) <-1.75,0.25> Total: 235206 W: 59134 L: 59132 D: 116940 Ptnml(0-2): 135, 26908, 63517, 26906, 137 https://github.com/official-stockfish/Stockfish/pull/5054 Bench: 1287996 commit 676a1d712d58ecf72212ac98a6beb0e6dbdbdfbd Merge: 7d0cd7bb 3c3f88b2 Author: Tierynn Byrnes Date: Fri Feb 23 07:58:38 2024 +1000 Merge branch 'TM_Change_2' of https://github.com/TierynnB/Stockfish into TM_Change_2 commit 7d0cd7bb63ac5d2ee7299a49a44f5b0521da9de2 Author: Tierynn Byrnes Date: Mon Feb 19 07:13:26 2024 +1000 parent 8b67b7ecd8b0d4d4ddf8c15c44806f8a6ab441d7 author Tierynn Byrnes 1708290806 +1000 committer Tierynn Byrnes 1708638981 +1000 use current time instead of '1' for timeLeft formula. make timeLeft a double, timepoint seemed unecessary since it was always casting back to double anyway. commit 3c3f88b2b8557bedd071cad99675e7535ba45114 Merge: 76c50a0d 61e80832 Author: Tierynn Byrnes Date: Fri Feb 23 07:54:46 2024 +1000 Merge branch 'TM_Change_2' of https://github.com/TierynnB/Stockfish into TM_Change_2 commit 76c50a0df3e19b85f27721c0e90226fe4a1f47ff Author: Tierynn Byrnes Date: Mon Feb 19 07:13:26 2024 +1000 use current time instead of '1' for timeLeft formula. make timeLeft a double, timepoint seemed unecessary since it was always casting back to double anyway. fixed comments commit 61e808328cb764194806528f68ca205b16f1c372 Merge: 5cf3f49d 8afec41f Author: Tierynn Byrnes Date: Thu Feb 22 19:44:21 2024 +1000 Merge branch 'TM_Change_2' of https://github.com/TierynnB/Stockfish into TM_Change_2 commit 5cf3f49d4ea7ffaa46bca70e41f819f1c3881633 Author: Tierynn Byrnes Date: Mon Feb 19 07:13:26 2024 +1000 use current time instead of '1' for timeLeft formula. make timeLeft a double, timepoint seemed unecessary since it was always casting back to double anyway. commit 8afec41fb973ed236c125c518f33e2bc920bc8c1 Author: Tierynn Byrnes Date: Mon Feb 19 07:50:30 2024 +1000 fixed comments commit de4a3c47a666b5ddc8d469b62bf858a6ea71d03c Author: Tierynn Byrnes Date: Mon Feb 19 07:32:09 2024 +1000 make timeLeft a double, timepoint seemed unecessary since it was always casting back to double anyway. commit e1f6b8718c7875c1c3c183b2d17829acbfe400a5 Merge: 8b67b7ec fc41f64d Author: Lemmy <10430540+TierynnB@users.noreply.github.com> Date: Mon Feb 19 07:14:27 2024 +1000 Merge branch 'official-stockfish:master' into TM_Change_2 commit 8b67b7ecd8b0d4d4ddf8c15c44806f8a6ab441d7 Author: Tierynn Byrnes Date: Mon Feb 19 07:13:26 2024 +1000 use current time instead of '1' for timeLeft formula. --- src/timeman.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/timeman.cpp b/src/timeman.cpp index 72a447af5b8..6ba1f2cacab 100644 --- a/src/timeman.cpp +++ b/src/timeman.cpp @@ -81,15 +81,22 @@ void TimeManagement::init(Search::LimitsType& limits, limits.npmsec = npmsec; } - // Maximum move horizon of 50 moves + // Maximum and default move horizon of 50 moves int mtg = limits.movestogo ? std::min(limits.movestogo, 50) : 50; - // Make sure timeLeft is > 0 since we may use it as a divisor - TimePoint timeLeft = std::max(TimePoint(1), limits.time[us] + limits.inc[us] * (mtg - 1) - - moveOverhead * (2 + mtg)); + // Make sure timeLeft is > 0 since we use it as a divisor + double timeLeft = + std::max(limits.time[us], limits.time[us] + limits.inc[us] * (mtg - 1) - moveOverhead * mtg); + + // Use extra time with larger increments + double optExtra = std::clamp(1.0 + 12.5 * limits.inc[us] / limits.time[us], 1.0, 1.11); + + // Calculate time constants based on current time left. + double optConstant = std::min(0.00334 + 0.0003 * std::log10(limits.time[us] / 1000.0), 0.0049); + double maxConstant = std::max(3.4 + 3.0 * std::log10(limits.time[us] / 1000.0), 2.76); // x basetime (+ z increment) - // If there is a healthy increment, timeLeft can exceed actual available + // If there is a healthy increment and low mtg, timeLeft can exceed actual available // game time for the current move, so also cap to 20% of available game time. if (limits.movestogo == 0) { @@ -102,7 +109,7 @@ void TimeManagement::init(Search::LimitsType& limits, double maxConstant = std::max(3.4 + 3.0 * std::log10(limits.time[us] / 1000.0), 2.76); optScale = std::min(0.0120 + std::pow(ply + 3.1, 0.44) * optConstant, - 0.21 * limits.time[us] / double(timeLeft)) + 0.21 * limits.time[us] / timeLeft) * optExtra; maxScale = std::min(6.9, maxConstant + ply / 12.2); } @@ -110,7 +117,7 @@ void TimeManagement::init(Search::LimitsType& limits, // x moves in y seconds (+ z increment) else { - optScale = std::min((0.88 + ply / 116.4) / mtg, 0.88 * limits.time[us] / double(timeLeft)); + optScale = std::min((0.88 + ply / 116.4) / mtg, 0.88 * limits.time[us] / timeLeft); maxScale = std::min(6.3, 1.5 + 0.11 * mtg); }