docs: step 3 (MCGS core) in mcgs-log: gates, time forfeits, measurements
Bench: 764208 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
14f672a666
commit
98fae48886
1 file changed
+241
@@ -7,6 +7,7 @@ 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 | | |
|
||||
|
||||
## Step 1 measurements
|
||||
|
||||
@@ -381,3 +382,243 @@ step 2 were run interleaved.
|
||||
`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: link and outcome to be filled in.
|
||||
- LTC 40.0+0.40, `[0.00, 5.00]`, Hash=256: link and outcome to be filled in.
|
||||
|
||||
The smoke gate failed (see above). The owner should decide on the reroot cost
|
||||
before starting either test.
|
||||
Reference in new issue
Block a user