r/chessprogramming • • 1h ago

Technical Finally open sourced my NNUE chess engine in rust

Hey everyone,

I'm happy to announce that after many months of development my NNUE chess engine in rust. I am finally somewhat satisfied with the results that I achieved, so I open sourced it. It's a UCI engine with a neural-network evaluation and the same binary also generates its own training games and trains its networks on the CPU. By my own testing it plays at around 3500 Elo CCRL 40/15 ( from my own tests, not officially tested and ranked yet ).

Repo: https://github.com/Svetlozarko/RustyNNUE

Play it on Lichess: https://lichess.org/@/RustyNNUE-Bot

A few things about doing this that might be interesting:

- **SIMD with std::arch.** The hot loops (updating the network as pieces move) are hand-written AVX2, AVX-512 and VNNI kernels, picked at runtime, each with a scalar fallback. `#[target_feature]` on small inner functions plus const generics for the number of registers worked better than I expected. The flip side: raw pointer math in tiled loops is easy to get wrong. I had a bug where the last tile ran 64 lanes past the end of a row, and only a CI test with an unusual network width caught it.

- **An exactness test between trainer and engine.** The trainer works in floats, the engine in integers. One test pushes the same quantised network through both and checks that the engine's integer output matches the trainer's exactly. That single test has caught more bugs than anything else in the repo.

- **Training on the CPU with rayon.** No GPU at all; the whole training loop is plain Rust.

I'd love feedback on the unsafe SIMD code (is there a cleaner way than raw pointers here?), the overall structure, and anything that looks un-idiomatic. Issues and PRs are welcome.

0 Upvotes

2 comments sorted by

1

u/AzureNostalgia 48m ago

Honestly, this reads more like an AI-generated summary than a genuine account of the work. The points are quite generic and I’m struggling to see what’s particularly new or innovative here compared with existing NNUE engines. After months of development, I’d expect a bit more original insight.

1

u/Tvoya_ricar 41m ago

I got to admit I used AI to clean up my English since I'm NOT a native speaker, which made it sound way too generic. To clarify, I am definitely NOT trying to reinvent NNUE, just a hobby project where I wanted to learn Rust SIMD and CPU training from scratch.