From 59d5af56f3d94e63ba94e9d4ffd91716934f59b3 Mon Sep 17 00:00:00 2001 From: rektdie Date: Mon, 16 Nov 2026 21:26:43 +0100 Subject: [PATCH 1/4] mcts: stop a playout at a child that is ahead of its edge (MCGS variant 5a) With always-descend, a playout runs through existing nodes until it reaches a new position or a draw of its path. In reversible endgames it wanders through cycles: mean playout depth 28 against main's 6 in KR v K (bench 15), at 0.15x main's playouts/s, with 30 % of playouts ending in a repetition. KataGo's stop rule: when the child an edge leads to already has more visits than the edge (other move orders reached it), the playout ends there. The edge counts the visit and its parent recomputes from the child's current Q; the child is left as it is. In a tree the two counts are equal, so this only fires on transpositions. The depth limit now ends a playout the same way. The bench changes because playouts stop at transpositions. Checked: zero warnings; VERIFY build: `verify` (a)-(d), the VERIFY searches of plan section 6 with forced GC at Hash 1 and 2, the reuse sequence at Hash 64, Hash 1 and from the 960 start, and the go nodes 1/2, go depth 1 smoke positions. Bench: 609350 Co-Authored-By: Claude Opus 5.5 --- src/mcts.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/mcts.cpp b/src/mcts.cpp index d28c69d..9d69386 100644 --- a/src/mcts.cpp +++ b/src/mcts.cpp @@ -650,7 +650,7 @@ void Searcher::playout() { edge_path_.clear(); // How the playout ended; it decides what happens to the last node. - enum Leaf { NEW_NODE, TERMINAL, NOT_EXPANDED, PATH_DRAW, DEPTH_LIMIT } leaf; + enum Leaf { NEW_NODE, TERMINAL, NOT_EXPANDED, PATH_DRAW, STOPPED } leaf; u32 idx = tree_.root(); path_.push_back(idx); int depth = 0; @@ -712,17 +712,24 @@ void Searcher::playout() { } idx = edge.child; path_.push_back(idx); - if (depth >= MAX_PLAYOUT_DEPTH) { + // Stop rule (KataGo, plan variant 5a): a child that already has more + // visits than this edge (other move orders reached it) is ahead of + // what this edge needs. The playout ends there: the edge counts the + // visit with the child's current value, and the child is left as it + // is. In a tree the two counts are equal and this never happens. The + // depth limit ends a playout the same way. + if (tree_.node(idx).visits > edge.visits || depth >= MAX_PLAYOUT_DEPTH) { value = -tree_.node(idx).q; - leaf = DEPTH_LIMIT; + leaf = STOPPED; break; } } // The last node. A new node already has its one visit (N = base = 1); a // terminal node and a node that could not be expanded count one more visit - // of their own value (q = u stays). A path draw has no node, and a node at - // the depth limit is left as it is: only the edge into it counts the visit. + // of their own value (q = u stays). A path draw has no node, and a node + // where the playout stopped is left as it is: only the edge into it counts + // the visit. if (leaf == TERMINAL || leaf == NOT_EXPANDED) { Node& node = tree_.node(path_.back()); node.visits++; From faa0b4700a254180e973f2111a07e4fbe748e4a6 Mon Sep 17 00:00:00 2001 From: rektdie Date: Mon, 16 Nov 2026 21:44:28 +0100 Subject: [PATCH 2/4] docs: 5313 passed; six MCGS variant tests (5314-5319) in mcgs-log Bench: 764208 Co-Authored-By: Claude Opus 5.5 --- docs/mcgs-log.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/docs/mcgs-log.md b/docs/mcgs-log.md index a9afee3..4dfd0da 100644 --- a/docs/mcgs-log.md +++ b/docs/mcgs-log.md @@ -8,7 +8,13 @@ only from results the owner provides. | 1 | `mcgs-stats` | `bec9871` | 663779 (normal and `STATS=1` builds) | none (never merged) | measurement only; the branch stays on its own | | 2 | `mcgs-step2-split` | `fb1b8a5` | 663779 (identical to main) | | | | 3 | `mcgs-step3-core` | `14f672a` | 764208 | [5312](https://bench.rektdie.com/test/5312/) STC 8.0+0.08 `[0.00, 5.00]`, base `main` | failed: LLR −3.19, 4758 games, 106 lost on time | -| 3b | `mcgs-step3-reroot` | `d38f0b1` | 764208 | [5313](https://bench.rektdie.com/test/5313/) STC 8.0+0.08 `[0.00, 5.00]`, base `main` | | +| 3b | `mcgs-step3-reroot` | `d38f0b1` | 764208 | [5313](https://bench.rektdie.com/test/5313/) STC 8.0+0.08 `[0.00, 5.00]`, base `main` | passed: LLR 3.09, 4600 games, 0 lost on time | +| 5 | `mcgs-v-arena12` | `0a9bb40` | 764208 | [5314](https://bench.rektdie.com/test/5314/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | | +| 5b | `mcgs-v-edgeq` | `e7f2bfb` | 769193 | [5315](https://bench.rektdie.com/test/5315/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | | +| 5a | `mcgs-v-stop` | `59d5af5` | 609350 | [5316](https://bench.rektdie.com/test/5316/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | | +| 5 | `mcgs-v-pathrep` | `b7bfb0b` | 755448 | [5317](https://bench.rektdie.com/test/5317/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | | +| 5c | `mcgs-v-novaluehash` | `9e7c3ef` | 765326 | [5318](https://bench.rektdie.com/test/5318/) Non-Regression STC `[-5.00, 0.00]`, base `mcgs-step3-reroot` | | +| 4 | `mcgs-v-reconcile` | `79fd017` | 764208 | [5319](https://bench.rektdie.com/test/5319/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | | ## Step 1 measurements @@ -687,4 +693,50 @@ At `go movetime 40` in the same replay, mean playouts per move were: main ### SPRT (owner) - STC 8.0+0.08, `[0.00, 5.00]`, Threads=1, Hash=64, base `main` (bench - 663779): https://bench.rektdie.com/test/5313/, outcome to be filled in. + 663779): https://bench.rektdie.com/test/5313/. Result as shown on the test + page (0 games lost on time): + + ``` + Elo | 12.24 +- 6.54 (95%) + SPRT | 8.0+0.08s Threads=1 Hash=64MB + LLR | 3.09 (-2.94, 2.94) [0.00, 5.00] + Games | N: 4600 W: 1533 L: 1371 D: 1696 + ``` + + This measures steps 2, 3 and 3b together against `main`. It is not merged. + +## Variants on top of step 3b (one branch and one SPRT each) + +Each branch is cut from `mcgs-step3-reroot` (`95e4909`) and tested against it +at STC 8.0+0.08, Threads=1, Hash=64, `UHO_Lichess_4852_v1.epd`, so a result +points at exactly one change. All passed the same gates before their test: +zero warnings, `verify` (a)–(d), the VERIFY searches of section 6 with forced +GC at Hash 1 and 2, the reuse sequence at Hash 64, Hash 1 and from the 960 +start, and the smoke positions. There were no local games. + +| branch | change | bench | test | +| --- | --- | ---: | --- | +| `mcgs-v-arena12` | arenas sized for 12 edges per node instead of 8 | 764208 (unchanged, no GC in bench) | [5314](https://bench.rektdie.com/test/5314/) `[0.00, 5.00]` | +| `mcgs-v-edgeq` | 5b: each edge caches its child's Q; selection and recompute read only the edges (20-byte edge, no running sum) | 769193 | [5315](https://bench.rektdie.com/test/5315/) `[0.00, 5.00]` | +| `mcgs-v-stop` | 5a: a playout stops at a child with more visits than its edge | 609350 | [5316](https://bench.rektdie.com/test/5316/) `[0.00, 5.00]` | +| `mcgs-v-pathrep` | selection scores Q = 0 for an edge whose child repeats the current path or the game | 755448 | [5317](https://bench.rektdie.com/test/5317/) `[0.00, 5.00]` | +| `mcgs-v-novaluehash` | 5c: no value hash, all Hash to the graph | 765326 | [5318](https://bench.rektdie.com/test/5318/) Non-Regression `[-5.00, 0.00]` | +| `mcgs-v-reconcile` | 3.6.7: after reuse each root edge is all draws or none | 764208 (unchanged, no reuse in bench) | [5319](https://bench.rektdie.com/test/5319/) `[0.00, 5.00]` | + +Notes: + +- **Arena split.** Collections over the 16 bench positions at 5 s and + Hash 64 (local, four builds running at once, so noisy): 8 edges per node + gave 67, 12 gave 53, 16 gave 51 and 20 gave 57. With 16, more collections + move into the endgames. +- **Edge-Q cache.** Root decisions still read the children's current Q. + The VERIFY build checks each cached Q (finite, in [-1, 1], 0 without a + child), and check (b) compares the cached Q too. +- **Stop rule.** The depth limit now ends a playout the same way the stop + rule does. +- **Reconciliation.** In reuse sequences from KR v K and two pawn endgames, + 1–8 root edges were reconciled on most moves. The VERIFY build checks + after every reuse, collection and search that every visited root edge is + all draws exactly when its move draws. + +Outcomes are to be filled in. From e24145d0e59c5b434759e3b4d7dead3c6b6a3024 Mon Sep 17 00:00:00 2001 From: rektdie Date: Mon, 16 Nov 2026 23:15:35 +0100 Subject: [PATCH 3/4] docs: 5316 and 5318 passed, 5317 failed in mcgs-log Also re-encodes two lines that were written as cp1252. Co-Authored-By: Claude Opus 5.5 --- docs/mcgs-log.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/mcgs-log.md b/docs/mcgs-log.md index 4dfd0da..8edbb73 100644 --- a/docs/mcgs-log.md +++ b/docs/mcgs-log.md @@ -11,9 +11,9 @@ only from results the owner provides. | 3b | `mcgs-step3-reroot` | `d38f0b1` | 764208 | [5313](https://bench.rektdie.com/test/5313/) STC 8.0+0.08 `[0.00, 5.00]`, base `main` | passed: LLR 3.09, 4600 games, 0 lost on time | | 5 | `mcgs-v-arena12` | `0a9bb40` | 764208 | [5314](https://bench.rektdie.com/test/5314/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | | | 5b | `mcgs-v-edgeq` | `e7f2bfb` | 769193 | [5315](https://bench.rektdie.com/test/5315/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | | -| 5a | `mcgs-v-stop` | `59d5af5` | 609350 | [5316](https://bench.rektdie.com/test/5316/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | | -| 5 | `mcgs-v-pathrep` | `b7bfb0b` | 755448 | [5317](https://bench.rektdie.com/test/5317/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | | -| 5c | `mcgs-v-novaluehash` | `9e7c3ef` | 765326 | [5318](https://bench.rektdie.com/test/5318/) Non-Regression STC `[-5.00, 0.00]`, base `mcgs-step3-reroot` | | +| 5a | `mcgs-v-stop` | `59d5af5` | 609350 | [5316](https://bench.rektdie.com/test/5316/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | passed: Elo +12.35 ± 6.40, LLR 3.31, 4898 games | +| 5 | `mcgs-v-pathrep` | `b7bfb0b` | 755448 | [5317](https://bench.rektdie.com/test/5317/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | failed: Elo −2.06 ± 3.73, LLR −3.12, 12956 games | +| 5c | `mcgs-v-novaluehash` | `9e7c3ef` | 765326 | [5318](https://bench.rektdie.com/test/5318/) Non-Regression STC `[-5.00, 0.00]`, base `mcgs-step3-reroot` | passed: Elo +13.59 ± 7.51, LLR 3.16, 3120 games | | 4 | `mcgs-v-reconcile` | `79fd017` | 764208 | [5319](https://bench.rektdie.com/test/5319/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | | ## Step 1 measurements @@ -710,18 +710,18 @@ At `go movetime 40` in the same replay, mean playouts per move were: main Each branch is cut from `mcgs-step3-reroot` (`95e4909`) and tested against it at STC 8.0+0.08, Threads=1, Hash=64, `UHO_Lichess_4852_v1.epd`, so a result points at exactly one change. All passed the same gates before their test: -zero warnings, `verify` (a)–(d), the VERIFY searches of section 6 with forced +zero warnings, `verify` (a)–(d), the VERIFY searches of section 6 with forced GC at Hash 1 and 2, the reuse sequence at Hash 64, Hash 1 and from the 960 start, and the smoke positions. There were no local games. -| branch | change | bench | test | -| --- | --- | ---: | --- | -| `mcgs-v-arena12` | arenas sized for 12 edges per node instead of 8 | 764208 (unchanged, no GC in bench) | [5314](https://bench.rektdie.com/test/5314/) `[0.00, 5.00]` | -| `mcgs-v-edgeq` | 5b: each edge caches its child's Q; selection and recompute read only the edges (20-byte edge, no running sum) | 769193 | [5315](https://bench.rektdie.com/test/5315/) `[0.00, 5.00]` | -| `mcgs-v-stop` | 5a: a playout stops at a child with more visits than its edge | 609350 | [5316](https://bench.rektdie.com/test/5316/) `[0.00, 5.00]` | -| `mcgs-v-pathrep` | selection scores Q = 0 for an edge whose child repeats the current path or the game | 755448 | [5317](https://bench.rektdie.com/test/5317/) `[0.00, 5.00]` | -| `mcgs-v-novaluehash` | 5c: no value hash, all Hash to the graph | 765326 | [5318](https://bench.rektdie.com/test/5318/) Non-Regression `[-5.00, 0.00]` | -| `mcgs-v-reconcile` | 3.6.7: after reuse each root edge is all draws or none | 764208 (unchanged, no reuse in bench) | [5319](https://bench.rektdie.com/test/5319/) `[0.00, 5.00]` | +| branch | change | bench | test | result | +| --- | --- | ---: | --- | --- | +| `mcgs-v-arena12` | arenas sized for 12 edges per node instead of 8 | 764208 (unchanged, no GC in bench) | [5314](https://bench.rektdie.com/test/5314/) `[0.00, 5.00]` | | +| `mcgs-v-edgeq` | 5b: each edge caches its child's Q; selection and recompute read only the edges (20-byte edge, no running sum) | 769193 | [5315](https://bench.rektdie.com/test/5315/) `[0.00, 5.00]` | | +| `mcgs-v-stop` | 5a: a playout stops at a child with more visits than its edge | 609350 | [5316](https://bench.rektdie.com/test/5316/) `[0.00, 5.00]` | passed | +| `mcgs-v-pathrep` | selection scores Q = 0 for an edge whose child repeats the current path or the game | 755448 | [5317](https://bench.rektdie.com/test/5317/) `[0.00, 5.00]` | failed | +| `mcgs-v-novaluehash` | 5c: no value hash, all Hash to the graph | 765326 | [5318](https://bench.rektdie.com/test/5318/) Non-Regression `[-5.00, 0.00]` | passed | +| `mcgs-v-reconcile` | 3.6.7: after reuse each root edge is all draws or none | 764208 (unchanged, no reuse in bench) | [5319](https://bench.rektdie.com/test/5319/) `[0.00, 5.00]` | | Notes: @@ -735,7 +735,7 @@ Notes: - **Stop rule.** The depth limit now ends a playout the same way the stop rule does. - **Reconciliation.** In reuse sequences from KR v K and two pawn endgames, - 1–8 root edges were reconciled on most moves. The VERIFY build checks + 1–8 root edges were reconciled on most moves. The VERIFY build checks after every reuse, collection and search that every visited root edge is all draws exactly when its move draws. From 6e807b5565dba93a3c9ac8714870856f4ac9d773 Mon Sep 17 00:00:00 2001 From: rektdie Date: Mon, 16 Nov 2026 23:17:59 +0100 Subject: [PATCH 4/4] docs: 5314, 5315 and 5319 stopped unfinished in mcgs-log Co-Authored-By: Claude Opus 5.5 --- docs/mcgs-log.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/mcgs-log.md b/docs/mcgs-log.md index 8edbb73..d44d317 100644 --- a/docs/mcgs-log.md +++ b/docs/mcgs-log.md @@ -9,12 +9,12 @@ only from results the owner provides. | 2 | `mcgs-step2-split` | `fb1b8a5` | 663779 (identical to main) | | | | 3 | `mcgs-step3-core` | `14f672a` | 764208 | [5312](https://bench.rektdie.com/test/5312/) STC 8.0+0.08 `[0.00, 5.00]`, base `main` | failed: LLR −3.19, 4758 games, 106 lost on time | | 3b | `mcgs-step3-reroot` | `d38f0b1` | 764208 | [5313](https://bench.rektdie.com/test/5313/) STC 8.0+0.08 `[0.00, 5.00]`, base `main` | passed: LLR 3.09, 4600 games, 0 lost on time | -| 5 | `mcgs-v-arena12` | `0a9bb40` | 764208 | [5314](https://bench.rektdie.com/test/5314/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | | -| 5b | `mcgs-v-edgeq` | `e7f2bfb` | 769193 | [5315](https://bench.rektdie.com/test/5315/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | | +| 5 | `mcgs-v-arena12` | `0a9bb40` | 764208 | [5314](https://bench.rektdie.com/test/5314/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | stopped unfinished: Elo −0.99 ± 3.78, LLR −2.09, 12288 games | +| 5b | `mcgs-v-edgeq` | `e7f2bfb` | 769193 | [5315](https://bench.rektdie.com/test/5315/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | stopped unfinished: Elo +1.10 ± 3.32, LLR −0.52, 16676 games | | 5a | `mcgs-v-stop` | `59d5af5` | 609350 | [5316](https://bench.rektdie.com/test/5316/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | passed: Elo +12.35 ± 6.40, LLR 3.31, 4898 games | | 5 | `mcgs-v-pathrep` | `b7bfb0b` | 755448 | [5317](https://bench.rektdie.com/test/5317/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | failed: Elo −2.06 ± 3.73, LLR −3.12, 12956 games | | 5c | `mcgs-v-novaluehash` | `9e7c3ef` | 765326 | [5318](https://bench.rektdie.com/test/5318/) Non-Regression STC `[-5.00, 0.00]`, base `mcgs-step3-reroot` | passed: Elo +13.59 ± 7.51, LLR 3.16, 3120 games | -| 4 | `mcgs-v-reconcile` | `79fd017` | 764208 | [5319](https://bench.rektdie.com/test/5319/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | | +| 4 | `mcgs-v-reconcile` | `79fd017` | 764208 | [5319](https://bench.rektdie.com/test/5319/) STC `[0.00, 5.00]`, base `mcgs-step3-reroot` | stopped unfinished: Elo +1.61 ± 3.83, LLR 0.04, 12288 games | ## Step 1 measurements @@ -716,12 +716,12 @@ start, and the smoke positions. There were no local games. | branch | change | bench | test | result | | --- | --- | ---: | --- | --- | -| `mcgs-v-arena12` | arenas sized for 12 edges per node instead of 8 | 764208 (unchanged, no GC in bench) | [5314](https://bench.rektdie.com/test/5314/) `[0.00, 5.00]` | | -| `mcgs-v-edgeq` | 5b: each edge caches its child's Q; selection and recompute read only the edges (20-byte edge, no running sum) | 769193 | [5315](https://bench.rektdie.com/test/5315/) `[0.00, 5.00]` | | +| `mcgs-v-arena12` | arenas sized for 12 edges per node instead of 8 | 764208 (unchanged, no GC in bench) | [5314](https://bench.rektdie.com/test/5314/) `[0.00, 5.00]` | stopped | +| `mcgs-v-edgeq` | 5b: each edge caches its child's Q; selection and recompute read only the edges (20-byte edge, no running sum) | 769193 | [5315](https://bench.rektdie.com/test/5315/) `[0.00, 5.00]` | stopped | | `mcgs-v-stop` | 5a: a playout stops at a child with more visits than its edge | 609350 | [5316](https://bench.rektdie.com/test/5316/) `[0.00, 5.00]` | passed | | `mcgs-v-pathrep` | selection scores Q = 0 for an edge whose child repeats the current path or the game | 755448 | [5317](https://bench.rektdie.com/test/5317/) `[0.00, 5.00]` | failed | | `mcgs-v-novaluehash` | 5c: no value hash, all Hash to the graph | 765326 | [5318](https://bench.rektdie.com/test/5318/) Non-Regression `[-5.00, 0.00]` | passed | -| `mcgs-v-reconcile` | 3.6.7: after reuse each root edge is all draws or none | 764208 (unchanged, no reuse in bench) | [5319](https://bench.rektdie.com/test/5319/) `[0.00, 5.00]` | | +| `mcgs-v-reconcile` | 3.6.7: after reuse each root edge is all draws or none | 764208 (unchanged, no reuse in bench) | [5319](https://bench.rektdie.com/test/5319/) `[0.00, 5.00]` | stopped | Notes: