GithubHelp home page GithubHelp logo

fairy-stockfish / variant-nnue-pytorch Goto Github PK

View Code? Open in Web Editor NEW
27.0 4.0 17.0 1004 KB

chess variant NNUE training code for Fairy-Stockfish

Home Page: https://github.com/fairy-stockfish/variant-nnue-pytorch/wiki/Introduction

CMake 0.29% Batchfile 0.07% Python 73.77% C++ 25.22% Shell 0.57% C 0.08%
board-game chess-variants nnue xiangqi shogi crazyhouse fairy-stockfish

variant-nnue-pytorch's Introduction

Variant NNUE trainer

This is the chess variant NNUE training code for Fairy-Stockfish. See the documentation in the wiki for more details on the training process and join our discord to ask questions. This project is derived from the trainer for standard chess used for official Stockfish.

Setup

Requires a CUDA capable GPU.

Install PyTorch

PyTorch installation guide

python3 -m venv env
source env/bin/activate
pip install python-chess==0.31.4 "pytorch-lightning<1.5.0" torch matplotlib

Install CuPy

First check what version of cuda is being used by pytorch.

import torch
torch.version.cuda

Then install CuPy with the matching CUDA version.

pip install cupy-cudaXXX

where XXX corresponds to the first 3 digits of the CUDA version. For example cupy-cuda112 for CUDA 11.2.

CuPy might use the PyTorch's private installation of CUDA, but it is better to install the matching version of CUDA separately. CUDA Downloads

Build the fast DataLoader

This requires a C++17 compiler and cmake.

Windows:

compile_data_loader.bat

Linux/Mac:

sh compile_data_loader.bat

Train a network

source env/bin/activate
python train.py train_data.bin val_data.bin

Resuming from a checkpoint

python train.py --resume_from_checkpoint <path> ...

Training on GPU

python train.py --gpus 1 ...

Feature set selection

By default the trainer uses a factorized HalfKAv2 feature set (named "HalfKAv2^") If you wish to change the feature set used then you can use the --features=NAME option. For the list of available features see --help The default is:

python train.py ... --features="HalfKAv2^"

Skipping certain fens in the training

--smart-fen-skipping currently skips over moves where the king is in check, or where the bestMove is a capture (typical of non-quiet positions). --random-fen-skipping N skip N fens on average before using one. Uses fewer fens per game, useful with large data sets.

Current recommended training invocation

python train.py --smart-fen-skipping --random-fen-skipping 3 --batch-size 16384 --threads 8 --num-workers 8 --gpus 1 trainingdata validationdata

best nets have been trained with 16B d9-scored nets, training runs >200 epochs

Export a network

Using either a checkpoint (.ckpt) or serialized model (.pt), you can export to SF NNUE format. This will convert last.ckpt to nn.nnue, which you can load directly in SF.

python serialize.py last.ckpt nn.nnue

Import a network

Import an existing SF NNUE network to the pytorch network format.

python serialize.py nn.nnue converted.pt

Visualize a network

Visualize a network from either a checkpoint (.ckpt), a serialized model (.pt) or a SF NNUE file (.nnue).

python visualize.py nn.nnue --features="HalfKAv2"

Visualize the difference between two networks from either a checkpoint (.ckpt), a serialized model (.pt) or a SF NNUE file (.nnue).

python visualize.py nn.nnue  --features="HalfKAv2" --ref-model nn.cpkt --ref-features="HalfKAv2^"

Logging

pip install tensorboard
tensorboard --logdir=logs

Then, go to http://localhost:6006/

Automatically run matches to determine the best net generated by a (running) training

python run_games.py --concurrency 16 --stockfish_exe ./stockfish.master --c_chess_exe ./c-chess-cli --ordo_exe ./ordo --book_file_name ./noob_3moves.epd run96

Automatically converts all .ckpt found under run96 to .nnue and runs games to find the best net. Games are played using c-chess-cli and nets are ranked using ordo. This script runs in a loop, and will monitor the directory for new checkpoints. Can be run in parallel with the training, if idle cores are available.

Thanks

variant-nnue-pytorch's People

Contributors

ddobbelaere avatar dpldgr avatar glinscott avatar ianfab avatar kennyfrc avatar nelloho avatar niklasf avatar nodchip avatar nomoras avatar rainrat avatar sergiovieri avatar sopel97 avatar vondele avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

