Push a patch

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

Moderators: hgm, Rebel, chrisw

Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: d4 and e4 blocked pawns - especially for SF

Post by Lyudmil Tsvetkov »

[d]6k1/5pp1/p4n1p/1p1p4/3P4/PP4PP/1B3P2/6K1 w - - 0 1

d4 blocked pawn is worth much bigger penalty than a3,f2 and g3 pawns, that are also on squares the colour of the bishop.
While all of the remaining mentioned pawns can advance to light-coloured squares, the d4 pawn can not do that, as it is permanently blocked, and besides it is central.

So big distinction here.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: Rook psqt

Post by Lyudmil Tsvetkov »

Lyudmil, excuse me for the inconvenience, but do you think that we should change our rook psqt table after Marco introduced full obligatory symmetry along the vertical axis of the board?

Man, I have always thought the d5 and e5 squares are different, but if Mraco and Lucas say they are the same...

Also could I please ask you to reset the priority of the rook psqt from -1 to some decent one, maybe normal, as in this way it will never run on the framework. All kinds of tuning patches, etc. have priority and this patch will simply never run.
User avatar
lantonov
Posts: 216
Joined: Sun Apr 13, 2014 5:19 pm

Re: Rook psqt

Post by lantonov »

OK, I'll take down and patch the patch accordingly.

As for symmetrical / assimetrical, I have mixed feelings. On the one hand, the fewer parameters the better. On the other hand, chess positions are essentially assymetric and my tests and analysis of the rook psqt A and H files showed that those have quite different blends of effects. I abstain from taking a stance on this until something is definitely proven one way or the other.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: Rook psqt

Post by Lyudmil Tsvetkov »

lantonov wrote:OK, I'll take down and patch the patch accordingly.

As for symmetrical / assimetrical, I have mixed feelings. On the one hand, the fewer parameters the better. On the other hand, chess positions are essentially assymetric and my tests and analysis of the rook psqt A and H files showed that those have quite different blends of effects. I abstain from taking a stance on this until something is definitely proven one way or the other.
Thanks Lyudmil.

Time will tell.

For me it was easier the other way, with full board, as I was trying to tune the piece values imagining the values of the different board squares, but obviously for autotuning purposes a smaller table might be better.

One way or another, we will have to accomodate.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: Piece values

Post by Lyudmil Tsvetkov »

