dshawul / Scorpio

Scorpio chess engine
Other
81 stars 19 forks source link

MCTS and multipv is boolean -vs- MultiPV is number #27

Open tissatussa opened 2 years ago

tissatussa commented 2 years ago

your .ini file has several sections .. i guess this is the MCTS section :

##################################################################
# montecarlo - Use montecarlo tree search (MCTS) if set to 1
# treeht - Maximum size of tree to store in memory given in MB.
#          Note that this memory is not allocated at start up; it only
#          specifies the maximum limit the tree could grow to.
#          Note: Don't think you are making scorpio weak by not setting
#          this memory to high value, infact treeht=0 is the strongest 
#          MCTS setting.
#          -- RB: 29695 is default
#
# frac_freeze_tree    [0 - 100] - freeze tree after this percentage of time is spent
# frac_alphabeta      [0 - 100] - rollouts alpha-beta search percentage when using AB-rollouts + MCTS with shared tree
# frac_abrollouts     [0 - 100] - rollouts alpha-beta search percentage when using AB-rollouts + AB with shared tree
# frac_abprior        [0 - 100] - standard alpha-beta search percentage when using AB + MCTS, and AB used as prior
# alphabeta_man_c     [0 - 32]  - switch to regular alpha-beta search with this many pieces on board
# mcts_strategy_depth [0 - 64]  - Lookahead depth for MCTS rollouts
# alphabeta_depth     [0 - 64]  - Fixed search depth for standard alphabeta searches at the leaves
# evaluate_depth      [-5 - 64]  - Fixed search depth for policy evaluation of new children during expansion 
#                                (-5=uniform,-4=eval,-3=see,-2=recap qsearch,-1=no-checks qsearch 0=qsearch,x=search)
# backup_type         [0 - 8]   - minmax = 0, averaging = 1, mixed = 2, for mixing score with 
#                                 previous ID use 3,4,5 resp., 6 is classic MCTS, 7 is mixing by visit count
#                                 8 is RMS averaging
# select_formula      [0 - 3]   - selection formula to be used for MCTS search
#                                 0=AlphaZero 1=UCT 2=Reverse KL
# reuse_tree                    - reuse MCTS tree between moves
# virtual_loss                  - virtual loss for parallel search
# visit_threshold               - minimum number of visits for minimax backup
# policy_temp                   - Temperature for move policy
# cpuct_init                    - Starting cpuct value in %
# cpuct_base                    - Denominator of cpuct forumula
# cpuct_factor                  - Multiplier for the log term in %
# fpu_is_loss                   - FPU is loss (1=loss, -1=win, 0=reduction)
# fpu_red                       - Reduction factor for FPU when fpu_is_loss = 0
# insta_move_factor  [0 - 1000] - Factor for making insta moves
# multipv                       - Use multipv check for hybrid search
# multipv_margin                - Multipv margin for validating NN move with AB search
##################################################################
montecarlo          1
treeht              64
frac_freeze_tree    100
frac_alphabeta      0
frac_abrollouts     20
frac_abprior        30
alphabeta_man_c     0
mcts_strategy_depth 30
alphabeta_depth     16
evaluate_depth      16
backup_type         6
rms_power           140
select_formula      0
reuse_tree          1
virtual_loss        1
visit_threshold     800
policy_temp         215
cpuct_init          84
cpuct_base          75610
cpuct_factor        348
fpu_red             33
fpu_is_loss         0
insta_move_factor   0
multipv             1
multipv_margin      100

here i changed some values, but i kept many (unclear) ones. the section ends with multipv : is it related to MCTS ?

another thing about your multipv option : it's a boolean, not what i expected .. to my scripting this is an exception : isn't "MultiPV" in the UCI protocol, being a number ?

can you give me a simple general tip to start some tuning the MCTS values () to give bestmove of a position in x seconds ? Can / should a testrun be done to "calibrate" the values according to the PC of the user ? I see some programmers use such runs, but what are they ? i'm developing on a 5 year old notebook .. ) which options (in this section) are related to MCTS ? All ? It's not obvious to me .. can you provide a link to a page with these MCTS terms ? Just learning ..

dshawul commented 2 years ago

I recommend that you use the installer as it will setup things properly and pull all the depencies. Scorpio has a lot of options that is just too much for the average user. To answer some of your questions.

multipv is an internal parameter to control use of AB in hybrid search to verfiy the NN move, and is thus not related to UCI's multipv mode. Scorpio does not display multiple PVs except when using MCTS in which multiple PVs come naturally. You can set verbose 1 to see multiple pvs from mcts search.

The best settings for MCTS + NN are configured properly to your hardware (GPU and CPU) by the installer which is why I strongly recommend that route. It will check the number of multiprocessors of your GPU, and set the batch size according to that. When the CPU accompanying the GPU is week (few cores) it will set the parameter delay 1 to boost nps etc..

Unfortunately the only documentation i have about the parameters is the comments in the ini file itself.

tissatussa commented 2 years ago

thanks, i will study and test further with this info. at this moment i don't want to use NN, but NNUE yes.

so with Scorpio, is MCTS typically related to NN ? Or can MCTS be used seperately ? That's not clear to me ..