variant-nnue-pytorch's Issues

Segmentation Fault While Training For a Variant

The Variant i'm using is as:

[chessGC]
customPiece1 = p:mfFcfW
knight = n
bishop = b
rook = r
queen = q
king = k
promotedPieceType = p:q
promotionRank = 8
mandatoryPiecePromotion = true
pieceDrops = true
castling = false
startFen = rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w - - 3+3 0 1
checkCounting = true

This Variant has the pawns moving diagonally and capturing forward and it also has the three check rule.
To generate data for this variant , i used the following commands:

uci
setoption name UCI_Variant value chessGC
setoption name PruneAtShallowDepth value false
setoption name Use NNUE value false
setoption name Threads value 6
setoption name Hash value 1024
isready
generate_training_data nodes 10 set_recommended_uci_options depth 8 keep_draws 1 eval_limit 3000 count 1000 output_file_name ./training_data/data.binpack

But It is showing the following error:

INFO: Executing generate_training_data command
INFO: Parameters:
  - search_depth_min       = 8
  - search_depth_max       = 8
  - nodes                  = 10
  - count                  = 1000
  - eval_limit             = 3000
  - eval_diff_limit        = 500
  - num threads (UCI)      = 1
  - random_move_min_ply    = 1
  - random_move_max_ply    = 24
  - random_move_count      = 5
  - random_move_like_apery = 0
  - random_multi_pv        = 0
  - random_multi_pv_diff   = 32000
  - random_multi_pv_depth  = 8
  - write_min_ply          = 16
  - write_max_ply          = 400
  - book                   = 
  - output_file_name       = ./training_data/data.binpack
  - save_every             = 18446744073709551615
  - random_file_name       = 0
  - write_drawn_games      = 1
  - draw by low score      = 1
  - draw by insuff. mat.   = 1
info string classical evaluation enabled
INFO (sfen_writer): Creating new data file at ./training_data/data.binpack
PRNG::seed = 1f4585ea784a7e06

INFO: generate_training_data finished.
Segmentation fault (core dumped)

How should i go about resolving this?

Sample variant.py for xiangqi

The variant.py in the master branch is for chess only.
Could you provide a sample for xiangqi training ?
My guess is something like: (please correct any mistakes)

RANKS = 10
FILES = 9
SQUARES = RANKS * FILES
KING_SQUARES = RANKS * FILES
PIECE_TYPES = 7
PIECES = 2 * PIECE_TYPES
USE_POCKETS = False
POCKETS = 2 * FILES if USE_POCKETS else 0

PIECE_VALUES = {
1 : 200, # copied from types.h in fairy stockfish, SoldierValueMg
2 : 420, # FersValueMg
3 : 300, # ElephantValueMg
4 : 520, # HorseValueMg
5 : 800, # CannonPieceValueMg
6 : 1276 # RookValueMg
}

Some questions about training NNUE.

May I ask the difference between the following data generation process and the final NNUE play strength?
A. 100M position of depth 10
B. 100M position of depth 20
C. 1B position of depth 10
D. 1B position of depth 20
Let me guess, technically speaking, D > B > C > A ?

Using the latest NNUE file to generate new training data, it's like the process of bootstrapping, will it cause Bootstrapping Error problem? i.e. If the latest NNUE weights and biases have weaknesses in some situations they will get amplified in the late nets.

BTW, from your point of view, how much does the final NNUE file trained with depth 20 stronger than depth 10? What's the play strength difference between 1B position training data using the classical evaluation of depth 20 and 1B position with the latest NNUE net evaluation of depth 10?

Furthermore, suppose I can't hold 1B position in the RAM at a time, I split them into 3 parts, 400M 300M 300M.
How much player strength difference it will be do you think in the following training process?
A. Training 1B at a time for 400 epochs.
B. Training 400M at a time for 400 epochs, continue training the following 300M position for 400 epochs and continue training the rest 300M for 400 epochs.

Finally, If I cause any inconvenience to you for taking your precious time to answer these questions, I am so sorry to bother you these days. ( >︿< )

Variant training support

  • Remove chess-specific logic in data loader
  • Test compatibility after simplifications
  • Generalize data loader (extended bin)
    • other board sizes
    • Pieces in hand
    • >5 non-king piece types
    • variants without kings
  • Generalize network architecture and training
    • Board sizes <8x8
    • Board sizes >8x8
    • Fairy pieces
    • >5 non-king piece types
    • Piece counts > 32
    • variants with pseudo-kings (atomic, extinction)
    • variants without kings
    • Pieces in hand