lucasart wrote:
Isaac wrote:Lyudmil, do you wish a single patch to tune the pieces values+psqt tables?
Or 1 patch for the pieces values + 1 patch for the psqt, etc?
I ask this because Joerg is currently trying your values for the piece values but nothing about your psqt values for king middle game nor rook middle game-end game.
Please don't waste resources with Lyudmil's random tweaks. The current PST is incredibly well tuned, far beyond the reach of hand-tuning. What are the odds that, in a 334-dimensional space of parameters, a random move leads to a 1.5-2 elo gain (below that we can't distinguish from noise) ?

SPRT(0,4) is costly, and fishtest is low on resources, so I would appreciate if people do some homework (eg. SPSA tuning locally) before wasting resources with random tuning tests.

This is not aimed at you, but a general comment for all who throw random tuning patches at the framework.
Sorry Lucas, but you deserved it.

It is not mine suggestions that are random, as I have been looking at thousands of SF games, games that I understand, in sharp distinction to many of the people who submit patches.

It is your patches that are really funny, especially your psqt attempts.

In the last one or 2 weeks you tried to tune some 10 different parameters, completely at random, and using sprt bounds that are BREAKING the rules of the framework. You pushed at least 5 or 6 patches BREAKING the rules established on the framework for tuning. I understand you are a maintainer, and you have somewhat bigger rights naturally, but that does in no way give you the right to break the rules.

You pushed patches with all imaginable bounds that are written nowhere.
You tried to tune 20-50 and even more than 100 parameters at the same time, in many cases completely unrelated. That is why I am happy none of your patches succeeded.

At long last, you are pushing you Final try on psqt, and, guess what, as you have to succeed now, you did the following:

- change one parameter for the mg 1 or 2 cps up, and the same parameter for the eg 1 or 2 cps down
- repeat the same for the next square
- repeat all over again for the next square
- from time to time change a bit more some square values, but very rarely, just to make a difference

In this way, you ensure yourself that your patch has relatively big chances to pass with some luck, as your patch is not far apart from the original values, and yet you have some changes in it.

That is what you have done; I would not have said it, but you asked for it.

I wonder how can you tune all the 6 psqt tables at once?
Does not that look as a completely unreasonable enterprise?

I can also do one or 2 cosmetical changes and succeed, but SF needs real changes, and not cosmetical ones.

Concerning waste of resources, but really it is a matter of fact, you can check the framework statistics, that YOU are the person who pushed the most patches lasting biggest number of games: you have pushed patches lasting 150 000, 200 000 and over 300 000 games, and you are the one complaining of wasting resources.

Look at what Marco does, be a bit more tolerant.

Again, I can never be really angry with you, as you are smart, but you fully deserved my comments here with your post here and your continuous comments on github.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: King psqt

Post by Lyudmil Tsvetkov »

S(303, 27), S(327, 81), S(270,108), S(220,116),
S(290, 74), S(321,128), S(260,155), S(210,165),
S(220,113), S(256,167), S(196,195), S(148,202),
S(192,135), S(226,193), S(167,219), S(119,228),
S(173,135), S(207,189), S(148,216), S(100,224),
S(146,111), S(180,165), S(121,192), S( 73,200),
S(119, 74), S(153,128), S( 94,155), S( 46,163),
S( 98, 27), S(132, 81), S( 73,108), S( 25,116),

Lyudmil, above are my latest king psqt values.

I initially introduced much more severe changes, but, looking at how everything that changes significantly SF code is doomed to fail, I decided to just somewhat change the values for the squares that I think need some changes.

In order to be specific: after observing many games, I changed the following squares:

- g1 down, h1 and h2 up; in a dynamic play, the g1 square is not that important, the king feels safe enough also on h1 and h2
- e1 down; SF sometimes seems to stay much too late in the mg on e1, without castling, and that occasionally creates problems
- f2 and e2 down; similarly, those are dangerous squares in the mg, where SF sometimes overstays
- all squares on the 4th rank a bit down; same here, those are dangerous squares, more dangerous than what SF thinks

Those are the mg values, because of which I made the changes.
As mg and eg values interact with interpolating, I also corrected a bit the respective eg values.

I would have like to do much more, but this time strictly the necessary.
:)

Wich significant changes, my piece values and rook psqt failed convincingly, although those were good changes. The problem is that, with all changes, when you change one parameter, you also influence a couple of related parameters, and therefore sweeping changes simply do not work.

I thought with very reasonable values they would work, but they do not.
Sf values for different terms have been tuned tens of times and even hundredths of times for specific parameters, so they are relatively well tuned to each other, although badly tuned in separation.

If you introduce sweeping changes to all parameters, and you know how they interact precisely, one can certainly add 500 elo to SF only based on good tuning, but the problem is that neither we humans, not autotuners are able to do that satisfactorily. So we must proceed with very minimal changes.

As we already started this thread, I wonder if you could, in case you happen to read this message, push one really last patch on king psqt, after that we can go on vacation. :)

I am certain that if you are not willing to push the patch, there will be no other volunteers.

In any case, we must do something to keep us busy, especially when life gets very boring around us.

PS. You might think that the last 2 patches were big failures, but no: I learned a lot from those patches.
User avatar
lantonov
Posts: 216
Joined: Sun Apr 13, 2014 5:19 pm

Re: King psqt

Post by lantonov »

Lyudmil Tsvetkov wrote:S(303, 27), S(327, 81), S(270,108), S(220,116),
S(290, 74), S(321,128), S(260,155), S(210,165),
S(220,113), S(256,167), S(196,195), S(148,202),
S(192,135), S(226,193), S(167,219), S(119,228),
S(173,135), S(207,189), S(148,216), S(100,224),
S(146,111), S(180,165), S(121,192), S( 73,200),
S(119, 74), S(153,128), S( 94,155), S( 46,163),
S( 98, 27), S(132, 81), S( 73,108), S( 25,116),

