pawn hash and eval tuning

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.
jwes
Posts: 777
Joined: Sat Jul 01, 2006 5:11 am

pawn hash and eval tuning

Post by jwes » Sun Feb 21, 2016 5:45 am

How do people handle pawn hash when tuning? It just occurred to me if I have a pawn hash, then 99% of the time I won't have pawn terms to tune.

User avatar
Desperado
Posts: 638
Joined: Mon Dec 15, 2008 10:45 am

Re: pawn hash and eval tuning

Post by Desperado » Sun Feb 21, 2016 8:25 am

Hi,

you can simply always compute the data when in tuning mode, like...

Code: Select all

pawn_t* PawnTable::getSlot(Position* pos)
{
    pawn_t* slot = &table[getKey(pos) & _HASHMASK];

    if( NOT_TUNING )
    if(BitUtil::hi32(getKey(pos)) == slot->lock) {
        return slot;
    }

    evaluate(pos,slot);
    return slot;
}
At least if the tuning algorithm is not sensitive to speed of the engine and you are talking of parameter tuning.

tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 3:57 pm
Location: Germany
Contact:

Re: pawn hash and eval tuning

Post by tpetzke » Sun Feb 21, 2016 11:32 am

This is not a feature of having a pawn hash or not. The pawn hash only saves some computation. If you remove the pawn hash and compute everything from scratch you have the same outcome from tuning (only a bit slower).
Thomas...

=======
http://macechess.blogspot.com - iCE Chess Engine

User avatar
Desperado
Posts: 638
Joined: Mon Dec 15, 2008 10:45 am

Re: pawn hash and eval tuning

Post by Desperado » Sun Feb 21, 2016 2:31 pm

tpetzke wrote:This is not a feature of having a pawn hash or not. The pawn hash only saves some computation. If you remove the pawn hash and compute everything from scratch you have the same outcome from tuning (only a bit slower).
I can't follow now. If parameters are changed for pawn evaluation you need to re-calculate the score of course.
For example if you have set 100 cp for a passed pawn but change the value to 105 cp you need to compute the outcome again. Otherwise you would retrieve the score which was computed with 100 cp.

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

Re: pawn hash and eval tuning

Post by bob » Sun Feb 21, 2016 5:51 pm

jwes wrote:How do people handle pawn hash when tuning? It just occurred to me if I have a pawn hash, then 99% of the time I won't have pawn terms to tune.
Not quite. 99% of the time you won't have to COMPUTE the pawn scores, but you use them at every terminal node... So the tuning is the same whether you hash or not.

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

Re: pawn hash and eval tuning

Post by bob » Sun Feb 21, 2016 5:53 pm

Desperado wrote:
tpetzke wrote:This is not a feature of having a pawn hash or not. The pawn hash only saves some computation. If you remove the pawn hash and compute everything from scratch you have the same outcome from tuning (only a bit slower).
I can't follow now. If parameters are changed for pawn evaluation you need to re-calculate the score of course.
For example if you have set 100 cp for a passed pawn but change the value to 105 cp you need to compute the outcome again. Otherwise you would retrieve the score which was computed with 100 cp.
Pawn hash doesn't survive program termination. You play a game, or test a position, then it would be cleared, at least when using games for testing. If you are talking about some sort of automated annealing or whatever, then you would likely want to disable it.

jdart
Posts: 3720
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: pawn hash and eval tuning

Post by jdart » Sun Feb 21, 2016 6:20 pm

For this reason I disable caching when tuning.

See https://github.com/jdart1/arasan-chess/ ... /scoring.h.

The evaluation function takes a boolean parameter:

Code: Select all

// evaluate "board" from the perspective of the side to move.
int evalu8( const Board &board, bool useCache = true );

User avatar
Desperado
Posts: 638
Joined: Mon Dec 15, 2008 10:45 am

Re: pawn hash and eval tuning

Post by Desperado » Sun Feb 21, 2016 6:29 pm

bob wrote:
Desperado wrote:
tpetzke wrote:This is not a feature of having a pawn hash or not. The pawn hash only saves some computation. If you remove the pawn hash and compute everything from scratch you have the same outcome from tuning (only a bit slower).
I can't follow now. If parameters are changed for pawn evaluation you need to re-calculate the score of course.
For example if you have set 100 cp for a passed pawn but change the value to 105 cp you need to compute the outcome again. Otherwise you would retrieve the score which was computed with 100 cp.
Pawn hash doesn't survive program termination. You play a game, or test a position, then it would be cleared, at least when using games for testing. If you are talking about some sort of automated annealing or whatever, then you would likely want to disable it.
Well, the tuning method needs to be specified for the original post.

mar
Posts: 1941
Joined: Fri Nov 26, 2010 1:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: pawn hash and eval tuning

Post by mar » Sun Feb 21, 2016 6:50 pm

Desperado wrote:I can't follow now. If parameters are changed for pawn evaluation you need to re-calculate the score of course.
Well, you run n threads on million(s) of positions for tuning, one run of course has the same parameters. Naturally you flush the caches between runs, I don't see any problem here.
Eval cache speeds up Texel tuning a lot, at least in my case it did.

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

Re: pawn hash and eval tuning

Post by bob » Sun Feb 21, 2016 7:33 pm

Desperado wrote:
bob wrote:
Desperado wrote:
tpetzke wrote:This is not a feature of having a pawn hash or not. The pawn hash only saves some computation. If you remove the pawn hash and compute everything from scratch you have the same outcome from tuning (only a bit slower).
I can't follow now. If parameters are changed for pawn evaluation you need to re-calculate the score of course.
For example if you have set 100 cp for a passed pawn but change the value to 105 cp you need to compute the outcome again. Otherwise you would retrieve the score which was computed with 100 cp.
Pawn hash doesn't survive program termination. You play a game, or test a position, then it would be cleared, at least when using games for testing. If you are talking about some sort of automated annealing or whatever, then you would likely want to disable it.
Well, the tuning method needs to be specified for the original post.
This is cache 101. If something invalidates the data, it can't be used again. If you allow the score weights to change, you have to take action. I would think that's pretty obvious...

Same problem with position learning. If ANYTHING changes, old position learning should be invalidated.

Post Reply