Board representation, evaluation speed and NNUE

Discussion of chess software programming and technical issues.

Moderator: Ras

gaard
Posts: 463
Joined: Mon Jun 07, 2010 3:13 am
Location: Holland, MI
Full name: Martin W

Board representation, evaluation speed and NNUE

Post by gaard »

My understanding is that bitboards make conventional position evaluations significantly faster, especially compared to mailbox, and that was primarily why many people abandoned mailbox years ago. Does NNUE negate that advantage any or is NNUE performance also heavily dependent on board representation?
AndrewGrant
Posts: 1960
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: Board representation, evaluation speed and NNUE

Post by AndrewGrant »

gaard wrote: Wed Sep 29, 2021 9:22 pm My understanding is that bitboards make conventional position evaluations significantly faster, especially compared to mailbox, and that was primarily why many people abandoned mailbox years ago. Does NNUE negate that advantage any or is NNUE performance also heavily dependent on board representation?
NNUE should not be impacted very much by board representation. Most updates are incremental, and I can see it being of equal cost both ways. The performance gap in NNUE is Fused-Multiply-Adds from the Input Layer to Layer 1, not the way you define the board structure.
gaard
Posts: 463
Joined: Mon Jun 07, 2010 3:13 am
Location: Holland, MI
Full name: Martin W

Re: Board representation, evaluation speed and NNUE

Post by gaard »

AndrewGrant wrote: Wed Sep 29, 2021 10:42 pm
gaard wrote: Wed Sep 29, 2021 9:22 pm My understanding is that bitboards make conventional position evaluations significantly faster, especially compared to mailbox, and that was primarily why many people abandoned mailbox years ago. Does NNUE negate that advantage any or is NNUE performance also heavily dependent on board representation?
NNUE should not be impacted very much by board representation. Most updates are incremental, and I can see it being of equal cost both ways. The performance gap in NNUE is Fused-Multiply-Adds from the Input Layer to Layer 1, not the way you define the board structure.
In your opinion, then, does this negate the main performance advantages of a bitboard engine?
Sopel
Posts: 391
Joined: Tue Oct 08, 2019 11:39 pm
Full name: Tomasz Sobczyk

Re: Board representation, evaluation speed and NNUE

Post by Sopel »

It doesn't negate it, just makes it relatively smaller
dangi12012 wrote:No one wants to touch anything you have posted. That proves you now have negative reputations since everyone knows already you are a forum troll.

Maybe you copied your stockfish commits from someone else too?
I will look into that.
AndrewGrant
Posts: 1960
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: Board representation, evaluation speed and NNUE

Post by AndrewGrant »

Sopel wrote: Thu Sep 30, 2021 12:15 am It doesn't negate it, just makes it relatively smaller
+1. I would still use bitboards though.
amanjpro
Posts: 883
Joined: Sat Mar 13, 2021 1:47 am
Full name: Amanj Sherwany

Re: Board representation, evaluation speed and NNUE

Post by amanjpro »

If you can make your move generator as fast, and SEE computation as fast using another techniques other than bitboards, then yes.

But I'm my very little experience bitboards shine in these two areas more than any other technologies
User avatar
hgm
Posts: 28401
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Board representation, evaluation speed and NNUE

Post by hgm »

A good mailbox implementation is faster than bitboards. But with NNUE the evaluation gets to dominate the time usage completely. And unlike HCE, it doesn't take any advantage from one representation or another.
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Board representation, evaluation speed and NNUE

Post by dangi12012 »

hgm wrote: Thu Sep 30, 2021 4:08 pm A good mailbox implementation is faster than bitboards. But with NNUE the evaluation gets to dominate the time usage completely. And unlike HCE, it doesn't take any advantage from one representation or another.
I can 100% confirm that this is not the case at all. There are a list of about a dozen optimisations that are not applicable to mailslots but to bitboards only.
Btw I can say that for sure because I implemented dozens of different approaches and it always goes that all mailslot ideas can be implemented in bitboards but not always the other way around:

Movegen - Single Thread - No Hash - Bulk counting Enabled.
Perft 7: 3195901860 2180ms
Perft Kiwi 6: 8031647685 3921ms

But yeah CPU time will be spent in NNUE - or pruning + sorting in general. Since every move not saved will translate to literally billions of wasted moves a few steps down the tree.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
AndrewGrant
Posts: 1960
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: Board representation, evaluation speed and NNUE

Post by AndrewGrant »

dangi12012 wrote: Thu Sep 30, 2021 4:16 pm
hgm wrote: Thu Sep 30, 2021 4:08 pm A good mailbox implementation is faster than bitboards. But with NNUE the evaluation gets to dominate the time usage completely. And unlike HCE, it doesn't take any advantage from one representation or another.
I can 100% confirm that this is not the case at all. There are a list of about a dozen optimisations that are not applicable to mailslots but to bitboards only.
Btw I can say that for sure because I implemented dozens of different approaches and it always goes that all mailslot ideas can be implemented in bitboards but not always the other way around:

Movegen - Single Thread - No Hash - Bulk counting Enabled.
Perft 7: 3195901860 2180ms
Perft Kiwi 6: 8031647685 3921ms

But yeah CPU time will be spent in NNUE - or pruning + sorting in general. Since every move not saved will translate to literally billions of wasted moves a few steps down the tree.
Bulk counting would obviously favor bitboards. General case, I think they are not so different speed wise. Both have advantages.
User avatar
hgm
Posts: 28401
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Board representation, evaluation speed and NNUE

Post by hgm »

Perft speed is meaningless for an engine. Engines do so many things that are ignored in perft. And they must mainly generate captures.