Source code for the Approvers
team's agent in the FIDE & Google Efficient Chess AI Challenge.
The engine is based on Cfish, a C port of Stockfish.
The NNUE architecture is (768x1hm -> 64)x2 -> 1x8
, being a pretty common pattern in the chess
programming community — 1 hidden layer with 768
features (2 colors * 6 piece types * 64 squares)
with implementation-specific modifications.
- Horizontal king mirroring: inputs are flipped along the vertical axis, i.e.,
a1
becomesh1
,b1
becomesg1
, etc., based on the position of the friendly king. - 8 output buckets based on the number of pieces left on the board:
(piece_count - 2) / 4
. - SCReLU (Squared Clipped Rectified Linear Unit) activation function:
f(x) = min(max(x, 0), 1)^2
.
The network training involves 3-stages of progressive training, with each stage restarting from the previous one with modifications, finally followed by an SPSA session.
For the full training configuration, see training/config.rs
.
The network is quantized to 8 bits for FT weights/biases and L1 weights, and 16 bits for L1 biases.
Also, due to unused features for pawns (1st and 8th ranks being illegal by the rules of chess)
and the mirror squares of kings, the input features are reduced to 704
.
The resulting network size is around 45 KB.
The dataset is based on test77-nov2021-2tb7p.min.dd.binpack, originally generated by the Leela Chess Zero project and made available under the Open Database License (ODbL).
For further use in the Bullet trainer, the dataset was filtered and converted into the bulletformat format, using the Primer tool with the following command:
./primer convert test77-nov2021-2tb7p.min.dd.binpack dataset.bin --max-score 2400 --filter-win -600 --filter-loss 600 --min-ply 20