Implement net files support for NNUE engines (#75)

This commit is contained in:
Volodymyr Shcherbyna authored and GitHub committed 2020-09-04 00:38:47 -04:00
1 parent 74bf5cbb93
commit d55943d77d
5 files changed
+42 -2

No files matched your search

+21 -1
View File
@@ -23,7 +23,6 @@ from __future__ import print_function
import argparse, ast, hashlib, json, math, multiprocessing, os import argparse, ast, hashlib, json, math, multiprocessing, os
import platform, re, requests, shutil, subprocess, sys, time, zipfile import platform, re, requests, shutil, subprocess, sys, time, zipfile
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
HTTP_TIMEOUT = 30 # Timeout in seconds for requests HTTP_TIMEOUT = 30 # Timeout in seconds for requests
@@ -241,6 +240,15 @@ def getEngine(data, engine):
# Cleanup the zipfile directory # Cleanup the zipfile directory
shutil.rmtree('tmp') shutil.rmtree('tmp')
def getNetworkWeights(network):
if network:
fname = pathjoin('Engines', os.path.basename(network)).rstrip('/')
if not os.path.isfile(fname): getFile(network, fname)
return os.path.basename(network)
return None
def getCutechessCommand(arguments, data, nps): def getCutechessCommand(arguments, data, nps):
# Parse options for Dev # Parse options for Dev
@@ -257,6 +265,10 @@ def getCutechessCommand(arguments, data, nps):
devCommand = addExtension(data['test']['dev']['sha']) devCommand = addExtension(data['test']['dev']['sha'])
baseCommand = addExtension(data['test']['base']['sha']) baseCommand = addExtension(data['test']['base']['sha'])
# Download network file(s) if configured
devnetwork = getNetworkWeights(data['test']['dev']['network'])
basenetwork = getNetworkWeights(data['test']['base']['network'])
# Scale the time control for this machine's speed # Scale the time control for this machine's speed
timecontrol = computeAdjustedTimecontrol(arguments, data, nps) timecontrol = computeAdjustedTimecontrol(arguments, data, nps)
@@ -284,12 +296,20 @@ def getCutechessCommand(arguments, data, nps):
'{0}-{1}'.format(data['test']['engine'], data['test']['dev']['name']) '{0}-{1}'.format(data['test']['engine'], data['test']['dev']['name'])
) )
# Add evaluation weights for the Dev engine if specified
if devnetwork:
devflags = devflags + " option.EvalFile=" + devnetwork
# Options for the Base Engine # Options for the Base Engine
baseflags = '-engine dir=Engines/ cmd=./{0} proto={1} tc={2}{3} name={4}'.format( baseflags = '-engine dir=Engines/ cmd=./{0} proto={1} tc={2}{3} name={4}'.format(
baseCommand, data['test']['base']['protocol'], timecontrol, baseoptions, baseCommand, data['test']['base']['protocol'], timecontrol, baseoptions,
'{0}-{1}'.format(data['test']['engine'], data['test']['base']['name']) '{0}-{1}'.format(data['test']['engine'], data['test']['base']['name'])
) )
# Add evaluation weights for the Base engine if specified
if basenetwork:
baseflags = baseflags + " option.EvalFile=" + basenetwork
# Options for opening selection # Options for opening selection
bookflags = '-openings file=Books/{0} format={1} order=random plies=16'.format( bookflags = '-openings file=Books/{0} format={1} order=random plies=16'.format(
data['test']['book']['name'], data['test']['book']['name'].split('.')[-1] data['test']['book']['name'], data['test']['book']['name'].split('.')[-1]
+3
View File
@@ -87,6 +87,9 @@ class Test(Model):
devoptions = CharField(max_length=256) devoptions = CharField(max_length=256)
baseoptions = CharField(max_length=256) baseoptions = CharField(max_length=256)
devnetwork = CharField(max_length=256)
basenetwork = CharField(max_length=256)
bookname = CharField(max_length=32) bookname = CharField(max_length=32)
timecontrol = CharField(max_length=16) timecontrol = CharField(max_length=16)
+10 -1
View File
@@ -203,6 +203,10 @@ def verifyNewTest(request):
if request.POST[field] not in OpenBench.config.OPENBENCH_CONFIG[parent].keys(): if request.POST[field] not in OpenBench.config.OPENBENCH_CONFIG[parent].keys():
errors.append('{0} was not found in the configuration'.format(fieldName)) errors.append('{0} was not found in the configuration'.format(fieldName))
def verifyGithubLink(field, fieldName):
if request.POST[field] and not request.POST[field].startswith('https://github.com/'):
errors.append('{0} must be located on a Github URL'.format(fieldName))
verifications = [ verifications = [
(verifyInteger, 'priority', 'Priority'), (verifyInteger, 'priority', 'Priority'),
(verifyInteger, 'throughput', 'Throughput'), (verifyInteger, 'throughput', 'Throughput'),
@@ -221,6 +225,8 @@ def verifyNewTest(request):
(verifyOptions, 'baseoptions', 'Hash', 'Base Options'), (verifyOptions, 'baseoptions', 'Hash', 'Base Options'),
(verifyConfiguration, 'enginename', 'Engine', 'engines'), (verifyConfiguration, 'enginename', 'Engine', 'engines'),
(verifyConfiguration, 'bookname', 'Book', 'books'), (verifyConfiguration, 'bookname', 'Book', 'books'),
(verifyGithubLink, 'devnetwork', 'Dev Network'),
(verifyGithubLink, 'basenetwork', 'Base Network'),
] ]
for verification in verifications: for verification in verifications:
@@ -245,6 +251,8 @@ def createNewTest(request):
test.source = request.POST['source'] test.source = request.POST['source']
test.devoptions = request.POST['devoptions'] test.devoptions = request.POST['devoptions']
test.baseoptions = request.POST['baseoptions'] test.baseoptions = request.POST['baseoptions']
test.devnetwork = request.POST['devnetwork']
test.basenetwork = request.POST['basenetwork']
test.bookname = request.POST['bookname'] test.bookname = request.POST['bookname']
test.timecontrol = request.POST['timecontrol'] test.timecontrol = request.POST['timecontrol']
test.priority = int(request.POST['priority']) test.priority = int(request.POST['priority'])
@@ -376,12 +384,12 @@ def workloadDictionary(test, result, machine):
'book' : OPENBENCH_CONFIG['books'][test.bookname], 'book' : OPENBENCH_CONFIG['books'][test.bookname],
'timecontrol' : test.timecontrol, 'timecontrol' : test.timecontrol,
'engine' : test.engine, 'engine' : test.engine,
'dev' : { 'dev' : {
'id' : test.dev.id, 'name' : test.dev.name, 'id' : test.dev.id, 'name' : test.dev.name,
'source' : test.dev.source, 'protocol' : test.dev.protocol, 'source' : test.dev.source, 'protocol' : test.dev.protocol,
'sha' : test.dev.sha, 'bench' : test.dev.bench, 'sha' : test.dev.sha, 'bench' : test.dev.bench,
'options' : test.devoptions, 'options' : test.devoptions,
'network' : test.devnetwork,
}, },
'base' : { 'base' : {
@@ -389,6 +397,7 @@ def workloadDictionary(test, result, machine):
'source' : test.base.source, 'protocol' : test.base.protocol, 'source' : test.base.source, 'protocol' : test.base.protocol,
'sha' : test.base.sha, 'bench' : test.base.bench, 'sha' : test.base.sha, 'bench' : test.base.bench,
'options' : test.baseoptions, 'options' : test.baseoptions,
'network' : test.basenetwork,
}, },
}, },
} }
+2
View File
@@ -63,11 +63,13 @@
<label> Bench </label> <input name="devbench"><br> <label> Bench </label> <input name="devbench"><br>
<label> Branch </label> <input name="devbranch" autofocus><br> <label> Branch </label> <input name="devbranch" autofocus><br>
<label> Options </label> <input id="devoptions" name="devoptions"><br> <label> Options </label> <input id="devoptions" name="devoptions"><br>
<label> Network </label> <input name="devnetwork"><br>
<h3> Base Settings </h3> <h3> Base Settings </h3>
<label> Bench </label> <input name="basebench"><br> <label> Bench </label> <input name="basebench"><br>
<label> Branch </label> <input value="master" name="basebranch"><br> <label> Branch </label> <input value="master" name="basebranch"><br>
<label> Options </label> <input id="baseoptions" name="baseoptions"><br> <label> Options </label> <input id="baseoptions" name="baseoptions"><br>
<label> Network </label> <input name="basenetwork"><br>
</div> </div>
+6
View File
@@ -15,10 +15,16 @@
<tr><th>Dev Bench</th><td>{{test.dev.bench}}</td></tr> <tr><th>Dev Bench</th><td>{{test.dev.bench}}</td></tr>
<tr><th>Dev Options</th><td>{{test.devoptions}}</td></tr> <tr><th>Dev Options</th><td>{{test.devoptions}}</td></tr>
<tr><th>Dev Sha</th><td>{{test.dev.sha}}</td></tr> <tr><th>Dev Sha</th><td>{{test.dev.sha}}</td></tr>
{% if test.devnetwork %}
<tr><th>Dev Network</th><td>{{test.devnetwork}}</td></tr>
{% endif %}
<tr><th>Base Branch</th><td>{{test.base.name|prettyName}}</td></tr> <tr><th>Base Branch</th><td>{{test.base.name|prettyName}}</td></tr>
<tr><th>Base Bench</th><td>{{test.base.bench}}</td></tr> <tr><th>Base Bench</th><td>{{test.base.bench}}</td></tr>
<tr><th>Base Options</th><td>{{test.baseoptions}}</td></tr> <tr><th>Base Options</th><td>{{test.baseoptions}}</td></tr>
<tr><th>Base Sha</th><td>{{test.base.sha}}</td></tr> <tr><th>Base Sha</th><td>{{test.base.sha}}</td></tr>
{% if test.basenetwork %}
<tr><th>Base Network</th><td>{{test.basenetwork}}</td></tr>
{% endif %}
<tr><th>Source Repo</th><td>{{test.source}}</td></tr> <tr><th>Source Repo</th><td>{{test.source}}</td></tr>
<tr><th>Opening Book</th><td>{{test.bookname}}</td></tr> <tr><th>Opening Book</th><td>{{test.bookname}}</td></tr>
<tr><th>Time Control</th><td>{{test.timecontrol}}s</td></tr> <tr><th>Time Control</th><td>{{test.timecontrol}}s</td></tr>