Unknown error when trying to Train

Hi,

For some reason i cannot get the code to work as it is not showing any errors currently. Could you help me figure out what is going on?

i am trying to create a nnue file for a 10x10 variant.

Could it be that the pytorch-lighning and pytorch is incompatible?
Not sure why assertion would fail :(

There are two extra pieces, would i have to code them manually into the code?

sorry if these questions are simple i'm trying my best to learn.

Thank you so much for your dedication, the chess engine world is thankful for all this amazing work

ERROR

(siege) C:\Users\Kosmic\Desktop\variant-nnue-pytorch-master>python train.py --smart-fen-skipping --random-fen-skipping 3 --batch-size 16384 --threads 20 --num-workers 20 --gpus 1 C:\Users\Kosmic\Desktop\Variant\Validation-data\1mil9depth.bin C:\Users\Kosmic\Desktop\Variant\Validation-data\1mil12depth.bin
Feature set: HalfKAv2^
Num real features: 150000
Num virtual features: 1600
Num features: 151600
Training with C:\Users\Kosmic\Desktop\Variant\Validation-data\1mil9depth.bin validating with C:\Users\Kosmic\Desktop\Variant\Validation-data\1mil12depth.bin
Global seed set to 42
Seed 42
Using batch size 16384
Smart fen skipping: True
Random fen skipping: 3
limiting torch to 20 threads.
Using log dir logs/
C:\Users\Kosmic\anaconda3\envs\siege\Lib\site-packages\pytorch_lightning\callbacks\model_checkpoint.py:487: LightningDeprecationWarning: Argument period in ModelCheckpoint is deprecated in v1.3 and will be removed in v1.5. Please use every_n_epochs instead.
rank_zero_deprecation(
C:\Users\Kosmic\anaconda3\envs\siege\Lib\site-packages\pytorch_lightning\callbacks\model_checkpoint.py:432: UserWarning: ModelCheckpoint(save_last=True, save_top_k=None, monitor=None) is a redundant configuration. You can save the last checkpoint with ModelCheckpoint(save_top_k=None, monitor=None).
rank_zero_warn(
ModelCheckpoint(save_last=True, save_top_k=-1, monitor=None) will duplicate the last checkpoint saved.
GPU available: True, used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
Using c++ data loader
Assertion failed: bits <= 6, file C:/Users/Kosmic/Desktop/variant-nnue-pytorch-master/lib/nnue_trainLOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
ing_datRanger optimizer loaded.
Gradient Centralization usage = False
a_formats.h, line 662
Assertion failed: bits <= 6, file C:/Users/Kosmic/Desktop/variant-nnue-pytorch-master/lib/nnue_training_data_formats.h, line 662

| Name | Type | Params

0 | input | DoubleFeatureTransformerSlice | 78.8 M
1 | layer_stacks | LayerStacks | 152 K

79.0 M Trainable params
0 Non-trainable params
79.0 M Total params
315.939 Total estimated model params size (MB)
Validation sanity check: 0it [00:00, ?it/s]C:\Users\Kosmic\anaconda3\envs\siege\Lib\site-packages\pytorch_lightning\trainer\data_loading.py:105: UserWarning: The dataloader, val dataloader 0, does not have many workers which may be a bottleneck. Consider increasing the value of the num_workers argument(try 20 which is the number of cpus on this machine) in theDataLoader` init to improve performance.
rank_zero_warn(
Validation sanity check: 0%| | 0/2 [00:00<?, ?it/s]
(siege) C:\Users\Kosmic\Desktop\variant-nnue-pytorch-master>

env Package!

absl-py 1.4.0 pypi_0 pypi
aiohttp 3.8.5 pypi_0 pypi
aiosignal 1.3.1 pypi_0 pypi
annotated-types 0.5.0 pypi_0 pypi
ansicon 1.89.0 pypi_0 pypi
anyio 3.7.1 pypi_0 pypi
arrow 1.2.3 pypi_0 pypi
async-timeout 4.0.3 pypi_0 pypi
attrs 23.1.0 pypi_0 pypi
backoff 2.2.1 pypi_0 pypi
beautifulsoup4 4.12.2 pypi_0 pypi
blessed 1.20.0 pypi_0 pypi
bzip2 1.0.8 he774522_0
ca-certificates 2023.7.22 h56e8100_0 conda-forge
cachetools 5.3.1 pypi_0 pypi
certifi 2022.12.7 pypi_0 pypi
charset-normalizer 2.1.1 pypi_0 pypi
click 8.1.7 pypi_0 pypi
colorama 0.4.6 pypi_0 pypi
contourpy 1.1.0 pypi_0 pypi
croniter 1.4.1 pypi_0 pypi
cuda-version 11.8 h70ddcb2_2 conda-forge
cudatoolkit 11.8.0 h09e9e62_12 conda-forge
cupy 12.2.0 py311h77068d7_0 conda-forge
cycler 0.11.0 pypi_0 pypi
dateutils 0.6.12 pypi_0 pypi
deepdiff 6.3.1 pypi_0 pypi
fastapi 0.103.0 pypi_0 pypi
fastrlock 0.8.2 py311h12c1d0e_0 conda-forge
filelock 3.9.0 pypi_0 pypi
fonttools 4.42.1 pypi_0 pypi
frozenlist 1.4.0 pypi_0 pypi
fsspec 2023.6.0 pypi_0 pypi
future 0.18.3 pypi_0 pypi
google-auth 2.22.0 pypi_0 pypi
google-auth-oauthlib 1.0.0 pypi_0 pypi
grpcio 1.57.0 pypi_0 pypi
h11 0.14.0 pypi_0 pypi
idna 3.4 pypi_0 pypi
inquirer 3.1.3 pypi_0 pypi
intel-openmp 2023.2.0 h57928b3_49496 conda-forge
itsdangerous 2.1.2 pypi_0 pypi
jinja2 3.1.2 pypi_0 pypi
jinxed 1.2.0 pypi_0 pypi
kiwisolver 1.4.5 pypi_0 pypi
libblas 3.9.0 17_win64_mkl conda-forge
libcblas 3.9.0 17_win64_mkl conda-forge
libffi 3.4.4 hd77b12b_0
libhwloc 2.9.1 h51c2c0f_0 conda-forge
libiconv 1.17 h8ffe710_0 conda-forge
liblapack 3.9.0 17_win64_mkl conda-forge
libxml2 2.10.4 h0ad7f3c_1
lightning 2.0.7 pypi_0 pypi
lightning-cloud 0.5.37 pypi_0 pypi
lightning-utilities 0.9.0 pypi_0 pypi
markdown 3.4.4 pypi_0 pypi
markdown-it-py 3.0.0 pypi_0 pypi
markupsafe 2.1.2 pypi_0 pypi
matplotlib 3.7.2 pypi_0 pypi
mdurl 0.1.2 pypi_0 pypi
mkl 2022.1.0 h6a75c08_874 conda-forge
mpmath 1.2.1 pypi_0 pypi
multidict 6.0.4 pypi_0 pypi
networkx 3.0 pypi_0 pypi
numpy 1.24.1 pypi_0 pypi
oauthlib 3.2.2 pypi_0 pypi
openssl 3.1.2 hcfcfb64_0 conda-forge
ordered-set 4.1.0 pypi_0 pypi
packaging 23.1 pypi_0 pypi
pillow 9.3.0 pypi_0 pypi
pip 23.2.1 py311haa95532_0
protobuf 4.24.2 pypi_0 pypi
psutil 5.9.5 pypi_0 pypi
pthreads-win32 2.9.1 hfa6e2cd_3 conda-forge
pyasn1 0.5.0 pypi_0 pypi
pyasn1-modules 0.3.0 pypi_0 pypi
pydantic 2.1.1 pypi_0 pypi
pydantic-core 2.4.0 pypi_0 pypi
pydeprecate 0.3.1 pypi_0 pypi
pygments 2.16.1 pypi_0 pypi
pyjwt 2.8.0 pypi_0 pypi
pyparsing 3.0.9 pypi_0 pypi
python 3.11.4 he1021f5_0
python-chess 0.31.4 pypi_0 pypi
python-dateutil 2.8.2 pypi_0 pypi
python-editor 1.0.4 pypi_0 pypi
python-multipart 0.0.6 pypi_0 pypi
python_abi 3.11 2_cp311 conda-forge
pytorch-lightning 1.4.9 pypi_0 pypi
pytz 2023.3 pypi_0 pypi
pyyaml 6.0.1 pypi_0 pypi
readchar 4.0.5 pypi_0 pypi
requests 2.28.1 pypi_0 pypi
requests-oauthlib 1.3.1 pypi_0 pypi
rich 13.5.2 pypi_0 pypi
rsa 4.9 pypi_0 pypi
setuptools 68.0.0 py311haa95532_0
six 1.16.0 pypi_0 pypi
sniffio 1.3.0 pypi_0 pypi
soupsieve 2.4.1 pypi_0 pypi
sqlite 3.41.2 h2bbff1b_0
starlette 0.27.0 pypi_0 pypi
starsessions 1.3.0 pypi_0 pypi
sympy 1.11.1 pypi_0 pypi
tbb 2021.9.0 h91493d7_0 conda-forge
tensorboard 2.14.0 pypi_0 pypi
tensorboard-data-server 0.7.1 pypi_0 pypi
tk 8.6.12 h2bbff1b_0
torch 2.0.1+cu118 pypi_0 pypi
torchaudio 2.0.2+cu118 pypi_0 pypi
torchmetrics 0.7.0 pypi_0 pypi
torchvision 0.15.2+cu118 pypi_0 pypi
tqdm 4.66.1 pypi_0 pypi
traitlets 5.9.0 pypi_0 pypi
typing-extensions 4.7.1 pypi_0 pypi
tzdata 2023c h04d1e81_0
ucrt 10.0.22621.0 h57928b3_0 conda-forge
urllib3 1.26.13 pypi_0 pypi
uvicorn 0.23.2 pypi_0 pypi
vc 14.2 h21ff451_1
vc14_runtime 14.36.32532 hfdfe4a8_17 conda-forge
vs2015_runtime 14.36.32532 h05e6639_17 conda-forge
wcwidth 0.2.6 pypi_0 pypi
websocket-client 1.6.2 pypi_0 pypi
websockets 11.0.3 pypi_0 pypi
werkzeug 2.3.7 pypi_0 pypi
wheel 0.38.4 py311haa95532_0
xz 5.4.2 h8cc25b3_0
yarl 1.9.2 pypi_0 pypi
zlib 1.2.13 h8cc25b3_0

Reinforcement learning on endgame result in bad opening and middle game performance.

Suppose I trained the model with some high-quality endgame training_data.bin using the following command:

python serialize.py --features='HalfKAv2' xiangqi-6f64c55fcb28.nnue startingpointfortraining.pt 
python train.py --resume-from-model startingpointfortraining.pt --batch-size 8000 --threads 12 --num-workers 88 --gpus 1 --max_epochs 520 --lambda 0 training_data.bin validation_data.bin

After some tests, I found that the performance of the endgame has significantly improved but at the same time, the performance of the opening and the middle game is reduced dramatically.

So theoretically HalfKAv2 model has 8 buckets, the training may significantly affect the buckets for the endgame and not the buckets on the opening and middlegame. The only possible reason I could come up with is the endgame training changes the weight and biases of the feature transformer layer that lead to this bad result.

If my assumption is correct, what should I do to fix this issue? i.e. to improve the endgame performance while not affecting the opening and middle game performance greatly?

BTW, is there anything wrong with the command I'm using?

Training Stops After Epoch 0

Hi, I am trying to get the NNUE trainer to work on an Ubuntu 20.04 cloud computer. To exclude variant specific issues, I went for normal chess first.

However, the training stops always after epoch 0 without saving any checkpoint in the specified directory "variant-nnue-pytorch-master/save_230724/default/version_0/checkpoints". Any idea what's going on here?

(env) us@nvdiat4-1vcpu-3-75gb-15cent-ubuntu2004:~/variant-nnue-pytorch-master$ python3.6 train.py --default_root_dir "save_230724" --threads 1 --num-workers 1 --gpus 1 --max_epochs 10 chess_depth5_100mio.bin chess_depth5_100mio.bin
Feature set: HalfKAv2^
Num real features: 45056
Num virtual features: 768
Num features: 45824
Training with chess_depth5_100mio.bin validating with chess_depth5_100mio.bin
Global seed set to 42
Seed 42
Using batch size 16384
Smart fen skipping: True
Random fen skipping: 3
limiting torch to 1 threads.
Using log dir save_230724
/home/us/env/lib/python3.6/site-packages/pytorch_lightning/callbacks/model_checkpoint.py:488: LightningDeprecationWarning: Argument period in ModelCheckpoint is deprecated in v1.3 and will be removed in v1.5. Please use every_n_epochs instead.
"Argument period in ModelCheckpoint is deprecated in v1.3 and will be removed in v1.5."
/home/us/env/lib/python3.6/site-packages/pytorch_lightning/callbacks/model_checkpoint.py:433: UserWarning: ModelCheckpoint(save_last=True, save_top_k=None, monitor=None) is a redundant configuration. You can save the last checkpoint with ModelCheckpoint(save_top_k=None, monitor=None).
"ModelCheckpoint(save_last=True, save_top_k=None, monitor=None) is a redundant configuration."
ModelCheckpoint(save_last=True, save_top_k=-1, monitor=None) will duplicate the last checkpoint saved.
GPU available: True, used: True
TPU available: False, using: 0 TPU cores
IPU available: False, using: 0 IPUs
Using c++ data loader
LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0]
Ranger optimizer loaded.
Gradient Centralization usage = False

| Name | Type | Params

0 | input | DoubleFeatureTransformerSlice | 23.8 M
1 | layer_stacks | LayerStacks | 152 K

24.0 M Trainable params
0 Non-trainable params
24.0 M Total params
95.925 Total estimated model params size (MB)
Global seed set to 42
Epoch 0: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1283/1283 [02:02<00:00, 10.44it/s, loss=0.0129, v_num=0Killed


This is my installed python environment:

(env) us@nvdiat4-1vcpu-3-75gb-15cent-ubuntu2004:~$ python3.6 -m pip freeze
absl-py==1.4.0
aiohttp==3.8.4
aiosignal==1.2.0
async-timeout==4.0.2
asynctest==0.13.0
attrs==22.2.0
cachetools==4.2.4
certifi==2023.5.7
charset-normalizer==2.0.12
cmake==3.26.4
cupy-cuda101==9.6.0
cycler==0.11.0
dataclasses==0.8
fastrlock==0.8.1
frozenlist==1.2.0
fsspec==2022.1.0
future==0.18.3
google-auth==2.22.0
google-auth-oauthlib==0.4.6
grpcio==1.48.2
idna==3.4
idna-ssl==1.1.0
importlib-metadata==4.8.3
importlib-resources==5.4.0
install==1.3.5
kiwisolver==1.3.1
Markdown==3.3.7
matplotlib==3.3.4
multidict==5.2.0
numpy==1.19.5
oauthlib==3.2.2
packaging==21.3
Pillow==8.4.0
protobuf==3.19.6
pyasn1==0.5.0
pyasn1-modules==0.3.0
pyDeprecate==0.3.1
pyparsing==3.1.0
python-chess==0.31.4
python-dateutil==2.8.2
pytorch-lightning==1.4.9
PyYAML==6.0
requests==2.27.1
requests-oauthlib==1.3.1
rsa==4.9
six==1.16.0
tensorboard==2.10.1
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
torch==1.8.1+cu101
torchmetrics==0.7.3
tqdm==4.64.1
typing_extensions==4.1.1
urllib3==1.26.16
Werkzeug==2.0.3
yarl==1.7.2
zipp==3.6.0

(env) us@nvdiat4-1vcpu-3-75gb-15cent-ubuntu2004:~$ python3.6
Python 3.6.15 (default, Apr 25 2022, 01:55:53)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import torch
torch.version.cuda
'10.1'

(env) us@nvdiat4-1vcpu-3-75gb-15cent-ubuntu2004:~$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243


The training data file was generated on another, cpu-only cloud machine:

us@c2-16vcpu-120gb-ubuntu2004-9cent:~$ ./fairy-stockfish-tools_x86-64-bmi2
Fairy-Stockfish 260422 by Fabian Fichter
uci
...
uciok
setoption name Use NNUE value false
setoption name Threads value 8
setoption name Hash value 2048
setoption name UCI_Variant value chess
lib/nnue_training_data_formats.h:
#define FILES 8
#define RANKS 8
#define PIECE_TYPES 6
#define PIECE_COUNT 32
#define POCKETS false
#define KING_SQUARES 64

variant.py:
RANKS = 8
FILES = 8
SQUARES = RANKS * FILES
KING_SQUARES = 64
PIECE_TYPES = 6
PIECES = 2 * PIECE_TYPES
USE_POCKETS = False
POCKETS = 2 * FILES if USE_POCKETS else 0

PIECE_VALUES = {
1: 126,
2: 781,
3: 825,
4: 1276,
5: 2538,
}
info string variant chess files 8 ranks 8 pocket 0 template fairy startpos rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
isready
readyok
generate_training_data depth 5 count 100000000 random_multi_pv 4 random_multi_pv_diff 100 random_move_count 8 random_move_max_ply 20 write_min_ply 5 eval_limit 10000 set_recommended_uci_options data_format bin output_file_name chess_depth5_100mio.bin
INFO: Executing generate_training_data command
INFO: Parameters:

  • search_depth_min = 5
  • search_depth_max = 5
  • nodes = 0
  • count = 100000000
  • eval_limit = 10000
  • eval_diff_limit = 500
  • num threads (UCI) = 8
  • random_move_min_ply = 1
  • random_move_max_ply = 20
  • random_move_count = 8
  • random_move_like_apery = 0
  • random_multi_pv = 4
  • random_multi_pv_diff = 100
  • random_multi_pv_depth = 5
  • write_min_ply = 5
  • write_max_ply = 400
  • book =
  • output_file_name = chess_depth5_100mio.bin
  • save_every = 18446744073709551615
  • random_file_name = 0
  • write_drawn_games = 1
  • draw by low score = 1
  • draw by insuff. mat. = 1
    info string classical evaluation enabled
    INFO (sfen_writer): Creating new data file at chess_depth5_100mio.bin
    PRNG::seed = cbbe2308f46191ed
    ........................................
    200000 sfens, 12277 sfens/second, at Sat Jul 22 03:47:07 2023
    ...
    100000000 sfens, 10813 sfens/second, at Sat Jul 22 06:18:04 2023

INFO: generate_training_data finished.
quit
us@c2-16vcpu-120gb-ubuntu2004-9cent:~$

add compiled file for windows users

to ubdip:
compiling fast dataloarder on windows is slow and complex.
if you like , I can upload my compiled file so that others can use it as well.

Add wall squares as an input

Just for documentation purposes.

"Perhaps they would be just one additional plane (not 1 per color as for piece types) in the NNUE"

Bug in pseudoroyal + custom piece variants training

As discussed in the discord channel, there is a bug somewhere as the pseudo-royal commoner is not the last piece in the ordering whenever there is a custom piece on top.

Example of variant with the bug:

[allexplodeatomic:nocheckatomic]
pawn = -
customPiece1 = p:fmWfceFifmnD
pawnTypes = p

Example of faulty behaviour (Custom piece [pawn] negative values):

NNUE derived piece values:
+-------+-------+-------+-------+-------+-------+-------+-------+
| r | n | b | q | k | b | n | r |
| -4.27 | -1.43 | -2.09 | -4.62 | | -1.87 | -1.69 | -4.34 |
+-------+-------+-------+-------+-------+-------+-------+-------+
| p | p | p | p | p | p | p | p |
| +2.16 | +2.47 | +2.49 | +2.70 | +2.28 | +2.02 | +2.87 | +2.16 |
+-------+-------+-------+-------+-------+-------+-------+-------+
| | | | | | | | |
| | | | | | | | |
+-------+-------+-------+-------+-------+-------+-------+-------+
| | | | | | | | |
| | | | | | | | |
+-------+-------+-------+-------+-------+-------+-------+-------+
| | | | | | | | |
| | | | | | | | |
+-------+-------+-------+-------+-------+-------+-------+-------+
| | | | | | | | |
| | | | | | | | |
+-------+-------+-------+-------+-------+-------+-------+-------+
| P | P | P | P | P | P | P | P |
| -2.01 | -2.69 | -2.53 | -2.80 | -2.20 | -1.65 | -2.93 | -2.22 |
+-------+-------+-------+-------+-------+-------+-------+-------+
| R | N | B | Q | K | B | N | R |
| +3.99 | +1.97 | +2.61 | +4.24 | | +2.44 | +1.97 | +4.40 |
+-------+-------+-------+-------+-------+-------+-------+-------+

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.