Skip to content

Commit

Permalink
Merge pull request #137 from kiudee/135_skip_benchmark
Browse files Browse the repository at this point in the history
Allow skipping the benchmark step
  • Loading branch information
kiudee committed Jun 26, 2021
2 parents 8d5850f + 29d6bce commit 817afd0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ History
functionality from disk (new default).
* Add ``--run-only-once`` flag to distributed tuning client. If True, it will
terminate after completing one job or immediately if no job is found.
* Add ``--skip-benchmark`` flag to distributed tuning client. If True, it will
skip the calibration of the time control, which involves running a benchmark
for both engines.
* Fix the match parser producing incorrect results, when concurrency > 1 is
used for playing matches.
* Fix the server for distributed tuning trying to compute the current optimum
Expand Down
15 changes: 14 additions & 1 deletion tune/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,24 @@ def cli():
is_flag=True,
help="Terminate the client after x minutes.",
)
@click.option(
"--skip-benchmark",
default=False,
is_flag=True,
help="Skip calibrating the time control by running a benchmark.",
)
@click.option(
"--clientconfig", default=None, help="Path to the client configuration file."
)
@click.argument("dbconfig")
def run_client(
verbose, logfile, terminate_after, run_only_once, clientconfig, dbconfig
verbose,
logfile,
terminate_after,
run_only_once,
skip_benchmark,
clientconfig,
dbconfig,
):
""" Run the client to generate games for distributed tuning.
Expand All @@ -67,6 +79,7 @@ def run_client(
terminate_after=terminate_after,
clientconfig=clientconfig,
run_only_once=run_only_once,
skip_benchmark=skip_benchmark,
)
tc.run()

Expand Down
44 changes: 24 additions & 20 deletions tune/db_workers/tuning_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
terminate_after=0,
clientconfig=None,
only_run_once=False,
skip_benchmark=False,
**kwargs,
):
self.end_time = None
Expand All @@ -47,6 +48,7 @@ def __init__(
signal.signal(signal.SIGINT, self.interrupt_handler)
self.interrupt_pressed = False
self.only_run_once = only_run_once
self.skip_benchmark = skip_benchmark
if os.path.isfile(dbconfig_path):
with open(dbconfig_path, "r") as config_file:
config = config_file.read().replace("\n", "")
Expand Down Expand Up @@ -337,29 +339,31 @@ def run(self):
with open("engines.json", "w") as file:
json.dump(engine_config, file, sort_keys=True, indent=4)
sleep(2)
# b) Adjust time control:
if self.lc0_benchmark is None:
self.logger.info(
"Running initial nodes/second benchmark to calibrate time "
"controls. Ensure that your pc is idle to get a good reading."
orig_tc = time_control = sql_result.time_control.to_tuple()
if not self.skip_benchmark:
# b) Adjust time control:
if self.lc0_benchmark is None:
self.logger.info(
"Running initial nodes/second benchmark to calibrate time "
"controls. Ensure that your pc is idle to get a good "
"reading."
)
self.run_benchmark(config)
self.logger.info(
f"Benchmark complete. Results: lc0: {self.lc0_benchmark} "
f"nps, sf: {self.sf_benchmark} nps"
)
else:
self.logger.debug(
f"Initial benchmark results: lc0: {self.lc0_benchmark} "
f"nps, sf: {self.sf_benchmark} nps"
)
time_control = self.adjust_time_control(
orig_tc, float(job.engine1_nps), float(job.engine2_nps),
)
self.run_benchmark(config)
self.logger.info(
f"Benchmark complete. Results: lc0: {self.lc0_benchmark} nps, "
f"sf: {self.sf_benchmark} nps"
)
else:
self.logger.debug(
f"Initial benchmark results: lc0: {self.lc0_benchmark} nps, "
f"sf: {self.sf_benchmark} nps"
f"Adjusted time control from {orig_tc} to {time_control}"
)
orig_tc = sql_result.time_control.to_tuple()
time_control = self.adjust_time_control(
orig_tc, float(job.engine1_nps), float(job.engine2_nps),
)
self.logger.debug(
f"Adjusted time control from {orig_tc} to {time_control}"
)

# 3. Run experiment (and block)
self.logger.info(f"Running match with time control\n{time_control}")
Expand Down

0 comments on commit 817afd0

Please sign in to comment.