Some newbie questions about lc0

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
phhnguyen
Posts: 1434
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Some newbie questions about lc0

Post by phhnguyen »

I’m new to lc0: just downloaded, took a look, read around, compiled it for my iMac then run training/contributing for a while. My purpose is to learn for fun then check possibilities to add some chess variants to lc0. I think it’s better to ask some (probably silly) questions here before diving deeply into a new world.

1. I see lc0 uses bitboards as board representation. What the benefits over using mailbox ones? In other words what difficulties if I change it to use mailboxes? What exactly lc0 needs from chess? Move list? All bitboard data?

2. Beside board representation, I know chess has some problems dealing with move history which is not easy to integrate to board representation such as 50-move draw, 3 fold repetition. How lc0 deals and solves those problems? Does it integrate that knowledge (50-moves, 3 folder draws) to training sets?

3. For training, what the benefit of having stronger graphics cards compared to weaker ones? I ask this question since the graphics card of my iMac is not a strong one, however, I see the training is faster than I expected. Are games training using a timer (so the quality will be reduced for slow cards I guess)?

4. I see there are so many networks, what’s the purpose of creating/training so many? Should we stick to one or very few only?

5. When the training of a network will complete?

6. When can lc0 stop training?

7. Has anyone tried to add chess variants to lc0?

Thanks
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager
brianr
Posts: 536
Joined: Thu Mar 09, 2006 3:01 pm

Re: Some newbie questions about lc0

Post by brianr »

Here is perhaps not the best place to ask about Lc0.
You may already know about the wiki as you compiled Lc0.
https://github.com/LeelaChessZero/lc0/wiki is a good source of info

There is also a Forum here
https://groups.google.com/forum/#!forum/lczero

and the #help channel here (which is the most active place)
https://discordapp.com/channels/4254194 ... 1627966466

In the #bot-spam channel if you type the command !papers you will see a list of research papers including the Alpha Zero ones which describe things in much more detail.

Bitboards are fed to the net sort of like images and the net outputs preferred moves and such.

50 move and other info is input the the nets, along with the last 8 ply of positions, which helps somewhat with 3-reps, although this area could be improved.

You are likely providing self-play games, which is sometimes referred to as training.
There is a more formal training of new nets that is done from batches of about a million of these games.
The self-play games only look at a relatively small number of positions each move are are done pretty quickly.
However, a strong graphics card is very important to making even a minimal contribution.
For the larger nets (current T60 run 1), an RTX 2060 would be a good starting point.

Each new network that is trained is tested to try and avoid gross regressions and then new nets are trained from there in an incremental fashion. Look at the History part of the wiki to get some idea of the various generations of nets. It has been about 18 months so far, and there seems to be no end in sight.

I think some folks have already started on Chess 960 or are at least talking about it.
brianr
Posts: 536
Joined: Thu Mar 09, 2006 3:01 pm

Re: Some newbie questions about lc0

Post by brianr »

!papers
LeelaBotBOTToday at 12:43 PM
A general reinforcement learning algorithm that masters chess, shogi and Go through self-play:
https://deepmind.com/documents/260/alph ... eprint.pdf
Mastering the game of Go with Deep Neural Networks & Tree Search:
https://deepmind.com/research/publicati ... ee-search/
Mastering the game of Go without Human Knowledge:
https://deepmind.com/research/publicati ... knowledge/
Mastering Chess and Shogi by Self-Play with a General Reinforcement Learning Algorithm:
https://arxiv.org/abs/1712.01815
Efficient selectivity and backup operators in Monte-Carlo tree search:
http://citeseerx.ist.psu.edu/viewdoc/su ... .1.81.6817
Bandit based Monte-Carlo Planning:
http://citeseerx.ist.psu.edu/viewdoc/su ... 1.102.1296
Train longer, generalize better: closing the generalization gap in large batch training of neural networks:
https://arxiv.org/abs/1705.08741
Squeeze-and-Excitation Networks:
https://arxiv.org/abs/1709.01507

