leela-zero / leela-zero

Go engine with no human-provided knowledge, modeled after the AlphaGo Zero paper.
GNU General Public License v3.0
5.28k stars 1.01k forks source link

Distributed network testing protocol #249

Closed marcocalignano closed 6 years ago

marcocalignano commented 6 years ago

I wanted to open another Issue for this discussion. Here we can discuss the commands the server send to the clients and the answer the clients send back to the server. At the end we make a decision (I guess @gcp have the last word ;) ). In the meanwhile @roy7 and me can concentrate on writing the client/server code without having to change it too many times. This is my suggestion for the two commands

{
        "cmd":"match",
        "white_hash":"223737476718d58a4a5b0f317a1eeeb4b38f0c06af5ab65cb9d76d68d9abadb6",
        "black_hash":"92c658d7325fe38f0c8adbbb1444ed17afd891b9f208003c272547a7bcb87909",
        options {
              "playouts":1000,
              "resignation_percent":3,
              "required_client_version":5,
              "noise":false,
              "randomcnt":0,
              "version" : 1
       }
}

{
        "cmd":"selfplay",
        "hash":"223737476718d58a4a5b0f317a1eeeb4b38f0c06af5ab65cb9d76d68d9abadb6",
        options {
              "playouts":1000,
              "resignation_percent":3,
              "required_client_version":5,
              "noise":true,
              "randomcnt":30,
              "version" : 1
        }
    }
marcocalignano commented 6 years ago

And this is the suggestion for the two answers:

-F winnerhash=aaaa
-F loserhash=bbbb
-F clientversion=6
-F winnercolor=black
-F movescount=321
-F score=B+45
-F optionver=1
http://zero-test.sjeng.org/submit-match

-F networkhash=aaaa
-F clientversion=6
-F sgf=@file
-F trainingdata=@data_file);
http://zero-test.sjeng.org/submit
roy7 commented 6 years ago

Some people have requested we upload the sgf files for matches. Could you upload those with the game result? I can change things on my end to move options into the options.* wrapper. I'm still at work for 4 more hours so it won't be immediate. :)

marcocalignano commented 6 years ago

@roy7 I'd like to test other stuff first but if you need it I'll do it

roy7 commented 6 years ago

You don't need to support it yet. Do it when everything else works. :)

sethtroisi commented 6 years ago

consider replacing "optionver=1" with a hash of the options calculated on the client side.

roy7 commented 6 years ago

On the test server, /get-task now uses the options.{} wrapper for all the options like you specified.

What does version=1 relate to? Version of this protocol?

roy7 commented 6 years ago

In fact I'll move this to live server as well, since no one is running your code yet.

roy7 commented 6 years ago

@marcocalignano Do you want to edit your specification above to have a -F sgf=@file for /submit-match as well? Then I'll program the server side to require and expect a compressed sgf file the same as /submit.

marcocalignano commented 6 years ago

What does version=1 relate to? Version of this protocol?

this is a version for the options object. I thought that maybe we want to do some experiments with the same networks but with different options, so you need a way to identify which submitted matches were play with one set of option or the other. The two networks are not enough anymore.

For the option -F sgf=@file I'd like to wait for more inputs discussion maybe suggestions from @gcp

marcocalignano commented 6 years ago

@sethtroisi Why an hash should be better than a version number?

roy7 commented 6 years ago

I see the point of storing the version (or hash or whatever we do), so like we could do some comparisons between two networks at 1000 playouts and 1600 playouts if we wanted and tell them apart with the version #.

I'm guessing the reason he suggested a hash is so we don't manually need a version #. If we run the same match with new options, the hash would change so they could all be grouped by hash automatically.

marcocalignano commented 6 years ago

Hash help not to make mistakes (two versions that are the same) but with the hash is more complicated to search in the database (I guess). But there are smarter people than me in SQL that would say 'easy peasy' ;)

roy7 commented 6 years ago

I'm having trouble deciding on a database structure for the matches on the server, but actual match game uploading should work now and be stored. I don't have the code in place to choose when to request matches yet though since I've been having a mental roadblock on the data structure. Compressed sgf is required when uploading match games.

isty2e commented 6 years ago

A tiny suggestion, but what about "options_version" instead of "version" for clarification?

marcocalignano commented 6 years ago

@isty2e version is inside the object called option

isty2e commented 6 years ago

Some might consider it self-explanatory or obvious, but there can also people confused with it at the first sight like me or roy7. Slightly lengthening key wouldn't harm too much, I guess. Of course if you don't like to change it, well it's your choice.

marcocalignano commented 6 years ago

So the current proposal is:

{
   "cmd" : "match",
   "white_hash" : "223737476718d58a4a5b0f317a1eeeb4b38f0c06af5ab65cb9d76d68d9abadb6",
   "black_hash" : "92c658d7325fe38f0c8adbbb1444ed17afd891b9f208003c272547a7bcb87909",
   "options_hash" : "c2e3"
   "options" : {
       "playouts" : 1000,
       "resignation_percent" : 3,
       "required_client_version" : 5,
       "noise" : "false",
       "randomcnt" : 0
    }
}

{
   "cmd" : "selfplay",
   "hash" : "223737476718d58a4a5b0f317a1eeeb4b38f0c06af5ab65cb9d76d68d9abadb6",
   "options_hash" : "ee21"
   "options" : {
       "playouts" : 1000,
       "resignation_percent" : 3,
       "required_client_version" : 5,
       "noise" : "true",
       "randomcnt" : 30
    }
}

and

