From 2fcb7329cea0622bfcd315cf82d9aa0f067f84de Mon Sep 17 00:00:00 2001 From: Andrew Grant Date: Tue, 12 Mar 2024 21:22:07 -0400 Subject: [PATCH] Implement support for DATAGEN Workloads through the genfens interface (#200) --- Client/cleanup.sh | 6 +- Client/genfens.py | 133 +++++++++++++++++++++++ Client/utils.py | 21 ++++ Client/worker.py | 73 +++++++++---- Config/config.json | 2 +- Engines/4ku.json | 14 +++ Engines/Akimbo.json | 14 +++ Engines/Alexandria.json | 14 +++ Engines/Altair.json | 14 +++ Engines/Berserk.json | 14 +++ Engines/Bit-Genie.json | 14 +++ Engines/BlackMarlin.json | 14 +++ Engines/Caissa.json | 14 +++ Engines/Carp.json | 14 +++ Engines/Clover.json | 14 +++ Engines/Demolito.json | 14 +++ Engines/Dragon.json | 14 +++ Engines/Drofa.json | 14 +++ Engines/Equisetum.json | 14 +++ Engines/Ethereal.json | 14 +++ Engines/FabChess.json | 14 +++ Engines/Halogen.json | 14 +++ Engines/Igel.json | 14 +++ Engines/Koivisto.json | 14 +++ Engines/Laser.json | 14 +++ Engines/Midnight.json | 14 +++ Engines/Obsidian.json | 14 +++ Engines/Polaris.json | 14 +++ Engines/Pytteliten.json | 14 +++ Engines/RubiChess.json | 14 +++ Engines/Seer.json | 14 +++ Engines/Stash.json | 14 +++ Engines/Stockfish.json | 14 +++ Engines/Stormphrax.json | 14 +++ Engines/Svart.json | 14 +++ Engines/Torch.json | 14 +++ Engines/Viridithas.json | 36 +++++- Engines/Wahoo.json | 14 +++ Engines/Weiss.json | 14 +++ Engines/Willow.json | 14 +++ Engines/Winter.json | 14 +++ Engines/Zahak.json | 14 +++ OpenBench/config.py | 48 +++++++- OpenBench/models.py | 24 ++-- OpenBench/static/create_workload.js | 16 +-- OpenBench/templatetags/mytags.py | 46 ++++---- OpenBench/urls.py | 5 + OpenBench/utils.py | 5 + OpenBench/views.py | 33 +++++- OpenBench/workloads/create_workload.py | 81 +++++++++++++- OpenBench/workloads/get_workload.py | 40 ++----- OpenBench/workloads/modify_workload.py | 1 - OpenBench/workloads/verify_workload.py | 80 +++++++++++++- OpenBench/workloads/view_workload.py | 13 ++- Templates/OpenBench/base.html | 1 + Templates/OpenBench/create_workload.html | 38 ++++++- Templates/OpenBench/workload.html | 21 +++- 57 files changed, 1096 insertions(+), 131 deletions(-) create mode 100644 Client/genfens.py diff --git a/Client/cleanup.sh b/Client/cleanup.sh index a1b384b..9d30186 100755 --- a/Client/cleanup.sh +++ b/Client/cleanup.sh @@ -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 \ No newline at end of file diff --git a/Client/genfens.py b/Client/genfens.py new file mode 100644 index 0000000..7d9a258 --- /dev/null +++ b/Client/genfens.py @@ -0,0 +1,133 @@ +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# # +# OpenBench is a chess engine testing framework by Andrew Grant. # +# # +# # +# 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 . # +# # +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + +# 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 " "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 " "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) diff --git a/Client/utils.py b/Client/utils.py index ab0dc32..f526c4b 100644 --- a/Client/utils.py +++ b/Client/utils.py @@ -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): diff --git a/Client/worker.py b/Client/worker.py index 7205101..42bd63a 100644 --- a/Client/worker.py +++ b/Client/worker.py @@ -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) diff --git a/Config/config.json b/Config/config.json index c3df688..6e235b4 100644 --- a/Config/config.json +++ b/Config/config.json @@ -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, diff --git a/Engines/4ku.json b/Engines/4ku.json index 13aed11..65aceb8 100644 --- a/Engines/4ku.json +++ b/Engines/4ku.json @@ -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" + } } } diff --git a/Engines/Akimbo.json b/Engines/Akimbo.json index 54cac39..0841f7c 100644 --- a/Engines/Akimbo.json +++ b/Engines/Akimbo.json @@ -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" + } } } diff --git a/Engines/Alexandria.json b/Engines/Alexandria.json index d563b3a..7f37bee 100644 --- a/Engines/Alexandria.json +++ b/Engines/Alexandria.json @@ -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" + } } } diff --git a/Engines/Altair.json b/Engines/Altair.json index e3cbb58..6a91583 100644 --- a/Engines/Altair.json +++ b/Engines/Altair.json @@ -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" + } } } diff --git a/Engines/Berserk.json b/Engines/Berserk.json index cd9316c..7c7b0ca 100644 --- a/Engines/Berserk.json +++ b/Engines/Berserk.json @@ -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" + } } } diff --git a/Engines/Bit-Genie.json b/Engines/Bit-Genie.json index ad1b277..c28384d 100644 --- a/Engines/Bit-Genie.json +++ b/Engines/Bit-Genie.json @@ -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" + } } } diff --git a/Engines/BlackMarlin.json b/Engines/BlackMarlin.json index 6abf9e8..3938434 100644 --- a/Engines/BlackMarlin.json +++ b/Engines/BlackMarlin.json @@ -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" + } } } diff --git a/Engines/Caissa.json b/Engines/Caissa.json index 0f31399..461504c 100644 --- a/Engines/Caissa.json +++ b/Engines/Caissa.json @@ -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" + } } } diff --git a/Engines/Carp.json b/Engines/Carp.json index 32dbddc..7ad3cb3 100644 --- a/Engines/Carp.json +++ b/Engines/Carp.json @@ -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" + } } } diff --git a/Engines/Clover.json b/Engines/Clover.json index 4b703e8..401155b 100644 --- a/Engines/Clover.json +++ b/Engines/Clover.json @@ -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" + } } } diff --git a/Engines/Demolito.json b/Engines/Demolito.json index 6ec5cbe..8966291 100644 --- a/Engines/Demolito.json +++ b/Engines/Demolito.json @@ -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" + } } } diff --git a/Engines/Dragon.json b/Engines/Dragon.json index 1a4a3c9..0c6d781 100644 --- a/Engines/Dragon.json +++ b/Engines/Dragon.json @@ -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" + } } } \ No newline at end of file diff --git a/Engines/Drofa.json b/Engines/Drofa.json index 2675739..9150186 100644 --- a/Engines/Drofa.json +++ b/Engines/Drofa.json @@ -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" + } } } diff --git a/Engines/Equisetum.json b/Engines/Equisetum.json index 9f77388..a1b2db2 100644 --- a/Engines/Equisetum.json +++ b/Engines/Equisetum.json @@ -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" + } } } diff --git a/Engines/Ethereal.json b/Engines/Ethereal.json index 5ca4360..b0471d2 100644 --- a/Engines/Ethereal.json +++ b/Engines/Ethereal.json @@ -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" + } } } \ No newline at end of file diff --git a/Engines/FabChess.json b/Engines/FabChess.json index 7e82a69..637fcb1 100644 --- a/Engines/FabChess.json +++ b/Engines/FabChess.json @@ -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" + } } } diff --git a/Engines/Halogen.json b/Engines/Halogen.json index 800a405..7009ceb 100644 --- a/Engines/Halogen.json +++ b/Engines/Halogen.json @@ -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" + } } } diff --git a/Engines/Igel.json b/Engines/Igel.json index 414d3b4..9102eb6 100644 --- a/Engines/Igel.json +++ b/Engines/Igel.json @@ -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" + } } } diff --git a/Engines/Koivisto.json b/Engines/Koivisto.json index 3cc0c5c..c5137a2 100644 --- a/Engines/Koivisto.json +++ b/Engines/Koivisto.json @@ -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" + } } } diff --git a/Engines/Laser.json b/Engines/Laser.json index a17e483..be39337 100644 --- a/Engines/Laser.json +++ b/Engines/Laser.json @@ -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" + } } } diff --git a/Engines/Midnight.json b/Engines/Midnight.json index 656518e..0bf3ffb 100644 --- a/Engines/Midnight.json +++ b/Engines/Midnight.json @@ -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" + } } } diff --git a/Engines/Obsidian.json b/Engines/Obsidian.json index db760af..af4920f 100644 --- a/Engines/Obsidian.json +++ b/Engines/Obsidian.json @@ -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" + } } } \ No newline at end of file diff --git a/Engines/Polaris.json b/Engines/Polaris.json index fea341c..df45b4e 100644 --- a/Engines/Polaris.json +++ b/Engines/Polaris.json @@ -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" + } } } diff --git a/Engines/Pytteliten.json b/Engines/Pytteliten.json index 4dd57c9..2eef9f9 100644 --- a/Engines/Pytteliten.json +++ b/Engines/Pytteliten.json @@ -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" + } } } diff --git a/Engines/RubiChess.json b/Engines/RubiChess.json index 9e1e4f2..0245fe7 100644 --- a/Engines/RubiChess.json +++ b/Engines/RubiChess.json @@ -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" + } } } diff --git a/Engines/Seer.json b/Engines/Seer.json index caa9b31..803cbf6 100644 --- a/Engines/Seer.json +++ b/Engines/Seer.json @@ -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" + } } } diff --git a/Engines/Stash.json b/Engines/Stash.json index ae2c8bf..37b713e 100644 --- a/Engines/Stash.json +++ b/Engines/Stash.json @@ -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" + } } } diff --git a/Engines/Stockfish.json b/Engines/Stockfish.json index c3de241..5fdcc65 100644 --- a/Engines/Stockfish.json +++ b/Engines/Stockfish.json @@ -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" + } } } diff --git a/Engines/Stormphrax.json b/Engines/Stormphrax.json index 99674c5..e1a5067 100644 --- a/Engines/Stormphrax.json +++ b/Engines/Stormphrax.json @@ -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" + } } } diff --git a/Engines/Svart.json b/Engines/Svart.json index efc6cba..7e2d947 100644 --- a/Engines/Svart.json +++ b/Engines/Svart.json @@ -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" + } } } diff --git a/Engines/Torch.json b/Engines/Torch.json index 03e464f..ee9d49b 100644 --- a/Engines/Torch.json +++ b/Engines/Torch.json @@ -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" + } } } \ No newline at end of file diff --git a/Engines/Viridithas.json b/Engines/Viridithas.json index 439826a..999b011 100644 --- a/Engines/Viridithas.json +++ b/Engines/Viridithas.json @@ -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" } } } diff --git a/Engines/Wahoo.json b/Engines/Wahoo.json index 821ea2e..9777215 100644 --- a/Engines/Wahoo.json +++ b/Engines/Wahoo.json @@ -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" + } } } diff --git a/Engines/Weiss.json b/Engines/Weiss.json index fdcd362..923b9d5 100644 --- a/Engines/Weiss.json +++ b/Engines/Weiss.json @@ -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" + } } } diff --git a/Engines/Willow.json b/Engines/Willow.json index 8f01e3a..3c4e6d3 100644 --- a/Engines/Willow.json +++ b/Engines/Willow.json @@ -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" + } } } diff --git a/Engines/Winter.json b/Engines/Winter.json index 3091361..cd6aced 100644 --- a/Engines/Winter.json +++ b/Engines/Winter.json @@ -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" + } } } diff --git a/Engines/Zahak.json b/Engines/Zahak.json index e8950ab..8fc0b73 100644 --- a/Engines/Zahak.json +++ b/Engines/Zahak.json @@ -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" + } } } diff --git a/OpenBench/config.py b/OpenBench/config.py index 802df66..b05a57e 100644 --- a/OpenBench/config.py +++ b/OpenBench/config.py @@ -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)) \ No newline at end of file diff --git a/OpenBench/models.py b/OpenBench/models.py index 4bda7ad..c7ec611 100644 --- a/OpenBench/models.py +++ b/OpenBench/models.py @@ -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 diff --git a/OpenBench/static/create_workload.js b/OpenBench/static/create_workload.js index 3fc7273..c291682 100644 --- a/OpenBench/static/create_workload.js +++ b/OpenBench/static/create_workload.js @@ -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); diff --git a/OpenBench/templatetags/mytags.py b/OpenBench/templatetags/mytags.py index 9bd73a1..50a82da 100644 --- a/OpenBench/templatetags/mytags.py +++ b/OpenBench/templatetags/mytags.py @@ -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: diff --git a/OpenBench/urls.py b/OpenBench/urls.py index 23ea74d..281cc7c 100644 --- a/OpenBench/urls.py +++ b/OpenBench/urls.py @@ -58,6 +58,11 @@ urlpatterns = [ django.urls.path(r'tune//', OpenBench.views.tune), django.urls.path(r'newTune/', OpenBench.views.create_tune), + # Links for viewing and managing datagen + django.urls.path(r'datagen//', OpenBench.views.datagen), + django.urls.path(r'datagen//', 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//', OpenBench.views.networks), diff --git a/OpenBench/utils.py b/OpenBench/utils.py index 1303e94..7a9eed4 100644 --- a/OpenBench/utils.py +++ b/OpenBench/utils.py @@ -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 diff --git a/OpenBench/views.py b/OpenBench/views.py index d4c2b7a..a3c8775 100644 --- a/OpenBench/views.py +++ b/OpenBench/views.py @@ -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 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # diff --git a/OpenBench/workloads/create_workload.py b/OpenBench/workloads/create_workload.py index 8e7bcad..7b19498 100644 --- a/OpenBench/workloads/create_workload.py +++ b/OpenBench/workloads/create_workload.py @@ -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 diff --git a/OpenBench/workloads/get_workload.py b/OpenBench/workloads/get_workload.py index 3b33e6d..70e3dfc 100644 --- a/OpenBench/workloads/get_workload.py +++ b/OpenBench/workloads/get_workload.py @@ -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] + } \ No newline at end of file diff --git a/OpenBench/workloads/modify_workload.py b/OpenBench/workloads/modify_workload.py index a126759..897aa4d 100644 --- a/OpenBench/workloads/modify_workload.py +++ b/OpenBench/workloads/modify_workload.py @@ -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!' diff --git a/OpenBench/workloads/verify_workload.py b/OpenBench/workloads/verify_workload.py index eafae2f..16b8944 100644 --- a/OpenBench/workloads/verify_workload.py +++ b/OpenBench/workloads/verify_workload.py @@ -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): diff --git a/OpenBench/workloads/view_workload.py b/OpenBench/workloads/view_workload.py index 7f91bfe..6d46522 100644 --- a/OpenBench/workloads/view_workload.py +++ b/OpenBench/workloads/view_workload.py @@ -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) diff --git a/Templates/OpenBench/base.html b/Templates/OpenBench/base.html index 4d0eb9f..34cbac9 100644 --- a/Templates/OpenBench/base.html +++ b/Templates/OpenBench/base.html @@ -94,6 +94,7 @@
  • Actions
  • Create Test
  • Create Tune
  • +
  • Create Datagen
  • Upload Net
  • diff --git a/Templates/OpenBench/create_workload.html b/Templates/OpenBench/create_workload.html index 917ae83..bc439e1 100644 --- a/Templates/OpenBench/create_workload.html +++ b/Templates/OpenBench/create_workload.html @@ -45,7 +45,7 @@ - {% if workload == "TEST" %} + {% if workload == "TEST" or workload == "DATAGEN" %}
    - {% if workload == "TEST" %} + {% if workload == "TEST" or workload == "DATAGEN" %}

    Base Settings

    @@ -174,12 +174,33 @@ + {% elif workload == "DATAGEN" %} + +

    Datagen Settings

    + +
    + +
    + +
    + +
    + +
    + + +
    + {% endif %}

    General Settings

    - - - + {% if workload == "DATAGEN" %} + + + {% else %} + + + + {% endif %}
    @@ -203,7 +229,7 @@ - {% if workload == "TEST" %} + {% if workload == "TEST" or workload == "DATAGEN" %}
    diff --git a/Templates/OpenBench/workload.html b/Templates/OpenBench/workload.html index dabda0c..aab14f7 100644 --- a/Templates/OpenBench/workload.html +++ b/Templates/OpenBench/workload.html @@ -18,7 +18,6 @@ Creation{{workload.creation|date:'U'}} - {{dev_text}} Engine{{workload.dev_engine}} {{dev_text}} Source{{workload.dev_repo}} {{dev_text}} Sha{{workload.dev.sha}} {{dev_text}} Branch{{workload.dev.name|prettyName}} @@ -28,8 +27,7 @@ {{dev_text}} Time{{workload.dev_time_control}} - {% if type == "TEST" %} - Base Engine{{workload.base_engine}} + {% if type == "TEST" or type == "DATAGEN" %} Base Source{{workload.base_repo}} Base Sha{{workload.base.sha}} Base Branch{{workload.base.name|prettyName}} @@ -39,7 +37,12 @@ Base Time{{workload.base_time_control}} {% endif %} - Opening Book{{workload.book_name}} + {% if workload|book_download_link %} + Opening Book{{workload.book_name}} + {% else %} + Opening Book{{workload.book_name}} + {% endif %} + Upload PGNs{{workload.upload_pgns}} Syzygy WDL{{workload.syzygy_wdl}} Syzygy ADJ.{{workload.syzygy_adj}} @@ -53,6 +56,9 @@ Reporting{{workload.spsa.reporting_type}} Distribution{{workload.spsa.distribution_type}} Pairs Per Point{{workload.workload_size}} + {% elif type == "DATAGEN" %} + Genfens Args{{workload.genfens_args}} + Play Reverses{{workload.play_reverses}} {% endif %} @@ -109,7 +115,7 @@ - {% if type == "TEST" %} + {% if type == "TEST" or type == "DATAGEN" %} @@ -143,6 +149,8 @@
    {{workload|longStatBlock|linebreaksbr}}
    {% elif type == "TUNE" %}
    {{workload|shortStatBlock|linebreaksbr}}
    + {% elif type == "DATAGEN" %} +
    {{workload|longStatBlock|linebreaksbr}}
    {% endif %} @@ -155,12 +163,13 @@ +
    - {% if type == "TEST" %} + {% if type == "TEST" or type == "DATAGEN" %}