Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CrazyAra nodes decreasing after 16 million nodes #39

Closed
catask opened this issue May 17, 2020 · 4 comments
Closed

CrazyAra nodes decreasing after 16 million nodes #39

catask opened this issue May 17, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@catask
Copy link

catask commented May 17, 2020

After 16.2 million nodes, CrazyAra node count starts going down (and also NPS). Not sure if this is a bug or intentional in some way.
image
As you can see it reached a max of around 16.3 mio nodes, then every second after it decreased by around 500nodes/second.

@catask
Copy link
Author

catask commented May 18, 2020

Edit: root command shows that the limit of visits is 2^24. Any particular reason for this?

@QueensGambit QueensGambit added the bug Something isn't working label May 21, 2020
@QueensGambit
Copy link
Owner

Thank you @catask for this bug report.
The problem was indeed due to reaching a numerical limitation because 2^24 exceeds the maximum representable positive floating point value:

I replaced float by uint32_t in a6e3628 for the number of visits which consumes the same memory but now allows generating 4,294,967,295 = 2^32 MCTS simulations in the search tree.

I plan to create a bug fix release 0.8.1 which fixes this issue and a rare crashing problem of the engine.

@QueensGambit
Copy link
Owner

QueensGambit commented Apr 9, 2021

The issue seems to re-occur again both for search type mcgs as well as mcts.

log for CrazyAra from starting position, Search_Type=mcgs:

info depth 92 seldepth 96 multipv 1 score cp 74 nodes 15091232 nps 16709 tbhits 0 time 903206 pv g1f3 d7d5 d2d4 c8f5 c1g5 h7h6 g5h4 b8c6 b1c3 g7g5 h4g3 f8g7 e2e3 c6b4 a1c1 g8f6 a2a3 b4c6 f1d3 f6e4 e1g1 e8g8 g1h1 g8h8 d1e2 d8d7 f1g1 a8d8 c1f1 f8g8 f3d2 e4d2 e2d2 N@e4 d2e2 d8f8 N@h5 g5g4 h5g7 g8g7 B@f4 N@g8 g3h4 f7f6 f2f3 g4f3 g2f3 e7e5 f3e4 d5e4 d3e4 P@h3 e4f5 P@g2 g1g2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 P@h3 e4f5 P@g2 g1g2 h3g2 e2g2 g7g2 f5d7 R@g7 B@g4 e5f4 h1g2 c6d4 e3d4 B@c6 d7c6 g7g4 g2h1 b7c6 R@h7 h8h7 B@e4 f6f5 P@g2 Q@g7 Q@e5 f5e4 e5g7 g4g7 P@g6 g7g6 P@h5 Q@g7 h5g6 g7g6 Q@d7 R@g7 R@g4 g6g4 d7g4 g7g4
info depth 92 seldepth 96 multipv 1 score cp 74 nodes 15085769 nps 16610 tbhits 0 time 908208 pv g1f3 d7d5 d2d4 c8f5 c1g5 h7h6 g5h4 b8c6 b1c3 g7g5 h4g3 f8g7 e2e3 c6b4 a1c1 g8f6 a2a3 b4c6 f1d3 f6e4 e1g1 e8g8 g1h1 g8h8 d1e2 d8d7 f1g1 a8d8 c1f1 f8g8 f3d2 e4d2 e2d2 N@e4 d2e2 d8f8 N@h5 g5g4 h5g7 g8g7 B@f4 N@g8 g3h4 f7f6 f2f3 g4f3 g2f3 e7e5 f3e4 d5e4 d3e4 P@h3 e4f5 P@g2 g1g2 h3g2 e2g2 g7g2 f5d7 R@g7 B@g4 e5f4 h1g2 c6d4 e3d4 B@c6 d7c6 g7g4 g2h1 b7c6 R@h7 h8h7 B@e4 f6f5 P@g2 Q@g7 Q@e5 f5e4 e5g7 g4g7 P@g6 g7g6 P@h5 Q@g7 h5g6 g7g6 Q@d7 R@g7 R@g4 g6g4 d7g4 g7g4
info depth 92 seldepth 96 multipv 1 score cp 74 nodes 15084391 nps 16591 tbhits 0 time 909208 pv g1f3 d7d5 d2d4 c8f5 c1g5 h7h6 g5h4 b8c6 b1c3 g7g5 h4g3 f8g7 e2e3 c6b4 a1c1 g8f6 a2a3 b4c6 f1d3 f6e4 e1g

log for ClassicAra from starting position, Search_Type=mcts:

