Calling All Armchair GPL Lawyers

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

Moderator: Ras

User avatar
hgm
Posts: 28386
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Calling All Armchair GPL Lawyers

Post by hgm »

Fulvio wrote: Sat Feb 13, 2021 10:00 amDoesn't matter: "This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts".
It is distributed as a part of a GPL program, therefore it is covered by GPL.
But the way I see it the NN is not "part of the work". It is just data the GPL'ed work can operate on. Like a GPL'ed image-processing program can process images, or a GPL'ed Python interpreter can execute Python programs. That doesn't mean every Python program automatically falls under the GPL, or that every PNG image automatically falls under the GPL. Not even when they are distributed together, for user convenience.

Like a digital audio track an NNUE is just a collection of numbers, with a well-defined format and a well-defined prescription for how to 'play' it to recover the thing is representing (be it sound or chess knowledge). There are many other 'players' of NNUE data other than Stockfish, and there are many more NNUE that Stockfish can 'play'.
jdart
Posts: 4405
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Calling All Armchair GPL Lawyers

Post by jdart »

IANAL, but the exact definition of what is copyrightable can vary by jurisdiction, even though most countries are under the framework of the Berne Convention. It is not completely clear to me that a neural net, the actual trained bits of it, is copyrightable. The answer might vary depending on which country's laws you are talking about. It may seem intuitive that since these things take a lot of time and effort to create, there would be legal protections for them, but one issue is the definition of authorship. If there's no human input, just data input and data output, then where is the "author" in the process?

Distribution of code is still covered under GPL. It seems to me they'd have to combine Stockfish with some custom NN code to read a differently configured net, and that would be a derivative work under GPL, so the code should be available. Still, as a practical matter, this is not readily enforceable.
Fulvio
Posts: 396
Joined: Fri Aug 12, 2016 8:43 pm

Re: Calling All Armchair GPL Lawyers

Post by Fulvio »

