Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 524083a
Merge: 8a0206f 4a5ba40
Author: Tierynn Byrnes <[email protected]>
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 8a0206f
Author: Tierynn Byrnes <[email protected]>
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 4a5ba40
Merge: ce952bf 676a1d7
Author: Tierynn Byrnes <[email protected]>
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 ce952bf
Author: cj5716 <[email protected]>
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 official-stockfish#5057

    Bench: 1303971

commit 4acf810
Author: Linmiao Xu <[email protected]>
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:
      # official-stockfish#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: official-stockfish#4942
    - increasing loss when Q is too high: official-stockfish#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 official-stockfish#5056

    Bench: 1351997

commit 40c6cdf
Author: cj5716 <[email protected]>
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 official-stockfish#5055

    Bench: 1474424

commit 9299d01
Author: Gahtan Nahdi <[email protected]>
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

    official-stockfish#5054

    Bench: 1287996

commit 676a1d7
Merge: 7d0cd7b 3c3f88b
Author: Tierynn Byrnes <[email protected]>
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 7d0cd7b
Author: Tierynn Byrnes <[email protected]>
Date:   Mon Feb 19 07:13:26 2024 +1000

    parent 8b67b7e
    author Tierynn Byrnes <[email protected]> 1708290806 +1000
    committer Tierynn Byrnes <[email protected]> 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 3c3f88b
Merge: 76c50a0 61e8083
Author: Tierynn Byrnes <[email protected]>
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 76c50a0
Author: Tierynn Byrnes <[email protected]>
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 61e8083
Merge: 5cf3f49 8afec41
Author: Tierynn Byrnes <[email protected]>
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 5cf3f49
Author: Tierynn Byrnes <[email protected]>
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 8afec41
Author: Tierynn Byrnes <[email protected]>
Date:   Mon Feb 19 07:50:30 2024 +1000

    fixed comments

commit de4a3c4
Author: Tierynn Byrnes <[email protected]>
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 e1f6b87
Merge: 8b67b7e fc41f64
Author: Lemmy <[email protected]>
Date:   Mon Feb 19 07:14:27 2024 +1000

    Merge branch 'official-stockfish:master' into TM_Change_2

commit 8b67b7e
Author: Tierynn Byrnes <[email protected]>
Date:   Mon Feb 19 07:13:26 2024 +1000

    use current time instead of '1' for timeLeft formula.
  • Loading branch information
TierynnB committed Feb 23, 2024
1 parent fc41f64 commit 49f3213
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/timeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -102,15 +109,15 @@ 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);
}

// 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);
}

Expand Down

0 comments on commit 49f3213

Please sign in to comment.