
Chess-playing neural network LC0 beats Stockfish in 100-game match - bonzini
https://tcec.chessdom.com/#
======
ganeshkrishnan
It's really amazing and impressive what LC0 has achieved with almost no money
and only community pooled training matches. They were struggling to pay $600
per month for the cloud server so have a baremetal server.

Pretty sure it can beat AlphaZero at this point of time.

~~~
mda
Pretty sure Alpha zero would destroy Leela.

~~~
ganeshkrishnan
No, I don't think so. Remember that AlphaZero played stockfish 8 which is
pretty outdated. Some of it's moves against SF was pretty amazing and you
could be right but everything is speculative right now.

My only vote for LC0 is that it can win against the latest iteration of SF

~~~
sanxiyn
Stockfish 8 evaluation was in 2017. In 2018, DeepMind re-did everything with
Stockfish 9 and nothing changed.

[https://deepmind.com/blog/alphazero-shedding-new-light-
grand...](https://deepmind.com/blog/alphazero-shedding-new-light-grand-games-
chess-shogi-and-go/)

------
dragontamer
LC0 and AlphaZero work on the following principles:

* GPU-based compute -- Deep Learning scales very well on GPUs, which are known to have superior parallelism over CPUs.

* MCTS -- "Monte Carlo Tree Search", which is a different tree-search compared to Minimax. MCTS seems closer to "human-like play", with regards to search order.

IMO, it is inelegant to use CNNs / neural nets as the evaluation layer.
However, its difficult to imagine an evaluation function that would scale to
GPUs. I'm curious how to use the SIMD-compute model to evaluate chess
positions, but it doesn't seem like very much research exists on the subject.

GPUs have significantly higher compute power than CPUs. Chess positions can
largely be represented by just a few 64-bit integers (!!). (An 8x8 bitboard is
64-bits, one bitboard per piece). So the compute-density of chess-evaluation
is very very high, there just aren't any algorithms that are well suited to
the GPU-architecture aside from deep learning right now.

\-------

I really think MCTS is the superior search tree algorithm. The only issue is
the evaluation function. Its certainly cool that Deep Learning / CNNs are
being used as a "universal" GPU-function (self-learn / self-train so that a
large CNN can "deeply" use a ton of GPU resources to make up its own
evaluation function). But as far as I'm concerned, its a crutch.

\----------

EDIT: If I had oceans of free time... I'd love to see what "translating"
Stockfish's algorithms (ex: backwards pawn check. Bishop moves check. Paired
Bishop advantage check. Etc. etc.) to a GPU would be like.

A GPU probably could evaluate a million boards for "backwards pawns". Then
evaluate the million boards for "paired bishops". Then evaluate the million
boards for "knight outpost". Etc. etc. In effect: calculate the millions of
positions in parallel, by lining them up and batching them together.

Stockfish's parallelism is CPU-based, with lots of if-statements. Batching
these checks into individual units would remove the if-statements and
potentially make it amendable to SIMD-compute.

The tree-evaluation would try to evaluate ~1-million boards at a time, to keep
the GPU busy. Maybe ~1-million boards per CPU-thread (somehow self-tuning the
evaluation process for an optimal mix of CPU + GPU time used).

Again: if I had mountains of free time, lol.

~~~
stuartriffle
I’m working on a brute force MCTS engine right now. It scales across SIMD (to
8x) and GPU (only CUDA so far).