hgm wrote: Sat Feb 13, 2021 1:52 pm
Fulvio wrote: Sat Feb 13, 2021 10:00 amDoesn't matter: "This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts".
It is distributed as a part of a GPL program, therefore it is covered by GPL.
But the way I see it the NN is not "part of the work". It is just data the GPL'ed work can operate on. Like a GPL'ed image-processing program can process images
I agree that the purpose of a GPL'ed image-processing is to process images, but I don't understand how you can argue that the purpose of Stockfish is to process NN.
It seems obvious to me that the purpose of Stockfish is to play chess and a different NN change how it works in a fundamental way (why if someone spends a lot of time improving the evaluation function that's part of the work and a different NN is not?).
The audio example also makes no sense: the copyright covers the song, not the binary data. A better example is that of remixes: add some bases, speed up the tempo and make it much better than the original. But the copyrights of the original still apply and you cannot distribute it without permission.
User avatar
hgm
Posts: 28386
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Calling All Armchair GPL Lawyers

Post by hgm »

One can argue that the NNUE are a standard format to encode Chess knowledge, and that Stockfish is an engine to express that Chess knowledge in the form of Chess games. Like MP3 is a standard format for encoding sound, and an MP3 player is a software tool to express that sound through the speakers of your laptop.

And yes, the copyright is on the song. But in thise NNUE case the copyright could be on the Chess knowledge encoded in the NNUE. Accumulation of Chess knowledge does seem like an intellectual effort that could result in the creation of intellectual property rights. And Stockfish in NNUE mode would not be able to play meaningful Chess without a proper NNUE; if you let it run from an uninitialized NNUE (all weigthts 0) it would just be a random mover.

So I think it is correct to consider Stockfish as a NNUE player, at least for one of its functions. It also has a hand-crafted evaluation, which could make it play Chess independently, but this is not used in Fat Fritz 2, and its existence is coincidental. It is like an MP3 player that can also be used as an alarm clock, through some built-in sounds. That there are many different NNUE nets that can be loaded into Stockfish, and that there are many engines that can be loaded with Stockfish NNUEs is also an indication that the analogy is good.
Fulvio
Posts: 396
Joined: Fri Aug 12, 2016 8:43 pm

Re: Calling All Armchair GPL Lawyers

Post by Fulvio »

hgm wrote: Sat Feb 13, 2021 4:24 pm One can argue that the NNUE are a standard format to encode Chess knowledge, and that Stockfish is an engine to express that Chess knowledge in the form of Chess games. Like MP3 is a standard format for encoding sound, and an MP3 player is a software tool to express that sound through the speakers of your laptop.
Maybe someone who doesn't know how a chess engine works. But you know that the static evaluation is only a part of an engine, and that while a song is the same regardless of the mp3 decoder, a NNUE produces different results when used in different engines (and therefore it is not independent).
gaard
Posts: 463
Joined: Mon Jun 07, 2010 3:13 am
Location: Holland, MI
Full name: Martin W

Re: Calling All Armchair GPL Lawyers

Post by gaard »

hgm wrote: Sat Feb 13, 2021 12:16 am [Moderation] As I interpret this as a general question on NN-using engines, to which the FF2 case just serves as a real-life example, I see no need to move it to the Engine Origins section. Other moderators are welcome to do so if they object to the thread.

My own 2 cents:

I am not really acquainted with the FF2 case, but from what I read here I gather that FF2 is a Stockfish version, perhaps slightly modified, using a 'private' NNUE. Where the sources of this modified version are available on-line. I agree with unserializable that the NNUE is data, and that the GPL does not extend to it. An interpreter of a programming language is a good analogy, even if we want to maintain that a NN is a program. Stockfish is just a 'NNUE interpreter'.

It also seems to me that there is no such thing as the 'source code' of a NN, so that the GPL cannot be applied to it (e.g. if I would want to extend an existing net, e.g. embed it into a larger one).

If there is a violation here, it would be the omission of the GPL licence text with the product, but I think this is a very minor one. When the source code is not included in the distribution, but available on line, no one that receives the package can actually make derivatives, so the conditions under which they could are completely irrelevant to them.

The license that the NN falls under, if any, is a red herring. If CB cannot or will not distribute it as part of the corresponding source of the complete work for whatever reason - which they should be since you cannot build the software without it as it's embedded - then they cannot legally distribute FF2.

GPLv3 wrote: 1. Source Code.

The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.

A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.

The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.

The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.

The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.

The Corresponding Source for a work in source code form is that same work.
GPLv3 wrote: 12. No Surrender of Others' Freedom.

If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
QED
User avatar
hgm
Posts: 28386
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Calling All Armchair GPL Lawyers

Post by hgm »

Fulvio wrote: Sat Feb 13, 2021 5:03 pm Maybe someone who doesn't know how a chess engine works. But you know that the static evaluation is only a part of an engine, and that while a song is the same regardless of the mp3 decoder, a NNUE produces different results when used in different engines (and therefore it is not independent).
MP3 players contain a complex decoding algorithm, which can be implemented in different ways in different players. I am not really into MP3, but I know it is not an exact representation of the original sound, like a .WAV file would be. So the reproduction of the original sound will in general not be perfect, so that there is room for improvement. It is conceivable that someone would make a decoding algorithm that supplements the information on the original sound that is actually supplied by educated guesses of its own for the data that had been 'compressed away', e.g. increasing the bandwidth or reducing the noise. This would produce better quality sound from the same recording, like the Stockfish search would produce better Chess from the same NNUE as the TSCP search.

So no, I don't see any essential difference at all.
gaard wrote: Sat Feb 13, 2021 5:04 pmThe license that the NN falls under, if any, is a red herring. If CB cannot or will not distribute it as part of the corresponding source of the complete work for whatever reason - which they should be since you cannot build the software without it as it's embedded - then they cannot legally distribute FF2.
Well, as I have learned in the mean time it seems they actually incorporated the NNUE data to the .exe file, which definitely weakens their case. I suppose they did this as a 'Windows resource'; WinBoard also uses that for storing the bitmap images of the pieces in the .exe file. This does make it impossible to build an identical or equivalent executable, so I suppose that strictly speaking it is a violation of the GPL.

It seems a very insignificant one. The Stockfish copyright holders could go to court over this, and when they would win, the verdict would be that in the future ChessBase would have to distribute Fat Fritz 2 with the NNUE in a separate file, which then could be placed under whichever license they wished, plus the Stockfish .exe under GPL. It is not clear who suffered any damage from the fact they did not do that in the first place.

One thing is not clear to me anyway. If they included the NNUE data in the binary, thry must have modified Stockfish to actually read it from its own binary. That is a code change, and the GPL obliges them to publish that code change in source. If it was thus published, we would have no difficulty to extract the NNUE data from the .exe file, even if it was somehow encrypted.
gaard
Posts: 463
Joined: Mon Jun 07, 2010 3:13 am
Location: Holland, MI
Full name: Martin W

Re: Calling All Armchair GPL Lawyers

Post by gaard »

AndrewGrant wrote: Fri Feb 12, 2021 9:03 pm I was trying to get a conversation going about what future people should do, in the eyes of the people, not about what FF2 in particular. I should have made that more clear. Mods are welcome to axe this thread, or move it elsewhere, since it just looks like a duplicate of the already existing conversation.

Namely, I've been working on some strong NNUE nets for a few months with all original efforts, and many have urged me to sell a pro version of future Ethereals with the NNUE nets being paid for. I would want to do it in a way that most people agree is up to code, even if there is no chance of someone coming after me for the code I actually own.
AFAIK, you should be able to copyright a NN since it's a creative and (presumably) original work. If I thought the price was fair I would even consider buying one. Maybe for shits-and-giggles you could put one together that was a minimum 10+ Elo over SF's (easier said than done) and put a limited number for auction on eBay.
unserializable
Posts: 65
Joined: Sat Oct 24, 2020 6:39 pm
Full name: Taimo Peelo

Re: Calling All Armchair GPL Lawyers

Post by unserializable »

I am by now truthfully confused about whether the FF2, which inspired this discussion thread, came with net in separate file or not.

In any case, my previous comments in this thread about distributing nets with GPL licensed engine (aggregate packaging) without needing to license net under GPL were all made with assumption that net is a separate data file and NOT embedded in the binary, as mentioned in the first comment:
unserializable wrote: Fri Feb 12, 2021 9:13 pm ...
The 2) also does not seem to hold, because network can be considered their work / plug-in / neural database and as far as I understand is altogether separate data file which is not embedded in the binary.
...
IF however the embedding of the net in FF2 executable SHOULD be true -- as HGM noted, already FF2 current source code publishings cannot be considered complete and in compliance with GPL, as the net loading code HAS NOT been published with embedded net loading functionality (indeed it has commits that explicitly disable NNUE embedding and change the external net file name ...).

