Skip to content

Commit

Permalink
Add flag to distributed tuning client which allows skipping the bench…
Browse files Browse the repository at this point in the history
…mark
  • Loading branch information
kiudee committed Jun 26, 2021
1 parent 8d5850f commit 6292868
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
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
43 changes: 23 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,30 @@ 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} 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"
)
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 6292868

Please sign in to comment.