Announcing lczero

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

Moderators: hgm, Rebel, chrisw

gladius
Posts: 568
Joined: Tue Dec 12, 2006 10:10 am
Full name: Gary Linscott

Announcing lczero

Post by gladius »

https://github.com/glinscott/leela-chess

It's a port of GCP's Leela Zero (https://github.com/gcp/leela-zero) to chess. GCP and the community have really done a wonderful job on the project.

The goal of the project is a distributed training project for the network weights, hopefully building a strong chess AI from scratch. I haven't had time to set up the training server yet. It's getting close though :). If anyone wants to work on it as well, please let me know! It's exciting to see a totally different method of search/evaluation be competitive, and we need a public version of this.

Interestingly for chess, it appears that you need a really fast GPU to match the speed of evaluating the NN using the CPU! I get about 1,200 nodes/sec, running on 2 threads using CPU on my macbook pro. The GPU gives only 120 nodes/sec! My desktop with a Titan X gets about 2000 nodes/sec. This is also using a 5x64 net, instead of the AlphaZero 20x256 net, which would probably only be feasible on GPU.

There is incredibly basic UCI support (plays out a fixed 800 nodes) included.

Here is a game generated using the initial (completely random) weights:
[pgn]
1. b4 h5 2. h4 d5 3. Nh3 Nd7 4. Na3 Rh7 5. f4 e5 6. c4 exf4 7. Nf2 Ke7 8. cxd5 g5
9. Qc2 g4 10. Qb1 Kf6 11. Qe4 Qe8 12. e3 Qe6 13. Bc4 Be7 14. Ke2 Rb8 15. Qd4+ Ne5
16. Ne4+ Kg7 17. Rd1 Bxb4 18. Rg1 Bd6 19. Bb3 Qg6 20. Qa4 Qg5 21. Qc4 Bf5 22. Qd4
Be7 23. Qa4 Bf6 24. Qe8 Bd8 25. Qe7 Bxe7 26. d6 Re8 27. dxe7 Bg6 28. hxg5 g3 29. Nf6
Nxe7 30. Ng8 N7c6 31. Ne7 Nd8 32. Nxg6 R8h8 33. Ne7 Rf8 34. Ng6 R8h8 35. Ne7 Rf8
36. Ng6 R8h8
[/pgn]
User avatar
CMCanavessi
Posts: 1142
Joined: Thu Dec 28, 2017 4:06 pm
Location: Argentina

Re: Announcing lczero

Post by CMCanavessi »

Interesting!!
jd1
Posts: 269
Joined: Wed Oct 24, 2012 2:07 am

Re: Announcing lczero

Post by jd1 »

Very interesting project!
Joerg Oster
Posts: 950
Joined: Fri Mar 10, 2006 4:29 pm
Location: Germany
Full name: Jörg Oster

Re: Announcing lczero

Post by Joerg Oster »

gladius wrote:https://github.com/glinscott/leela-chess

It's a port of GCP's Leela Zero (https://github.com/gcp/leela-zero) to chess. GCP and the community have really done a wonderful job on the project.

The goal of the project is a distributed training project for the network weights, hopefully building a strong chess AI from scratch. I haven't had time to set up the training server yet. It's getting close though :). If anyone wants to work on it as well, please let me know! It's exciting to see a totally different method of search/evaluation be competitive, and we need a public version of this.
Wow! This looks like another great project!

I predict Fishtest will stall for a while once the distributed training will be online.
Jörg Oster
gladius
Posts: 568
Joined: Tue Dec 12, 2006 10:10 am
Full name: Gary Linscott

Re: Announcing lczero

Post by gladius »

Overnight, I did the first training run, which consists of generating self-play games with noise enabled, in this case only 160 games. Then, ran the tensorflow training script, which optimizes the net for those 160 games. This resulted in a new network, which I then pitted in a 100 game match against the old network.

The result was 31-3-66, or 100 ELO improvement. So it is proving that the network can learn, and the code is not too buggy!

There are a few things left to do before kicking off the distributed work. The positions are not sent to the network relative to the player to move, which is something AlphaZero did.
User avatar
CMCanavessi
Posts: 1142
Joined: Thu Dec 28, 2017 4:06 pm
Location: Argentina

Re: Announcing lczero

Post by CMCanavessi »

That is really awesome news! I'll follow this project closely.

I predict Fishtest will stall for a while once the distributed training will be online.
I predict that sooner or later Stockfish will have to change and adopt NN one way or another, and fishtest will be migrated to make Stockfish learn playing itself.
gladius
Posts: 568
Joined: Tue Dec 12, 2006 10:10 am
Full name: Gary Linscott

Re: Announcing lczero

Post by gladius »

A pretty amusing training game :).

[pgn]
1. f3 d5 2. b3 c6 3. d3 Qd6 4. Bh6 Qxh6 5. Nh3 Qe6 6. Kf2 Qf5 7. Kg3 h5 8. Nf2
h4# {Black mates} 0-1
[/pgn]
Jhoravi
Posts: 291
Joined: Wed May 08, 2013 6:49 am

Re: Announcing lczero

Post by Jhoravi »

Hi, Does the playing engine require GPU or just during training?
gladius
Posts: 568
Joined: Tue Dec 12, 2006 10:10 am
Full name: Gary Linscott

Re: Announcing lczero

Post by gladius »

Jhoravi wrote:Hi, Does the playing engine require GPU or just during training?
GPU is not required for playing games currently (although a fast GPU will be faster than a CPU).
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: Announcing lczero

Post by cdani »

Nice! Congratulations!