Lyudmil, above are my latest king psqt values.

I initially introduced much more severe changes, but, looking at how everything that changes significantly SF code is doomed to fail, I decided to just somewhat change the values for the squares that I think need some changes.

In order to be specific: after observing many games, I changed the following squares:

- g1 down, h1 and h2 up; in a dynamic play, the g1 square is not that important, the king feels safe enough also on h1 and h2
- e1 down; SF sometimes seems to stay much too late in the mg on e1, without castling, and that occasionally creates problems
- f2 and e2 down; similarly, those are dangerous squares in the mg, where SF sometimes overstays
- all squares on the 4th rank a bit down; same here, those are dangerous squares, more dangerous than what SF thinks

Those are the mg values, because of which I made the changes.
As mg and eg values interact with interpolating, I also corrected a bit the respective eg values.

I would have like to do much more, but this time strictly the necessary.
:)

Wich significant changes, my piece values and rook psqt failed convincingly, although those were good changes. The problem is that, with all changes, when you change one parameter, you also influence a couple of related parameters, and therefore sweeping changes simply do not work.

I thought with very reasonable values they would work, but they do not.
Sf values for different terms have been tuned tens of times and even hundredths of times for specific parameters, so they are relatively well tuned to each other, although badly tuned in separation.

If you introduce sweeping changes to all parameters, and you know how they interact precisely, one can certainly add 500 elo to SF only based on good tuning, but the problem is that neither we humans, not autotuners are able to do that satisfactorily. So we must proceed with very minimal changes.

As we already started this thread, I wonder if you could, in case you happen to read this message, push one really last patch on king psqt, after that we can go on vacation. :)

I am certain that if you are not willing to push the patch, there will be no other volunteers.

In any case, we must do something to keep us busy, especially when life gets very boring around us.

PS. You might think that the last 2 patches were big failures, but no: I learned a lot from those patches.
Hi, Lyudmil!

I don't think that a patch coming from you is useless. The last patch convinced me that common sense cannot help in tuning as the right values are counter-intuitive. This is not surprising to me at all. Having a long experience in statistical optimisation, I have seen this happen all the time. With such a complicated mess of effects, and so many parameters, it won't be easy to find the right transformation matrix. (The essence of any optimisation is to make a linear transformation of the parameter matrix A in the form TAT', where T is the transformation matrix. This involves diagonalisation of A and finding the eigenvalues and eigenvectors. In the present case, we have 2 matrices to transform: the gradient, which is a 1-column matrix (vector) and the Hessian, which is a square matrix). SPSA is one of the methods to do this, though one has to be careful in choosing the test parameters. In this respect, SPSA tuning with parameters that make very small changes at each iteration arrive at a local optimum which has a chance to succeed but it will add 2 or 3 Elo instead of the possible 200-300.

PSQT tables are a sort of catch-all: they compensate for mistuned parameters elsewhere in SF. If all other parameters are ideally tuned, the optimal values in the PSQTs should be all zeroes, so the PSQTs will become superfluous. This is unlikely to happen in the foreseeable future. In order to make a proper tuning, all PSQTs should be tuned at once. Tuning PSQTs one by one is not going to be very rewarding. Especially rook PSQT is one of the most Elo-insensitive. The best candidates for individual PSQT tuning are king and knight PSQTs.

You are right to direct your attention to the king PSQT. Your reasons for changes are very sensible but, as we saw, PSQTs defy common sense. I have no objection to testing it though would prefer to do the testing locally before doing it on Fishtest to see the direction to move. For one thing, these gigantic values strike me as odd. The king is maybe the most tuned piece of all (king safety, etc.) while these large values show that the king is most mistuned of all. This is a contradiction that does not appeal. I will compare also with SPSA results for additional guidance.

I am not staying idle these days. I do local SPSA tuning trying to choose the best test parameters: those leading to the fastest convergence and a global optimum. Also, as I wrote above, I am adapting better tuning methods: ROCK* and RSPSA.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: King psqt

Post by Lyudmil Tsvetkov »

lantonov wrote:
Lyudmil Tsvetkov wrote:S(303, 27), S(327, 81), S(270,108), S(220,116),
S(290, 74), S(321,128), S(260,155), S(210,165),
S(220,113), S(256,167), S(196,195), S(148,202),
S(192,135), S(226,193), S(167,219), S(119,228),
S(173,135), S(207,189), S(148,216), S(100,224),
S(146,111), S(180,165), S(121,192), S( 73,200),
S(119, 74), S(153,128), S( 94,155), S( 46,163),
S( 98, 27), S(132, 81), S( 73,108), S( 25,116),

Lyudmil, above are my latest king psqt values.

I initially introduced much more severe changes, but, looking at how everything that changes significantly SF code is doomed to fail, I decided to just somewhat change the values for the squares that I think need some changes.

In order to be specific: after observing many games, I changed the following squares:

- g1 down, h1 and h2 up; in a dynamic play, the g1 square is not that important, the king feels safe enough also on h1 and h2
- e1 down; SF sometimes seems to stay much too late in the mg on e1, without castling, and that occasionally creates problems
- f2 and e2 down; similarly, those are dangerous squares in the mg, where SF sometimes overstays
- all squares on the 4th rank a bit down; same here, those are dangerous squares, more dangerous than what SF thinks

Those are the mg values, because of which I made the changes.
As mg and eg values interact with interpolating, I also corrected a bit the respective eg values.

I would have like to do much more, but this time strictly the necessary.
:)

