Step 4: The Leela Chess Zero Engine


Lc0, a distant descendant of Google's AlphaZero engine, is a different breed of engine than Stockfish in many ways. 
  • It is a GPU-based engine (vs. Stockfish's CPU base).
  • It is more difficult to compile because of the need to set up CUDA on your machine (I assume a NVIDIA GPU for this discussion).
  • Unlike Stockfish, the best version of the engine and the best neural net to use with it aren't necessarily the ones at its official github depository and its "best nets" site.
    • Development of the engine is primarily done by individuals on their own forks of the official github Lc0 source and/or their own training of neural nets. Often these are the most promising versions of Lc0, but extra work may be  required to update these forks so they can be compiled on your development stack.
  • You really need to follow the Lc0 Discord channel to get a sense of the most promising versions of Lc0 and the best neural nets to use with it. In the Discord sub-channels users contribute their own idiosyncratic test results comparing  different versions of the engine and different nets.
    • Often tantalizing reports of new nets are discussed, but the nets may not be available even if you ask.  The developers keep them private until they feel the nets have been fully trained and/or additional software has been written to allow Lc0 to handle nets of different sizes/architectures.

Promising Developments 

Lc0 is a very strong engine and - like Stockfish - it has gotten stronger over time.  There is the perennial hope that new developments and newly trained nets will one day close the gap with Stockfish. 

While this will change with time, right now interesting versions to watch are the "dag-update" branch of borg323's Lc0 fork, and, Daniel Monroe's "uncertainty-weighted" and "boosting" branches in his Lc0 github fork.  You will see test results for some of these branches on the Discord channel, at the TCEC computer competitions, on Chess.com's computer chess site, and at Navs "engine battle" Twitch channel.  To compile Daniel Monroe's versions, I had to make some updates to his code so that I could compile it on the most up to date version of gcc.

The best net to use at this moment is the T2-768x15x24h-swa-5230000 net available at the "best nets" site.  However, the best net to use changes several times a year as new neural nets are trained. BT3 is a new net architecture being developed that sounds promisin. However it's currently not available to anyone but the developers.

Using Lc0

If you have ninja-build, meson, and cuda set up on your computer, compiling Lc0 is straightforward. You just clone the git branch you're interested in and run ./build.sh in the branch directory. The executable Lc0 will be in lc0/build/release/ directory.  You should copy all of the files in that directory to a new directory you create outside of your git clone directory.  You can also copy your downloaded neural net that Lc0 will need to run into your new directory.

You can use the Lc0 engine in your Scid database GUI, adding it just like you would add Stockfish. However, there is another GUI called Nibbler that is every nice for doing analysis with Lc0.  At a glance it shows all of the alternatives Lc0 is exploring.



There is a simple one line statement for installing Nibbler in a Linux environment:

curl -L https://raw.githubusercontent.com/rooklift/nibbler/master/files/scripts/install.sh | bash

If you run Nibbler and it crashes quickly, its likely that your GPU architecture is such that you need to start nibbler with the command:

 ./nibbler --no-sandbox  

 You add the Lc0 engine to Nibbler by using the "Engine" tab and the "Choose Engine" sub-menu option. You can read more about Nibbler at its github page.


Comments

Popular Posts