Booot progress

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

booot
Posts: 82
Joined: Sun Jul 03, 2016 10:29 pm

Re: Booot progress

Post by booot »

Second stage done!

Simple input-featured Keras model with the same NN structure of hidden layers is built, trained,quantized and measured.

I took "Circle" function f(x,y)=20*(sqrt(X)-sqrt(Y)) to train NN. X and Y are in range (0..1023) integer (10 digits of binary code each). This function gives result in range (-640,640) - quite similar as chess evaluation function does. I generated 1M train data easy with input featured layer [:,20].
I spent a good time to train - quantize - evaluate the model and finally my game with it ends with final score 1:1. I received working train code and clear understanding what quantization exactly does in NN, model received the last layer (last neuron weights) int16 instead of int8. So my NN structure will have final view:
1 layer (input feature layer) - int16 weights
2-3 2 hidden layers - int8 weights
4 output layer - int16 weights

Int16 weights in the last layer cost nothing in terms of NN probing code speed but helps much to train model efficiently.

Quantized model was brought to Delphi and showed exactly the same results with python! So my SIMD code in Delphi with AVX512 and AVX2 support works fine and ready for future chess evaluating function.

I was surprised to see how exact the quantized model is!
For example : after 2 epochs of training the float32 Keras model shoed average 'mae' metric (mean absolute error) -1,19
Correponding quantized model in Delphi shoed the same metric on level 1,97. More then promising as for me!
User avatar
lithander
Posts: 880
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Booot progress

Post by lithander »

When you say Delphi do you really mean that oldschool pascal-like programming language? I loved that back in the day but after Borland sold it seems to have lost all practical relevance. Why are you using it to build your chess engine? Because you like it personally or are there some distinct advantages I'm not aware of?
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
booot
Posts: 82
Joined: Sun Jul 03, 2016 10:29 pm

Re: Booot progress

Post by booot »

Yes - i write in pascal. There is only language i know well to write an engine.
User avatar
lithander
Posts: 880
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: Booot progress

Post by lithander »

booot wrote: Sat May 15, 2021 2:57 pm Yes - i write in pascal. There is only language i know well to write an engine.
Makes the CCRL Rating even more impressive. Really awesome to hear that good old Delphi is on par with C/C++ there! :thumbsup:
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess
User avatar
Steve Maughan
Posts: 1221
Joined: Wed Mar 08, 2006 8:28 pm
Location: Florida, USA

Re: Booot progress

Post by Steve Maughan »

Delphi is doing quite well. It can now target Win32, Win64, MacOS, iOS, Android and Linux. There are even third-party frameworks that target the web. Even after 26 years, there really isn't anything better for creating Windows applications. And while my chess engine is written in C, I use Delphi daily. Here's a link to my mapping application written entirely in Delphi:

https://www.alignmix.com

When it comes to speed the Delphi EXEs are definitely slower than the best C EXEs — I'd estimate 30% slower. Which makes Booot's strength even more impressive. The Delphi roadmap shows that the compiler may get some speed related improvement in the next update (10.5) — fingers crossed.

Steve
lithander wrote: Sat May 15, 2021 2:09 pm When you say Delphi do you really mean that oldschool pascal-like programming language? I loved that back in the day but after Borland sold it seems to have lost all practical relevance. Why are you using it to build your chess engine? Because you like it personally or are there some distinct advantages I'm not aware of?
http://www.chessprogramming.net - Maverick Chess Engine
booot
Posts: 82
Joined: Sun Jul 03, 2016 10:29 pm

Re: Booot progress

Post by booot »

Yes, Steve! Delphi is not so bad as it sounds :-). And if i will be able to pass all the way to NN eval with SIMD - Booot would be as fast as other C engines : SIMD works the same anywhere!
booot
Posts: 82
Joined: Sun Jul 03, 2016 10:29 pm

Re: Booot progress

Post by booot »

SSSE3 and SS2 support added to Delphi for future NN forward pass. Now everything is ready for the next stage : 'Booot's move'. After some pause i will start to write a procedure , generating zillions of positions, evaluated by Booot. I still do not know exactly what will be my feature schema but i still have some time to think about it.
User avatar
Kotlov
Posts: 266
Joined: Fri Jul 10, 2015 9:23 pm
Location: Russia

Re: Booot progress

Post by Kotlov »

booot wrote: Mon May 17, 2021 4:15 pm Yes, Steve! Delphi is not so bad as it sounds :-). And if i will be able to pass all the way to NN eval with SIMD - Booot would be as fast as other C engines : SIMD works the same anywhere!
Мне кажется Делфи (Паскаль) слишком высокоуровневый язык для таких, зависимых от быстродействия, проектов как шахматные движки.
Я сам когда-то начинал с Паскаля... но рано или поздно перешел к парадигме мультиязычности в программировании. Поверьте, это не так сложно как кажется, нужно просто сделать первый шаг.
Eugene Kotlov
Hedgehog 2.1 64-bit coming soon...
booot
Posts: 82
Joined: Sun Jul 03, 2016 10:29 pm

Re: Booot progress

Post by booot »

Наверное. Но у меня нет мотивации изучать С - я не программист. Я могу поиграться для себя в нейросети попутно выучив пайтон с фреймворками, но вот целенаправленно учить язык чтобы написать движок... Нет. С другой стороны : я уже реализовал SIMD - они будут в будущем основное время процессора занимать. И им все равно откуда их вызвали.
booot
Posts: 82
Joined: Sun Jul 03, 2016 10:29 pm

Re: Booot progress

Post by booot »

Next stage done!
I wrote self-play FEN generator in Booot. I made reasonably simpler generation method just to continue the whole process. Some details:
1. Booot saves search score (uses Eval function) for each FEN after 6 ply Search.
2. Each game has random number (4-6) of random moves.
3. I try store only quiet positions : not under check, best move = quiet move, small difference between static evaluation and search evaluation.
4. Simple algorithm to avoid FEN doubles.

Booot is slow engine, so generation speed does not make me happy : on 20 cores it gives me about 8-10 Millions Fens per hour. So i need to wait so looooooong to reach 1Billion training set. I still have time to think about configuration of my input feature NN layer.