From 0419a5b557d4568f753d89f44612048d32ef0c37 Mon Sep 17 00:00:00 2001 From: Tilps Date: Tue, 1 Jan 2019 11:21:48 +1100 Subject: [PATCH 1/3] Enforce parallelism of 2 for match games to avoid short game bias. --- lc0_main.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lc0_main.go b/lc0_main.go index 538501f..ceeac62 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -251,7 +251,7 @@ func checkLc0() { } } -func (c *cmdWrapper) launch(networkPath string, otherNetPath string, args []string, input bool) { +func (c *cmdWrapper) launch(networkPath string, otherNetPath string, args []string, input bool, parallelismOverride int) { dir, _ := os.Getwd() c.Cmd = exec.Command(path.Join(dir, "lc0")) // Add the "selfplay" or "uci" part first @@ -268,6 +268,9 @@ func (c *cmdWrapper) launch(networkPath string, otherNetPath string, args []stri c.Cmd.Args = append(c.Cmd.Args, parts...) } parallelism := *parallel + if parallelismOverride > 0 { + parallelism = parallelismOverride + } if *backopts != "" { // Check agains small token blacklist, currently only "random" tokens := regexp.MustCompile("[,=().0-9]").Split(*backopts, -1) @@ -417,7 +420,11 @@ func playMatch(httpClient *http.Client, ngr client.NextGameResponse, baselinePat params = append(params, "--training=true") params = append(params, "--visits=800") c := createCmdWrapper() - c.launch(candidatePath, baselinePath, params /* input= */, false) + // Enforce a parallelism of 2 for match games - otherwise there could be significant 'short game' bias. + // With parallelism of 2 there is always one normal and one flipped game in progress at a time, ensuring no bias. + // Match games are played with settings designed to utilize a full gpu rather than aiming for accuracy like training games. + // So parallelism of 2 should be plenty. + c.launch(candidatePath, baselinePath, params /* input= */, false, 2) trainDirHolder := make([]string, 1) trainDirHolder[0] = "" defer func() { @@ -569,7 +576,7 @@ func train(httpClient *http.Client, ngr client.NextGameResponse, params = append([]string{"selfplay"}, params...) params = append(params, "--training=true") c := createCmdWrapper() - c.launch(networkPath, otherNetPath, params /* input= */, false) + c.launch(networkPath, otherNetPath, params /* input= */, false, 0) trainDirHolder := make([]string, 1) trainDirHolder[0] = "" defer func() { From f822bc8f66805f8bb43c26687ba5ae28fec7ee8f Mon Sep 17 00:00:00 2001 From: Tilps Date: Tue, 1 Jan 2019 11:49:46 +1100 Subject: [PATCH 2/3] Fix comment. --- lc0_main.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lc0_main.go b/lc0_main.go index ceeac62..1e4425e 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -420,10 +420,9 @@ func playMatch(httpClient *http.Client, ngr client.NextGameResponse, baselinePat params = append(params, "--training=true") params = append(params, "--visits=800") c := createCmdWrapper() - // Enforce a parallelism of 2 for match games - otherwise there could be significant 'short game' bias. - // With parallelism of 2 there is always one normal and one flipped game in progress at a time, ensuring no bias. - // Match games are played with settings designed to utilize a full gpu rather than aiming for accuracy like training games. - // So parallelism of 2 should be plenty. + // Enforce a parallelism of 2 for match games - to reduce the level of 'short game' bias. + // Match games use parameter settings that utilize more gpu than a single game in training, + // so 2 should be enough to get decent saturation. c.launch(candidatePath, baselinePath, params /* input= */, false, 2) trainDirHolder := make([]string, 1) trainDirHolder[0] = "" From c5eda914d12686790d8fa055ee7c8261ab96dc9a Mon Sep 17 00:00:00 2001 From: Tilps Date: Tue, 1 Jan 2019 12:12:01 +1100 Subject: [PATCH 3/3] Revise again to allow up to 4, but let the user limit it lower if they want. --- lc0_main.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lc0_main.go b/lc0_main.go index 1e4425e..417ca9b 100644 --- a/lc0_main.go +++ b/lc0_main.go @@ -251,7 +251,7 @@ func checkLc0() { } } -func (c *cmdWrapper) launch(networkPath string, otherNetPath string, args []string, input bool, parallelismOverride int) { +func (c *cmdWrapper) launch(networkPath string, otherNetPath string, args []string, input bool, parallelismLimitOverride int) { dir, _ := os.Getwd() c.Cmd = exec.Command(path.Join(dir, "lc0")) // Add the "selfplay" or "uci" part first @@ -268,8 +268,10 @@ func (c *cmdWrapper) launch(networkPath string, otherNetPath string, args []stri c.Cmd.Args = append(c.Cmd.Args, parts...) } parallelism := *parallel - if parallelismOverride > 0 { - parallelism = parallelismOverride + if parallelismLimitOverride > 0 { + if parallelism <= 0 || parallelism > parallelismLimitOverride { + parallelism = parallelismLimitOverride + } } if *backopts != "" { // Check agains small token blacklist, currently only "random" @@ -420,10 +422,10 @@ func playMatch(httpClient *http.Client, ngr client.NextGameResponse, baselinePat params = append(params, "--training=true") params = append(params, "--visits=800") c := createCmdWrapper() - // Enforce a parallelism of 2 for match games - to reduce the level of 'short game' bias. + // Enforce a parallelism of at most 4 for match games - to reduce the level of 'short game' bias. // Match games use parameter settings that utilize more gpu than a single game in training, - // so 2 should be enough to get decent saturation. - c.launch(candidatePath, baselinePath, params /* input= */, false, 2) + // so 4 should be enough to get decent saturation. + c.launch(candidatePath, baselinePath, params /* input= */, false, 4) trainDirHolder := make([]string, 1) trainDirHolder[0] = "" defer func() {