Hey what's up guys, Code Monkey King's here.
First of all I'd like to thank Daniel Shawul for creating NNUE probe library based on CFish's code.
https://github.com/dshawul/nnue-probe
because without this library my work would never exist.
I've just made a quick and dirty embedding of SF NNUE to my engine BBC and results are fantastic,
here's the example game:
There are still lots of improvements, but it now already works as a proof of concept.
Yeah, almost forgot - here's a link to YouTube series:
https://www.youtube.com/watch?v=zieTAE2 ... gMaG24HTc4
Embedding Stockfish NNUE to ANY CHESS ENGINE: YouTube series
Moderators: hgm, Dann Corbit, Harvey Williamson
Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
- maksimKorzh
- Posts: 550
- Joined: Sat Sep 08, 2018 3:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
- Contact:
Embedding Stockfish NNUE to ANY CHESS ENGINE: YouTube series
JavaScript chess engine with UCI support, own GUI and public API:
https://github.com/maksimKorzh/wukongJS
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://github.com/maksimKorzh/wukongJS
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
- maksimKorzh
- Posts: 550
- Joined: Sat Sep 08, 2018 3:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
- Contact:
Re: Embedding Stockfish NNUE to ANY CHESS ENGINE: YouTube series
Finally series is finished!
Here's the BBC with NNUE!
(I used handcrafted eval in the endgame though to speed up engine on ultra fast time controls)
https://github.com/maksimKorzh/bbc/tree ... c/bbc_nnue
Linux version only for now, I'm working on windows compatibility. If you manage to compile it on windows faster than I please share your solution.
Btw, if I'm now using SF NNUE does it mean that I need to change the licence to GNU GPL 3 like in SF?
Here's the BBC with NNUE!
(I used handcrafted eval in the endgame though to speed up engine on ultra fast time controls)
https://github.com/maksimKorzh/bbc/tree ... c/bbc_nnue
Linux version only for now, I'm working on windows compatibility. If you manage to compile it on windows faster than I please share your solution.
Btw, if I'm now using SF NNUE does it mean that I need to change the licence to GNU GPL 3 like in SF?
JavaScript chess engine with UCI support, own GUI and public API:
https://github.com/maksimKorzh/wukongJS
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://github.com/maksimKorzh/wukongJS
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
Re: Embedding Stockfish NNUE to ANY CHESS ENGINE: YouTube series
If all of the code has licenses that you can change, that would be easiest, but if you distribute MIT and GPL code together, it’s really more of an issue for someone wanting to do something that the MIT License permits but the GPL does not.Btw, if I'm now using SF NNUE does it mean that I need to change the licence to GNU GPL 3 like in SF?
-
- Posts: 4073
- Joined: Tue Mar 14, 2006 10:34 am
- Location: Ethiopia
- Contact:
Re: Embedding Stockfish NNUE to ANY CHESS ENGINE: YouTube series
A couple of notes.maksimKorzh wrote: ↑Sat Oct 17, 2020 9:59 pmLinux version only for now, I'm working on windows compatibility. If you manage to compile it on windows faster than I please share your solution.
Btw, if I'm now using SF NNUE does it mean that I need to change the licence to GNU GPL 3 like in SF?
You need to define compiler flags that may give you upto 5x speedup with gcc. With clang it is only about 2x but,
I suspect you are missing on this speed up.
Just add this flags when compiling the nnue.cpp file.
Code: Select all
DEFINES =
DEFINES += -DIS_64BIT
ifeq ($(COMP),$(filter $(COMP),gcc clang win icpc))
DEFINES += -DUSE_AVX2 -mavx2
DEFINES += -DUSE_SSE41 -msse4.1
DEFINES += -DUSE_SSSE3 -mssse3
DEFINES += -DUSE_SSE2 -msse2
DEFINES += -DUSE_SSE -msse
endif
so you can just drop them in your project and use them. There were some intrinsics for BitScanFirst that were missing.
- maksimKorzh
- Posts: 550
- Joined: Sat Sep 08, 2018 3:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
- Contact:
Re: Embedding Stockfish NNUE to ANY CHESS ENGINE: YouTube series
Finally BBC + SF NNUE version is released!
https://github.com/maksimKorzh/bbc/releases/tag/1.3
And here're some games from recent match BBC 1.2 + SF NNUE vs VICE
https://github.com/maksimKorzh/bbc/tree ... ue_vs_vice
https://github.com/maksimKorzh/bbc/releases/tag/1.3
And here're some games from recent match BBC 1.2 + SF NNUE vs VICE
https://github.com/maksimKorzh/bbc/tree ... ue_vs_vice
JavaScript chess engine with UCI support, own GUI and public API:
https://github.com/maksimKorzh/wukongJS
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://github.com/maksimKorzh/wukongJS
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
Re: Embedding Stockfish NNUE to ANY CHESS ENGINE: YouTube series
A few questions:
1) the nnue should be ~80% of the speed of hce of something like Scorpio (so 20% slower). After the compiler optimizations Daniel suggested, are you seeing something similar?
2) nnue is updated a little bit with each move/null move (and undo of a move). That’s what makes it efficient. Looking at your first video it didn’t seem you were doing that but performing a nnue initialization and eval from scratch, an expensive operation. Did I misunderstand your video?
1) the nnue should be ~80% of the speed of hce of something like Scorpio (so 20% slower). After the compiler optimizations Daniel suggested, are you seeing something similar?
2) nnue is updated a little bit with each move/null move (and undo of a move). That’s what makes it efficient. Looking at your first video it didn’t seem you were doing that but performing a nnue initialization and eval from scratch, an expensive operation. Did I misunderstand your video?
- maksimKorzh
- Posts: 550
- Joined: Sat Sep 08, 2018 3:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
- Contact:
Re: Embedding Stockfish NNUE to ANY CHESS ENGINE: YouTube series
re: 1dkappe wrote: ↑Sun Oct 18, 2020 7:54 pmA few questions:
1) the nnue should be ~80% of the speed of hce of something like Scorpio (so 20% slower). After the compiler optimizations Daniel suggested, are you seeing something similar?
2) nnue is updated a little bit with each move/null move (and undo of a move). That’s what makes it efficient. Looking at your first video it didn’t seem you were doing that but performing a nnue initialization and eval from scratch, an expensive operation. Did I misunderstand your video?
- I didn't use optimization flags - my engine just crashes, I didn't dig deeper. I was interested in proofing the concept
re: 2
- Daniel's lib allows calculate NNUE scores without incremental updates and that's why I love it.
Just to give an overall direction of my work - I'm trying to deliver some complicated concepts to noobs like me so they could pick those concepts up as a proof of concept. I'm not trying to make my engine as strong and as fast as possible, I'm not interested in that because competetive aspect is something I hate the most. For me the FACT that SF NNUE works with engine I've handcrafted on my own is already a victory. Ones person achieves the goal of proving the concept he can then go for optimizations on his own.
If you're going wide spread you just don't have enough power to go deeper, on the other hand when you're endeepening significantly you can't explain complicated things in an easy way. I'm having the following problem all the time: everyone around is MUCH SMARTER than I, but they often can't explain me some very simple things. Well, maybe they can, but I'm too noob to get those explanations. So most of my efforts are spent on trying to dig the very gist of whatever concept. The entire BBC engine is a set of "proof of concepts" in all the parts of the engine (movegen, search techniques and now nnue). There are enough smart people whocreate really strong engines, bit there's noone out there who would explain chess programming to five year old kid (who is monkey at the same time). What I'm trying to do is explaining to 5 year old monkey kids)
Hope that makes sense.
JavaScript chess engine with UCI support, own GUI and public API:
https://github.com/maksimKorzh/wukongJS
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://github.com/maksimKorzh/wukongJS
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