[https://github.com/StuartRiffle/Jaglavak](https://github.com/StuartRiffle/Jaglavak)

My GTX 780 can play about 1M games to completion per sec. Still under
construction, but any advice is appreciated!

~~~
dragontamer
I finished groking the CUDA stuff, looks good in general!

For those who want an overview: stuartriffle follows the MCTS algorithm, which
has two parts. The MCTS is the general C++ code "TreeSearch" (which I haven't
grok'd yet. The textbook UCT evaluation function is there, but there's some
async stuff going on that I don't understand yet). For the evaluation function
/ heuristic, its a classic random-rollout code, which randomly plays Chess
until it discovers a win, loss, or "draw" (which seems to be a "max moves ==
0" case).

"Random Rollout" is the most naive implementation of MCTS, but its still an
important demonstration showing that GPUs can indeed play chess within its
shaders. The engine as a whole seems free of any obvious GPU-divergence
issues, so I'd expect it to be reasonably efficient at random chess playing.

So chess engines CAN be ported to a GPU. From here on out, its a matter of
experimenting with various methodologies to see what creates the most powerful
chess player.

\--------

I'm going to have to go through the MCTS part later. Its clearly some kind of
parallel implementation that batches up nodes for MCTS evaluation.

The GPU probably can run some of the MCTS stuff faster than the CPU (ex: the
UCT evaluation probably should be on the GPU: which could be done relatively
easily by passing play-statistics to the GPU kernel. GPUs are very fast at
square-roots and stuff, and you're already spinning up a GPU thread for the
whole random-rollout thing, might as well evaluate the UCT value while you're
still in GPU land. I think anyway)

But yeah, I haven't fully understood how you're doing the MCTS stuff yet. Its
definitely interesting code though.

\----------

EDIT: I'd personally want to figure out how to get the MCTS search into the
GPU somehow. But doing the rollouts on the GPU is the "obvious" first step (at
a minimum, you need to have a chess engine in the GPU before any further steps
are possible), and its cool that you found a practical use of the random-play
engine with the classic MCTS algorithm.

------
mrob
FIDE Candidate Master Kingscrusher (Tryfon Gavriel) has been posting analysis
videos for some of these games on Youtube. LC0's win as black against the
Trompowsky Attack was particularly impressive:

[https://www.youtube.com/watch?v=rz51_wFgNrQ](https://www.youtube.com/watch?v=rz51_wFgNrQ)

~~~
ganeshkrishnan
I have been following kingscrusher for years and I never knew his real name.

------
symplee
Official website: [http://lczero.org/](http://lczero.org/)

GitHub:
[https://github.com/LeelaChessZero/](https://github.com/LeelaChessZero/)

Still a very active community project.

Didn't see the link posted here in the comments yet, definitely worth checking
out. Most of the devs and serious contributors are active in the discord
channel.

------
joe_the_user
I cannot figure out what exactly is happening from the site. I see a table
showing "Gull 3" (presumably using the LC0 enginer) with five wins and few
other engines with 1-2 losses.

I can't see draws on the table. A lot of engines show no wins or losses.

All this matters somewhat considering that there was talk in AlphaZero match
about whether the win percentage was realistic and whether the Stockfish was
given it's full opening book. The thing is by the time you're 3000+ elo
points, chess tends to be pretty drawish. One program might better than
another but it can take while to get anything a draw.

~~~
bwasti
I think that link expired and now shows the wrong games. Here's a link to the
final game between LC0 and Stockfish
[https://cd.tcecbeta.club/archive.html?season=15&div=sf&game=...](https://cd.tcecbeta.club/archive.html?season=15&div=sf&game=100)

------
ngcc_hk
Some of the discussion seems forget that the lc0 use neural network. There is
essential no logic and there is no mtcs in the core part. Just play.

And it is called zero ad it does not read any human game, like alpha go zero.

It is just play and play to train the neural network ... you may say it want
to find a function by itself that play the game. And the function is in the
weights.

------
mindgam3
Anyone have a direct link to the games? Current article link goes a generic
TCEC landing page.

~~~
wces
100 games:
[https://cd.tcecbeta.club/archive.html?season=15&div=sf&game=...](https://cd.tcecbeta.club/archive.html?season=15&div=sf&game=1)

~~~
mindgam3
Thanks!

------
tim333
Anyone know how the LC0 vs Stockfish hardware compares? I believe a criticism
of the Stockfish vs AlphaZero games was that AlphaZero had fancier hardware.

~~~
mot524
I believe LC0 was being run on dual RTX 2080 Tis and Stockfish was being run
on "43 cores" which I take to mean a workstation with dual Intel 22-core
processors. So you're talking about two $1200 graphics cards vs. two $3000+
CPUs. So you could make an argument that LC0 was running on inferior hardware,
at least dollar-wise.

------
bonzini
53-46, one game to go

~~~
Someone
Last one is a draw. Weird ending, with one of them refusing to take a pawn
because the resulting end game is in a table base and is 100% known to be a
draw, and the computer evaluates the position where it doesn’t take the pawn
as a 0.x% win and a 99.y% draw.

~~~
umanwizard
[https://cd.tcecbeta.club/archive.html?season=15&div=sf&game=...](https://cd.tcecbeta.club/archive.html?season=15&div=sf&game=100)

Weird indeed. Can anyone explain why LC0 thought it had a chance? It seems
obvious (thinking like a human) that white can't make progress: it can't move
its rook off the h file without losing the pawn, and it can't promote its pawn
without moving its rook. And it can't bring its king up to help the h-pawn
without letting black's pawn promote.

LC0 evaluates the final position at 0.04, which I guess is close enough to 0
for it to agree to a draw, but I wonder why Stockfish is able to see that it's
truly 0.00 and LC0 isn't.

~~~
Someone
_”it can 't move its rook off the h file without losing the pawn”_

Nitpick: I agree there’s nothing for white in that position, rook a6, b6 or c6
seem possible moves in the end position (if black takes the pawn, the rook
gives chess on row 5 and takes black’s rook in the next move). From there, it
could move the rook to row 5 to defend the pawn. If so, the rook can get away
from the h file.

Also, if black’s king were to walk towards the black pawn, the rook has to
move from the h file to give chess.

In general, LC0 seems to be way more optimistic in its scoring function than
Stockfish. As an extreme, look at game 70. Stockfish sees it as a 100.0% draw
after move 49, but play goes on until move 202 (!), with LC0 at some stage
thinking it has a 25% chance at winning (around move 106)

~~~
umanwizard
RE your nitpick: Fair point. I hadn’t seen the pinning tactic after 140. Ra6
Rxh5??? 141. Ra5+

As is probably obvious from that oversight, I am not a very strong player.

However, I still see no way for white to make progress. After 140. Ra6, black
just walks its king towards the white pawn. White’s only options then are to
give perpetual check with the rook, or to give up the pawn.

It’s plausible to me why lc0 _doesnt_ see this — I guess it is just searching
down random paths involving useless rook moves forever, and never gets to the
end of the tree. I’m more curious about how Stockfish _is_ able to prove it’s
a draw.

Edit: after poking around the Stockfish code a bit, I _think_ what's going on
is that Stockfish sees that down every non-pruned path of the tree, either
player has the ability to give check, so neither player can be ahead
(basically each side has a perpetural check). Would love if any Stockfish
expert reading this can comment on whether that's a valid understanding.