This book is worthwhile also:
https://www.amazon.com/Deep-Learning-Ga ... 1617295329
User avatar
phhnguyen
Posts: 1434
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: Some newbie questions about lc0

Post by phhnguyen »

Thanks for replies and info.
brianr wrote: Sun Aug 25, 2019 6:39 pm Bitboards are fed to the net sort of like images and the net outputs preferred moves and such.
Got it!

According to Chessprogramming (CPW), lc0 uses 5 bitboards, equal 5 x 8 = 40 bytes. Thus the input of lc0 is at least those 40 bytes, is it correct?

If I use a mailbox board and 4 bits per square, the input may be reduced to 32 bytes. Is better or worse? Could it help?
brianr wrote: Sun Aug 25, 2019 6:39 pm 50 move and other info is input the the nets, along with the last 8 ply of positions, which helps somewhat with 3-reps, although this area could be improved.
It means the history length and repetition status (for 50 moves and 3-fold) will be encoded as few more extra bytes for input, doesn't it?
brianr wrote: Sun Aug 25, 2019 6:39 pm However, a strong graphics card is very important to making even a minimal contribution.
Does it mean if my graphics card is good enough to start donating, a better and/or extra cards won't help more?
brianr wrote: Sun Aug 25, 2019 6:39 pm The self-play games only look at a relatively small number of positions each move are are done pretty quickly.
I am curious what happens if, say, my computer and my friend computer have the same configurations, do they create similar self-play games (so one becomes redundant)?
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager
brianr
Posts: 536
Joined: Thu Mar 09, 2006 3:01 pm

Re: Some newbie questions about lc0

Post by brianr »

The input size is not a major factor and bitmaps are needed to approximate an "image" of the board for the nets to learn to generalize from, so mailbox might not work at all. The Alpha Zero paper explains it in detail. It is something like 14 bitmaps of 8x8 for 8 ply plus some for castling and such for a total of 119 bitmaps of 8x8.

You can certainly add a "good" gpu card and use that one for Lc0 and your other for your monitor and whatever else, if you have room to install more than one card. Keep in mind that the gpu for Lc0 will get quite warm so provide for good cooling. Some people run several strong gpus in the same PC too. Configurations are only really limited by your budget. The "best buy" is an RTX 2060 which can be had on sale for about $300.

The games are intentionally somewhat random, so you could run many instances of the client on separate PCs or even on one very powerful one and all of the games will be used.
User avatar
phhnguyen
Posts: 1434
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: Some newbie questions about lc0

Post by phhnguyen »

Thanks a lot for very useful information. I can jump quickly to what I need.
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager
jp
Posts: 1470
Joined: Mon Apr 23, 2018 7:54 am

Re: Some newbie questions about lc0

Post by jp »

phhnguyen wrote: Mon Aug 26, 2019 2:28 am I am curious what happens if, say, my computer and my friend computer have the same configurations, do they create similar self-play games (so one becomes redundant)?
Not for the training games. They add noise (temperature) to generate those, so they'll be different.
User avatar
phhnguyen
Posts: 1434
Joined: Wed Apr 21, 2010 4:58 am
Location: Australia
Full name: Nguyen Hong Pham

Re: Some newbie questions about lc0

Post by phhnguyen »

Few more questions which I cannot find out answers from lz0 forum, all about limiting graphics cards:

1) Is there any option/way to reduce graphics computing power for lz0? I am looking something similar to option Threads for cpu. On my computer, an iMac, lz0 running makes the whole system be laggy. It uses very little cpu computer but almost 100% gpu.

2) I plan to buy a new graphics card (probably RTX 2060 as Brian's suggestion) to plug it into my son's computer as a secondary one, mostly for lz0 only. How can I set lz0 to play on that card only but not the first one (I don't want to affect my son's work too much)?
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager
brianr
Posts: 536
Joined: Thu Mar 09, 2006 3:01 pm

Re: Some newbie questions about lc0

Post by brianr »

I am not aware of a good way to limit gpu use with Lc0, other than to have another gpu card.

If you have more than one, see here:
https://blog.lczero.org/2019/04/backend ... ation.html