-F winnerhash=223737476718d58a4a5b0f317a1eeeb4b38f0c06af5ab65cb9d76d68d9abadb6
-F loserhash=92c658d7325fe38f0c8adbbb1444ed17afd891b9f208003c272547a7bcb87909
-F clientversion=6
-F winnercolor=black
-F movescount=321
-F score=B+45
-F options_hash=c2e3
-F sgf=@file
http://zero-test.sjeng.org/submit-match

-F networkhash=223737476718d58a4a5b0f317a1eeeb4b38f0c06af5ab65cb9d76d68d9abadb6
-F clientversion=6
-F options_hash=ee21
-F sgf=@file
-F trainingdata=@data_file
http://zero-test.sjeng.org/submit
roy7 commented 6 years ago

Is options_hash something the server will calculate and send, and you'll just echo it back when reporting in?

marcocalignano commented 6 years ago

@roy7 yes! So the server can connect the hash to the options that (I guess) are saved in a different DB table.

roy7 commented 6 years ago

Ok cool that'll be helpful. In fact, I can then more easily support multiple matches in the match database with different options as well.

roy7 commented 6 years ago

Ok options_hash is supported now. If I'm not mistaken, all reporting back to server is done and the client requests are both handled correctly. The open task for me tonight is finish up /get-task when it sends out a match, to actually generate those off my database of pending matches. Then behind the scenes I'll add some helpful functions for gcp to easily add new matches to the list when he wants them run.

marcocalignano commented 6 years ago

@roy7 do you need to leave my client running to test your server script?

roy7 commented 6 years ago

Probably not required, but no harm if you do want to. Since you'll just do self-play games for now anyway like normal clients. :)

marcocalignano commented 6 years ago

but if I push on the test server you can change the commands and see if it works. For example if you do test commands the hash has to alternate white black so you can test it

marcocalignano commented 6 years ago

One thing I have noticed is that required_client_version goes outside the option object. like that:

{
   "cmd" : "selfplay",
   "hash" : "223737476718d58a4a5b0f317a1eeeb4b38f0c06af5ab65cb9d76d68d9abadb6",
   "options_hash" : "ee21",
   "required_client_version" : 5,
   "options" : {
       "playouts" : 1000,
       "resignation_percent" : 3,
       "noise" : "true",
       "randomcnt" : 30
    }

}

roy7 commented 6 years ago

I put it in options at the moment. You want me to move it outside, right? Yes you are welcome to run your autogtp on the test server for now. :)

marcocalignano commented 6 years ago

yes please put it outside so I give it a test! The sgf has to be gziped right?

roy7 commented 6 years ago

It's outside now.

sgf should be gzip'ed yes. Thanks.

marcocalignano commented 6 years ago

Client is running

marcocalignano commented 6 years ago

You should have gotten two self played games

marcocalignano commented 6 years ago

If that is true you can try with a test match

roy7 commented 6 years ago

Ok I see from your games I wasn't storing options_hash, I am now. I'll let 1 more game come in to check it then I'll change you to getting matches instead of selfplays.

roy7 commented 6 years ago

Test server now serving matches. Your normal game submissions looked good.

marcocalignano commented 6 years ago

what about the test match submission (any other spelling mistake?)

roy7 commented 6 years ago

@marcocalignano I see task requests but no test match submissions at all. Hmm. You see no response text from curl on your end?

marcocalignano commented 6 years ago

Oh yes lost in the debug output Upload failed. Curl Exit code: 26 my command line is curl -F winnerhash=92c658d7325fe38f0c8adbbb1444ed17afd891b9f208003c272547a7bcb87909 -F loserhash=223737476718d58a4a5b0f317a1eeeb4b38f0c06af5ab65cb9d76d68d9abadb6 -F clientversion=6 -F winnercolor=black -F movescount=266 -F score=B+0.5 -F options_hash=3e4e92 -F sgf=@f285bc656a9a4d0084f38c587f74fd8e.gz http://zero-test.sjeng.org/submit-match

marcocalignano commented 6 years ago

OK @roy7 bug on retreiving the sgf file name let's see how it does now.

roy7 commented 6 years ago

I wish it'd print the result text from the server, if any, since I do return clear error text messages. I'm logging any call to /submit-match at all though, and I'm not seeing it being called. So it might be failing before it even goes out. Do you need to escape the @ on your command line? I normally wrap that in quotes.

marcocalignano commented 6 years ago

I believe it failed on my side because it did not find the file I wanted to send

roy7 commented 6 years ago

Yeah curl error 26 is 'can't open file'.

marcocalignano commented 6 years ago

Now?

roy7 commented 6 years ago

{"winnerhash":"92c658d7325fe38f0c8adbbb1444ed17afd891b9f208003c272547a7bcb87909","loserhash":"223737476718d58a4a5b0f317a1eeeb4b38f0c06af5ab65cb9d76d68d9abadb6","clientversion":"6","winnercolor":"black","movescount":"200","score":"B+4.5","options_hash":"3e4e92"}

roy7 commented 6 years ago

Although it didn't process it. Checking.

roy7 commented 6 years ago

It seems you have all the fields although I didn't print out if you included a full sgf file. What was the response on your side to that curl command?

marcocalignano commented 6 years ago

I didn't print it out. It will wit ht e next game!

roy7 commented 6 years ago

Found a bug that I wasn't storing the sgf game itself, fixed. Hopefully your next submit goes smooth!

roy7 commented 6 years ago

@marcocalignano Score was "" on your most recent submission btw.

roy7 commented 6 years ago

@marcocalignano Got your match, and it saved fine. I had a mismatch between the dummy match and the database's match info, so I fixed that too just now. If you upload 1 more it should update everything on my end properly now!

marcocalignano commented 6 years ago

OHHHHHH I found a bug that a lot of people thought was something else!!!!!

roy7 commented 6 years ago

Latest upload worked as expected, both database tables updated properly. I think it's working.