Skip to content

Commit 21da95d

Browse files
committed
Add multiple nets support to the server
Required by the new SF architecture with a Big + Small nets official-stockfish/Stockfish#4915 official-stockfish/Stockfish#5068
1 parent 9af4606 commit 21da95d

File tree

4 files changed

+34
-35
lines changed

4 files changed

+34
-35
lines changed

server/fishtest/rundb.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
# To make this practical we will eventually put all schemas
5151
# in a separate module "schemas.py".
5252

53-
net_name = regex("nn-[a-z0-9]{12}.nnue", name="net_name")
53+
net_name = regex("nn-[a-f0-9]{12}.nnue", name="net_name")
5454
tc = regex(r"([1-9]\d*/)?\d+(\.\d+)?(\+\d+(\.\d+)?)?", name="tc")
5555
str_int = regex(r"[1-9]\d*", name="str_int")
5656
sha = regex(r"[a-f0-9]{40}", name="sha")
@@ -111,8 +111,8 @@
111111
"args": {
112112
"base_tag": str,
113113
"new_tag": str,
114-
"base_net": net_name,
115-
"new_net": net_name,
114+
"base_nets": [net_name, ...],
115+
"new_nets": [net_name, ...],
116116
"num_games": int,
117117
"tc": tc,
118118
"new_tc": tc,
@@ -322,8 +322,8 @@ def new_run(
322322
msg_new="",
323323
base_signature="",
324324
new_signature="",
325-
base_net=None,
326-
new_net=None,
325+
base_nets=None,
326+
new_nets=None,
327327
rescheduled_from=None,
328328
base_same_as_master=None,
329329
start_time=None,
@@ -344,8 +344,8 @@ def new_run(
344344
run_args = {
345345
"base_tag": base_tag,
346346
"new_tag": new_tag,
347-
"base_net": base_net,
348-
"new_net": new_net,
347+
"base_nets": base_nets,
348+
"new_nets": new_nets,
349349
"num_games": num_games,
350350
"tc": tc,
351351
"new_tc": new_tc,

server/fishtest/views.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -729,35 +729,34 @@ def get_sha(branch, repo_url):
729729
return "", ""
730730

731731

732-
def get_net(commit_sha, repo_url):
733-
"""Get the net from evaluate.h or ucioption.cpp in the repo"""
732+
def get_nets(commit_sha, repo_url):
733+
"""Get the nets from evaluate.h or ucioption.cpp in the repo"""
734734
api_url = repo_url.replace(
735735
"https://github.com", "https://raw.githubusercontent.com"
736736
)
737737
try:
738-
net = None
738+
nets = []
739+
pattern = re.compile("nn-[a-f0-9]{12}.nnue")
739740

740741
url1 = api_url + "/" + commit_sha + "/src/evaluate.h"
741742
options = requests.get(url1).content.decode("utf-8")
742743
for line in options.splitlines():
743744
if "EvalFileDefaultName" in line and "define" in line:
744-
p = re.compile("nn-[a-z0-9]{12}.nnue")
745-
m = p.search(line)
745+
m = pattern.search(line)
746746
if m:
747-
net = m.group(0)
747+
nets.append(m.group(0))
748748

749-
if net:
750-
return net
749+
if nets:
750+
return nets
751751

752752
url2 = api_url + "/" + commit_sha + "/src/ucioption.cpp"
753753
options = requests.get(url2).content.decode("utf-8")
754754
for line in options.splitlines():
755755
if "EvalFile" in line and "Option" in line:
756-
p = re.compile("nn-[a-z0-9]{12}.nnue")
757-
m = p.search(line)
756+
m = pattern.search(line)
758757
if m:
759-
net = m.group(0)
760-
return net
758+
nets.append(m.group(0))
759+
return nets
761760
except:
762761
raise Exception("Unable to access developer repository: " + api_url)
763762

@@ -919,19 +918,19 @@ def strip_message(m):
919918
)
920919
data["base_same_as_master"] = master_diff.text == ""
921920

922-
# Test existence of net
923-
new_net = get_net(data["resolved_new"], data["tests_repo"])
924-
if new_net:
921+
# Test existence of nets
922+
new_nets = get_nets(data["resolved_new"], data["tests_repo"])
923+
for new_net in new_nets:
925924
if not request.rundb.get_nn(new_net):
926925
raise Exception(
927926
"The net {}, used by {}, is not "
928927
"known to Fishtest. Please upload it to: "
929928
"{}/upload.".format(new_net, data["new_tag"], request.host_url)
930929
)
931930

932-
# Store net info
933-
data["new_net"] = new_net
934-
data["base_net"] = get_net(data["resolved_base"], data["tests_repo"])
931+
# Store nets info
932+
data["new_nets"] = new_nets
933+
data["base_nets"] = get_nets(data["resolved_base"], data["tests_repo"])
935934

936935
# Integer parameters
937936
data["threads"] = int(request.POST["threads"])
@@ -1004,8 +1003,8 @@ def update_nets(request, run):
10041003
run_id = str(run["_id"])
10051004
data = run["args"]
10061005
if run["base_same_as_master"]:
1007-
base_net = data["base_net"]
1008-
if base_net:
1006+
base_nets = data["base_nets"]
1007+
for base_net in base_nets:
10091008
net = request.rundb.get_nn(base_net)
10101009
if not net:
10111010
# Should never happen:
@@ -1017,8 +1016,8 @@ def update_nets(request, run):
10171016
if "is_master" not in net:
10181017
net["is_master"] = True
10191018
request.rundb.update_nn(net)
1020-
new_net = data["new_net"]
1021-
if new_net:
1019+
new_nets = data["new_nets"]
1020+
for new_net in new_nets:
10221021
net = request.rundb.get_nn(new_net)
10231022
if not net:
10241023
return
@@ -1366,12 +1365,12 @@ def tests_view(request):
13661365
"new_signature",
13671366
"new_options",
13681367
"resolved_new",
1369-
"new_net",
1368+
"new_nets",
13701369
"base_tag",
13711370
"base_signature",
13721371
"base_options",
13731372
"resolved_base",
1374-
"base_net",
1373+
"base_nets",
13751374
"sprt",
13761375
"num_games",
13771376
"spsa",

server/tests/test_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def new_run(self, add_tasks=0):
3939
msg_new="Super stuff",
4040
base_signature="123456",
4141
new_signature="654321",
42-
base_net="nn-0000000000a0.nnue",
43-
new_net="nn-0000000000a0.nnue",
42+
base_nets=["nn-0000000000a0.nnue"],
43+
new_nets=["nn-0000000000a0.nnue", "nn-0000000000a1.nnue"],
4444
rescheduled_from="653db116cc309ae839563103",
4545
base_same_as_master=False,
4646
tests_repo="https://google.com",

server/tests/test_rundb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ def test_10_create_run(self):
7272
msg_new="Super stuff",
7373
base_signature="123456",
7474
new_signature="654321",
75-
base_net="nn-0000000000a0.nnue",
76-
new_net="nn-0000000000a0.nnue",
75+
base_nets="nn-0000000000a0.nnue",
76+
new_nets=["nn-0000000000a0.nnue", "nn-0000000000a1.nnue"],
7777
rescheduled_from="653db116cc309ae839563103",
7878
base_same_as_master=False,
7979
tests_repo="https://google.com",

0 commit comments

Comments
 (0)