glinscott / leela-chess

**MOVED TO https://github.com/LeelaChessZero/leela-chess ** A chess adaption of GCP's Leela Zero
http://lczero.org
GNU General Public License v3.0
759 stars 298 forks source link

Time losses with LC0 (build May 18) at time control with increment #662

Closed zz4032 closed 4 years ago

zz4032 commented 6 years ago

I get a lot of losses on time for LC0 running through cutechess-cli when using time control with increment of about 1/50th of main time control. I ran some matches for statistics:

Time control  Percentage of time losses
6+0.4         20%    
12+0.2        54%               
12+0.8        4%  
24            0%   
24+0.4        22%

No time losses with time control without increments. Higher probability of time losses with lower increment time. Not dependent on main time (at least for the settings above). Number of time losses also independent of uci parameter "ScaleThinkingTime".

LC0 built May 18 2018 Network Id312

Has anybody noticed any issues with time losses with LC0? Didn't have a single loss on time with LCZero.

A sample cutechess script for reproducing the results with 54% time losses:

./cutechess-cli \
   -tournament gauntlet \
   -rounds 50 \
   -openings file=./opening_book.pgn format=pgn order=random plies=16 \
   -concurrency 1 \
   -engine name=LC0_Id312_17c9 cmd=lc0 \
   -engine name=LC0_Id312_17c9 cmd=lc0 \
   -each proto=uci tc=12+0.2
mooskagh commented 6 years ago

Thanks for reporting! Do you by any chance have a log file for that?

zz4032 commented 6 years ago

3rd game in the match, 4th game was aborted by me: 1) cutechess debug output: https://gist.github.com/zz4032/7af71a696cb2a0f2bc6116a3d27cb0bb search for "loses on time" 2) pgn: https://gist.github.com/zz4032/aa20c53b950982e04c6abbae48aaa4e4

rwbc commented 6 years ago

Was that with some system overhead/lag? I mean did you run other processes while running the match? The debug says time was overstepped by 20ms (in lost position). You could try to set the 'timemargin' option' cutechess-cli.

I know you said LCZ did not bevave that way, but I guess LC0 has more IO going on with that huge cuda dlls.

zz4032 commented 6 years ago

No, seems to happen without any system CPU/GPU load as well. I can try to find a value for timemargin in cutechess where LC0 stops losing on time.

I saw that move overhead was implemented in LC0 4 days ago. https://github.com/glinscott/leela-chess/commit/a58953c59a64e6eec68cfc9c2a79b76e8c74354a Isn't this basically the same just handled by LC0 internally? In this case I would prefer to find the correct uci parameter value for move overhead instead of timemargin in cutechess.

rwbc commented 6 years ago

Yes, I didn't check for newer uci params. If move overhead is present in current LC0, then better use that.

zz4032 commented 6 years ago

Good news, looks like the move overhead commit solved the issue. No losses on time with latest LC0 built today. However a match with a much lower value for MoveTimeOverhead performed much stronger at 12s+0.2s/move and did not lose on time once in 100 games:

   # PLAYER                                 :  RATING  ERROR  POINTS   GAMES
   1 LC0_Id312_17c9_MoveTimeOverhead=10     :     109     47    65.0     100
   2 LC0_Id312_17c9_MoveTimeOverhead=100    :       0   ----    35.0     100

Is there a reason for MoveTimeOverhead to be at 100? It moves too quickly in the endgame when low on time. I would recommend changing it to 10.

Edit: By running some more matches with longer TC I could observe time losses with MoveTimeOverhead=10. It looks like 100 is a safe choice, but loses performance in games at very short TC.