628 lines
36 KiB
Markdown
628 lines
36 KiB
Markdown
# MCGS log
|
||
|
||
One section per branch: commit, bench, SPRT link, outcome. Outcomes are filled in
|
||
only from results the owner provides.
|
||
|
||
| step | branch | commit | bench | SPRT (link, TC, bounds) | outcome |
|
||
| --- | --- | --- | --- | --- | --- |
|
||
| 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 | [5310](https://bench.rektdie.com/test/5310/) STC 8.0+0.08 `[0.00, 5.00]`; [5311](https://bench.rektdie.com/test/5311/) LTC 40.0+0.40 `[0.00, 5.00]`; base `mcgs-step2-split` | |
|
||
|
||
## Step 1 measurements
|
||
|
||
All numbers below come from the **stats build** (`make STATS=1`) at `bec9871`, on
|
||
the owner's Windows machine, 2026-11-16. Rates, cycle shares and playouts per
|
||
second are local measurements of that build. They say nothing about strength.
|
||
|
||
**Stats-build overhead.** The key maps and timers slow the search down. Over the
|
||
16 positions, the normal build ran:
|
||
|
||
- 811k playouts/s at 1000 ms (12.7M playouts);
|
||
- 770k playouts/s at 5000 ms (61.3M playouts).
|
||
|
||
The stats build ran 498k/s and 474k/s, about 61 % of that. A stats-build
|
||
5000 ms tree is about the size of a normal-build 3 s tree.
|
||
|
||
**Definitions** (plan section 4, with these choices made explicit):
|
||
|
||
- A *tree node* is a node MCGS would create: the root, plus every
|
||
first-visited position that is not a path-dependent draw. Repetition and
|
||
50-move leaves are never graph nodes, so they are not counted.
|
||
- `newleaf` = playouts that end at such a first visit.
|
||
- `lf_tt` (`leaf_tt`) = new leaves whose key already had a tree node, as a
|
||
percentage of new leaves. That is the denominator the ValueHash comment uses
|
||
("leaf evaluations"). Per playout it is about 0.55× that.
|
||
- `vh` = ValueHash hits as a percentage of all first visits.
|
||
- `exp_dup` = expansions of a key that already had an expanded node, as a
|
||
percentage of expansions.
|
||
- `path_tt` = playouts with at least one path node whose key has ≥ 2 tree nodes.
|
||
`inner` is the same count without the new leaf.
|
||
- `dup` = tree nodes / distinct keys.
|
||
- `r_tree` = child slots / visited nodes: edges per node in the step 2 layout.
|
||
- `r_grph` = child slots counted once per distinct expanded key / distinct keys,
|
||
which approximates edges per node after merging.
|
||
- The key maps are rebuilt from the tree after root expansion, reroot and every
|
||
GC. The end-of-search figures are taken after the last GC.
|
||
|
||
Each run searched the 16 bench positions, each with a fresh `Searcher` (so no
|
||
reuse), at Hash 64 unless stated otherwise.
|
||
|
||
### `mcgsstats 1000` (Hash 64)
|
||
|
||
```
|
||
pos playouts po/s newleaf lf_tt tt_exp vh exp_dup path_tt inner rep r50 dup r_tree r_grph gc
|
||
1 249792 254889 249757 51.8 34.0 50.8 47.8 95.8 95.0 11 0 1.965 15.74 17.14 1
|
||
2 171008 174497 170960 23.8 15.1 22.9 22.1 92.9 92.6 16 0 1.278 14.88 15.37 1
|
||
3 250240 255346 250197 56.4 38.1 56.1 53.0 89.6 88.4 41 0 2.080 13.04 14.37 2
|
||
4 277376 283036 277372 76.8 58.3 76.5 74.2 95.4 94.7 2 0 4.076 14.73 15.45 2
|
||
5 232512 237257 232455 40.4 25.7 39.2 36.1 87.0 85.3 56 0 1.605 16.64 17.95 1
|
||
6 202944 207085 201798 32.1 20.5 30.7 29.9 88.4 87.4 206 0 1.430 15.48 16.08 1
|
||
7 192064 195983 191629 30.0 18.6 29.0 28.8 89.0 88.2 392 0 1.386 16.16 16.71 1
|
||
8 199808 203885 199106 23.2 14.5 22.5 20.9 80.5 79.4 684 0 1.263 16.85 17.67 1
|
||
9 252928 258089 250454 39.8 25.7 37.6 36.6 91.9 91.0 2418 0 1.546 9.05 9.79 1
|
||
10 307136 313404 268891 41.7 29.4 36.7 38.6 96.3 96.0 37831 0 1.716 11.09 11.75 0
|
||
11 886848 904946 451555 91.2 78.0 86.3 90.5 100.0 100.0 432838 0 11.403 4.09 7.98 0
|
||
12 821440 838204 524144 91.2 82.4 86.5 89.4 99.9 99.8 296636 0 11.331 3.56 4.61 0
|
||
13 224384 228963 223701 24.5 15.0 21.5 22.1 74.6 72.8 616 0 1.325 13.93 14.44 0
|
||
14 244992 247716 243015 31.4 20.2 29.7 28.3 88.4 87.6 1975 0 1.379 11.49 12.22 2
|
||
15 679936 693812 672593 93.8 75.5 88.5 88.9 99.7 99.6 6524 0 14.199 3.09 7.59 1
|
||
16 2625600 2679183 14470 34.0 21.3 32.7 29.9 99.3 99.3 2562358 0 1.515 12.70 13.58 0
|
||
all 7819008 498375 4422097 60.1 46.5 57.4 56.2 96.0 95.6 3342604 0 2.536 9.47 14.03 14
|
||
```
|
||
|
||
### `mcgsstats 5000` (Hash 64)
|
||
|
||
```
|
||
pos playouts po/s newleaf lf_tt tt_exp vh exp_dup path_tt inner rep r50 dup r_tree r_grph gc
|
||
1 1016192 204054 1015943 50.2 30.0 56.2 43.9 97.9 97.5 81 0 1.778 6.46 7.19 12
|
||
2 786880 156874 785729 19.9 10.8 24.0 16.3 96.6 96.5 535 0 1.210 6.26 6.44 9
|
||
3 1186880 238329 1186600 63.6 39.6 71.3 57.6 95.0 94.4 252 0 2.407 8.97 10.20 17
|
||
4 1244480 249895 1244387 73.5 50.5 80.4 67.0 97.6 97.3 77 0 3.885 9.09 11.53 16
|
||
5 1053568 211009 1052812 43.8 25.2 49.8 36.8 92.9 92.0 743 0 1.649 5.94 6.57 13
|
||
6 914112 183556 904648 33.9 19.1 36.8 28.1 94.3 93.9 4722 0 1.438 7.00 7.61 9
|
||
7 958720 192514 944891 31.5 18.2 37.0 27.4 96.1 95.8 13719 0 1.405 9.56 9.98 10
|
||
8 944000 189558 936972 22.9 12.5 28.0 18.4 92.4 92.0 6815 0 1.242 7.42 7.90 11
|
||
9 1159680 230828 1143522 40.5 25.2 42.0 35.0 93.9 93.3 15583 0 1.518 4.35 4.75 8
|
||
10 1658304 332992 1265760 51.5 34.4 47.7 43.9 99.1 99.0 389253 0 1.844 5.52 6.50 7
|
||
11 4141760 831678 1755422 92.2 78.4 86.9 90.5 100.0 100.0 2366999 0 12.889 2.80 6.53 4
|
||
12 3398208 682371 1913929 93.7 83.7 87.5 91.7 100.0 100.0 1307918 0 13.707 2.57 4.14 3
|
||
13 973888 195559 955354 27.2 15.4 28.6 22.3 89.5 88.9 14102 0 1.328 6.27 6.78 7
|
||
14 1050432 210930 1035983 27.2 14.8 32.5 21.1 94.5 94.2 14413 0 1.318 7.58 8.20 12
|
||
15 3230592 648713 3202909 96.0 78.0 90.9 89.9 99.9 99.9 24843 0 19.104 2.93 7.39 15
|
||
16 14102272 2831781 41850 40.1 25.6 38.1 35.1 99.9 99.8 13855364 0 1.670 12.31 13.34 0
|
||
all 37819968 474094 19386711 60.7 45.0 61.5 57.2 98.3 98.2 18015419 0 2.674 5.04 7.38 153
|
||
```
|
||
|
||
### `mcgsstats 5000 16` (Hash 16, GC-heavy)
|
||
|
||
```
|
||
pos playouts po/s newleaf lf_tt tt_exp vh exp_dup path_tt inner rep r50 dup r_tree r_grph gc
|
||
1 1047040 210248 1046869 42.5 20.8 54.9 33.1 94.6 93.8 37 0 1.689 5.27 5.92 60
|
||
2 792384 159113 791393 15.4 6.8 24.6 10.7 96.4 96.2 378 0 1.219 3.98 4.12 41
|
||
3 1216576 243851 1216235 56.4 29.2 69.6 45.7 94.4 93.6 258 0 2.067 3.92 4.32 83
|
||
4 1238592 248713 1238497 63.9 36.2 76.5 54.4 97.0 96.5 16 0 2.992 6.02 7.54 79
|
||
5 1056896 211972 1055994 34.6 16.2 48.0 25.0 90.8 89.7 838 0 1.428 3.61 3.97 64
|
||
6 853312 171347 847890 15.9 7.1 27.9 10.8 93.8 93.3 2705 0 1.149 3.51 3.61 45
|
||
7 948608 190139 945462 27.8 14.0 39.4 21.2 97.1 96.8 2859 0 1.422 3.57 3.67 51
|
||
8 930112 186769 926062 14.7 6.9 29.2 10.1 89.1 88.5 3640 0 1.145 5.08 5.31 51
|
||
9 1138688 228652 1130927 28.9 15.0 37.8 21.7 89.0 87.9 7255 0 1.290 2.67 2.83 42
|
||
10 1390144 279145 1170515 38.4 20.6 36.6 27.7 98.7 98.6 215548 0 1.560 3.03 3.44 34
|
||
11 4220352 847460 1785559 89.4 74.6 84.0 86.6 100.0 100.0 2421567 0 11.163 1.27 2.38 25
|
||
12 3396352 681998 1876547 89.9 75.6 81.8 85.2 100.0 100.0 1494614 0 8.520 1.83 3.00 24
|
||
13 980480 196883 960668 18.4 9.0 29.6 13.1 86.2 85.5 14413 0 1.152 3.95 4.18 37
|
||
14 1125632 225622 1093084 23.9 10.8 36.7 16.2 93.4 93.0 32457 0 1.279 3.19 3.39 61
|
||
15 3027584 607948 3012539 93.1 65.9 81.6 79.3 99.9 99.9 13000 0 9.931 1.59 5.07 67
|
||
16 14088960 2829108 41827 40.2 25.7 34.5 35.3 99.9 99.8 13842528 0 1.673 12.29 13.33 0
|
||
all 37451712 469831 19140068 53.6 35.9 57.6 48.9 97.7 97.5 18052113 0 2.162 3.09 4.25 764
|
||
```
|
||
|
||
### Extra: `mcgsstats 5000 1024` (no GC)
|
||
|
||
Not in the plan. GC prunes child slots, so the end-of-search `r` at Hash 64
|
||
(153 GCs) is a post-pruning figure. At Hash 1024 no GC happens, and `r` is the
|
||
ratio at which an arena fills.
|
||
|
||
```
|
||
pos playouts po/s newleaf lf_tt tt_exp vh exp_dup path_tt inner rep r50 dup r_tree r_grph gc
|
||
1 1108224 222534 1107765 58.2 41.7 56.9 55.7 98.3 98.0 77 0 2.391 18.88 19.93 0
|
||
2 797824 160205 794007 18.7 11.5 18.3 17.5 97.4 97.3 2446 0 1.231 20.02 20.27 0
|
||
3 1261888 253391 1261542 71.8 57.0 70.8 70.1 95.2 94.8 270 0 3.546 20.37 21.55 0
|
||
4 1263936 253802 1263722 77.1 62.6 76.4 76.1 97.9 97.7 214 0 4.373 20.66 21.31 0
|
||
5 1150592 231042 1149845 53.9 38.8 52.4 51.3 94.6 93.9 747 0 2.168 19.50 20.45 0
|
||
6 972288 195238 967436 39.8 27.2 38.8 38.0 94.4 93.9 2466 0 1.660 19.58 20.01 0
|
||
7 994816 199762 994059 41.5 28.7 40.4 40.5 97.7 97.5 554 0 1.709 19.98 20.18 0
|
||
8 972480 195277 966716 26.4 17.0 25.8 24.6 92.8 92.3 5155 0 1.359 20.98 21.51 0
|
||
9 1183744 237699 1162150 42.6 28.8 41.9 39.8 96.0 95.5 20460 0 1.743 13.17 13.81 0
|
||
10 1859456 373384 1267715 55.9 42.9 54.2 53.1 98.5 98.4 586712 0 2.268 10.90 11.72 0
|
||
11 4432384 890036 1785406 93.7 83.5 89.6 93.1 100.0 100.0 2625372 0 15.750 4.41 8.97 0
|
||
12 3578688 718612 2007906 94.5 86.8 90.8 93.5 100.0 100.0 1367082 0 18.339 3.59 5.31 0
|
||
13 1042880 209413 1022986 31.7 21.7 30.9 29.5 89.2 88.5 15776 0 1.465 14.12 14.90 0
|
||
14 1226432 246271 1212002 39.7 28.1 38.7 37.7 96.5 96.3 14361 0 1.658 19.99 20.44 0
|
||
15 4031168 809471 3983269 98.0 89.9 96.6 96.6 100.0 99.9 44174 0 49.578 5.45 9.66 0
|
||
16 14052352 2821757 41766 40.1 25.6 39.4 35.1 99.9 99.8 13806006 0 1.669 12.29 13.33 0
|
||
all 39929152 501118 20988292 66.0 54.8 64.6 63.8 98.5 98.4 18491872 0 2.938 13.04 18.13 0
|
||
```
|
||
|
||
### Totals
|
||
|
||
| counter | 1000 ms | 5000 ms | 5000 ms, Hash 16 | 5000 ms, Hash 1024 |
|
||
| --- | ---: | ---: | ---: | ---: |
|
||
| playouts | 7,819,008 | 37,819,968 | 37,451,712 | 39,929,152 |
|
||
| new leaves (% of playouts) | 56.6 % | 51.3 % | 51.1 % | 52.6 % |
|
||
| `leaf_tt` (% of new leaves) | **60.1 %** | **60.7 %** | **53.6 %** | **66.0 %** |
|
||
| `leaf_tt` (% of playouts) | 34.0 % | 31.1 % | 27.4 % | 34.7 % |
|
||
| `leaf_tt_expanded` (% of new leaves) | 46.5 % | 45.0 % | 35.9 % | 54.8 % |
|
||
| `vh_hits` (% of first visits) | 57.4 % | 61.6 % | 57.6 % | 64.6 % |
|
||
| `leaf_tt_eval` (% of value calls) | 7.4 % | 13.2 % | 18.4 % | 2.1 % |
|
||
| value calls (% of playouts) | 23.7 % | 19.4 % | 21.3 % | 18.3 % |
|
||
| `exp_dup` (% of expansions) | 56.2 % | 57.2 % | 48.9 % | 63.8 % |
|
||
| `path_tt` / `inner` (% of playouts) | 96.0 / 95.6 % | 98.3 / 98.2 % | 97.7 / 97.5 % | 98.5 / 98.4 % |
|
||
| `rep_draws` (% of playouts) | 42.7 % | 47.6 % | 48.2 % | 46.3 % |
|
||
| `rep_draws` without position 16 | 780,246 | 4,160,055 | 4,209,585 | 4,685,866 |
|
||
| `r50_draws` | 0 | 0 | 0 | 0 |
|
||
| GC runs | 14 | 153 | 764 | 0 |
|
||
| `dup` (tree nodes / distinct keys) | 2.54 | 2.67 | 2.16 | 2.94 |
|
||
| visited / allocated | 10.6 % | 19.8 % | 32.4 % | 7.7 % |
|
||
| `r_tree` (edges per node) | 9.47 | 5.04 | 3.09 | **13.04** |
|
||
| `r_graph` (edges per distinct key) | 14.03 | 7.38 | 4.25 | **18.13** |
|
||
|
||
`tt_halfmove_hist`: the halfmove clock at `leaf_tt` hits, as a share of hits.
|
||
|
||
| halfmove | 1000 ms | 5000 ms | 5000 ms, Hash 16 | 5000 ms, Hash 1024 |
|
||
| --- | ---: | ---: | ---: | ---: |
|
||
| 0 | 22.5 % | 22.2 % | 21.0 % | 22.0 % |
|
||
| 1–3 | 28.4 % | 27.9 % | 26.0 % | 28.0 % |
|
||
| 4–7 | 36.5 % | 34.6 % | 38.6 % | 29.8 % |
|
||
| 8–15 | 12.4 % | 15.0 % | 14.0 % | 19.8 % |
|
||
| 16–31 | 0.24 % | 0.38 % | 0.38 % | 0.35 % |
|
||
| 32–63 | 0 | 0 | 0 | 0 |
|
||
| ≥ 64 | 0 | 0 | 0 | 0 |
|
||
|
||
Time split, as a share of `playout()` cycles (rdtsc, stats build). `vhash` is
|
||
also counted inside `backprop` (the store) and in leaf evaluation (the probe).
|
||
|
||
| part | 1000 ms | 5000 ms | 5000 ms, Hash 16 | 5000 ms, Hash 1024 |
|
||
| --- | ---: | ---: | ---: | ---: |
|
||
| value (net + qsearch) | 23.0 % | 18.9 % | 20.1 % | 18.2 % |
|
||
| policy | 13.9 % | 14.0 % | 15.5 % | 12.2 % |
|
||
| movegen | 5.4 % | 5.2 % | 5.5 % | 5.0 % |
|
||
| `select_child` | 28.0 % | 30.7 % | 28.8 % | 32.3 % |
|
||
| backprop loop | 11.1 % | 11.7 % | 11.1 % | 12.8 % |
|
||
| ValueHash probe + store | 6.2 % | 6.3 % | 5.9 % | 6.7 % |
|
||
| `make_move` | 5.3 % | 5.7 % | 5.6 % | 5.7 % |
|
||
|
||
### Derived bounds (stats build)
|
||
|
||
The table gives the search time MCGS could free, as a share of playout time.
|
||
`f_value` is applied per value call and `f_policy` per expansion, because
|
||
those are what the timers cover.
|
||
|
||
| | 1000 ms | 5000 ms | 5000 ms, Hash 16 | 5000 ms, Hash 1024 |
|
||
| --- | ---: | ---: | ---: | ---: |
|
||
| plan formula `f_value·max(0, leaf_tt − vh_hits)/value_calls + f_policy·exp_dup/expansions` | 8.96 % | 8.03 % | 7.59 % | 8.16 % |
|
||
| exact value term `f_value·leaf_tt_eval/value_calls + f_policy·exp_dup/expansions` | 9.52 % | 10.51 % | 11.28 % | 8.13 % |
|
||
| of which policy (`f_policy·exp_dup/expansions`) | 7.82 % | 8.03 % | 7.59 % | 7.75 % |
|
||
| cost upper bound `f_select + f_backprop` | 39.1 % | 42.4 % | 39.8 % | 45.1 % |
|
||
|
||
- **The saving is mostly policy, not value.** ValueHash already answers almost
|
||
every leaf transposition.
|
||
- The value evaluations MCGS would still skip (`leaf_tt_eval`: transposed
|
||
leaves that missed ValueHash) are 2–18 % of value calls.
|
||
- They grow with GC because ValueHash is small: 64 MB / 32 / 12 B ≈ 175k
|
||
entries, so entries get overwritten.
|
||
- About 55 % of expansions repeat an already-expanded key, and those policy
|
||
calls are what MCGS saves.
|
||
- **The plan formula's value term is 0 at 5000 ms (Hash 64 and Hash 16)**,
|
||
because `vh_hits > leaf_tt` there. After GC, ValueHash also answers positions
|
||
that GC dropped from the tree, which `leaf_tt` does not count. The exact
|
||
counter `leaf_tt_eval` is the right numerator, so the second row is the bound
|
||
to use.
|
||
- **The cost bound is loose.** `select_child` is about 30 % of playout time
|
||
today. The recompute per path node costs about one more `select_child` pass,
|
||
so the real added cost is below roughly 40 %. Steps 2 and 3 measure it. None
|
||
of these bounds covers what sharing subtree statistics is worth; only the SPRT
|
||
measures that.
|
||
- **Shared structure is everywhere.**
|
||
- 96–99 % of playouts pass through a node whose key has at least two tree
|
||
nodes.
|
||
- On average there are 2.2–2.9 tree nodes per distinct position.
|
||
- **Variant 5d (window key for halfmove ≥ T).**
|
||
- No `leaf_tt` hit had halfmove ≥ 32, and 0.24–0.38 % had 16–31. So T = 16
|
||
would lose under 0.4 % of the merges here, and T ≥ 32 none.
|
||
- That says little: every bench position starts with halfmove 0–8, so long
|
||
reversible stretches are under-represented. `r50_draws` is 0 for the same
|
||
reason.
|
||
- **Repetition draws are common: 43–48 % of playouts.**
|
||
- Position 16 (`6k1/6p1/8/6KQ/1r6/q2b4/8/8 w`) alone has 2.6M of the 3.3M at
|
||
1000 ms and 13.9M of the 18.0M at 5000 ms. It is a perpetual-check position
|
||
where 98 % of playouts end in a repetition.
|
||
- Without it there are still 0.8M (1 s) to 4.7M (5 s) repetition-draw
|
||
playouts, mostly in positions 10–12.
|
||
- So the per-edge draw counts of 3.5 will get real use.
|
||
|
||
### Cross-check against the ValueHash comment (37–85 %)
|
||
|
||
The comment in `mcts.h` says 37–85 % of leaf evaluations in a 5-second search
|
||
repeat a position already evaluated. Measured `leaf_tt` over all positions:
|
||
|
||
- 60.1 % at 1000 ms;
|
||
- 60.7 % at 5000 ms;
|
||
- 53.6 % at Hash 16;
|
||
- 66.0 % without GC.
|
||
|
||
All four are inside the range. Per position the spread is wider, 15–98 %:
|
||
|
||
- Low: the open middlegames 2 and 8, at 15–26 %.
|
||
- High: the pawn endgames 11 and 12 and the rook endgame 15, at 89–98 %.
|
||
|
||
The comment does not say which positions it measured, so a wider spread per
|
||
position is plausible. `vh_hits` stays within a few points of `leaf_tt` in every
|
||
row, which is consistent with the counters being right.
|
||
|
||
### Edges per node for the arena split (step 2)
|
||
|
||
| measurement | `r_tree` (edges per visited node) | `r_graph` (per distinct key) |
|
||
| --- | ---: | ---: |
|
||
| 5000 ms, Hash 1024, no GC (growth ratio) | **13.0** (per position 3.6–21.0; middlegames 18.9–21.0, endgames 11/12/15 3.6–5.5) | 18.1 |
|
||
| 5000 ms, Hash 64, end of search after 153 GCs | 5.0 (2.6–12.3) | 7.4 |
|
||
| 1000 ms, Hash 64 (14 GCs) | 9.5 | 14.0 |
|
||
| 5000 ms, Hash 16 (764 GCs) | 3.1 | 4.3 |
|
||
|
||
- With 16 B edges and 32 B nodes, the edge-to-node arena byte ratio is `r/2`:
|
||
6.5 at r = 13, about 10 for middlegames at r ≈ 20.
|
||
- GC keeps pruned nodes and drops their edges, so `r` right after a collection
|
||
is far below the ratio at which the arenas fill between collections.
|
||
- The no-GC figure decides which arena fills first. Step 2 should size for it,
|
||
or for the middlegame value, and check that the 5000 ms Hash 64 runs do not
|
||
hit GC on the node arena first.
|
||
|
||
## Step 2: Edge/Node split (`mcgs-step2-split`)
|
||
|
||
Code at `fb1b8a5`, on top of `mcgs-plan` (`479f6cf`). Commits:
|
||
|
||
- `18911b0` tests: add `tests/fischer.epd` (sha256 `4bc384f2…70b3cd`, checked);
|
||
- `6629525` the split itself;
|
||
- `226106e` the `verify` command (VERIFY builds only);
|
||
- `fb1b8a5` the arena-split comment.
|
||
|
||
What changed: 16-byte `Edge` and 32-byte `Node` in two arenas (plan 3.2), lazy
|
||
node creation, edge visits kept equal to child visits, selection and root
|
||
decisions on edges, root index as a member, and mark → forwarding → slide →
|
||
remap compaction for both arenas with the tree-exact threshold. `key`/`check` are
|
||
set at node creation, and `u`/`base` are set by pruning. Nothing reads them yet.
|
||
`draws` stays 0. Path draws still live in `node.state`.
|
||
|
||
**Arena split: 8 edges per node** (edge arena 128 of every 160 bytes). All of the
|
||
following are local single runs at 5 s, Hash 64, on the 16 bench positions. GC runs:
|
||
|
||
| | main | 4 | 6 | 8 | 13 | 20 |
|
||
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
|
||
| GC runs | 200 | 217 | 183 | 184 | 184 | 249 |
|
||
|
||
- 13 (the no-GC growth ratio) cut middlegame collections further. It gave 2–3× more
|
||
in positions 11, 12 and 15, where the node arena fills first.
|
||
- 8 stays near main in every phase.
|
||
- Step 4 re-measures this split once the graph exists.
|
||
|
||
Deviations from the plan's wording:
|
||
|
||
- `src/uci.cpp` gains the VERIFY-only `verify` command.
|
||
- VERIFY builds also run `verify_tree` at the end of every search, not only on
|
||
the next search. Otherwise a single `go` would never be checked.
|
||
- `verify_tree` additionally recomputes each node's state from its position and
|
||
its path, including repetition. That is exact while the search is a tree.
|
||
- Check (b) identifies nodes by move path, not by key, because a tree has
|
||
several nodes per key.
|
||
- `info string reused N nodes` now counts positions, not child slots.
|
||
|
||
### Gates (all on the owner's machine, 2026-11-16)
|
||
|
||
- **Build:** `make -j EXE=rigby-dev` and the VERIFY build, zero warnings.
|
||
- **Bench:** `663779`, identical to main.
|
||
- **Perft:**
|
||
- `perftsuite`: all passed (590,175,385 nodes);
|
||
- `perftfile tests/fischer.epd 5`: 960 positions, 0 failed, 17,614,927,759 nodes, 53 s.
|
||
- **Reuse sequence**, Hash 256, `go nodes 50000`, 10 moves (best move plus the
|
||
second PV move): every `bestmove` and every `info depth` line (depth, seldepth,
|
||
score, nodes, PV) identical to main. Only `nps`, `time`, `hashfull` and the
|
||
`reused N` count differ.
|
||
- **VERIFY searches**, all clean (`tree verified` after every reroot, GC and
|
||
search, no abort):
|
||
- the `go nodes 200000` positions of section 6, including the 960 start with
|
||
`UCI_Chess960 true`;
|
||
- forced GC with `go nodes 300000`: Hash 1 gave 144 collections (startpos) and
|
||
121 (960); Hash 2 gave 82 and 63;
|
||
- the reuse sequence with the VERIFY build at Hash 64, at Hash 1 (28–36
|
||
collections per move) and from the 960 start.
|
||
- Under GC the output differs from main because the bytes per node differ.
|
||
That is expected.
|
||
- **`verify`:**
|
||
- (a) 96,434 random plies over 7 standard and 960 FENs, incremental key = FEN key;
|
||
- (b) three forced collections (to 1/2, 1/4, 1/8) and a reroot on 4
|
||
positions, all survivors identical.
|
||
- **Smoke:**
|
||
- `go nodes 1`, `go nodes 2`, `go depth 1` on the section 6 positions (plus
|
||
the perpetual-check bench position and two no-move positions): output
|
||
identical to main;
|
||
- cutechess-ob: 100 games of dev vs main at 2+0.02, Hash 16, UHO book, and 20
|
||
games of the VERIFY build against itself at `nodes=20000`. All games ended by
|
||
mate, the 50-move rule, repetition or insufficient material. There were no
|
||
illegal moves, disconnects, time forfeits or aborts. Not strength evidence.
|
||
- **Note:** on `6k1/5ppp/8/8/8/8/5PPP/3R2K1 w - - 0 1` both main and step 2 play
|
||
`g1f1` at 200k nodes, not `Rd8#`. White is a rook up, every move already has
|
||
Q ≈ 0.996, and the mate (Q = 1) barely stands out. This was there before the
|
||
split.
|
||
|
||
### NPS versus main (local, noisy machine)
|
||
|
||
The machine had other load (about 40 % CPU from other applications), so main and
|
||
step 2 were run interleaved.
|
||
|
||
| measurement | main | step 2 | ratio |
|
||
| --- | ---: | ---: | ---: |
|
||
| `bench` nps, 5 alternating runs each (mean) | 3,443,510 | 3,356,540 | 0.975 |
|
||
| playouts/s, 5 s per bench position, Hash 64, interleaved per position, 2 rounds | 610,987 | 545,670 | **0.893** |
|
||
| the same at Hash 1024 (no GC), 1 round | 778,216 | 679,995 | 0.874 |
|
||
|
||
- The loss grows with tree size (−2.5 % on bench's 5000-playout trees, −11 to
|
||
−13 % at 5 s). It is the same without GC, so it is in the playout, not in
|
||
compaction.
|
||
- Likely cause: selection now loads every visited child node, scattered over
|
||
the node arena, where it used to read sibling Q values from one contiguous
|
||
block.
|
||
- A software prefetch of those nodes and `alignas(32)` nodes were each tried and
|
||
each measured within noise (+0.5 %, +0.7 %). Both were dropped.
|
||
- Variant 5b (edge-Q cache) is the plan's answer to this cost.
|
||
- The drop is over 3 %, so the plan's LTC condition applies.
|
||
|
||
### SPRT (owner)
|
||
|
||
- STC Non-Regression `[-5.00, 0.00]`, 8.0+0.08, Threads=1, Hash=64,
|
||
`UHO_Lichess_4852_v1.epd`: link and outcome to be filled in.
|
||
- LTC Non-Regression `[-5.00, 0.00]`, 40.0+0.40, Threads=1, Hash=256 (NPS drop
|
||
> 3 %): link and outcome to be filled in.
|
||
|
||
## Step 3: MCGS core (`mcgs-step3-core`)
|
||
|
||
Code at `14f672a`, on top of `mcgs-step2-split` (`5424e1a`). Commits:
|
||
|
||
- `6ec8769`: the MCGS core (search, key table, sizing, graph-safe GC
|
||
threshold, graph `verify_tree`, key-based check (b));
|
||
- `14f672a`: checks (c) and (d) of the `verify` command (VERIFY builds only).
|
||
|
||
**Bench: 764208** (step 2 and main: 663779). The bench changes for three reasons:
|
||
|
||
- The tree becomes a graph: transpositions share nodes, so playouts run on
|
||
through existing nodes, and their depths and visited positions change.
|
||
- The root gets its own evaluation, and N = 1 + the edges' visits.
|
||
- Repetitions and the 50-move rule are judged on every playout instead of
|
||
once per node.
|
||
|
||
What changed (plan 3.1–3.5 and 3.6.5):
|
||
|
||
- **Key table.** Each slot is 8 bytes, `{key_hi, node}`, with linear probing.
|
||
The table is a power of two with at least 2× the node arena's slots. A hit
|
||
needs the full key and the 16-bit check. The table is rebuilt after every
|
||
collection and reroot.
|
||
- **Node creation.** `create_node` evaluates a position on its first visit
|
||
(N = base = 1, q = u). The root is created and evaluated through it.
|
||
- **Descent.** After `make_move`, repetition and the 50-move rule (mate
|
||
first) are judged before the lookup, and they are only ever counted in
|
||
`edge.draws`. An edge links to its child on first selection, to an
|
||
existing node when the table has one. `MAX_PLAYOUT_DEPTH` is 512.
|
||
- **Backprop.** For every path node: `edge.visits++` (and `draws++` for a
|
||
path draw), `node.visits++`, and q = (base·u − Σ (N−D)·c.q) / N, summed in
|
||
`double`. ValueHash is stored for every path node, with no `TERMINAL_DRAW`
|
||
test. The butterfly update is as before.
|
||
- **Edges everywhere.** Selection, root decisions, score, PV and dashboard
|
||
use edges, with draws counted as 0. The PV also stops after a repeated
|
||
position and at 64 plies.
|
||
- **Root check.** At search start, the root's edges are checked against its
|
||
legal moves. If they differ, the graph is cleared.
|
||
- **GC threshold.** It uses a visited bitmap and counts the root apart, so
|
||
the estimate stays an upper bound on a DAG.
|
||
- **Hash split.** Hash now covers the node arena, the edge arena (still 8
|
||
edges per node) and the table. The table's power of two is rounded down or
|
||
up, whichever leaves more nodes. At Hash 64 that gives 353,894 nodes and
|
||
2^20 slots (step 2: 406,323 nodes).
|
||
|
||
Deviations and choices the plan does not cover:
|
||
|
||
- **Full node arena.** If node allocation fails, the playout is dropped
|
||
without a trace: no visit is counted and no iteration is used. The graph is
|
||
then collected. The plan only says what happens when expansion fails
|
||
(value −n.q, the node's visit counted as a base visit, so q = u stays).
|
||
- **Depth limit.** At `MAX_PLAYOUT_DEPTH`, the node reached is not changed;
|
||
only the edge into it counts the visit. The recompute reads its q anyway.
|
||
- **Terminal nodes** count each visit in `base` as well, so N = base + Σ
|
||
edge visits holds for every node and VERIFY can check it everywhere.
|
||
- **Former roots.** `verify_tree` accepts a non-terminal node with
|
||
insufficient material at the root and at positions of the game history
|
||
(former roots). Insufficient material is never terminal at the root.
|
||
- **Arena split.** It stays at 8 edges per node, the step 2 value. In graph
|
||
searches the edge arena fills first: at the end of 5 s searches,
|
||
`hashfull` comes from the edge arena. Step 4 re-measures the split, as
|
||
planned.
|
||
|
||
### Gates (owner's machine, 2026-11-16)
|
||
|
||
- **Build:** normal and VERIFY builds, zero warnings.
|
||
- **Bench:** `764208`.
|
||
- **Perft:**
|
||
- `perftsuite`: all passed (590,175,385 nodes);
|
||
- `perftfile tests/fischer.epd 5`: 960 positions, 0 failed,
|
||
17,614,927,759 nodes, 55 s.
|
||
- **VERIFY searches** (`go nodes 200000`), each ending with `tree verified`
|
||
and no abort:
|
||
- startpos;
|
||
- the transposition line;
|
||
- the history repetition (`g1f3 g8f6 f3g1 f6g8 g1f3 g8f6`);
|
||
- bench positions 11, 12, 15 and 16;
|
||
- `8/8/8/4k3/8/8/2KR4/8 w - - 95 100` (seldepth 5);
|
||
- the mate-in-1 FEN (still `g1f1`, as on main and step 2);
|
||
- the 960 start with `UCI_Chess960 true`.
|
||
- **Forced GC** (`go nodes 300000`), every collection verified:
|
||
- Hash 1: 190 collections (startpos) and 145 (960);
|
||
- Hash 2: 104 and 77.
|
||
- **Reuse sequence** (VERIFY build, `go nodes 50000`, best move plus the
|
||
second PV move, 10 moves), clean every time:
|
||
- Hash 64 (21k–69k positions reused per move);
|
||
- Hash 1 (24–42 collections per move);
|
||
- the 960 start at Hash 64.
|
||
- **`verify`**, all passed:
|
||
- (a) 96,434 plies, incremental key = FEN key.
|
||
- (b) Three forced collections (to 1/2, 1/4 and 1/8) and a reroot on 4
|
||
positions: every survivor is identical by key, including edges and child
|
||
keys, and no pruned node has more visits than a kept one.
|
||
- (c) Five positions with forced or frequent repetitions and 50-move draws
|
||
(knight shuffle in the history, perpetual check, KR v K at half-move 95,
|
||
two pawn endgames). Every node state matches its position alone, and the
|
||
draws appear on edges: 30 to 29,077 draw visits per position. In the
|
||
KR v K position, 10,504 draw edges are at half-move 100+.
|
||
- (d) After every forced collection and reroot, the table has exactly one
|
||
entry per surviving node, and the table finds each node by its position.
|
||
- **Smoke:**
|
||
- `go nodes 1`, `go nodes 2` and `go depth 1` on the section 6 positions,
|
||
two no-move positions and a KB v K root: clean.
|
||
- 20 VERIFY self-play games at `nodes=20000`, Hash 16: all ended by mate,
|
||
repetition, the 50-move rule or insufficient material, with no abort.
|
||
- **Smoke, step 3 vs main: FAILED.** 100 games at 2+0.02, Hash 16, UHO book,
|
||
cutechess-ob, concurrency 10, while the VERIFY self-play (concurrency 10)
|
||
and the owner's own game were running. Step 3 lost **2 games on time**
|
||
(games 31 and 81, both as White, rook endgames at ply 180–181, half-move
|
||
clock about 70). There were no illegal moves, disconnects or aborts. See
|
||
the next section.
|
||
- **Control:** step 3 vs main and step 2 vs main, run at the same time, 100
|
||
games each at concurrency 6. There were no time forfeits, but step 3 still
|
||
had 23 moves in 11 games that stopped at ≤ 64 playouts. Step 2 and main had
|
||
none.
|
||
|
||
### Time forfeits: rerooting a graph is O(graph)
|
||
|
||
Step 3 ended moves at 64 playouts in late endgames (the clock is checked every
|
||
64 playouts, and those moves were already past the hard limit). In both
|
||
forfeits, every step 3 move over the last 10–20 moves had 64 playouts in
|
||
about 28 ms. In the same games, main searched about 10,000 playouts per move.
|
||
|
||
Cause, measured by replaying game 31 in one session (Hash 16, local
|
||
instrumented build that is not committed):
|
||
|
||
- **Cost before the first playout.** With `go nodes 1` after each move,
|
||
step 3 averages 3.5 ms (max 14 ms), against 0.3 ms for main and step 2.
|
||
- **The reroot itself.** Over 179 reroots it took 3.3 ms on average and kept
|
||
27,262 nodes on average: mark 1.4 ms, slide and remap 1.6 ms, table rebuild
|
||
0.26 ms. The worst case was 14.5 ms with 65,081 nodes kept.
|
||
- **Why it keeps so much.** In a reversible endgame, almost the whole graph
|
||
stays reachable from the new root, because the old positions can be reached
|
||
again. A tree reroot keeps one subtree, so main's cost stays small.
|
||
- **Why the clock drains.** At 2+0.02 under heavy load, a fixed cost per move
|
||
above the 20 ms increment drains the clock.
|
||
|
||
This is a gap in plan 3.6.6. "Reroot = mark/compact with T = 0" is O(nodes
|
||
kept), and on a graph that is close to O(graph) in endgames. As instructed, I
|
||
did not change the design. Options for the owner:
|
||
|
||
- (a) Reroot by moving the root index only (unreachable parts go at the next
|
||
collection, and the table stays valid). This changes 3.6.6.
|
||
- (b) Make compaction cheaper (a forwarding array instead of `lower_bound`,
|
||
reused buffers). This is a constant factor only.
|
||
- (c) Count the setup cost in time management.
|
||
|
||
The 8+0.08 STC has a 4× larger increment, but OpenBench workers also run
|
||
under load.
|
||
|
||
### Measurements (local, owner playing a game at the same time: noisy)
|
||
|
||
**Playouts/s at 5 s per bench position, Hash 64.** One round, the four
|
||
engines interleaved per position. Step 3 is run twice: the normal build and
|
||
the counter build.
|
||
|
||
| pos | main | step 2 | step 3 | step 3 / main |
|
||
| ---: | ---: | ---: | ---: | ---: |
|
||
| 1 | 200,122 | 181,012 | 117,808 | 0.59 |
|
||
| 2 | 148,819 | 134,104 | 111,678 | 0.75 |
|
||
| 3 | 217,946 | 202,846 | 108,144 | 0.50 |
|
||
| 4 | 220,530 | 197,230 | 106,011 | 0.48 |
|
||
| 5 | 197,654 | 171,347 | 124,401 | 0.63 |
|
||
| 6 | 168,134 | 161,465 | 113,824 | 0.68 |
|
||
| 7 | 179,816 | 162,171 | 119,518 | 0.66 |
|
||
| 8 | 173,057 | 164,973 | 127,588 | 0.74 |
|
||
| 9 | 227,084 | 204,864 | 148,048 | 0.65 |
|
||
| 10 | 335,241 | 318,534 | 192,549 | 0.57 |
|
||
| 11 | 959,036 | 912,732 | 425,445 | 0.44 |
|
||
| 12 | 774,695 | 703,203 | 361,420 | 0.47 |
|
||
| 13 | 191,421 | 175,871 | 133,590 | 0.70 |
|
||
| 14 | 199,466 | 194,403 | 147,058 | 0.74 |
|
||
| 15 | 667,244 | 678,618 | 101,590 | 0.15 |
|
||
| 16 | 4,619,553 | 4,342,926 | 3,595,617 | 0.78 |
|
||
| all | **592,489** | **556,526** | **377,088** | **0.64** (0.68 vs step 2) |
|
||
|
||
- `bench` nps, 5 alternating runs each (mean): main 2,996,116, step 2
|
||
2,974,460, step 3 2,572,979 (0.86× main).
|
||
- Playouts are longer, so playouts/s understates the positions searched.
|
||
The mean playout depth at 5 s is:
|
||
|
||
| position | main | step 2 | step 3 |
|
||
| --- | ---: | ---: | ---: |
|
||
| startpos | 14 | 14 | 13 |
|
||
| bench 11 | 12 | 12 | 16 (seldepth 80) |
|
||
| bench 15, KR v K | 6 | 6 | 28 (seldepth 100) |
|
||
|
||
With always-descend, a playout runs through existing nodes until it reaches
|
||
a new position, a repetition or the 50-move rule. In reversible endgames it
|
||
wanders through cycles. In bench 15, 30 % of playouts end in a repetition,
|
||
and the root score is 739 cp against main's 1,701. The plan leaves stopping
|
||
early to variant 5a.
|
||
- In the 2+0.02 games (heavy load), the median playouts per move was 4,480
|
||
for step 3 against 8,256 for main. In the control match it was 5,312
|
||
against 9,664, with step 2 at 9,024.
|
||
|
||
**Rates** from the counter build (5 s, Hash 64, same run as above):
|
||
|
||
| pos | playouts | mean depth | lookups | **hit %** | **path draw %** | of which 50-move % | new node % | GC |
|
||
| ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
|
||
| 1 | 621,248 | 13.4 | 769,706 | 19.3 | 0.0 | 0 | 100.0 | 10 |
|
||
| 2 | 540,608 | 21.2 | 581,323 | 7.1 | 0.1 | 0 | 99.9 | 6 |
|
||
| 3 | 563,520 | 12.8 | 710,180 | 20.8 | 0.1 | 0 | 99.9 | 10 |
|
||
| 4 | 528,640 | 19.0 | 613,787 | 14.0 | 0.1 | 0 | 99.9 | 7 |
|
||
| 5 | 620,096 | 11.3 | 727,622 | 14.9 | 0.1 | 0 | 99.9 | 9 |
|
||
| 6 | 589,696 | 18.5 | 629,636 | 6.8 | 0.3 | 0 | 99.5 | 7 |
|
||
| 7 | 587,392 | 17.9 | 632,662 | 7.4 | 0.2 | 0 | 99.7 | 7 |
|
||
| 8 | 627,456 | 15.4 | 669,276 | 7.0 | 0.7 | 0 | 99.2 | 8 |
|
||
| 9 | 747,520 | 20.0 | 879,332 | 19.1 | 4.8 | 0 | 95.1 | 3 |
|
||
| 10 | 958,144 | 15.2 | 901,621 | 21.4 | 25.9 | 0 | 73.9 | 3 |
|
||
| 11 | 2,148,608 | 16.7 | 1,051,775 | 45.3 | 71.8 | 0 | 26.8 | 2 |
|
||
| 12 | 1,762,496 | 19.7 | 835,300 | 52.2 | 71.5 | 0 | 22.7 | 1 |
|
||
| 13 | 671,360 | 22.4 | 731,789 | 9.2 | 0.6 | 0 | 99.0 | 5 |
|
||
| 14 | 766,144 | 12.5 | 842,901 | 10.7 | 1.7 | 0 | 98.3 | 9 |
|
||
| 15 | 522,688 | 28.3 | 2,026,421 | 83.8 | 32.3 | 2.15 | 62.9 | 1 |
|
||
| 16 | 17,866,176 | 4.0 | 53,747 | 18.2 | 98.3 | 0 | 0.2 | 0 |
|
||
| all | 30,121,792 | 9.5 | 12,657,078 | **30.1** | **69.2** | 0.04 | 29.4 | 88 |
|
||
|
||
- **Lookup.** A lookup is the table probe when an edge is first selected (no
|
||
child linked yet). A hit links the edge to an existing node.
|
||
- **Hit rate.** 30.1 % of lookups hit over all positions: 7–21 % in
|
||
middlegames, 45–52 % in the pawn endgames and 84 % in KR v K.
|
||
- **Path draws.** 69.2 % of playouts end in a path draw, almost all by
|
||
repetition. Without position 16 (perpetual check), the figure is 26.8 %.
|
||
- **Other endings.** Over all positions, 420,673 playouts ended at a terminal
|
||
node and 87 at a node that could not be expanded. One playout was dropped
|
||
because the node arena was full, and none reached the depth limit.
|
||
- **Edge arena.** Middlegames fill the edge arena first. At 8 edges per node,
|
||
`hashfull` reached 965 at 5 s from startpos, against 661 for main.
|
||
|
||
### SPRT (owner)
|
||
|
||
The plan recommends these tests, both with Threads=1 and
|
||
`UHO_Lichess_4852_v1.epd`:
|
||
|
||
- STC 8.0+0.08, `[0.00, 5.00]`, Hash=64:
|
||
https://bench.rektdie.com/test/5310/, outcome to be filled in.
|
||
- LTC 40.0+0.40, `[0.00, 5.00]`, Hash=256:
|
||
https://bench.rektdie.com/test/5311/, outcome to be filled in.
|
||
|
||
Both tests use base `mcgs-step2-split` (bench 663779), so they measure step 3
|
||
alone. The owner started them knowing about the failed smoke gate; the reroot
|
||
is unchanged.
|