Beating Fairy-Max 4.8

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: Beating Fairy-Max 4.8

Post by JoshPettus »

hgm wrote:
Henk wrote:Do you think you could write a super simple engine that beats Fairy-Max easily ?
I got a bit carried away by this question. (I know, unwise...) So last week I spent writing a new engine for orthodox Chess, as a response to this challenge (and to relieve the 'after-ICGA blues). I started on Sunday night, got a bit carried away
You sir are my hero! :lol:
Dann Corbit
Posts: 12541
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: Beating Fairy-Max 4.8

Post by Dann Corbit »

If you are doing matrix multiplications, perhaps you can benefit from a GPU card as a coprocessor.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Beating Fairy-Max 4.8

Post by Henk »

matthewlai wrote:
Henk wrote:Do you think you could write a super simple engine that beats Fairy-Max easily ?


Nodes per second of Fairy-Max is at least five times more than Skipper2.

Skipper uses killer moves and non captures are sorted. Also King safety is more complicated.

At this moment Skipper searches two plies less deep than Fairy-Max. For instance it doesn't reduce depth at all when in check.
Giraffe can beat Fairy-Max pretty easily

Code: Select all

Rank Name                   Elo    +    - games score oppo. draws 
   1 Giraffe 63f71c3eb204   101   60   52    38   75%  -101    3% 
   2 Fairy-Max 4.8S        -101   52   60    38   25%   101    3% 
It also searches at about 1/5 the speed of Fairy-Max. However, it does have a world-class evaluation function.

Also, that means Skipper is searching at the same speed as Giraffe... which means there is something seriously wrong with Skipper performance-wise. Giraffe does a deep neural network evaluation for each position, which involves multiple large matrix-vector multiplications.

You should definitely find a profiler (several have been suggested in this thread) and see what Skipper is spending all its time on. Also, remember to turn on compiler optimizations.
If you have a slow evaluation function you cannot use it on the leaves or maybe only on the first leave. Searching deeper is perhaps always better.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Beating Fairy-Max 4.8

Post by Henk »

I tried to use a profiler one year ago. Result was that my system crashed. So it did not work for my C#.NET code.

Just installed VerySleepy but it probably only works for C++ code for it doesn't display any useful information. It only reports statistics about threads not code. Otherwise I don't know how to use it.

I don't want to use the free visual studio community version for I don't want to develop open source.

Probably bottleneck is qSearch what else could it be.
matthewlai
Posts: 793
Joined: Sun Aug 03, 2014 4:48 am
Location: London, UK

Re: Beating Fairy-Max 4.8

Post by matthewlai »

Dann Corbit wrote:If you are doing matrix multiplications, perhaps you can benefit from a GPU card as a coprocessor.
I actually do have GPU support implemented. It helps a bit with training but not for playing.

The reason is that matrix-matrix multiplications (used in training) is compute-bound, while on modern computers, matrix-vector multiplications (used in playing) are memory-bound. The matrices are also not quite big enough to cover up PCI-E latency. Most experiments showed that GPU only beats an optimized CPU implementation for matrices larger than 1000x1000 or so. I am only using ~300x300.
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.
matthewlai
Posts: 793
Joined: Sun Aug 03, 2014 4:48 am
Location: London, UK

Re: Beating Fairy-Max 4.8

Post by matthewlai »

Henk wrote:I tried to use a profiler one year ago. Result was that my system crashed. So it did not work for my C#.NET code.

Just installed VerySleepy but it probably only works for C++ code for it doesn't display any useful information. It only reports statistics about threads not code. Otherwise I don't know how to use it.

I don't want to use the free visual studio community version for I don't want to develop open source.

Probably bottleneck is qSearch what else could it be.
Ah yes, if you use C# your options are much more limited. Most people write high performance applications in C/C++.

VS Community Edition doesn't need you to open source your code. It can be used by an individual (instead of a team) for any purpose.
https://www.visualstudio.com/support/legal/dn877550
Individual license. If you are an individual working on your own applications to sell or for any other purpose, you may use the software to develop and test those applications.
It may or may not be qSearch. Programmers are very bad at guessing where bottlenecks are. There's good possibility that it will turn out to be somewhere you never thought about.
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Beating Fairy-Max 4.8

Post by Henk »

I found a profiler which seems to work. It is called SlimTune. For instance it says evaluation is a bottleneck. Passed pawns evaluation and checking if rook on open file. Don't know yet if I interpret the results right.
matthewlai
Posts: 793
Joined: Sun Aug 03, 2014 4:48 am
Location: London, UK

Re: Beating Fairy-Max 4.8

Post by matthewlai »

Henk wrote:I found a profiler which seems to work. It is called SlimTune. For instance it says evaluation is a bottleneck. Passed pawns evaluation and checking if rook on open file. Don't know yet if I interpret the results right.
That sounds plausible. If that's the case pawn hash may help.

For rook on open file, this is why bitboards are great. Passed pawn evaluations are also much faster with bitboards.
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Beating Fairy-Max 4.8

Post by Henk »

Seems that using iterator and visitor design patterns also do no good to performance. Even garbage collect slows it down. I use visitors in evaluation to visit pieces and get their value. I knew it was slow but did not care.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Beating Fairy-Max 4.8

Post by Henk »

Looks like you have to adopt a 70's style programming and language to get a real high node count.