1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-03 01:59:36 +00:00
BadFish/src
MichaelB7 b939c80513 Update the default net to nn-76a8a7ffb820.nnue.
combined work by Serio Vieri, Michael Byrne, and Jonathan D (aka SFisGod) based on top of previous developments, by restarts from good nets.

Sergio generated the net https://tests.stockfishchess.org/api/nn/nn-d8609abe8caf.nnue:

The initial net nn-d8609abe8caf.nnue is trained by generating around 16B of training data from the last master net nn-9e3c6298299a.nnue, then trained, continuing from the master net, with lambda=0.2 and sampling ratio of 1. Starting with LR=2e-3, dropping LR with a factor of 0.5 until it reaches LR=5e-4. in_scaling is set to 361. No other significant changes made to the pytorch trainer.

Training data gen command (generates in chunks of 200k positions):

generate_training_data min_depth 9 max_depth 11 count 200000 random_move_count 10 random_move_max_ply 80 random_multi_pv 12 random_multi_pv_diff 100 random_multi_pv_depth 8 write_min_ply 10 eval_limit 1500 book noob_3moves.epd output_file_name gendata/$(date +"%Y%m%d-%H%M")_${HOSTNAME}.binpack

PyTorch trainer command (Note that this only trains for 20 epochs, repeatedly train until convergence):

python train.py --features "HalfKAv2^" --max_epochs 20 --smart-fen-skipping --random-fen-skipping 500 --batch-size 8192 --default_root_dir $dir --seed $RANDOM --threads 4 --num-workers 32 --gpus $gpuids --track_grad_norm 2 --gradient_clip_val 0.05 --lambda 0.2 --log_every_n_steps 50 $resumeopt $data $val

See https://github.com/sergiovieri/Stockfish/tree/tools_mod/rl for the scripts used to generate data.

Based on that Michael generated nn-76a8a7ffb820.nnue in the following way:

The net being submitted was trained with the pytorch trainer: https://github.com/glinscott/nnue-pytorch

python train.py i:/bin/all.binpack i:/bin/all.binpack --gpus 1 --threads 4 --num-workers 30 --batch-size 16384 --progress_bar_refresh_rate 30 --smart-fen-skipping --random-fen-skipping 3 --features=HalfKAv2^ --auto_lr_find True --lambda=1.0 --max_epochs=240 --seed %random%%random% --default_root_dir exp/run_109 --resume-from-model ./pt/nn-d8609abe8caf.pt

This run is thus started from Segio Vieri's net nn-d8609abe8caf.nnue

all.binpack equaled 4 parts Wrong_NNUE_2.binpack https://drive.google.com/file/d/1seGNOqcVdvK_vPNq98j-zV3XPE5zWAeq/view?usp=sharing plus two parts of Training_Data.binpack https://drive.google.com/file/d/1RFkQES3DpsiJqsOtUshENtzPfFgUmEff/view?usp=sharing
Each set was concatenated together - making one large Wrong_NNUE 2 binpack and one large Training so the were approximately equal in size. They were then interleaved together. The idea was to give Wrong_NNUE.binpack closer to equal weighting with the Training_Data binpack

model.py modifications:
loss = torch.pow(torch.abs(p - q), 2.6).mean()
LR = 8.0e-5 calculated as follows: 1.5e-3*(.992^360) - the idea here was to take a highly trained net and just use all.binpack as a finishing micro refinement touch for the last 2 Elo or so. This net was discovered on the 59th epoch.
optimizer = ranger.Ranger(train_params, betas=(.90, 0.999), eps=1.0e-7, gc_loc=False, use_gc=False)
scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=1, gamma=0.992)
For this micro optimization, I had set the period to "5" in train.py. This changes the checkpoint output so that every 5th checkpoint file is created

The final touches were to adjust the NNUE scale, as was done by Jonathan in tests running at the same time.

passed LTC
https://tests.stockfishchess.org/tests/view/60fa45aed8a6b65b2f3a77a4
LLR: 2.94 (-2.94,2.94) <0.50,3.50>
Total: 53040 W: 1732 L: 1575 D: 49733
Ptnml(0-2): 14, 1432, 23474, 1583, 17

passed STC
https://tests.stockfishchess.org/tests/view/60f9fee2d8a6b65b2f3a7775
LLR: 2.94 (-2.94,2.94) <-0.50,2.50>
Total: 37928 W: 3178 L: 3001 D: 31749
Ptnml(0-2): 100, 2446, 13695, 2623, 100.

closes https://github.com/official-stockfish/Stockfish/pull/3626

Bench: 5169957
2021-07-24 18:04:59 +02:00
..
incbin Embed default net, and simplify using non-default nets 2020-08-29 21:56:00 +02:00
nnue Simplify format_cp_aligned_dot() 2021-07-03 09:25:16 +02:00
syzygy Fix a rare case of wrong TB ranking 2021-06-14 17:28:30 +02:00
benchmark.cpp Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
bitbase.cpp Small cleanups (march 2021) 2021-03-24 17:11:06 +01:00
bitboard.cpp Small clean-up 2021-03-31 08:12:25 +02:00
bitboard.h Small clean-up 2021-03-31 08:12:25 +02:00
endgame.cpp Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
endgame.h Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
evaluate.cpp Update the default net to nn-76a8a7ffb820.nnue. 2021-07-24 18:04:59 +02:00
evaluate.h Update the default net to nn-76a8a7ffb820.nnue. 2021-07-24 18:04:59 +02:00
main.cpp Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
Makefile Add macOS and windows to CI 2021-07-23 18:16:05 +02:00
material.cpp Small cleanups (march 2021) 2021-03-24 17:11:06 +01:00
material.h Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
misc.cpp Add macOS and windows to CI 2021-07-23 18:16:05 +02:00
misc.h Read NNUE net faster 2021-06-13 09:39:03 +02:00
movegen.cpp Simplify promotion move generator 2021-06-08 20:16:20 +02:00
movegen.h Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
movepick.cpp Simplify lowply-history scoring logic 2021-07-23 18:53:03 +02:00
movepick.h Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
pawns.cpp Small cleanups (march 2021) 2021-03-24 17:11:06 +01:00
pawns.h Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
position.cpp SEE: simplify stm variable initialization 2021-07-13 17:31:15 +02:00
position.h Change trace with NNUE eval support 2021-06-19 11:57:01 +02:00
psqt.cpp Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
psqt.h Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
search.cpp Apply good/bad history reduction also when inCheck 2021-07-23 19:02:58 +02:00
search.h Limit double extensions 2021-06-11 20:33:24 +02:00
thread.cpp Small cleanups (march 2021) 2021-03-24 17:11:06 +01:00
thread.h Remove the Contempt UCI option 2021-06-21 22:58:56 +02:00
thread_win32_osx.h Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
timeman.cpp Remove Tempo 2021-05-19 20:34:37 +02:00
timeman.h Remove Tempo 2021-05-19 20:34:37 +02:00
tt.cpp Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
tt.h Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
tune.cpp Remove BoolConditions from tuning code 2021-05-15 09:40:40 +02:00
tune.h Remove BoolConditions from tuning code 2021-05-15 09:40:40 +02:00
types.h Remove Tempo 2021-05-19 20:34:37 +02:00
uci.cpp Update WDL model for NNUE 2021-06-28 21:13:30 +02:00
uci.h Add Stockfish namespace. 2021-03-07 14:26:54 +01:00
ucioption.cpp Remove the Contempt UCI option 2021-06-21 22:58:56 +02:00