info depth 38 seldepth 44 multipv 1 score cp 51 nodes 16769078 nps 18546 tbhits 0 time 904170 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 f8b4 c1g5 d5c4 e2e4 c7c5 f1c4 c5d4 f3d4 d8a5 g5d2 a5c5 c4b5 c8d7 d4b3 c5b6 b5d3 b8c6 e1g1 c6e5 d2e3 b6d6 d3e2 d6d1 f1d1 b4c3 b2c3 f6e4 e3d4 f7f6 f2f3 e4d6
info depth 38 seldepth 44 multipv 1 score cp 51 nodes 16769053 nps 18526 tbhits 0 time 905170 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 f8b4 c1g5 d5c4 e2e4 c7c5 f1c4 c5d4 f3d4 d8a5 g5d2 a5c5 c4b5 c8d7 d4b3 c5b6 b5d3 b8c6 e1g1 c6e5 d2e3 b6d6 d3e2 d6d1 f1d1 b4c3 b2c3 f6e4 e3d4 f7f6 f2f3 e4d6
info depth 38 seldepth 44 multipv 1 score cp 51 nodes 16769025 nps 18505 tbhits 0 time 906170 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 f8b4 c1g5 d5c4 e2e4 c7c5 f1c4 c5d4 f3d4 d8a5 g5d2 a5c5 c4b5 c8d7 d4b3 c5b6 b5d3 b8c6 e1g1 c6e5 d2e3 b6d6 d3e2 d6d1 f1d1 b4c3 b2c3 f6e4 e3d4 f7f6 f2f3 e4d6
info depth 38 seldepth 44 multipv 1 score cp 51 nodes 16769008 nps 18485 tbhits 0 time 907171 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 f8b4 c1g5 d5c4 e2e4 c7c5 f1c4 c5d4 f3d4 d8a5 g5d2 a5c5 c4b5 c8d7 d4b3 c5b6 b5d3 b8c6 e1g1 c6e5 d2e3 b6d6 d3e2 d6d1 f1d1 b4c3 b2c3 f6e4 e3d4 f7f6 f2f3 e4d6
info depth 38 seldepth 44 multipv 1 score cp 51 nodes 16768987 nps 18465 tbhits 0 time 908171 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 f8b4 c1g5 d5c4 e2e4 c7c5 f1c4 c5d4 f3d4 d8a5 g5d2 a5c5 c4b5 c8d7 d4b3 c5b6 b5d3 b8c6 e1g1 c6e5 d2e3 b6d6 d3e2 d6d1 f1d1 b4c3 b2c3 f6e4 e3d4 f7f6 f2f3 e4d6

Root command shows visits > 16 million.

info string apply move to tree
root
  #  | Move  |    Visits    |  Policy   |  Q-values  |  CP   |    Type    
-----+-------+--------------+-----------+------------+-------+------------
 001 |    d4 |     18676687 | 0.2907067 |  0.1066185 |    61 |  UNSOLVED
 000 |    e4 |       494800 | 0.3534094 |  0.0734411 |    41 |  UNSOLVED
 002 |   Nf3 |       325991 | 0.1475940 |  0.0834626 |    47 |  UNSOLVED
 003 |    c4 |       178554 | 0.1050453 |  0.0777516 |    44 |  UNSOLVED
 004 |    g3 |        38636 | 0.0307955 |  0.0563404 |    31 |  UNSOLVED
 005 |    b3 |        34696 | 0.0222731 |  0.0476352 |    26 |  UNSOLVED
 007 |   Nc3 |        32128 | 0.0089250 |  0.0570832 |    32 |  UNSOLVED
 018 |    h4 |        31766 | 0.0007151 |  0.0447622 |    25 |  UNSOLVED
 012 |    g4 |        31726 | 0.0020321 |  0.0017689 |     0 |  UNSOLVED
 008 |    e3 |        31723 | 0.0048269 |  0.0529488 |    29 |  UNSOLVED
 017 |   Nh3 |        31697 | 0.0007326 |  0.0295292 |    16 |  UNSOLVED
 016 |    a4 |        31688 | 0.0007822 |  0.0320324 |    17 |  UNSOLVED
 006 |    f4 |        31640 | 0.0156891 |  0.0088752 |     4 |  UNSOLVED
 015 |    h3 |        31583 | 0.0009797 |  0.0491602 |    27 |  UNSOLVED
 010 |    a3 |        31571 | 0.0039296 |  0.0546463 |    30 |  UNSOLVED
 014 |    f3 |        31565 | 0.0010401 |  0.0159474 |     8 |  UNSOLVED
 009 |    b4 |        31522 | 0.0046526 |  0.0318002 |    17 |  UNSOLVED
 013 |    c3 |        31485 | 0.0019126 |  0.0503534 |    28 |  UNSOLVED
 011 |    d3 |        31376 | 0.0034245 |  0.0321645 |    17 |  UNSOLVED
 019 |   Na3 |        31318 | 0.0005335 |  0.0323622 |    18 |  UNSOLVED
