will Tcec allow Stockfish with a Leela net to play?

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

Moderator: Ras

User avatar
xr_a_y
Posts: 1872
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: will Tcec allow Stockfish with a Leela net to play?

Post by xr_a_y »

connor_mcmonigle wrote: Fri Jun 18, 2021 12:08 am
kranium wrote: Thu Jun 17, 2021 9:22 pm ...

The only thing that looks like a 'statement' is
Houdini "DQ'd for covertly containing copied code"

certainly doesn't explain much, but it's pretty clear what happened, and is continuing to happen today
not-so-subtle innuendo against Komodo, rage against FF, Fire, and others
enormous outrage, criticism, and pressure on the testers
etc

Apparently it's down to Ethereal, SF, and Seer! and Komodo listed as a (suspicious/maybe)

Mahem should be freed from this unreasonable oppression!
Test Mayhem now! :D
Hopefully, reconnecting this to the original discussion:

You're misinterpreting/misrepresenting Andrew's list. Ethereal, Stockfish (prior to training on Lc0 data), Seer and Komodo are all engines which have NNUE inspired evaluation functions which don't rely (or are unlikely to rely - in the case of Komodo - ) on any code directly copied from another engine for inference, training, data generation (self play, etc.) and all other components of the training pipeline. Whether or not this matters at all is pretty subjective, to be fair.



Here's an overview of how engines relying on NNUE based evaluation functions currently compare (feel free to correct the below descriptions if there are any inaccuracies):

