예제 #1
0
 def build_versus_n_games_cmd(self, pipe_pairs):
     assert self.config.opts.p1_model_config_path
     assert self.config.opts.p1_model_weight_path
     assert self.config.opts.p2_model_config_path
     assert self.config.opts.p2_model_weight_path
     cmd = build_child_cmd(type='versus_n_games',
                           config=self.config,
                           pipe_pairs=pipe_pairs)
     cmd.extend([
         '--n-games',
         f'{self.config.opts.n_games}',
         '--n-workers',
         f'{self.config.opts.n_workers}',
         "--p1-model-config-path",
         self.config.opts.p1_model_config_path,
         "--p1-model-weight-path",
         self.config.opts.p1_model_weight_path,
         "--p2-model-config-path",
         self.config.opts.p2_model_config_path,
         "--p2-model-weight-path",
         self.config.opts.p2_model_weight_path,
     ])
     if self.config.opts.save_versus_dir:
         cmd.extend(["--save-versus-dir", self.config.opts.save_versus_dir])
     if self.config.opts.p1_first:
         cmd.extend(['--p1-first', f'{self.config.opts.p1_first}'])
     if self.config.opts.n_minutes:
         cmd.extend(['--n-minutes', f'{self.config.opts.n_minutes}'])
     return cmd
예제 #2
0
 def start_model_serving_process(self, model_config_path, model_weight_path, pipe_pairs):
     cmd = build_child_cmd(type='model_serving', config=self.config, pipe_pairs=pipe_pairs)
     cmd.extend([
         '--model-config-path', model_config_path,
         '--model-weight-path', model_weight_path,
     ])
     return start_child_proc(cmd=cmd)
예제 #3
0
 def build_versus_n_games_cmd(self, pipe_pairs):
     cmd = build_child_cmd(type='versus_n_games_ntest',
                           config=self.config,
                           pipe_pairs=pipe_pairs)
     cmd.extend([
         '--n-games',
         f'{self.config.opts.n_games}',
         '--n-workers',
         f'{self.config.opts.n_workers}',
         "--model-config-path",
         self.config.resource.model_config_path,
         "--model-weight-path",
         self.config.resource.model_weight_path,
         '--ntest-depth',
         f'{self.config.opts.ntest_depth}',
         '--p1-name',
         self.get_p1_name(),
         '--p2-name',
         self.get_p2_name(),
     ])
     if self.config.opts.save_versus_dir:
         cmd.extend(["--save-versus-dir", self.config.opts.save_versus_dir])
     if self.config.opts.p1_first:
         cmd.extend(['--p1-first', f'{self.config.opts.p1_first}'])
     if self.config.opts.n_minutes:
         cmd.extend(['--n-minutes', f'{self.config.opts.n_minutes}'])
     return cmd
예제 #4
0
 def start_gtp_server_process(pipe_pairs, config):
     cmd = build_child_cmd(type='gtp_server',
                           config=config,
                           pipe_pairs=pipe_pairs)
     if config.opts.n_minutes:
         cmd.extend(['--n-minutes', f'{config.opts.n_minutes}'])
     return start_child_proc(cmd=cmd, nocuda=True)
예제 #5
0
 def start_p1_server(self, gtp_pipe_pair):
     cmd = build_child_cmd(type='gtp_server',
                           config=self.config,
                           pipe_pairs=[gtp_pipe_pair, self.p1_pipe_pair])
     if self.config.opts.n_minutes:
         cmd.extend(['--n-minutes', f'{self.config.opts.n_minutes}'])
     return start_child_proc(cmd=cmd, nocuda=True)
예제 #6
0
    def vs(self, player1 : Player, player2 : Player, n_games):

        pipe_pairs = self.pipe_files.make_pipes(1)
        cmd = build_child_cmd(type='versus_n_games', config=self.config, pipe_pairs=reverse_in_out(pipe_pairs))
        cmd.extend([
            '--n-games', f'{n_games}',
            '--n-workers', f'{self.config.opts.n_workers}',
            '--p1-n-sims', f'{player1.n_sims}',
            "--p1-model-config-path", player1.config,
            "--p1-model-weight-path", player1.weight,
            '--p2-n-sims', f'{player2.n_sims}',
            "--p2-model-config-path", player2.config,
            "--p2-model-weight-path", player2.weight,
        ])

        pipe_pairs[0].open_read_nonblock()
        p = start_child_proc(cmd=cmd).wait()

        result = pipe_pairs[0].read_no_empty()
        assert result
        result = result.decode()
        result = result.split(',')
        result = [int(x) for x in result]

        pipe_pairs[0].close_read()
        self.pipe_files.clear_pipes()

        return result
예제 #7
0
    def start_1_game_process(self, pps, p1_first):
        cmd = build_child_cmd(type='versus_a_game_kernel', config=self.config, pipe_pairs=pps)
        cmd.extend(['--p1-first', f'{p1_first}'])
        if self.config.opts.save_versus_dir:
            cmd.extend(["--save-versus-dir", self.config.opts.save_versus_dir])
        if self.config.opts.n_minutes:
            cmd.extend(['--n-minutes', f'{self.config.opts.n_minutes}'])

        return start_child_proc(cmd=cmd, nocuda=True)
예제 #8
0
 def start_http_server_process(self, pipe_pairs, port):
     cmd = build_child_cmd(type='http_server',
                           config=self.config,
                           pipe_pairs=pipe_pairs)
     cmd.extend([
         '--http-port',
         f'{port}',
         '--model-config-path',
         self.config.resource.model_config_path,
         '--model-weight-path',
         self.config.resource.model_weight_path,
     ])
     return start_child_proc(cmd=cmd, nocuda=True)
예제 #9
0
    def eval_model_elo(self, to_eval_config_path, to_eval_weight_path):
        rc = self.config.resource

        pipe_pairs = self.pipe_files.make_pipes(1)

        cmd = build_child_cmd(type='elo_p1',
                              config=self.config,
                              pipe_pairs=reverse_in_out(pipe_pairs))
        cmd.extend([
            '--n-games',
            f'{self.config.eval.n_games}',
            '--n-workers',
            f'{self.config.opts.n_workers}',
            "--p1-model-config-path",
            to_eval_config_path,
            "--p1-model-weight-path",
            to_eval_weight_path,
            "--p2-model-config-path",
            rc.model_config_path,
            "--p2-model-weight-path",
            rc.model_weight_path,
            '--p1-elo',
            '0',
            '--p2-elo',
            '0',
        ])
        pipe_pairs[0].open_read_nonblock()
        start_child_proc(cmd=cmd).wait()

        result = pipe_pairs[0].read_no_empty()
        result = result.decode()
        result = result.split(',')
        elo = float(result[0])
        win = int(result[1])
        draw = int(result[2])
        lose = int(result[3])
        self.pipe_files.clear_pipes()

        return elo, win, draw, lose
예제 #10
0
 def start_gtp_server_process(self, pipe_pairs):
     cmd = build_child_cmd(type='gtp_server',
                           config=self.config,
                           pipe_pairs=pipe_pairs)
     return start_child_proc(cmd=cmd, nocuda=True)
예제 #11
0
 def start_p2_server(self, gtp_pipe_pair):
     cmd = build_child_cmd(type='gtp_server_ntest',
                           config=self.config,
                           pipe_pairs=[gtp_pipe_pair])
     cmd.extend(['--ntest-depth', f'{self.config.opts.ntest_depth}'])
     return start_child_proc(cmd=cmd, nocuda=True)