Wich significant changes, my piece values and rook psqt failed convincingly, although those were good changes. The problem is that, with all changes, when you change one parameter, you also influence a couple of related parameters, and therefore sweeping changes simply do not work.

I thought with very reasonable values they would work, but they do not.
Sf values for different terms have been tuned tens of times and even hundredths of times for specific parameters, so they are relatively well tuned to each other, although badly tuned in separation.

If you introduce sweeping changes to all parameters, and you know how they interact precisely, one can certainly add 500 elo to SF only based on good tuning, but the problem is that neither we humans, not autotuners are able to do that satisfactorily. So we must proceed with very minimal changes.

As we already started this thread, I wonder if you could, in case you happen to read this message, push one really last patch on king psqt, after that we can go on vacation. :)

I am certain that if you are not willing to push the patch, there will be no other volunteers.

In any case, we must do something to keep us busy, especially when life gets very boring around us.

PS. You might think that the last 2 patches were big failures, but no: I learned a lot from those patches.
Hi, Lyudmil!

I don't think that a patch coming from you is useless. The last patch convinced me that common sense cannot help in tuning as the right values are counter-intuitive. This is not surprising to me at all. Having a long experience in statistical optimisation, I have seen this happen all the time. With such a complicated mess of effects, and so many parameters, it won't be easy to find the right transformation matrix. (The essence of any optimisation is to make a linear transformation of the parameter matrix A in the form TAT', where T is the transformation matrix. This involves diagonalisation of A and finding the eigenvalues and eigenvectors. In the present case, we have 2 matrices to transform: the gradient, which is a 1-column matrix (vector) and the Hessian, which is a square matrix). SPSA is one of the methods to do this, though one has to be careful in choosing the test parameters. In this respect, SPSA tuning with parameters that make very small changes at each iteration arrive at a local optimum which has a chance to succeed but it will add 2 or 3 Elo instead of the possible 200-300.

PSQT tables are a sort of catch-all: they compensate for mistuned parameters elsewhere in SF. If all other parameters are ideally tuned, the optimal values in the PSQTs should be all zeroes, so the PSQTs will become superfluous. This is unlikely to happen in the foreseeable future. In order to make a proper tuning, all PSQTs should be tuned at once. Tuning PSQTs one by one is not going to be very rewarding. Especially rook PSQT is one of the most Elo-insensitive. The best candidates for individual PSQT tuning are king and knight PSQTs.

You are right to direct your attention to the king PSQT. Your reasons for changes are very sensible but, as we saw, PSQTs defy common sense. I have no objection to testing it though would prefer to do the testing locally before doing it on Fishtest to see the direction to move. For one thing, these gigantic values strike me as odd. The king is maybe the most tuned piece of all (king safety, etc.) while these large values show that the king is most mistuned of all. This is a contradiction that does not appeal. I will compare also with SPSA results for additional guidance.

I am not staying idle these days. I do local SPSA tuning trying to choose the best test parameters: those leading to the fastest convergence and a global optimum. Also, as I wrote above, I am adapting better tuning methods: ROCK* and RSPSA.
Thanks for reading and replying, Lyudmil.

Psqt is very important, I even think many more things could be done in psqt, for example, have precalculated long chain bonus.

SF psqt could be improved a lot, but difficult to do so.
Take this very same king psqt: many values, both for the mg and the eg, are strcitly illogical.
- central 4th and 5th ranks score higher penalty in the mg than 7th and 8th ranks, when in actual case it is much easier to mate the enemy king on its 8th rank
- 5th and 6th ranks in the eg get lower bonus than 4th rank, when in actual case it is precisely the opposite - the king is worth more when gaining space advantage in the eg

So, it is a bit of a mess in SF psqt, but it still works as reasonably tuned to the whole. Of course, if there was not that mess, you could tune it much better, but now we simply do not know how to do that, as too many parameters interact at the same time, one bad parameter correcting other bad parameter, etc.

I see it in the games, you can tune better many terms, but not easy to do.

That is one of the reasons Komodo scales better than SF - its terms are better tuned. They do not believe Bertil Eklund, but they should.

Lyudmil, please, do me this last favour, as we already started this thread, to push king psqt on fishtest. Of course, when you have the time, and have done your local tests. We should also probably wait for Lucas psqt to finish, so we are not in a hurry at all. :)

