Stockfish NNUE Questions

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

Dann Corbit
Posts: 12814
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Stockfish NNUE Questions

Post by Dann Corbit »

The AVX build option is new. I need to try it, because I am just running 'Modern' right now.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
Stephen Ham
Posts: 2505
Joined: Wed Mar 08, 2006 9:40 pm
Location: Eden Prairie, Minnesota
Full name: Stephen Ham

Re: Stockfish NNUE Questions

Post by Stephen Ham »

Hi Dann,

I was like you in running only Modern. But Corres is correct that the AVX build seems a bit faster.

Regards,
-Steve-
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Stockfish NNUE Questions

Post by zullil »

Dann Corbit wrote: Sun Aug 16, 2020 10:58 pm The AVX build option is new. I need to try it, because I am just running 'Modern' right now.
Modern uses popcnt, but not the AVX2 instructions.

ifeq ($(ARCH),$(filter $(ARCH),x86-64-sse41-popcnt x86-64-modern))
arch = x86_64
prefetch = yes
popcnt = yes
sse = yes
ssse3 = yes
sse41 = yes
endif

ifeq ($(ARCH),x86-64-avx2)
arch = x86_64
prefetch = yes
popcnt = yes
sse = yes
ssse3 = yes
sse41 = yes
avx2 = yes
endif
Stephen Ham
Posts: 2505
Joined: Wed Mar 08, 2006 9:40 pm
Location: Eden Prairie, Minnesota
Full name: Stephen Ham

Re: Stockfish NNUE Questions

Post by Stephen Ham »

Hi Louis,

I'm TalkChess' resident computer dummy. Nonetheless in your display, we see: popcnt = yes. Doesn't that mean popcnt is still used by the AVX build?

ifeq ($(ARCH),x86-64-avx2)
arch = x86_64
prefetch = yes
popcnt = yes
sse = yes
ssse3 = yes
sse41 = yes
avx2 = yes
endif

Regards,
-Steve-
Milos
Posts: 4190
Joined: Wed Nov 25, 2009 1:47 am

Re: Stockfish NNUE Questions

Post by Milos »

zullil wrote: Sun Aug 16, 2020 10:23 pm
Modern Times wrote: Sun Aug 16, 2020 9:57 pm
corres wrote: Sat Aug 15, 2020 11:43 pm I have a Ryzen 9 3950x CPU and I found the most faster SF+NNUE binary (.exe) is the AVX2 optimized one.
Yes, same with my Ryzen 7 laptop,
I suppose this is because the bmi2 binaries include the PEXT instruction, which is very slow on Ryzen?
I never understood all the fuss with that PEXT instruction. I don't even know where it is used in SF source but judging by what it does it seems can be totally avoided by carefully coding the stuff, and I can't believe it would bring more than a mare 1-2% speedup in the very best case.
AVX is on the other hand a proper SIMD thing and brings up a lot.
The AVX compile switch is anyway not for SF but for NNUE part compilation where SIMD insteuctions are handcoded in updating NN score computation.
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: Stockfish NNUE Questions

Post by zullil »

Stephen Ham wrote: Mon Aug 17, 2020 12:56 am Hi Louis,

I'm TalkChess' resident computer dummy. Nonetheless in your display, we see: popcnt = yes. Doesn't that mean popcnt is still used by the AVX build?

ifeq ($(ARCH),x86-64-avx2)
arch = x86_64
prefetch = yes
popcnt = yes
sse = yes
ssse3 = yes
sse41 = yes
avx2 = yes
endif

Regards,
-Steve-
Yes. The avx2 build uses popcnt in addition to the avx2 instructions. But unlike the bmi2 build, it doesn't use the pext instruction. On my Intel system, the bmi2 build is fastest; it uses popcnt, avx2 and pext.
Dann Corbit
Posts: 12814
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Stockfish NNUE Questions

Post by Dann Corbit »

Thanks to all for the AVX2 hints, it was an excellent gain for my threadripper.

If you have a threadripper or other modern AMD, and you like to use my builds, try the stockfish-x64-avx2.exe binary.
I saw a tangible benefit
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
h1a8
Posts: 518
Joined: Fri Jun 04, 2010 7:23 am

Re: Stockfish NNUE Questions

Post by h1a8 »

Three Questions:

1. In engine parameters, For the "use nnue" box selected is it best to select max threads (8 in my case) or use lower threads (like 6 or 2)?

2. Is there an option to choose hybrid and pure?

3. in android (or ios) for the latest version of stockfish which is stronger hybrid or pure?
h1a8
Posts: 518
Joined: Fri Jun 04, 2010 7:23 am

Re: Stockfish NNUE Questions

Post by h1a8 »

I have an 8 core machine. When I install stockfish nnue I notice that, in engine parameters, the default number of threads is 6. Is this best? Or should I change it to 8 threads?
bastiball
Posts: 5368
Joined: Tue Oct 20, 2020 4:18 am
Full name: Basti Dangca

Re: Stockfish NNUE Questions

Post by bastiball »

h1a8 wrote: Sun May 09, 2021 5:00 pm I have an 8 core machine. When I install stockfish nnue I notice that, in engine parameters, the default number of threads is 6. Is this best? Or should I change it to 8 threads?
If you want the best performance, you could use 8cores and it is much faster than 6 threads.
Basti Dangca
CCRL testing group