Stockfish:
- Training: nnue-pytorch project (https://github.com/glinscott/nnue-pytorch) developed primarily by Sopel, Gary and Vondele, written in Python and using the PyTorch library. Early Stockfish networks (such as those trained by Sergio Vieri) relied upon C++ training code initially written for computer Shogi and adapted to chess by Nodchip.

- Inference: initially contributed to Stockfish by Nodchip and used ubiquitously in modern Shogi engines largely relying on Stockfish's search code. The inference speed and flexibility of the code has been notably improved by Sopel and others.

- Architecture: A variant of the original architecture with tweaked input features (HalfKA-V2) and some other tweaks (notable is the addition of a skip connection from the input features to the output enabling piece values to be more explicitly learned).

- Data Generation: Initially, Stockfish's training data was generated by heavily modified computer Shogi derived code for generating self play games ("gensfen"). The initial labels for the self play positions were supplied by a mixture of Stockfish's classical evaluation function (later the bootstrapped NNUE evaluation function) and the self play game outcome. The latest Stockfish networks are trained on data derived from the Lc0 project.



Komodo Dragon:
- Training: Unknown, though possibly originating from some modification to the nnue-pytorch project, the original NNUE training code ported by Nodchip or something all original. It has been stated that the architecture differs somewhat, necessitating some modification irrespective of its origin.

- Inference: Original. It has been mentioned (speculated?) that not all the layers are quantized and the quantization scheme differs somewhat as compared to Stockfish and those engines relying upon inference code derived from Stockfish.

- Architecture: The first layer is known to be a 128x2 feature transformer (as compared to the 2x256 feature transformer initially used in Stockfish and pretty much exclusively used in engines relying upon Stockfish derived inference code). Whether there are other more interesting modifications is unknown. Input features are presumably either HalfKA/HalfKP-esque

- Data Generation: The Dragon network is presumably trained on positions from Komodo self play games labeled using a mixture of Komodo's unique classical evaluation function and the self play game outcomes. Specifics are obviously unknown here.


Ethereal:
- Training: Ethereal's training code (NNTrainer) is private, written in C and not derived from any existing project. Halogen relies on the same project for its training code

- Inference: Ethereal's networks use a differing quantization scheme as compared to Stockfish and later layers in the network are not quantized. The inference code is publicly available and can be found on GitHub.

- Architecture: Ethereal uses a standard architecture with HalfKP input features and a 2x256 feature transformer with HalfKP-2x256-32-32-1 architecture as initially ported to chess by Nodchip. Being code level original, it is likely to have some other subtle differences.

- Data Generation: Ethereal self play games with labels originating from the evaluations provided by Ethereal's unique classical evaluation function.

Seer:
- Training: Seer’s training code is written in Python and makes use of the PyTorch library. It predates the nnue-pytorch project. Seer’s training code is thoroughly integrated with the engine and relies on pybind11 to expose engine components to the PyTorch training code. It is publicly available and can be found here: https://github.com/connormcmonigle/seer-training

- Inference: Original. Seer does not use quantization and, instead, relies upon minimal use of SIMD intrinsics for reasonable performance.

- Architecture: Seer uses HalfKA input features with an asymmetric 2x160 feature transformer. The remaining layers are densely connected (each input is concatenated with the corresponding, learned, affine transform, enabling superior gradient flow) and use ReLU (instead of clipped ReLU activations). Additionally, the network predicts WDL probabilities (3 values) which is unique to Seer, Winter and Lc0.

- Data generation: Seer uses a retrograde learning process to iteratively back up EGTB WDL values to positions sampled from human games on Lichess.

Minic:
- Training: Minic’s training code is written in Python and makes use of the PyTorch library. It is derived from both the nnue-pytorch project and Seer’s training code. The author has made a number of modifications to adapt the training code for Minic.

- Inference: Minic’s inference code is loosely derived from Seer’s inference code with some modifications and improvements. Notably, the author has implemented a minimal quantization scheme to improve performance.

- Architecture: Minic uses HalfKA input features a la Seer with an asymmetric 2x128 feature transformer. The remaining layers are densely connected (each input is concatenated with the affine transforms enabling superior gradient flow) and use clipped ReLU activations. Minic's networks predict a single scalar corresponding to the score.

- Data generation: Minic is trained on positions from Minic self play games with labels originating from Minic's classical evaluation function with some post processing. Later networks are trained on labels originating from the previously trained Minic networks. Minic makes use of adapted “gensfen” code from Stockfish.


Marvin:
- Training: Marvin’s training code is derived from the nnue-pytorch project with a number of modifications.

- Inference: Marvin’s inference code seems to be somewhat derived from CFish, but mostly original. Marvin makes use of the same quantization scheme used in Stockfish.

- Architecture: The standard HalfKP-256-32-32-1 originally adapted by Nodchip to chess.

- Data generation: Marvin is trained on positions from Marvin self play games with evaluations supplied by Marvin’s evaluation function.


Halogen:
- Training: Halogen relies on the NNTrainer project originating from Ethereal.

- Inference: Halogen’s inference code is quite simple due to the tiny network it relies upon. The network is fully quantized and does not make use of any SIMD intrinsics.

- Architecture: Halogen uses KP features (the standard 768 psqt features). The network is fully connected with ReLU activations and has layer sizes KP-512-1. It predicts absolute scores as opposed to relative scores, relying upon a fixed tempo adjustment.

- Data Generation: Ethereal self play games with labels originating from the evaluations provided by Ethereal's unique classical evaluation function.


Igel:
- Training: nnue-pytorch (see Stockfish)
- Inference: See Stockfish
- Architecture: The standard HalfKP-256-32-32-1 originally adapted by Nodchip to chess.
- Data Generation: Igel self play games using a modified version of the "gensfen" code adapted for chess by Nodchip. (labels from its classical evaluation function + previously trained Igel networks)


RubiChess:
- Training: C++ training code contributed to Stockfish by Nodchip and ported from computer Shogi (see Stockfish).
- Inference: See Stockfish
- Architecture: The standard HalfKP-256-32-32-1 originally adapted by Nodchip to chess.
- Data Generation: RubiChess self play games using a modified version of the "gensfen" code adapted for chess by Nodchip. (labels from its classical evaluation function + previously trained RubiChes networks)


Nemorino:
- Training: C++ training code contributed to Stockfish by Nodchip and ported from computer Shogi (see Stockfish).
- Inference: See Stockfish
- Architecture: The standard HalfKP-256-32-32-1 originally adapted by Nodchip to chess.
- Data Generation: Nemorino self play games using a modified version of the "gensfen" code adapted for chess by Nodchip. (labels from its classical evaluation function + previously trained Nemorino networks)


BBC:
- Training: N/A ~ Using a network trained by SV for Stockfish (see Stockfish).
- Inference: Daniel Shawul's probe library which is adapted from Ronald's CFish C port of Stockfish's original inference code contributed by Nodchip.
- Architecture: The standard HalfKP-256-32-32-1 originally adapted by Nodchip to chess.
- Data Generation: N/A ~ Using a network trained by SV for Stockfish (see Stockfish).

Mayhem:
- Training: N/A ~ Using a network trained by SV for Stockfish (see Stockfish).
- Inference: Daniel Shawul's probe library which is adapted from Ronald's CFish C port of Stockfish's original inference code contributed by Nodchip.
- Architecture: The standard HalfKP-256-32-32-1 originally adapted by Nodchip to chess.
- Data Generation: N/A ~ Using a network trained by SV for Stockfish (see Stockfish).

Fire:
- Training: N/A ~ Using a network trained by SV for Stockfish (see Stockfish).
- Inference: Daniel Shawul's probe library which is adapted from Ronald's CFish C port of Stockfish's original inference code contributed by Nodchip.
- Architecture: The standard HalfKP-256-32-32-1 originally adapted by Nodchip to chess.
- Data Generation: N/A ~ Using a network trained by SV for Stockfish (see Stockfish).
Very good post Connor! Thanks a lot, I just have to be more precise about Minic on some points :

Minic:
- Training: Minic’s training code is written in Python and makes use of the PyTorch library. It is derived from both the nnue-pytorch project and Seer’s training code. The author has made a number of modifications to adapt the training code for Minic. Training process also make uses of an adapted "run_game" script by @Vondele and some plotting stuff from the nnue-pytorch projet and some others things written by myself. I also recently adopt Connor's factorizer and dropout implementation.

- Inference: Minic’s inference code is loosely derived from Seer’s inference code with some modifications and improvements. Notably, the author has implemented a minimal quantization scheme to improve performance. As of today the quantization scheme and clipped relu are turned off, but retry that is on my todo list.

- Architecture: Minic uses HalfKA input features a la Seer with an asymmetric 2x128 feature transformer. The remaining layers are densely connected (each input is concatenated with the affine transforms enabling superior gradient flow) and use (clipped) ReLU activations. Minic's networks predict a single scalar corresponding to the score. I the last 9 months, I tried many architecture (some smaller, some bigger, with or without skip connection) but did not found a better one for now... Still trying ...

- Data generation: Official Minic nets are trained on positions from Minic self play games with labels originating from Minic's classical evaluation function with some post processing (nets based on SF or "LC0" data are clearly not official ones, not for competitions nor rating lists). Later networks are trained on labels originating from the previously trained Minic networks. Minic does not use Stockfish genfen code anymore except for converting between format (plain, bin, binpack, pgn), I'll make a clean up commit to make this last thing clearer.


Again, thanks for the analysis.
Madeleine Birchfield
Posts: 512
Joined: Tue Sep 29, 2020 4:29 pm
Location: Dublin, Ireland
Full name: Madeleine Birchfield

Re: will Tcec allow Stockfish with a Leela net to play?

Post by Madeleine Birchfield »

Regarding the original topic, the Stockfish team trained their own net. None of Fire, BBC, and Mayhem trained their own nets, which brings me to my next point. Why is jjoshua allowed to insert his Stein net into Allie and submit it into TCEC, while dkappe isn't allowed to insert his Night Nurse into Igel and submit it into TCEC? Both nets should either be allowed in TCEC or both should be banned. There are enough variety in neural network architectures that restricting guidelines to only NNUE is not enough for TCEC.
noobpwnftw
Posts: 703
Joined: Sun Nov 08, 2015 11:10 pm
Full name: Bojun Guo

Re: will Tcec allow Stockfish with a Leela net to play?

Post by noobpwnftw »

Madeleine Birchfield wrote: Fri Jun 18, 2021 3:22 pm Regarding the original topic, the Stockfish team trained their own net. None of Fire, BBC, and Mayhem trained their own nets, which brings me to my next point. Why is jjoshua allowed to insert his Stein net into Allie and submit it into TCEC, while dkappe isn't allowed to insert his Night Nurse into Igel and submit it into TCEC? Both nets should either be allowed in TCEC or both should be banned. There are enough variety in neural network architectures that restricting guidelines to only NNUE is not enough for TCEC.
Simple, TCEC is invitational, impersonating a d*ck probably won't get too far over there.

Some people don't like? Get rich. :D
JohnWoe
Posts: 529
Joined: Sat Mar 02, 2013 11:31 pm

Re: will Tcec allow Stockfish with a Leela net to play?

Post by JohnWoe »

Mayhem has at least own net "nn-cb80fb9393af.nnue". I use the same naming scheme as in SF "sha256sum | head -c 12" I generated that net 3 months ago. Not interested in these 45MB nets. That net is not from Mayhem data so not unique. I have only touched the Probing code very lightly so it doesn't leek, no VLA, no UB so on trivial things. Like Fire author said NNUE and Syzygy are pretty similar. Both probe (syzygy code snatched from SF...) evaluation binaries and return evaluation. Who would want to write probing code for syzygy egtb to be really unique? I don't see TCEC as the promised land. Haven't read the rules but you need to utilize lots of cores? Tho Mayhem could be easily made to burn as many CPUs if one wishes so.

I see reusing code as a good thing. That's what good developers do all the time. Chess programming however is more competition than real programming.
AndrewGrant
Posts: 2003
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: will Tcec allow Stockfish with a Leela net to play?

Post by AndrewGrant »

JohnWoe wrote: Fri Jun 18, 2021 8:42 pm Like Fire author said NNUE and Syzygy are pretty similar. Both probe (syzygy code snatched from SF...) evaluation binaries and return evaluation.
I disagree here. Becuase the only way for Stockfish's NNUE to be a "probing" tool, is for you to use the same architecture. You lose the ability to experiment to a large degree. You are able to add layers and extend them, but that is about it. You don't have the power to do non-quantized layers. You cannot simply add HalfKA at will.

The tools are only "Syzygy like" if you don't plan on ever straying from the beaten path. Plus, writing vector code is a valuable thing to do and learn. Its not so easy to get things done in an efficient manner.
connor_mcmonigle
Posts: 544
Joined: Sun Sep 06, 2020 4:40 am
Full name: Connor McMonigle

Re: will Tcec allow Stockfish with a Leela net to play?

Post by connor_mcmonigle »

JohnWoe wrote: Fri Jun 18, 2021 8:42 pm Mayhem has at least own net "nn-cb80fb9393af.nnue". I use the same naming scheme as in SF "sha256sum | head -c 12" I generated that net 3 months ago. Not interested in these 45MB nets. That net is not from Mayhem data so not unique. I have only touched the Probing code very lightly so it doesn't leek, no VLA, no UB so on trivial things. Like Fire author said NNUE and Syzygy are pretty similar. Both probe (syzygy code snatched from SF...) evaluation binaries and return evaluation. Who would want to write probing code for syzygy egtb to be really unique? I don't see TCEC as the promised land. Haven't read the rules but you need to utilize lots of cores? Tho Mayhem could be easily made to burn as many CPUs if one wishes so.

I see reusing code as a good thing. That's what good developers do all the time. Chess programming however is more competition than real programming.
Ahh, I'll correct my list to reflect this. Am I correct in understanding from your post that Mayhem is bundled with a network you trained yourself on Stockfish data? Was it trained with the Nodchip C++ training code or the nnue-pytorch code?

I also disagree. Syzygy probing code is only really of much use in the rare tricky endgame. For top engines, it has a fairly negligible impact on strength. From the perspective of playing style, it is wholly irrelevant. On the other hand, replacing your entire evaluation function with the NNUE evalution code + a Stockfish network has a massive impact on both playing strength and playing stye. In my opinion, you've effectively killed half (the other half being the search) of what made your engine unique and interesting. At the end of the day, why not go all the way and just probe Stockfish?
jhellis3
Posts: 548
Joined: Sat Aug 17, 2013 12:36 am

Re: will Tcec allow Stockfish with a Leela net to play?

Post by jhellis3 »

In my opinion, you've effectively killed half (the other half being the search) of what made your engine unique and interesting.
That is kind of the point of NNs though, to unburden oneself.
connor_mcmonigle
Posts: 544
Joined: Sun Sep 06, 2020 4:40 am
Full name: Connor McMonigle

Re: will Tcec allow Stockfish with a Leela net to play?

Post by connor_mcmonigle »

jhellis3 wrote: Fri Jun 18, 2021 9:51 pm
In my opinion, you've effectively killed half (the other half being the search) of what made your engine unique and interesting.
That is kind of the point of NNs though, to unburden oneself.
Well, you could really unburden yourself by just probing Stockfish...

It remains an open question which NN topology (input features + architecture) is optimal for chess and there exists even greater potential for diversity with neural networks than existed with classical evaluation functions. Classical evaluation functions are nothing more than one layered networks for all intents and purposes. However, no one was (publicly) copying Stockfish's evaluation function before so I don't see the difference here, really. For what it's worth, I don't think this practice is wrong, provided sufficient attribution is provided. Perhaps this even makes sense were one only interested in experimenting with search ideas, but if you're copying all the parameters, topology and implementation from Stockfish, then your engine is a Stockfish derivative (nothing wrong in that, though tournaments are unlikely to invite you). By copying another engine's evaluation function, you're killing any room for creativity w.r.t the evaluation function.
AndrewGrant
Posts: 2003
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: will Tcec allow Stockfish with a Leela net to play?

Post by AndrewGrant »

connor_mcmonigle wrote: Fri Jun 18, 2021 11:02 pm
jhellis3 wrote: Fri Jun 18, 2021 9:51 pm
In my opinion, you've effectively killed half (the other half being the search) of what made your engine unique and interesting.
That is kind of the point of NNs though, to unburden oneself.
... However, no one was (publicly) copying Stockfish's evaluation function before so I don't see the difference here, really. For what it's worth, I don't think this practice is wrong, provided sufficient attribution is provided...
One can look at Stockfish, see an eval term named DoThisThing and think to themselves "Wow! What a good idea. Let me add that to my engine". And then you add it to your engine, it kinda works. But you add some tweaks to it to fit your needs. Maybe you limit when the term is applied, maybe you expand it, maybe you vary the value of the term over some dimension.

In this case, you can see something, take it as a starting point, and then work and fit it to your own unique engine. In the NN case ... well I cannot just go "Oh boy oh boy, I sure do like Stockfish L2 neurons 1, 4, 16, and 17. Let me snag those up". You don't borrow, you replace. If you run a Stockfish net, you are running Stockfish's evaluation function.
kranium
Posts: 2130
Joined: Thu May 29, 2008 10:43 am

Re: will Tcec allow Stockfish with a Leela net to play?

Post by kranium »

JohnWoe wrote: Fri Jun 18, 2021 8:42 pm Like Fire author said NNUE and Syzygy are pretty similar. Both probe (syzygy code snatched from SF...) evaluation binaries and return evaluation.
connor_mcmonigle wrote: Fri Jun 18, 2021 9:45 pm I also disagree. Syzygy probing code is only really of much use in the rare tricky endgame. For top engines, it has a fairly negligible impact on strength. From the perspective of playing style, it is wholly irrelevant. On the other hand, replacing your entire evaluation function with the NNUE evalution code + a Stockfish network has a massive impact on both playing strength and playing stye. In my opinion, you've effectively killed half (the other half being the search) of what made your engine unique and interesting. At the end of the day, why not go all the way and just probe Stockfish?
"only really of much use in the rare tricky endgame." ?

No that's wrong..
I'm not sure what syzygy implementation you're using Connor, but most engines begin probing nnue early in the game, often start of middlegame...I've seen SF even get TB hits in the opening. Check it out for yourself. The WDL info can help guide the engine's middelgame search toward a won endgame.
In other words TBs are pretty much used the whole game.

"replacing your entire evaluation function with the NNUE evalution code + a Stockfish network has a massive impact on both playing strength and playing stye"

playing style? c'mon...engine playing style is a human construct and not real or discernable at this level of play (3600-3700)


edit: I just checked - Seer doesn't support syzygy so you not understanding it kinda makes sense