Sorry for bothering you again.
Many thanks for pushing all those patches!
Haikouichthys
Posts: 38
Joined: Sun Oct 06, 2013 6:16 am

Re: King psqt

Post by Haikouichthys »

I believe you're misinterpreting the PSQT. PSQT values are not penalties, but bonuses. So what you're seeing is that in the endgame, SF prefers to have its king centralized.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: King psqt

Post by Lyudmil Tsvetkov »

Haikouichthys wrote:I believe you're misinterpreting the PSQT. PSQT values are not penalties, but bonuses. So what you're seeing is that in the endgame, SF prefers to have its king centralized.
I am misinterpreting nothing.

Of course, they are bonuses, and not penalties.

Here is my corrected table, but I did not correct any ranks above 4.

S(303, 27), S(327, 81), S(270,108), S(220,116),
S(290, 74), S(321,128), S(260,155), S(210,165),
S(220,113), S(256,167), S(196,195), S(148,202),
S(192,135), S(226,193), S(167,219), S(119,228),
S(173,135), S(207,189), S(148,216), S(100,224),
S(146,111), S(180,165), S(121,192), S( 73,200),
S(119, 74), S(153,128), S( 94,155), S( 46,163),
S( 98, 27), S(132, 81), S( 73,108), S( 25,116),


As you see, SF prefers 4th rank in the mg to 8th rank, but king is mated easier not in the center, but on the 8th rank.

SF prefers 4th rank to 5th and 6th ranks in the eg, but 5th and 6th ranks are better for the king in the eg.

etc., etc.

So SF has it all wrong, but, when you tune 5 bad terms well, they produce a working unity, that is far from optimal, but difficult to correct, as you do not know what related terms interact and how you should change their values.

That is why I am already afraid to touch anything no matter how suspicious it looks: it seems that currently only small gradual steps are possible, both in tuning and in general knowledge implementation.