Implement support for DATAGEN Workloads through the genfens interface (#200)

This commit is contained in:
Andrew Grant authored and GitHub committed 2024-03-12 21:22:07 -04:00
1 parent 45302fa347
commit 2fcb7329ce
57 files changed
+1096 -131

No files matched your search

+1 -5
View File
@@ -5,8 +5,4 @@ rm -rf PGNS/
rm -rf Networks/
rm -rf __pycache__/
rm machine.txt
rm requirements.txt
rm worker.py
rm cutechess-ob
rm cutechess-ob.exe
rm machine.txt
+133
View File
@@ -0,0 +1,133 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# OpenBench is a chess engine testing framework by Andrew Grant. #
# <https://github.com/AndyGrant/OpenBench> <andrew@grantnet.us> #
# #
# OpenBench is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# OpenBench is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# The sole purpose of this module is to invoke create_genfens_opening_book().
#
# This will execute engines with commands like the following:
# ./engine "genfens N seed S book <None|Books/book.epd> <?exta>" "quit"
#
# This work is split over many engines. If a workload requires 1024 openings,
# and there are 16 threads, then each thread will generate 128 openings. The
# openings are saved to Books/openbench.genfens.epd
#
# create_genfens_opening_book() may raise utils.OpenBenchFailedGenfensException.
# This occurs when longer than 15 seconds has elapsed since getting an opening.
# This should only occur if one or more of the engine processes has stalled.
import math
import os
import queue
import subprocess
import time
import multiprocessing
from utils import kill_process_by_name
from utils import OpenBenchFailedGenfensException
def create_genfens_opening_book(config, binary_name, network):
# Format: ./engine "genfens N seed S book <None|book.epd>" "quit"
N = genfens_required_openings_each(config)
seed = config.workload['test']['book_index']
args = genfens_command_args(config, binary_name, network)
print ('\nGenerating %d Openings using %d Threads...' % (N * config.threads, config.threads))
start_time = time.time()
# Execute all the helpers, who will dump results into the Queue
output = multiprocessing.Queue()
for f in range(config.threads):
command = genfens_command_builder(*args, seed)
multiprocessing.Process(target=genfens_single_threaded, args=(command, output)).start()
seed += N # Step the seed ahead to vary it over the Threads
# Parse the Queue and save the content into Books/openbench.genfens.epd
with open(os.path.join('Books', 'openbench.genfens.epd'), 'w') as fout:
try:
for iteration in range(N * config.threads):
fout.write(output.get(timeout=15) + '\n')
genfens_progress_bar(iteration+1, N * config.threads)
except queue.Empty:
kill_process_by_name(binary_name)
raise OpenBenchFailedGenfensException('[%s] Stalled during genfens' % (binary_name))
print('\nFinished Building Opening Book in %.3f seconds' % (time.time() - start_time))
def genfens_required_openings_each(config):
cutechess_cnt = config.workload['distribution']['cutechess-count']
games_per = config.workload['distribution']['games-per-cutechess']
repeat = config.workload['test']['play_reverses']
total_games = cutechess_cnt * games_per // (1 + repeat)
return math.ceil(total_games / config.threads)
def genfens_command_args(config, binary_name, network):
binary = os.path.join('Engines', binary_name)
private = config.workload['test']['dev']['private']
N = genfens_required_openings_each(config)
book = genfens_book_input_name(config)
extra_args = config.workload['test']['genfens_args']
return (binary, network, private, N, book, extra_args)
def genfens_book_input_name(config):
book_name = config.workload['test']['book']['name']
book_none = book_name.upper() == 'NONE'
return 'None' if book_none else os.path.join('Books', book_name)
def genfens_command_builder(binary, network, private, N, book, extra_args, seed):
command = ['./%s' % (binary)]
if network and private:
command += ['setoption name EvalFile value %s' % (network)]
command += ['genfens %d seed %d book %s %s' % (N, seed, book, extra_args), 'quit']
return command
def genfens_single_threaded(command, queue):
try:
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in iter(process.stdout.readline, b''):
if line.decode('utf-8').startswith('info string genfens '):
queue.put(line.decode('utf-8').split('genfens ')[1].rstrip())
process.wait()
except:
raise
def genfens_progress_bar(curr, total):
prev_progress = int(50 * (curr - 1) / total)
curr_progress = int(50 * (curr - 0) / total)
if curr_progress != prev_progress:
bar_text = '=' * curr_progress + ' ' * (50 - curr_progress)
print ('\r[%s] %d/%d' % (bar_text, curr, total), end='', flush=True)
+21
View File
@@ -28,6 +28,9 @@ import subprocess
import tempfile
import zipfile
IS_WINDOWS = platform.system() == 'Windows' # Don't touch this
IS_LINUX = platform.system() != 'Windows' # Don't touch this
class OpenBenchBuildFailedException(Exception):
def __init__(self, message, logs):
self.message = message
@@ -65,6 +68,20 @@ class OpenBenchBadServerResponseException(Exception):
self.message = ''
super().__init__(self.message)
class OpenBenchFailedGenfensException(Exception):
def __init__(self, message):
self.message = message
super().__init__(self.message)
def kill_process_by_name(process_name):
if IS_LINUX:
subprocess.run(['pkill', '-f', process_name])
if IS_WINDOWS:
subprocess.run(['taskkill', '/f', '/im', process_name])
def url_join(*args, trailing_slash=True):
@@ -200,6 +217,10 @@ def download_opening_book(book_sha, book_source, book_name):
book_path = os.path.join('Books', book_name)
# Datagen workloads might not include a book
if book_name.upper() == 'NONE':
return
# Book might already have been downloaded
if not os.path.exists(book_path):
+49 -24
View File
@@ -50,6 +50,7 @@ from client import try_forever
from utils import *
from pgn_util import compress_list_of_pgns
from genfens import create_genfens_opening_book
## Basic configuration of the Client. These timeouts can be changed at will
@@ -277,7 +278,7 @@ class ServerReporter:
return ServerReporter.report(config, 'clientSubmitError', payload)
@staticmethod
def report_engine_error(config, error, pgn):
def report_engine_error(config, error, pgn=None):
payload = {
'test_id' : config.workload['test']['id'],
@@ -379,8 +380,12 @@ class Cutechess:
is_frc = 'FRC' in book_name or '960' in book_name or 'FISCHER' in book_name
variant = ['standard', 'fischerandom'][is_frc]
# Always include -repeat and -recover
return '-repeat -recover -variant %s' % (variant)
# Only include -repeat if not skipping the reverses in DATAGEN
is_datagen = config.workload['test']['type'] == 'DATAGEN'
no_reverse = is_datagen and not config.workload['test']['play_reverses']
# Always include -recover and -variant
return ['-repeat', ''][no_reverse] + ' -recover -variant %s' % (variant)
@staticmethod
def concurrency_settings(config):
@@ -417,6 +422,15 @@ class Cutechess:
@staticmethod
def book_settings(config, cutechess_idx):
# DATAGEN creates their own book
if config.workload['test']['type'] == 'DATAGEN':
# -repeat might not be applied, so handle the book offsets
no_reverse = not config.workload['test']['play_reverses']
pairs = config.workload['distribution']['games-per-cutechess'] // 2
start = 1 + (cutechess_idx * pairs * (1 + no_reverse))
return '-openings file=Books/openbench.genfens.epd format=epd order=sequential start=%d' % (start)
# Can handle EPD and PGN Books, which must be specified
book_name = config.workload['test']['book']['name']
book_suffix = book_name.split('.')[-1]
@@ -522,14 +536,13 @@ class Cutechess:
def kill_everything(dev_process, base_process):
if IS_LINUX:
subprocess.run(['pkill', '-f', 'cutechess-ob'])
subprocess.run(['pkill', '-f', dev_process])
subprocess.run(['pkill', '-f', base_process])
kill_process_by_name('cutechess-ob')
if IS_WINDOWS:
subprocess.run(['taskkill', '/f', '/im', 'cutechess-ob.exe'])
subprocess.run(['taskkill', '/f', '/im', dev_process])
subprocess.run(['taskkill', '/f', '/im', base_process])
kill_process_by_name('cutechess-ob.exe')
kill_process_by_name(dev_process)
kill_process_by_name(base_process)
@staticmethod
def pgn_name(config, timestamp, cutechess_idx):
@@ -940,16 +953,20 @@ def complete_workload(config):
)
# Download each NNUE file, throws an exception on corruption
dev_network = download_network_weights(config, 'dev' )
base_network = download_network_weights(config, 'base')
dev_network = safe_download_network_weights(config, 'dev' )
base_network = safe_download_network_weights(config, 'base')
# Build or download each engine, or exit if an error occured
dev_name = download_engine(config, 'dev' , dev_network )
base_name = download_engine(config, 'base', base_network)
dev_name = safe_download_engine(config, 'dev' , dev_network )
base_name = safe_download_engine(config, 'base', base_network)
# Datagen creates a book on-the-fly
if config.workload['test']['type'] == 'DATAGEN':
safe_create_genfens_opening_book(config, dev_name, dev_network)
# Run the benchmarks and compute the scaling NPS value
dev_nps = run_benchmarks(config, 'dev' , dev_name , dev_network )
base_nps = run_benchmarks(config, 'base', base_name, base_network)
dev_nps = safe_run_benchmarks(config, 'dev' , dev_name , dev_network )
base_nps = safe_run_benchmarks(config, 'base', base_name, base_network)
ServerReporter.report_nps(config, dev_nps, base_nps)
# Scale the engines together, using their NPS relative to expected
@@ -962,11 +979,6 @@ def complete_workload(config):
print ('Scale Factor Base : %.4f' % (base_factor))
print ('Scale Factor Avg : %.4f' % (avg_factor ))
# Scale using the base factor only, in the event of a cross-engine test
dev_engine = config.workload['test']['dev' ]['engine']
base_engine = config.workload['test']['base']['engine']
scale_factor = base_factor if dev_engine != base_engine else avg_factor
# Server knows how many copies of Cutechess we should run
cutechess_cnt = config.workload['distribution']['cutechess-count']
concurrency_per = config.workload['distribution']['concurrency-per']
@@ -975,7 +987,12 @@ def complete_workload(config):
print () # Record this information
print ('%d cutechess copies' % (cutechess_cnt))
print ('%d concurrent games per copy' % (concurrency_per))
print ('%d total games per cutechess copy' % (games_per))
print ('%d total games per cutechess copy\n' % (games_per))
# Scale using the base factor only, in the event of a cross-engine test
dev_engine = config.workload['test']['dev' ]['engine']
base_engine = config.workload['test']['base']['engine']
scale_factor = base_factor if dev_engine != base_engine else avg_factor
# Launch and manage all of the Cutechess workers
with ThreadPoolExecutor(max_workers=cutechess_cnt) as executor:
@@ -1009,7 +1026,7 @@ def complete_workload(config):
pgn_files = [Cutechess.pgn_name(config, timestamp, x) for x in range(cutechess_cnt)]
ServerReporter.report_pgn(config, compress_list_of_pgns(pgn_files, scale_factor, compact))
def download_network_weights(config, branch):
def safe_download_network_weights(config, branch):
# Wraps utils.py:download_network()
# May raise OpenBenchCorruptedNetworkException
@@ -1028,7 +1045,7 @@ def download_network_weights(config, branch):
return net_path
def download_engine(config, branch, net_path):
def safe_download_engine(config, branch, net_path):
# Wraps utils.py:download_public_engine() and utils.py:download_private_engine()
@@ -1070,8 +1087,15 @@ def download_engine(config, branch, net_path):
ServerReporter.report_build_fail(config, branch, error.logs)
raise
def safe_create_genfens_opening_book(config, dev_name, dev_network):
def run_benchmarks(config, branch, engine, network):
try: create_genfens_opening_book(config, dev_name, dev_network)
except OpenBenchFailedGenfensException as error:
ServerReporter.report_engine_error(config, error.message)
raise
def safe_run_benchmarks(config, branch, engine, network):
name = config.workload['test'][branch]['name']
private = config.workload['test'][branch]['private']
@@ -1091,6 +1115,7 @@ def run_benchmarks(config, branch, engine, network):
print('Speed for %s is %d' % (name, speed))
return speed
def build_cutechess_command(config, dev_cmd, base_cmd, scale_factor, timestamp, cutechess_idx):
flags = ' ' + Cutechess.basic_settings(config)
+1 -1
View File
@@ -1,7 +1,7 @@
{
"client_version" : 26,
"client_repo_url" : "https://github.com/AndyGrant/OpenBench",
"client_repo_ref" : "master",
"client_repo_ref" : "datagen",
"use_cross_approval" : false,
"require_login_to_view" : false,
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -72,5 +72,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -67,5 +67,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -71,5 +71,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -87,5 +87,19 @@
"dev_options" : "Threads=1 Hash=8",
"dev_time_control" : "10.0+0.10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -65,5 +65,19 @@
"dev_options" : "Threads=1 Hash=8",
"dev_time_control" : "10.0+0.10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -81,5 +81,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -129,5 +129,19 @@
"dev_options" : "Threads=1 Hash=128 Minimal=true",
"dev_time_control" : "180.0+1.80"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -73,5 +73,19 @@
"dev_options" : "Threads=1 Hash=128",
"dev_time_control" : "180.0+1.80"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -71,5 +71,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"dev_options" : "Threads=1 Hash=64",
"dev_time_control" : "30.0+0.30"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -71,5 +71,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -71,5 +71,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -99,5 +99,19 @@
"win_adj" : "movecount=5 score=600",
"draw_adj" : "movenumber=32 movecount=6 score=15"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -71,5 +71,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -71,5 +71,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -129,5 +129,19 @@
"dev_options" : "Threads=1 Hash=128 Minimal=true",
"dev_time_control" : "180.0+1.80"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+35 -1
View File
@@ -77,9 +77,43 @@
"tune_presets" : {
"default" : {
"book_name" : "Pohl.epd",
"book_name" : "UHO_4060_v2.epd",
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
},
"STC" : {
"dev_options" : "Threads=1 Hash=8",
"dev_time_control" : "10.0+0.10"
},
"MTC" : {
"dev_options" : "Threads=1 Hash=32",
"dev_time_control" : "30.0+0.30"
},
"LTC" : {
"dev_options" : "Threads=1 Hash=64",
"dev_time_control" : "60.0+0.60"
},
"VLTC" : {
"dev_options" : "Threads=1 Hash=128",
"dev_time_control" : "180.0+1.80"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -71,5 +71,19 @@
"win_adj" : "None",
"draw_adj" : "None"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -77,5 +77,19 @@
"dev_options" : "Threads=1 Hash=128",
"dev_time_control" : "40.0+0.4"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -41,5 +41,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+14
View File
@@ -53,5 +53,19 @@
"win_adj" : "movecount=3 score=400",
"draw_adj" : "movenumber=40 movecount=8 score=10"
}
},
"datagen_presets" : {
"default" : {
"win_adj" : "None",
"draw_adj" : "None",
"workload_size" : 128
},
"40k Nodes" : {
"both_options" : "Threads=1 Hash=16",
"both_time_control" : "N=40000"
}
}
}
+47 -1
View File
@@ -25,7 +25,7 @@ import traceback
from OpenSite.settings import PROJECT_PATH
OPENBENCH_STATIC_VERSION = 'v2'
OPENBENCH_STATIC_VERSION = 'v3'
OPENBENCH_CONFIG = None # Initialized by OpenBench/apps.py
@@ -67,6 +67,7 @@ def load_engine_config(engine_name):
assert 'default' in conf['test_presets'].keys()
assert 'default' in conf['tune_presets'].keys()
assert 'default' in conf['datagen_presets'].keys()
for key, test_preset in conf['test_presets'].items():
verify_engine_test_preset(test_preset)
@@ -74,6 +75,9 @@ def load_engine_config(engine_name):
for key, tune_preset in conf['tune_presets'].items():
verify_engine_tune_preset(tune_preset)
for key, datagen_preset in conf['datagen_presets'].items():
verify_engine_datagen_preset(datagen_preset)
except Exception as error:
traceback.print_exc()
print ('%s has errors on the configuration json' % (engine_name))
@@ -191,3 +195,45 @@ def verify_engine_tune_preset(tune_preset):
for key in tune_preset.keys():
if key not in valid_keys:
raise Exception('Contains invalid key: %s' % (key))
def verify_engine_datagen_preset(datagen_preset):
valid_keys = [
'both_branch',
'both_bench',
'both_network',
'both_options',
'both_time_control',
'dev_branch',
'dev_bench',
'dev_network',
'dev_options',
'dev_time_control',
'base_branch',
'base_bench',
'base_network',
'base_options',
'base_time_control',
'book_name',
'upload_pgns',
'priority',
'throughput',
'workload_size',
'syzygy_wdl',
'syzygy_adj',
'win_adj',
'draw_adj',
'datagen_custom_genfens',
'datagen_play_reverses',
'datagen_max_games',
]
for key in datagen_preset.keys():
if key not in valid_keys:
raise Exception('Contains invalid key: %s' % (key))
+13 -11
View File
@@ -126,17 +126,19 @@ class Test(Model):
win_adj = CharField(max_length=64, default='movecount=3 score=400')
draw_adj = CharField(max_length=64, default='movenumber=40 movecount=8 score=10')
# Test Mode specific values, either SPRT or GAMES
test_mode = CharField(max_length=16, default='SPRT')
elolower = FloatField(default=0.0) # SPRT
eloupper = FloatField(default=0.0) # SPRT
alpha = FloatField(default=0.0) # SPRT
beta = FloatField(default=0.0) # SPRT
lowerllr = FloatField(default=0.0) # SPRT
currentllr = FloatField(default=0.0) # SPRT
upperllr = FloatField(default=0.0) # SPRT
max_games = IntegerField(default=0) # GAMES
spsa = JSONField(default=dict, blank=True, null=True) # SPSA
# Test Mode specific values, either SPRT, GAMES, SPSA, or DATAGEN
test_mode = CharField(max_length=16, default='SPRT')
elolower = FloatField(default=0.0) # SPRT
eloupper = FloatField(default=0.0) # SPRT
alpha = FloatField(default=0.0) # SPRT
beta = FloatField(default=0.0) # SPRT
lowerllr = FloatField(default=0.0) # SPRT
currentllr = FloatField(default=0.0) # SPRT
upperllr = FloatField(default=0.0) # SPRT
max_games = IntegerField(default=0) # GAMES or DATAGEN
spsa = JSONField(default=dict, blank=True, null=True) # SPSA
genfens_args = CharField(max_length=256, default='') # DATAGEN
play_reverses = BooleanField(default=False) # DATAGEN
# Collection of all individual Result() objects
games = IntegerField(default=0) # Overall
+9 -7
View File
@@ -43,8 +43,9 @@ function create_preset_buttons(engine, workload_type) {
while (button_div.hasChildNodes())
button_div.removeChild(button_div.lastChild);
const presets = workload_type == 'TEST' ? config.engines[engine].test_presets
: workload_type == 'TUNE' ? config.engines[engine].tune_presets : {};
const presets = workload_type == 'TEST' ? config.engines[engine].test_presets
: workload_type == 'TUNE' ? config.engines[engine].tune_presets
: workload_type == 'DATAGEN' ? config.engines[engine].datagen_presets : {};
var index = 0;
for (let mode in presets) {
@@ -94,8 +95,9 @@ function get_base_engine() {
}
function get_presets(engine, preset, workload_type) {
return workload_type == 'TEST' ? config.engines[engine].test_presets[preset]
: workload_type == 'TUNE' ? config.engines[engine].tune_presets[preset] : {};
return workload_type == 'TEST' ? config.engines[engine].test_presets[preset]
: workload_type == 'TUNE' ? config.engines[engine].tune_presets[preset]
: workload_type == 'DATAGEN' ? config.engines[engine].datagen_presets[preset] : {};
}
@@ -205,14 +207,14 @@ function apply_preset(preset, workload_type) {
else {
set_option(option.replace('both_', 'dev_'), settings[option]);
if (workload_type != 'TUNE')
if (workload_type == 'TEST' || workload_type == "DATAGEN")
set_option(option.replace('both_', 'base_'), settings[option]);
}
}
// For cross-engine tests, keep the original Hash/Threads, but
// add any other settings that might be specific to the engine
if (workload_type != 'TUNE') {
if (workload_type == 'TEST' || workload_type == "DATAGEN") {
try {
retain_specific_options(get_base_engine(), preset, workload_type);
} catch (error) {}
@@ -226,7 +228,7 @@ function change_engine(engine, target, workload_type) {
if (target == 'dev')
create_preset_buttons(engine, workload_type);
if (target == 'dev' && workload_type == 'TEST')
if (target == 'dev' && (workload_type == 'TEST' || workload_type == 'DATAGEN'))
set_engine(engine, 'base');
apply_preset('STC', workload_type);
+23 -23
View File
@@ -60,30 +60,32 @@ def gitDiffLink(test):
def shortStatBlock(test):
if test.test_mode == 'SPSA':
return '\n'.join([
'Tuning %d Parameters' % (len(test.spsa['parameters'].keys())),
'%d/%d Iterations' % (test.games / (2 * test.spsa['pairs_per']), test.spsa['iterations']),
'%d/%d Games Played' % (test.games, 2 * test.spsa['iterations'] * test.spsa['pairs_per'])])
if test.test_mode == 'SPRT':
top_line = 'LLR: %0.2f (%0.2f, %0.2f) [%0.2f, %0.2f]' % (
test.currentllr, test.lowerllr, test.upperllr, test.elolower, test.eloupper)
if test.test_mode == 'GAMES':
lower, elo, upper = OpenBench.stats.ELO([test.losses, test.draws, test.wins])
top_line = 'Elo: %0.2f +- %0.2f (95%%) [N=%d]' % (elo, max(upper - elo, elo - lower), test.max_games)
tri_line = 'Games: %d W: %d L: %d D: %d' % (test.games, test.wins, test.losses, test.draws)
penta_line = 'Pntml(0-2): %d, %d, %d, %d, %d' % (test.LL, test.LD, test.DD, test.DW, test.WW)
if test.use_penta:
return '\n'.join([top_line, tri_line, penta_line])
if test.test_mode == 'SPSA':
statlines = [
'Tuning %d Parameters' % (len(test.spsa['parameters'].keys())),
'%d/%d Iterations' % (test.games / (2 * test.spsa['pairs_per']), test.spsa['iterations']),
'%d/%d Games Played' % (test.games, 2 * test.spsa['iterations'] * test.spsa['pairs_per'])]
if test.use_tri:
return '\n'.join([top_line, tri_line])
elif test.test_mode == 'SPRT':
llr_line = 'LLR: %0.2f (%0.2f, %0.2f) [%0.2f, %0.2f]' % (
test.currentllr, test.lowerllr, test.upperllr, test.elolower, test.eloupper)
statlines = [llr_line, tri_line, penta_line] if test.use_penta else [llr_line, tri_line]
return 'Test uses neither Trinomoal nor Pentanomial'
elif test.test_mode == 'GAMES':
lower, elo, upper = OpenBench.stats.ELO([test.losses, test.draws, test.wins])
elo_line = 'Elo: %0.2f +- %0.2f (95%%) [N=%d]' % (elo, max(upper - elo, elo - lower), test.max_games)
statlines = [elo_line, tri_line, penta_line] if test.use_penta else [elo_line, tri_line]
elif test.test_mode == 'DATAGEN':
status_line = 'Generated %d/%d Games' % (test.games, test.max_games)
lower, elo, upper = OpenBench.stats.ELO([test.losses, test.draws, test.wins])
elo_line = 'Elo: %0.2f +- %0.2f (95%%) [N=%d]' % (elo, max(upper - elo, elo - lower), test.max_games)
statlines = [status_line, elo_line, penta_line] if test.use_penta else [status_line, elo_line, tri_line]
return '\n'.join(statlines)
def longStatBlock(test):
@@ -92,13 +94,13 @@ def longStatBlock(test):
threads = int(OpenBench.utils.extract_option(test.dev_options, 'Threads'))
hashmb = int(OpenBench.utils.extract_option(test.dev_options, 'Hash'))
timecontrol = test.dev_time_control + ['s', '']['=' in test.dev_time_control]
test_type = 'SPRT' if test.test_mode == 'SPRT' else 'Conf'
type_text = 'SPRT' if test.test_mode == 'SPRT' else 'Conf'
lower, elo, upper = OpenBench.stats.ELO([test.losses, test.draws, test.wins])
lines = [
'Elo | %0.2f +- %0.2f (95%%)' % (elo, max(upper - elo, elo - lower)),
'%-5s | %s Threads=%d Hash=%dMB' % (test_type, timecontrol, threads, hashmb),
'%-5s | %s Threads=%d Hash=%dMB' % (type_text, timecontrol, threads, hashmb),
]
if test.test_mode == 'SPRT':
@@ -112,8 +114,6 @@ def longStatBlock(test):
return '\n'.join(lines)
return 'Test uses neither Trinomoal nor Pentanomial'
def testResultColour(test):
if test.passed:
+5
View File
@@ -58,6 +58,11 @@ urlpatterns = [
django.urls.path(r'tune/<int:id>/<str:action>', OpenBench.views.tune),
django.urls.path(r'newTune/', OpenBench.views.create_tune),
# Links for viewing and managing datagen
django.urls.path(r'datagen/<int:id>/', OpenBench.views.datagen),
django.urls.path(r'datagen/<int:id>/<str:action>', OpenBench.views.datagen),
django.urls.path(r'newDatagen/', OpenBench.views.create_datagen),
# Links for viewing and managing Networks
django.urls.path(r'networks/', OpenBench.views.networks),
django.urls.path(r'networks/<str:engine>/', OpenBench.views.networks),
+5
View File
@@ -469,6 +469,11 @@ def update_test(request, machine):
test.finished = test.games >= 2 * test.spsa['pairs_per'] * test.spsa['iterations']
elif test.test_mode == 'DATAGEN':
# Finished, and always passing, for a completed DATAGEN Workload
test.passed = test.finished = test.games >= test.max_games
test.save()
# Update Result object; No risk from concurrent access
+32 -1
View File
@@ -473,9 +473,13 @@ def test(request, id, action=None):
return redirect(request, '/index/', error='No such Test exists')
# Verify that it is indeed a Test and not a Tune
if test.test_mode != 'SPRT' and test.test_mode != 'GAMES':
if test.test_mode == 'TUNE':
return redirect(request, '/tune/%d' % (id))
# Verify that it is indeed a Test and not Datagen
if test.test_mode == 'DATAGEN':
return redirect(request, '/datagen/%d' % (id))
return view_workload(request, test, 'TEST')
def tune(request, id, action=None):
@@ -492,14 +496,41 @@ def tune(request, id, action=None):
if tune.test_mode == 'SPRT' or tune.test_mode == 'GAMES':
return redirect(request, '/test/%d' % (id))
# Verify that it is indeed a Tune and not Datagen
if tune.test_mode == 'DATAGEN':
return redirect(request, '/datagen/%d' % (id))
return view_workload(request, tune, 'TUNE')
def datagen(request, id, action=None):
# Request is to modify or interact with the Datagen
if action != None:
return modify_workload(request, id, action)
# Verify that the Datagen id exists
if not (datagen := Test.objects.filter(id=id).first()):
return redirect(request, '/index/', error='No such Datagen exists')
# Verify that it is indeed a Datagen and not a Tune
if datagen.test_mode == 'TUNE':
return redirect(request, '/tune/%d' % (id))
# Verify that it is indeed a Datagen and not a Test
if datagen.test_mode == 'SPRT' or datagen.test_mode == 'GAMES':
return redirect(request, '/test/%d' % (id))
return view_workload(request, datagen, 'DATAGEN')
def create_test(request):
return create_workload(request, 'TEST')
def create_tune(request):
return create_workload(request, 'TUNE')
def create_datagen(request):
return create_workload(request, 'DATAGEN')
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# NETWORK MANAGEMENT VIEWS #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+76 -5
View File
@@ -40,7 +40,7 @@ from OpenBench.workloads.verify_workload import verify_workload
def create_workload(request, workload_type):
assert workload_type in [ 'TEST', 'TUNE' ]
assert workload_type in [ 'TEST', 'TUNE', 'DATAGEN' ]
if not request.user.is_authenticated:
return OpenBench.views.redirect(request, '/login/', error='Only enabled users can create tests')
@@ -66,17 +66,27 @@ def create_workload(request, workload_type):
data['submit_text'] = 'Create SPSA Tune'
data['submit_endpoint'] = '/newTune/'
if workload_type == 'DATAGEN':
data['workload'] = workload_type
data['dev_text'] = 'Dev'
data['dev_title_text'] = 'Dev'
data['submit_text'] = 'Create Datagen'
data['submit_endpoint'] = '/newDatagen/'
return OpenBench.views.render(request, 'create_workload.html', data)
if workload_type == 'TEST':
workload, errors = create_new_test(request)
if workload_type == 'TUNE':
elif workload_type == 'TUNE':
workload, errors = create_new_tune(request)
elif workload_type == 'DATAGEN':
workload, errors = create_new_datagen(request)
if errors != [] and errors != None:
url = '/newTest/' if workload_type == 'TEST' else '/newTune/'
return OpenBench.views.redirect(request, url, error='\n'.join(errors))
paths = { 'TEST' : '/newTest/', 'TUNE' : '/newTune/', 'DATAGEN' : '/newDatagen/' }
return OpenBench.views.redirect(request, paths[workload_type], error='\n'.join(errors))
if warning := OpenBench.utils.branch_is_out_of_date(workload):
warning = 'Consider Rebasing: Dev (%s) appears behind Base (%s)' % (workload.dev.name, workload.base.name)
@@ -91,7 +101,6 @@ def create_workload(request, workload_type):
return OpenBench.views.redirect(request, '/index/', warning=warning)
def create_new_test(request):
# Collects erros, and collects all data from the Github API
@@ -205,6 +214,68 @@ def create_new_tune(request):
return test, None
def create_new_datagen(request):
# Collects erros, and collects all data from the Github API
errors, engine_info = verify_workload(request, 'DATAGEN')
dev_info, dev_has_all = engine_info[0]
base_ingo, base_has_all = engine_info[1]
if errors:
return None, errors
test = Test()
test.author = request.user.username
test.book_name = request.POST['book_name']
test.upload_pgns = request.POST['upload_pgns']
test.dev = get_engine(*dev_info)
test.dev_repo = request.POST['dev_repo']
test.dev_engine = request.POST['dev_engine']
test.dev_options = request.POST['dev_options']
test.dev_network = request.POST['dev_network']
test.dev_time_control = OpenBench.utils.TimeControl.parse(request.POST['dev_time_control'])
test.base = get_engine(*base_ingo)
test.base_repo = request.POST['base_repo']
test.base_engine = request.POST['base_engine']
test.base_options = request.POST['base_options']
test.base_network = request.POST['base_network']
test.base_time_control = OpenBench.utils.TimeControl.parse(request.POST['base_time_control'])
test.max_games = int(request.POST['datagen_max_games'])
test.genfens_args = request.POST['datagen_custom_genfens']
test.play_reverses = request.POST['datagen_play_reverses'] == 'YES'
test.workload_size = int(request.POST['workload_size'])
test.priority = int(request.POST['priority'])
test.throughput = int(request.POST['throughput'])
test.syzygy_wdl = request.POST['syzygy_wdl']
test.syzygy_adj = request.POST['syzygy_adj']
test.win_adj = request.POST['win_adj']
test.draw_adj = request.POST['draw_adj']
test.test_mode = 'DATAGEN'
test.awaiting = not (dev_has_all and base_has_all)
test.use_tri = not test.play_reverses
test.use_penta = test.play_reverses
if test.dev_network:
test.dev_netname = Network.objects.get(engine=test.dev_engine, sha256=test.dev_network).name
if test.base_network:
test.base_netname = Network.objects.get(engine=test.base_engine, sha256=test.base_network).name
test.save()
profile = Profile.objects.get(user=request.user)
profile.tests += 1
profile.save()
return test, None
def extract_spas_params(request):
spsa = {} # SPSA Hyperparams
+10 -30
View File
@@ -35,7 +35,6 @@ from OpenBench.models import Result, Test
from django.db import transaction
def get_workload(machine):
# Select a workload from the possible ones, if we can
@@ -191,12 +190,14 @@ def workload_to_dictionary(test, result, machine):
'draw_adj' : test.draw_adj,
'workload_size' : test.workload_size,
'upload_pgns' : test.upload_pgns,
'genfens_args' : test.genfens_args,
'play_reverses' : test.play_reverses,
}
workload['test']['book'] = {
'name' : test.book_name,
'sha' : OPENBENCH_CONFIG['books'][test.book_name]['sha'],
'source' : OPENBENCH_CONFIG['books'][test.book_name]['source'],
'sha' : OPENBENCH_CONFIG['books'].get(test.book_name, { 'sha' : None })['sha' ],
'source' : OPENBENCH_CONFIG['books'].get(test.book_name, { 'source' : None })['source'],
}
workload['test']['dev'] = {
@@ -244,7 +245,11 @@ def workload_to_dictionary(test, result, machine):
cutechess_cnt = workload['distribution']['cutechess-count']
pairs_per_cnt = workload['distribution']['games-per-cutechess'] // 2
test.book_index += cutechess_cnt * pairs_per_cnt
if test.test_mode == 'DATAGEN' and not test.play_reverses:
test.book_index += cutechess_cnt * pairs_per_cnt * 2
else:
test.book_index += cutechess_cnt * pairs_per_cnt
test.save()
return workload
@@ -350,29 +355,4 @@ def game_distribution(test, machine):
'cutechess-count' : spsa_count if is_multiple_spsa else worker_sockets,
'concurrency-per' : 2 if is_multiple_spsa else max_concurrency,
'games-per-cutechess' : 2 * test.workload_size * (1 if is_multiple_spsa else max_concurrency),
}
def effective_allocation(tests, distribution):
# We track the "ratio" of threads relative to the effective-throughput (ETP) of a test.
# This is used to determine which tests have more or less resources, relative to each
# other, when taking into account the ETP.
#
# The ETP is just the throughput of a test by default. The 'balance_engine_throughputs'
# option in the main configuration file will scale the throughput of each test in relation
# to the number of tests that exist for the same engine.
#
# For example: Suppose there are four tests, each with Throughput=1000. Three of the tests
# are for Ethereal, and one is for Laser. When computing resources, the Throughput of the
# Ethereal tests will be scaled down by a factor of 3.
# Count of total tests, and total throughput, for each engine
engines = set([x.dev_engine for x in tests])
test_count = { engine : sum(x.dev_engine == engine for x in tests) for engine in engines }
# Ignore the test_count entirely when not doing engine balancing
if not OPENBENCH_CONFIG['balance_engine_throughputs']:
test_count = { engine : 1 for engine in engines }
# Threads working on the test, per unit of effective-throughput
return [distribution[x.id]['threads'] / (x.throughput / test_count[x.dev_engine]) for x in tests]
}
-1
View File
@@ -62,7 +62,6 @@ def modify_workload(request, id, action=None):
# Send back to the index, notifying them of the success
return OpenBench.views.redirect(request, '/index/', status=message)
def approve_workload(request, profile, workload):
workload.approved = True;
return 'Workload was Approved!'
+76 -4
View File
@@ -21,9 +21,9 @@
# Module serves a singular purpose, to invoke:
# >>> verify_workload(request, type)
#
# Given a request, and a workload_type [TEST, TUNE], verify all of the form
# inputs, collect all of the information from Github, verify all of the data
# from Github, and return a tuple of (errors, engines)
# Given a request, and a workload_type [TEST, TUNE, DATAGEN], verify all of
# the form inputs, collect all of the information from Github, verify all of
# the data from Github, and return a tuple of (errors, engines)
#
# For Verifying and Collection information on a Test:
# >>> errors, engine_info = verify_workload(request, 'TEST')
@@ -31,6 +31,10 @@
#
# For Verifying and Collection information on a Tune:
# >>> errors, engine_info = verify_workload(request, 'TUNE')
#
# For Verifying and Collection information on Datagen:
# >>> errors, engine_info = verify_workload(request, 'DATAGEN')
# >>> dev_info, base_info = engine_info
import os
import re
@@ -44,7 +48,7 @@ from OpenBench.models import *
def verify_workload(request, workload_type):
assert workload_type in [ 'TEST', 'TUNE' ]
assert workload_type in [ 'TEST', 'TUNE', 'DATAGEN' ]
errors = []
@@ -59,6 +63,11 @@ def verify_workload(request, workload_type):
engine = collect_github_info(errors, request, 'dev')
return errors, engine
if workload_type == 'DATAGEN':
verify_datagen_creation(errors, request)
dev = collect_github_info(errors, request, 'dev')
base = collect_github_info(errors, request, 'base')
return errors, (dev, base)
def verify_test_creation(errors, request):
@@ -153,6 +162,51 @@ def verify_tune_creation(errors, request):
for verification in verifications:
verification[0](errors, request, *verification[1:])
def verify_datagen_creation(errors, request):
verifications = [
# Verify everything about the Dev Engine
(verify_configuration , 'dev_engine', 'Dev Engine', 'engines'),
(verify_github_repo , 'dev_repo'),
(verify_network , 'dev_network', 'Dev Network', 'dev_engine'),
(verify_options , 'dev_options', 'Threads', 'Dev Options'),
(verify_options , 'dev_options', 'Hash', 'Dev Options'),
(verify_time_control , 'dev_time_control', 'Dev Time Control'),
# Verify everything about the Base Engine
(verify_configuration , 'base_engine', 'Base Engine', 'engines'),
(verify_github_repo , 'base_repo'),
(verify_network , 'base_network', 'Base Network', 'base_engine'),
(verify_options , 'base_options', 'Threads', 'Base Options'),
(verify_options , 'base_options', 'Hash', 'Base Options'),
(verify_time_control , 'base_time_control', 'Base Time Control'),
# Verify everything about the Datagen Settings
(verify_datagen_games , 'datagen_max_games'),
(verify_datagen_genfens, 'datagen_custom_genfens'),
(verify_datagen_reverse, 'datagen_play_reverses'),
(verify_datagen_book , 'book_name', 'Book', 'books'),
(verify_upload_pgns , 'upload_pgns', 'Upload PGNs'),
# Verify everything about the General Settings
(verify_integer , 'priority', 'Priority'),
(verify_greater_than , 'throughput', 'Throughput', 0),
(verify_syzygy_field , 'syzygy_wdl', 'Syzygy WDL'),
# Verify everything about the Workload Settings
(verify_integer , 'workload_size', 'Workload Size'),
(verify_greater_than , 'workload_size', 'Workload Size', 0),
# Verify everything about the Adjudicaton Settings
(verify_syzygy_field , 'syzygy_adj', 'Syzygy Adjudication'),
(verify_win_adj , 'win_adj'),
(verify_draw_adj , 'draw_adj'),
]
for verification in verifications:
verification[0](errors, request, *verification[1:])
def verify_integer(errors, request, field, field_name):
try: int(request.POST[field])
@@ -276,6 +330,24 @@ def verify_upload_pgns(errors, request, field, field_name):
try: request.POST[field] in ['FALSE', 'COMPACT', 'VERBOSE']
except: errors.append('"%s" must be FALSE, COMPACT, or VERBOSE' % (field_name))
def verify_datagen_games(errors, request, field):
try: assert int(request.POST[field]) > 0
except: errors.append('Data Generation must last for at least one game')
def verify_datagen_genfens(errors, request, field):
try: assert '"' not in request.POST[field]
except: errors.append('Quotes are not allowed in genfens args')
def verify_datagen_reverse(errors, request, field):
try: assert request.POST[field] in ['YES', 'NO']
except: errors.append('Play Reverses must either be YES or NO')
def verify_datagen_book(errors, request, field, field_name, parent):
try:
valid = ['NONE'] + list(OpenBench.config.OPENBENCH_CONFIG[parent].keys())
assert request.POST[field] in valid
except: errors.append('{0} was neither NONE nor found in the configuration'.format(field_name))
def collect_github_info(errors, request, field):
+8 -5
View File
@@ -21,8 +21,9 @@
# Module serves a singular purpose, to invoke:
# >>> view_workload(request, workload, type)
#
# A Workload can be a "TEST", which is an SPRT, or FIXED type.
# A Workload can be a "TEST", which is an SPRT, or FIXED type
# A Workload can be a "TUNE", which is an SPSA tuning session
# A Workload can be a "DATAGEN", which is a Data Generation session
import datetime
import OpenBench.views
@@ -32,7 +33,7 @@ from OpenBench.models import *
def view_workload(request, workload, workload_type):
assert workload_type in [ 'TEST', 'TUNE' ]
assert workload_type in [ 'TEST', 'TUNE', 'DATAGEN' ]
data = {
'workload' : workload,
@@ -40,17 +41,19 @@ def view_workload(request, workload, workload_type):
}
for result in Result.objects.filter(test=workload):
data['results'].append({ 'data' : result, 'active' : is_active(result) })
data['results'].append({ 'data' : result, 'active' : is_active(result) })
if workload_type == 'TEST':
data['type'] = workload_type
data['dev_text'] = 'Dev'
data['submit_endpoint'] = '/newTest/'
if workload_type == 'TUNE':
data['type'] = workload_type
data['dev_text'] = ''
data['submit_endpoint'] = '/newTune/'
if workload_type == 'DATAGEN':
data['type'] = workload_type
data['dev_text'] = 'Dev'
return OpenBench.views.render(request, 'workload.html', data)
+1
View File
@@ -94,6 +94,7 @@
<li class="header">Actions</li>
<li><a href="/newTest"><i class="fa-solid fa-plus fa-fw"></i> Create Test</a></li>
<li><a href="/newTune"><i class="fa-solid fa-vial fa-fw"></i> Create Tune</a></li>
<li><a href="/newDatagen"><i class="fa-solid fa-database fa-fw"></i> Create Datagen</a></li>
<li><a href="/newNetwork"><i class="fa-solid fa-upload fa-fw"></i> Upload Net</a></li>
</ul>
+32 -6
View File
@@ -45,7 +45,7 @@
<label for="dev_repo"> {{dev_text}} Source </label> <input id="dev_repo" name="dev_repo">
</div>
{% if workload == "TEST" %}
{% if workload == "TEST" or workload == "DATAGEN" %}
<div class="row">
<label for="base_engine"> Base Engine </label>
<select id="base_engine" name="base_engine" onchange="change_engine(value, 'base', '{{workload}}');">
@@ -78,7 +78,7 @@
<label for="dev_time_control"> {{dev_text}} Time </label> <input id="dev_time_control" name="dev_time_control">
</div>
{% if workload == "TEST" %}
{% if workload == "TEST" or workload == "DATAGEN" %}
<h3> Base Settings </h3>
@@ -174,12 +174,33 @@
<label for="spsa_pairs_per"> Pairs-Per </label> <input value="8" id="spsa_pairs_per" name="spsa_pairs_per">
</div>
{% elif workload == "DATAGEN" %}
<h3> Datagen Settings </h3>
<div class="row">
<label for="datagen_max_games"> Max Games </label> <input id="datagen_max_games" name="datagen_max_games">
</div>
<div class="row">
<label for="datagen_custom_genfens"> Genfens Args </label> <input id="datagen_custom_genfens" name="datagen_custom_genfens">
</div>
<div class="row">
<label for="test_mode"> Play Reverses </label>
<select id="datagen_play_reverses" name="datagen_play_reverses">
<option value="YES"> Yes </option>
<option selected value="NO"> No </option>
</select>
</div>
{% endif %}
<h3> General Settings </h3>
<div class="row">
<label for="book_name"> Opening Book </label> <select id="book_name" name="book_name">
<option selected value="NONE"> None </option>
{% for name, data in config.books.items %}
<option value="{{ name }}">{{ name }}</option>
{% endfor %}
@@ -189,9 +210,14 @@
<div class="row">
<label for="upload_pgns"> Upload PGNs </label>
<select id="upload_pgns" name="upload_pgns">
<option selected value="FALSE"> False </option>
<option value="COMPACT"> Compact </option>
<option value="VERBOSE"> Verbose </option>
{% if workload == "DATAGEN" %}
<option selected value="COMPACT"> Compact </option>
<option value="VERBOSE"> Verbose </option>
{% else %}
<option selected value="FALSE"> False </option>
<option value="COMPACT"> Compact </option>
<option value="VERBOSE"> Verbose </option>
{% endif %}
</select>
</div>
@@ -203,7 +229,7 @@
<label for="throughput"> Throughput </label> <input value="1000" id="throughput" , name="throughput">
</div>
{% if workload == "TEST" %}
{% if workload == "TEST" or workload == "DATAGEN" %}
<div class="row">
<label for="workload_size"> Workload Size </label> <input id="workload_size" name="workload_size">
</div>
+15 -6
View File
@@ -18,7 +18,6 @@
<tr><td class="td-label">Creation</td><td class="timestamp">{{workload.creation|date:'U'}}</td></tr>
<!-- All of the Dev Engine ( or Sole Engine ) information -->
<tr><td class="td-label">{{dev_text}} Engine</td><td>{{workload.dev_engine}}</td></tr>
<tr><td class="td-label">{{dev_text}} Source</td><td><a href="{{workload.dev_repo}}">{{workload.dev_repo}}</a></td></tr>
<tr><td class="td-label">{{dev_text}} Sha</td><td>{{workload.dev.sha}}</td></tr>
<tr><td class="td-label">{{dev_text}} Branch</td><td class="branch_name">{{workload.dev.name|prettyName}}</td></tr>
@@ -28,8 +27,7 @@
<tr><td class="td-label">{{dev_text}} Time</td><td>{{workload.dev_time_control}}</td></tr>
<!-- All of the Base Engine information, which only exists for TESTs -->
{% if type == "TEST" %}
<tr><td class="td-label">Base Engine</td><td>{{workload.base_engine}}</td></tr>
{% if type == "TEST" or type == "DATAGEN" %}
<tr><td class="td-label">Base Source</td><td><a href="{{workload.base_repo}}">{{workload.base_repo}}</a></td></tr>
<tr><td class="td-label">Base Sha</td><td>{{workload.base.sha}}</td></tr>
<tr><td class="td-label">Base Branch</td><td class="branch_name">{{workload.base.name|prettyName}}</td></tr>
@@ -39,7 +37,12 @@
<tr><td class="td-label">Base Time</td><td>{{workload.base_time_control}}</td></tr>
{% endif %}
<tr><td class="td-label">Opening Book</td><td><a href="{{workload|book_download_link}}">{{workload.book_name}}</a></td></tr>
{% if workload|book_download_link %}
<tr><td class="td-label">Opening Book</td><td><a href="{{workload|book_download_link}}">{{workload.book_name}}</a></td></tr>
{% else %}
<tr><td class="td-label">Opening Book</td><td><a>{{workload.book_name}}</a></td></tr>
{% endif %}
<tr><td class="td-label">Upload PGNs</td><td>{{workload.upload_pgns}}</td></tr>
<tr><td class="td-label">Syzygy WDL</td><td>{{workload.syzygy_wdl}}</td></tr>
<tr><td class="td-label">Syzygy ADJ.</td><td>{{workload.syzygy_adj}}</td></tr>
@@ -53,6 +56,9 @@
<tr><td class="td-label">Reporting</td><td>{{workload.spsa.reporting_type}}</td></tr>
<tr><td class="td-label">Distribution</td><td>{{workload.spsa.distribution_type}}</td></tr>
<tr><td class="td-label">Pairs Per Point</td><td>{{workload.workload_size}}</td></tr>
{% elif type == "DATAGEN" %}
<tr><td class="td-label">Genfens Args</td><td>{{workload.genfens_args}}</td></tr>
<tr><td class="td-label">Play Reverses</td><td>{{workload.play_reverses}}</td></tr>
{% endif %}
</table>
@@ -109,7 +115,7 @@
</div>
<!-- Copy Button: Copy the current results statblock -->
{% if type == "TEST" %}
{% if type == "TEST" or type == "DATAGEN" %}
<div class="anchor-container">
<a class="mt-1 anchorbutton btn-blue" onclick="copy_text('long-statblock', true)">Copy Stat Block</a>
</div>
@@ -143,6 +149,8 @@
<pre class="long-statblock" id="long-statblock">{{workload|longStatBlock|linebreaksbr}}</pre>
{% elif type == "TUNE" %}
<pre class="long-statblock" id="long-statblock">{{workload|shortStatBlock|linebreaksbr}}</pre>
{% elif type == "DATAGEN" %}
<pre class="long-statblock" id="long-statblock">{{workload|longStatBlock|linebreaksbr}}</pre>
{% endif %}
<!-- Forum to modify the Priority, Throughput, or (Tests only) Workload Size -->
@@ -155,12 +163,13 @@
<label for="priority">Priority</label>
<input value="{{workload.priority}}" id="priority" name="priority">
</div>
<div class="row">
<label for="throughput">Throughput</label>
<input value="{{workload.throughput}}" id="throughput" name="throughput">
</div>
{% if type == "TEST" %}
{% if type == "TEST" or type == "DATAGEN" %}
<div class="row">
<label for="workload_size">Workload Size</label>
<input value="{{workload.workload_size}}" id="workload_size" name="workload_size">