I have created Numbfish, a strong python chess engine based on Sunfish but with some additional features, the most important of which is the Efficiently Updatable Neural Network (NNUE). For the first time ever, NNUE has been implemented in python, specifically numpy (and tflite) using the incremental updates just like Stockfish does in C++. The result is a very strong engine, much stronger than Sunfish. The additional positional information from NNUE makes this engine probably the strongest python engine running on 1-thread CPU.
You can challenge it also on lichess for 5+0 min games:
Supports both UCI protocol and regular play from the terminal. Please, leave a star if you like it . If you make Numbfish stronger I will merge your improvements!
I have created Numbfish, a strong python chess engine based on Sunfish but with some additional features, the most important of which is the Efficiently Updatable Neural Network (NNUE). For the first time ever, NNUE has been implemented in python, specifically numpy (and tflite) using the incremental updates just like Stockfish does in C++. The result is a very strong engine, much stronger than Sunfish. The additional positional information from NNUE makes this engine probably the strongest python engine running on 1-thread CPU.
You can challenge it also on lichess for 5+0 min games:
Supports both UCI protocol and regular play from the terminal. Please, leave a star if you like it . If you make Numbfish stronger I will merge your improvements!
Very interesting! Can generate a EXE based on UCI protocol?
I have created Numbfish, a strong python chess engine based on Sunfish but with some additional features, the most important of which is the Efficiently Updatable Neural Network (NNUE). For the first time ever, NNUE has been implemented in python, specifically numpy (and tflite) using the incremental updates just like Stockfish does in C++. The result is a very strong engine, much stronger than Sunfish. The additional positional information from NNUE makes this engine probably the strongest python engine running on 1-thread CPU.
You can challenge it also on lichess for 5+0 min games:
Supports both UCI protocol and regular play from the terminal. Please, leave a star if you like it . If you make Numbfish stronger I will merge your improvements!
Super cool! I'm actually writing a NNUE version of sunfish myself, that I'm hoping can participate in the TCEC 4K competition. For this reason, my net will be really tiny, so my sunfish_nnue probably won't be much of a match against numbfish. Looking forward to trying it though!
Note about lichess.org: I found that many humans don't like sunfish taking 30 seconds before it plays its first time. They think something is wrong and just leave the game. So when I had sunfish playing on lichess I forced it to play the first move quickly. It doesn't matter much what it plays anyway.
I have created Numbfish, a strong python chess engine based on Sunfish but with some additional features, the most important of which is the Efficiently Updatable Neural Network (NNUE). For the first time ever, NNUE has been implemented in python, specifically numpy (and tflite) using the incremental updates just like Stockfish does in C++. The result is a very strong engine, much stronger than Sunfish. The additional positional information from NNUE makes this engine probably the strongest python engine running on 1-thread CPU.
You can challenge it also on lichess for 5+0 min games:
Supports both UCI protocol and regular play from the terminal. Please, leave a star if you like it . If you make Numbfish stronger I will merge your improvements!
Super cool! I'm actually writing a NNUE version of sunfish myself, that I'm hoping can participate in the TCEC 4K competition. For this reason, my net will be really tiny, so my sunfish_nnue probably won't be much of a match against numbfish. Looking forward to trying it though!
Note about lichess.org: I found that many humans don't like sunfish taking 30 seconds before it plays its first time. They think something is wrong and just leave the game. So when I had sunfish playing on lichess I forced it to play the first move quickly. It doesn't matter much what it plays anyway.
Great! Didn't know you are writing a NNUE version as well! When I introduced stockfish NNUE inference in Sunfish it limited greatly the NPS. Without the hardware optimizations I did on numbfish as well as the "efficiently updatable" accumulator the NPS was waay less. Got a speed-up of like 20x with these. So remember to do something similar (if possible) with your net.
You can always start from my implementation as a base. As i did with your excellent Sunfish repo. Hope we will end with something even better.
Anyways, good luck with the implementation and the competition!
thomasahle wrote: ↑Tue Dec 06, 2022 5:42 pm
I'm curious what kind of "hardware" optimizations you did?
Also, how did you implement NNUE before you had the accumulator?
I first implemented the NNUE using Tensorflow. With hardware optimizations I mean writing efficient numpy code (probably vectorized) for the accumulator operations along with converting the second part of the Tensorflow model (after the transformation step) into tf-lite, which is optimized for low latency inference in CPUs.
dimdano wrote: ↑Fri Dec 02, 2022 7:00 pm
For the first time ever, NNUE has been implemented in python
D-house uses an NNUE evaluation, so I may have beaten you to the punch
dimdano wrote: ↑Fri Dec 02, 2022 7:00 pm
The additional positional information from NNUE makes this engine probably the strongest python engine running on 1-thread CPU.
Always awesome to see new python chess engines! I'd love to test out the validity of this claim at some point.
dimdano wrote: ↑Fri Dec 02, 2022 7:00 pm
The additional positional information from NNUE makes this engine probably the strongest python engine running on 1-thread CPU.
Antares (https://github.com/Alex2262/Antares), another python engine, is about 225 elo stronger than numbfish in my (very brief) test at 1min+0.5s, in CCRL terms it places numbfish around 1800-2000 elo.
Also I recommend allowing it to end the search at any time, rather than just at the end of each depth iteration, as it loses on time for short games.
alvinypeng wrote: ↑Thu Dec 08, 2022 9:05 pm
Always awesome to see new python chess engines! I'd love to test out the validity of this claim at some point.
JacquesRW wrote: ↑Fri Dec 09, 2022 1:30 am
Antares (https://github.com/Alex2262/Antares), another python engine, is about 225 elo stronger than numbfish in my (very brief) test at 1min+0.5s, in CCRL terms it places numbfish around 1800-2000 elo.
Great! Didn't know such engines existed! That's why I said the word "probably" My aim was not to create the strongest python engine because this would add a lot more lines of code and ruin my python programming motive. I wanted to create a NNUE evaluation without adding many more lines in the existing engine of Sunfish. Surely you must have included some advanced chess tricks into your engines so I guess it is normal yours can beat mine!
JacquesRW wrote: ↑Fri Dec 09, 2022 1:30 am
Also I recommend allowing it to end the search at any time, rather than just at the end of each depth iteration, as it loses on time for short games.
The optimal play for Numbfish is at 5min so yes 1min is very short indeed.