crafty eval cache

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Cardoso
Posts: 275
Joined: Thu Mar 16, 2006 6:39 pm

crafty eval cache

Post by Cardoso » Fri Jan 01, 2016 2:06 am

Hi,
I noticed crafty 25 has an eval hash table.
It uses 32 bits from the upper part of the hashkey plus 16 bits from the hash size (65536), this is 48 bits total, do you think this is enough?
I understand it is nice to have 64 bits for the eval hash entries (32 for key + 32 for score), but 48 bits for the key seems a bit risky.

Alvaro

Cardoso
Posts: 275
Joined: Thu Mar 16, 2006 6:39 pm

Re: crafty eval cache

Post by Cardoso » Fri Jan 01, 2016 2:12 am

Of course since all of this happens so far from the root, any collisions may have very little impact on the final propagated score/pv.

Alvaro

User avatar
Evert
Posts: 2898
Joined: Fri Jan 21, 2011 11:42 pm
Location: NL
Contact:

Re: crafty eval cache

Post by Evert » Fri Jan 01, 2016 8:42 am

Cardoso wrote:Hi,
I noticed crafty 25 has an eval hash table.
It uses 32 bits from the upper part of the hashkey plus 16 bits from the hash size (65536), this is 48 bits total, do you think this is enough?
I understand it is nice to have 64 bits for the eval hash entries (32 for key + 32 for score), but 48 bits for the key seems a bit risky.
I think this is fine from what I remember with Jazz and SjaakII, but I wonder why you'd need 32 bits to store the evaluation score...

Dann Corbit
Posts: 8662
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: crafty eval cache

Post by Dann Corbit » Fri Jan 01, 2016 8:44 am

Evert wrote:
Cardoso wrote:Hi,
I noticed crafty 25 has an eval hash table.
It uses 32 bits from the upper part of the hashkey plus 16 bits from the hash size (65536), this is 48 bits total, do you think this is enough?
I understand it is nice to have 64 bits for the eval hash entries (32 for key + 32 for score), but 48 bits for the key seems a bit risky.
I think this is fine from what I remember with Jazz and SjaakII, but I wonder why you'd need 32 bits to store the evaluation score...
If 8 byte alignment, then no loss because of padding anyway.
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.

User avatar
Evert
Posts: 2898
Joined: Fri Jan 21, 2011 11:42 pm
Location: NL
Contact:

Re: crafty eval cache

Post by Evert » Fri Jan 01, 2016 8:50 am

Dann Corbit wrote:
Evert wrote:
Cardoso wrote:Hi,
I noticed crafty 25 has an eval hash table.
It uses 32 bits from the upper part of the hashkey plus 16 bits from the hash size (65536), this is 48 bits total, do you think this is enough?
I understand it is nice to have 64 bits for the eval hash entries (32 for key + 32 for score), but 48 bits for the key seems a bit risky.
I think this is fine from what I remember with Jazz and SjaakII, but I wonder why you'd need 32 bits to store the evaluation score...
If 8 byte alignment, then no loss because of padding anyway.
Sure, you want one entry in 64 bits, but if you use 16 bits for the evaluation result you can use 48 bits for the lock.

Dann Corbit
Posts: 8662
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: crafty eval cache

Post by Dann Corbit » Fri Jan 01, 2016 8:55 am

Evert wrote:
Dann Corbit wrote:
Evert wrote:
Cardoso wrote:Hi,
I noticed crafty 25 has an eval hash table.
It uses 32 bits from the upper part of the hashkey plus 16 bits from the hash size (65536), this is 48 bits total, do you think this is enough?
I understand it is nice to have 64 bits for the eval hash entries (32 for key + 32 for score), but 48 bits for the key seems a bit risky.
I think this is fine from what I remember with Jazz and SjaakII, but I wonder why you'd need 32 bits to store the evaluation score...
If 8 byte alignment, then no loss because of padding anyway.
Sure, you want one entry in 64 bits, but if you use 16 bits for the evaluation result you can use 48 bits for the lock.
Depending on how many entries you have the extra bits may be overkill.

I tend to use a much simpler eval hash, but I am sure that Bob tested it carefully.
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.

User avatar
Evert
Posts: 2898
Joined: Fri Jan 21, 2011 11:42 pm
Location: NL
Contact:

Re: crafty eval cache

Post by Evert » Fri Jan 01, 2016 9:14 am

Dann Corbit wrote: Depending on how many entries you have the extra bits may be overkill.

I tend to use a much simpler eval hash, but I am sure that Bob tested it carefully.
Sure, but the original question was whether 48 bits (32 lock + 16 index) is enough; as you say I'm sure Bob tested that this was fine, but I don't see why you couldn't have 64 bits (48 lock + 16 index) by storing the evaluation result in 16 bits rather than 32.
Of course if it's redundant it neither helps no hurts, so the question is entirely academic.

User avatar
hgm
Posts: 22274
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: crafty eval cache

Post by hgm » Fri Jan 01, 2016 10:18 am

It probably would not even hurt if you did 16 bit key + 16 bit eval. But that would need to be confirmed by testing.

With 32 bits of key you would have a false hit only once every 4 billion probes, i.e. at 4Mnps once very 1000 sec. You have to compare that extra probability to get an eval that is totally off to the ~1% of the leave nodes that have evals that are totally off for search-related reasons (e.g. because a 'bad capture' turned out not to be bad at all due to soft-pinning or overloading of one of the involved pieces). So you would drive up the error rate from 1% to 1.000000025%...

bob
Posts: 20342
Joined: Mon Feb 27, 2006 6:30 pm
Location: Birmingham, AL

Re: crafty eval cache

Post by bob » Tue Jan 05, 2016 10:29 pm

Cardoso wrote:Hi,
I noticed crafty 25 has an eval hash table.
It uses 32 bits from the upper part of the hashkey plus 16 bits from the hash size (65536), this is 48 bits total, do you think this is enough?
I understand it is nice to have 64 bits for the eval hash entries (32 for key + 32 for score), but 48 bits for the key seems a bit risky.

Alvaro
More than enough. First, a collision won't crash a thing. Based on the paper Cozzie and I wrote a few years back on hash collisions, even one in a million bad hashes won't do a thing, and the collision rate won't be anywhere near that...

Also notice that less than 1/2 of the positions get stored anyway. If there is a lazy exit, we don't store a thing.

bob
Posts: 20342
Joined: Mon Feb 27, 2006 6:30 pm
Location: Birmingham, AL

Re: crafty eval cache

Post by bob » Tue Jan 05, 2016 10:31 pm

Evert wrote:
Cardoso wrote:Hi,
I noticed crafty 25 has an eval hash table.
It uses 32 bits from the upper part of the hashkey plus 16 bits from the hash size (65536), this is 48 bits total, do you think this is enough?
I understand it is nice to have 64 bits for the eval hash entries (32 for key + 32 for score), but 48 bits for the key seems a bit risky.
I think this is fine from what I remember with Jazz and SjaakII, but I wonder why you'd need 32 bits to store the evaluation score...
It was simple. I tried several versions, including storing the score, the bounds, and what the current score means (score from lazy1, lazy2 or full eval. There was no benefit. Mike kept fiddling with it and this was worth a couple of elo, just doing the simple "only store full evals". But we did not go back to trying to recover the 16 bits we no longer needed. I might do that at some point, but the rise is close enough to zero...

Post Reply