-----+-------+--------------+-----------+------------+-------+------------
initial value:	0.0983739
nodeType:	UNSOLVED
isTerminal:	0
isTablebase:	0
unsolvedNodes:	20
Visits:		16777216
freeVisits:	3076608/16777216
root
  #  | Move  |    Visits    |  Policy   |  Q-values  |  CP   |    Type    
-----+-------+--------------+-----------+------------+-------+------------
 001 |    d4 |     19164656 | 0.2907067 |  0.1080278 |    62 |  UNSOLVED
 000 |    e4 |       495589 | 0.3534094 |  0.0734571 |    41 |  UNSOLVED
 002 |   Nf3 |       326789 | 0.1475940 |  0.0834572 |    47 |  UNSOLVED
 003 |    c4 |       179353 | 0.1050453 |  0.0777568 |    44 |  UNSOLVED
 004 |    g3 |        39382 | 0.0307955 |  0.0563129 |    31 |  UNSOLVED
 005 |    b3 |        35468 | 0.0222731 |  0.0475062 |    26 |  UNSOLVED
 007 |   Nc3 |        32930 | 0.0089250 |  0.0570678 |    32 |  UNSOLVED
 018 |    h4 |        32593 | 0.0007151 |  0.0443781 |    24 |  UNSOLVED
 012 |    g4 |        32517 | 0.0020321 |  0.0016173 |     0 |  UNSOLVED
 017 |   Nh3 |        32499 | 0.0007326 |  0.0294725 |    16 |  UNSOLVED
 008 |    e3 |        32482 | 0.0048269 |  0.0529293 |    29 |  UNSOLVED
 016 |    a4 |        32447 | 0.0007822 |  0.0317133 |    17 |  UNSOLVED
 006 |    f4 |        32399 | 0.0156891 |  0.0087123 |     4 |  UNSOLVED
 010 |    a3 |        32375 | 0.0039296 |  0.0545923 |    30 |  UNSOLVED
 014 |    f3 |        32354 | 0.0010401 |  0.0156743 |     8 |  UNSOLVED
 015 |    h3 |        32352 | 0.0009797 |  0.0490086 |    27 |  UNSOLVED
 009 |    b4 |        32313 | 0.0046526 |  0.0315824 |    17 |  UNSOLVED
 013 |    c3 |        32251 | 0.0019126 |  0.0502409 |    28 |  UNSOLVED
 011 |    d3 |        32158 | 0.0034245 |  0.0321382 |    17 |  UNSOLVED
 019 |   Na3 |        32116 | 0.0005335 |  0.0322232 |    17 |  UNSOLVED
-----+-------+--------------+-----------+------------+-------+------------
initial value:	0.0984263
nodeType:	UNSOLVED
isTerminal:	0
isTablebase:	0
unsolvedNodes:	20
Visits:		16777216
freeVisits:	3162557/16777216

@QueensGambit
Copy link
Owner

Problem should be fixed now.

info depth 43 seldepth 58 multipv 1 score cp 58 nodes 18726058 nps 18665 tbhits 0 time 1003283 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 g2g3 f8b4 c1d2 b4e7 f1g2 e8g8 e1g1 c7c6 d1c2 b8d7 d2f4 b7b6 b1c3 d5c4 f3d2 f6d5 d2c4 d5f4 g3f4 d8c7 e2e3 c8a6 c2a4 a6b7 a1c1 a7a6 b2b4 f8c8 a4b3 a8b8 f1d1 c6c5 d4c5 b6c5 b4b5 b7g2 g1g2
info depth 43 seldepth 59 multipv 1 score cp 58 nodes 18744989 nps 18665 tbhits 0 time 1004284 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 g2g3 f8b4 c1d2 b4e7 f1g2 e8g8 e1g1 c7c6 d1c2 b8d7 d2f4 b7b6 b1c3 d5c4 f3d2 f6d5 d2c4 d5f4 g3f4 d8c7 e2e3 c8a6 c2a4 a6b7 a1c1 a7a6 b2b4 f8c8 a4b3 a8b8 f1d1 c6c5 d4c5 b6c5 b4b5 b7g2 g1g2

The issue was due to auto cast from uint32_t to float.

QueensGambit added a commit that referenced this issue Apr 20, 2021
This is to avoid artificats for more than 16 million visits (#39)
QueensGambit added a commit that referenced this issue Apr 20, 2021
Changed variable type of MCTS-Policy to double. (#88)
This is to avoid artificats for more than 16 million visits (#39)
Deleted unused function mcts_policy_based_on_q_n().

TC: 10s + 0.1s

Score of ClassicAra 0.9.1 - TB- 3-4-5-wdl vs ClassicAra 0.9.1 - TB- 3-4-5-wdl - prev: 8 - 6 - 26 [0.525]
Elo difference: 17.4 +/- 64.3, LOS: 70.4 %, DrawRatio: 65.0 %

40 of 1000 games finished.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants