Implement support for DATAGEN Workloads through the genfens interface (#200)
This commit is contained in:
1 parent
45302fa347
commit
2fcb7329ce
57 files changed
+1096
-131
No files matched your search
+47
-1
@@ -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
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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
@@ -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 #
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
}
|
||||
@@ -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!'
|
||||
|
||||
@@ -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):
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in new issue
Block a user