Best of luck to Andrew Grant, who is certainly are able refrain from putting nets into executable, if he so desires.
Monchester 1.0, chess engine playing at scholastic level: https://github.com/unserializable/monchester ("Daddy, it is gonna take your horsie!")
Tickle Monchester at: https://lichess.org/@/monchester
gaard
Posts: 463
Joined: Mon Jun 07, 2010 3:13 am
Location: Holland, MI
Full name: Martin W

Re: Calling All Armchair GPL Lawyers

Post by gaard »

hgm wrote: Sat Feb 13, 2021 5:29 pm (snip)
Well, as I have learned in the mean time it seems they actually incorporated the NNUE data to the .exe file, which definitely weakens their case. I suppose they did this as a 'Windows resource'; WinBoard also uses that for storing the bitmap images of the pieces in the .exe file. This does make it impossible to build an identical or equivalent executable, so I suppose that strictly speaking it is a violation of the GPL.

It seems a very insignificant one. The Stockfish copyright holders could go to court over this, and when they would win, the verdict would be that in the future ChessBase would have to distribute Fat Fritz 2 with the NNUE in a separate file, which then could be placed under whichever license they wished, plus the Stockfish .exe under GPL. It is not clear who suffered any damage from the fact they did not do that in the first place.

One thing is not clear to me anyway. If they included the NNUE data in the binary, thry must have modified Stockfish to actually read it from its own binary. That is a code change, and the GPL obliges them to publish that code change in source. If it was thus published, we would have no difficulty to extract the NNUE data from the .exe file, even if it was somehow encrypted.
It seems less than significant to me also. However, neither your name nor mine are on the copyright, so our opinions as to the significance of the violation are also insignificant, IMO. But as long as we can agree that they are there, then we are on the same page.

As far as damages go, this might have a lot to do with why many similar cases are settled out of court. The offending party usually meets compliance by one of two ways, 1) Not distributing the software at all or, 2) The inclusion of all required data (files) necessary to build the software.

As to their inclusion of the NN in the binary, it is likely they embedded it with the code already included with SF, namely, Incbin, which is public domain and therefor not especially relevant to the question of how, IMO.