How do NN's work with non-graphic intensive engines?

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

Moderator: Ras

Cornfed
Posts: 511
Joined: Sun Apr 26, 2020 11:40 pm
Full name: Brian D. Smith

How do NN's work with non-graphic intensive engines?

Post by Cornfed »

Quick question since I've not been able to find where anyone has 'dumbed it down' enough for a layman to understand:

For an engine (lets say Stockfish) that does not rely on an expensive GPU, how does a NN work? How does it aid the engine in finding moves? As I understand a NN good for primarily quite middlegames where neither side has an appreciable advantage according to an A/B engine.

Mainly....What is the process the engine goes thru when....lets say you sick it on a position that came up on maybe move 15 of a game you just played or that same position you have already looked at for your opening repertoire?
Dann Corbit
Posts: 12824
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: How do NN's work with non-graphic intensive engines?

Post by Dann Corbit »

The NN (using the GPU or using the CPU) is recognizing patterns. It is not doing any graphical work, in reality.

A giant network has a lot more work to do and the unbelievable compute power of a GPU is used to calculate the result with really large networks.
The problem with GPU computation is mostly due to moving the information from the computers's memory to the video memory (used by the graphic card) and then moving the calculated result back to computer memory from the video memory.
The GPU is not really doing graphical calculations. It is being used because it is really good at doing math.

A neural net on a CPU is doing exactly the same thing. It is recognizing beneficial patterns. However, the CPU is more than 1000 times less powerful than the GPU. So it must calculate with a much smaller network. But it has the benefit of direct access, because we do not have to copy anything back and forth from the computer RAM to the Video RAM.

So the calculations using the network are basically the same but the CPU cannot perform the same volume of math, and therefore it uses a smaller network. It still manages to be powerful because we do not have to read and write from video RAM and that delay is very costly. The video RAM reads are done over the PCIE bus.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
Cornfed
Posts: 511
Joined: Sun Apr 26, 2020 11:40 pm
Full name: Brian D. Smith

Re: How do NN's work with non-graphic intensive engines?

Post by Cornfed »

Dann Corbit wrote: Sun Sep 06, 2020 7:44 pm The NN (using the GPU or using the CPU) is recognizing patterns. It is not doing any graphical work, in reality.

A giant network has a lot more work to do and the unbelievable compute power of a GPU is used to calculate the result with really large networks.
The problem with GPU computation is mostly due to moving the information from the computers's memory to the video memory (used by the graphic card) and then moving the calculated result back to computer memory from the video memory.
The GPU is not really doing graphical calculations. It is being used because it is really good at doing math.

A neural net on a CPU is doing exactly the same thing. It is recognizing beneficial patterns. However, the CPU is more than 1000 times less powerful than the GPU. So it must calculate with a much smaller network. But it has the benefit of direct access, because we do not have to copy anything back and forth from the computer RAM to the Video RAM.

So the calculations using the network are basically the same but the CPU cannot perform the same volume of math, and therefore it uses a smaller network. It still manages to be powerful because we do not have to read and write from video RAM and that delay is very costly. The video RAM reads are done over the PCIE bus.
Thanks for the response and that is helpful.

But perhaps my question is a bit more basic: I have fire up SF NN at move 15 of a game. This is a position that is surely not in any existing NN - no position found in my Chessbase DB either. Just what happens? I guess that is what I am getting at.
syzygy
Posts: 5891
Joined: Tue Feb 28, 2012 11:56 pm

Re: How do NN's work with non-graphic intensive engines?

Post by syzygy »

Cornfed wrote: Sun Sep 06, 2020 7:26 pm Quick question since I've not been able to find where anyone has 'dumbed it down' enough for a layman to understand:

For an engine (lets say Stockfish) that does not rely on an expensive GPU, how does a NN work? How does it aid the engine in finding moves? As I understand a NN good for primarily quite middlegames where neither side has an appreciable advantage according to an A/B engine.
Stockfish with NNUE is just as much an alpha-beta engine as it was.

In Stockfish, the NN just produces an evaluation score.

Mainly....What is the process the engine goes thru when....lets say you sick it on a position that came up on maybe move 15 of a game you just played or that same position you have already looked at for your opening repertoire?
The NN is not learning while the engine is playing. The NN is trained offline. In SF's case, it is fed a billion positions with desired evaluations.
syzygy
Posts: 5891
Joined: Tue Feb 28, 2012 11:56 pm

Re: How do NN's work with non-graphic intensive engines?

Post by syzygy »

Cornfed wrote: Sun Sep 06, 2020 8:04 pmBut perhaps my question is a bit more basic: I have fire up SF NN at move 15 of a game. This is a position that is surely not in any existing NN - no position found in my Chessbase DB either. Just what happens? I guess that is what I am getting at.
The NN is not a database of positions.

A good explanation of how SF's NN works is written up here:
https://www.chessprogramming.org/Stockfish_NNUE
Image

(Not really important for this discussion, but the "bonanza" explanation is a bit weird. The extra "+1" is simply not used and could be removed to make the network file a bit smaller.)
Dann Corbit
Posts: 12824
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: How do NN's work with non-graphic intensive engines?

Post by Dann Corbit »

Cornfed wrote: Sun Sep 06, 2020 8:04 pm But perhaps my question is a bit more basic: I have fire up SF NN at move 15 of a game. This is a position that is surely not in any existing NN - no position found in my Chessbase DB either. Just what happens? I guess that is what I am getting at.
Ronald's explanation in excellent.
In more basic terms, the patterns recognized are the sort of things we recognize.
"If I control the center that is good."
"If my pawns are connected diagonally to form a chain they are harder to attack"
"If I have more than one bishop, it is good."
"If I put a rook on an open file, that is good"
"If there is a lot of space behind my pawns so that the enemy is cramped, that is good"
"If I undermine somthing guarding a big piece, it can result in something good..."
etc, etc.

They are not recognizing board positions. Recognizing board positions is simply not a feasible way to learn. The number of board positions is so enormous, at move 15 your are almost certain to be playing something that has never been played before. This explains your puzzling.

The neural net is learning structures and patterns that lead to wins, but not individual positions.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.