official-stockfish/nnue-pytorch

Stockfish NNUE (Chess evaluation) trainer in Pytorch

What it solves

This project provides a PyTorch-based framework for training NNUE (Efficiently Updatable Neural Networks) for the Stockfish chess engine. It allows developers to train neural networks that can be used for board evaluation in chess, leveraging modern GPU acceleration (NVIDIA, AMD, and Apple Silicon).

How it works

The system uses PyTorch to handle the network training process. It includes a specialized sparse data loader for efficiency and supports various hardware accelerators. The workflow involves training the network, saving checkpoints (.ckpt), and using a separate script (run_games.py) to automatically convert these checkpoints to the .nnue format and run matches to evaluate and rank the best-performing network using tools like c-chess-cli and ordo.

Who it’s for

Chess engine developers and researchers who want to train custom evaluation networks for Stockfish using PyTorch.

Highlights

  • Support for multiple GPU vendors including NVIDIA (CUDA), AMD (ROCm), and Apple Silicon (MPS).
  • Integrated automation for converting checkpoints to .nnue files and running evaluation games.
  • Docker-based setup to simplify environment configuration and C++ compilation.
  • Integration with TensorBoard for training logs.

Related

  • Project
  • Project
  • Project
  • Project
  • Project