Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79fd017348 | ||
|
|
95e49098ec |
No files matched your search
+66
-2
@@ -7,7 +7,8 @@ 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 |
|
| 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) | | |
|
| 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` | |
|
| 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` | |
|
||||||
|
|
||||||
## Step 1 measurements
|
## Step 1 measurements
|
||||||
|
|
||||||
@@ -618,9 +619,72 @@ The plan recommends these tests, both with Threads=1 and
|
|||||||
`UHO_Lichess_4852_v1.epd`:
|
`UHO_Lichess_4852_v1.epd`:
|
||||||
|
|
||||||
- STC 8.0+0.08, `[0.00, 5.00]`, Threads=1, Hash=64, base `main` (bench
|
- STC 8.0+0.08, `[0.00, 5.00]`, Threads=1, Hash=64, base `main` (bench
|
||||||
663779): https://bench.rektdie.com/test/5312/, outcome to be filled in.
|
663779): https://bench.rektdie.com/test/5312/. Result as shown on the test
|
||||||
|
page:
|
||||||
|
|
||||||
|
```
|
||||||
|
Elo | -8.91 +- 6.44 (95%)
|
||||||
|
SPRT | 8.0+0.08s Threads=1 Hash=64MB
|
||||||
|
LLR | -3.19 (-2.94, 2.94) [0.00, 5.00]
|
||||||
|
Games | N: 4758 W: 1504 L: 1626 D: 1628
|
||||||
|
```
|
||||||
|
|
||||||
|
The workers report 106 games lost on time (18 + 88). The earlier Rigby STC
|
||||||
|
test 5308 lost none in 1618 games.
|
||||||
|
|
||||||
The owner chose a single STC test against `main`, so it measures steps 2 and
|
The owner chose a single STC test against `main`, so it measures steps 2 and
|
||||||
3 together. Tests 5310 (STC) and 5311 (LTC) against `mcgs-step2-split` were
|
3 together. Tests 5310 (STC) and 5311 (LTC) against `mcgs-step2-split` were
|
||||||
deleted soon after they started. The owner started the test knowing about the
|
deleted soon after they started. The owner started the test knowing about the
|
||||||
failed smoke gate; the reroot is unchanged.
|
failed smoke gate; the reroot is unchanged.
|
||||||
|
|
||||||
|
## Step 3b: reroot moves only the root (`mcgs-step3-reroot`)
|
||||||
|
|
||||||
|
Code at `d38f0b1`, on top of `mcgs-step3-core` (`f4b79a4`). This deviates from
|
||||||
|
plan 3.6.6, on the owner's decision after the time forfeits above.
|
||||||
|
|
||||||
|
**Bench: 764208**, unchanged, because bench never reuses a graph.
|
||||||
|
|
||||||
|
What changed:
|
||||||
|
|
||||||
|
- `Tree::reroot` only sets the root index. It no longer compacts.
|
||||||
|
- Nodes the new root no longer reaches keep their memory and their table
|
||||||
|
entries until the next collection. Search may link to them again in the
|
||||||
|
meantime. The collection keeps only what the root reaches.
|
||||||
|
- `info string reused N` now counts every node in the graph, reachable or
|
||||||
|
not.
|
||||||
|
- **VERIFY:**
|
||||||
|
- `verify_tree` requires full reachability only right after a collection.
|
||||||
|
The table must always hold every node in the arena.
|
||||||
|
- Check (b) now verifies two things: a reroot changes nothing, and the next
|
||||||
|
collection keeps exactly the nodes the new root reaches, unchanged.
|
||||||
|
|
||||||
|
Gates (owner's machine, 2026-11-16):
|
||||||
|
|
||||||
|
- Zero warnings. Bench 764208.
|
||||||
|
- `verify` (a)–(d) passed. The reroot check reported, for example, 10,803
|
||||||
|
nodes in the pawn endgame, with 10,802 reachable from the new root and
|
||||||
|
10,802 kept by the collection.
|
||||||
|
- The VERIFY searches of section 6 all passed, including forced GC: Hash 1
|
||||||
|
gave 190 and 145 collections, Hash 2 gave 104 and 77.
|
||||||
|
- The reuse sequence passed at Hash 64, at Hash 1 and from the 960 start.
|
||||||
|
- The `go nodes 1/2` and `go depth 1` smoke positions passed.
|
||||||
|
- Perft was not re-run, because move generation is untouched.
|
||||||
|
- No local games: the owner asked for the SPRT directly.
|
||||||
|
|
||||||
|
Replay of the 2+0.02 game that step 3 lost on time (game 31, Hash 16), measuring the time
|
||||||
|
before the first playout (`go nodes 1` after each move, 90 moves). This is a
|
||||||
|
local measurement:
|
||||||
|
|
||||||
|
| | mean | max |
|
||||||
|
| --- | ---: | ---: |
|
||||||
|
| main | 0.2 ms | 1 ms |
|
||||||
|
| step 3 | 3.5 ms | 13 ms |
|
||||||
|
| step 3b | 0 ms | 0 ms |
|
||||||
|
|
||||||
|
At `go movetime 40` in the same replay, mean playouts per move were: main
|
||||||
|
12,083, step 3 5,047, step 3b 5,899.
|
||||||
|
|
||||||
|
### 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.
|
||||||
+58
-2
@@ -259,6 +259,46 @@ size_t Tree::compact(u32 new_root, u32 min_visits) {
|
|||||||
|
|
||||||
Searcher::Searcher() { set_hash(64); }
|
Searcher::Searcher() { set_hash(64); }
|
||||||
|
|
||||||
|
bool Searcher::root_child_drawn(const Position& child, const std::vector<u64>& keys) {
|
||||||
|
const int n = int(keys.size());
|
||||||
|
for (int back = 4; back <= child.halfmove && back < n; back += 2)
|
||||||
|
if (keys[n - 1 - back] == child.key) return true;
|
||||||
|
return child.halfmove >= 100 && !(child.in_check() && !has_legal_move(child));
|
||||||
|
}
|
||||||
|
|
||||||
|
int Searcher::reconcile_root_edges(const Position& root) {
|
||||||
|
// Draw counts on the root's edges were collected under other game
|
||||||
|
// histories (the root was an inner node then). Now the history is common
|
||||||
|
// to every path: a move into a repetition (or past the 50-move rule)
|
||||||
|
// draws on every path, any other move on none. A drawn edge keeps its
|
||||||
|
// visits, all of them draws; an edge that is no longer drawn loses the
|
||||||
|
// draw visits, and so does the root.
|
||||||
|
Node& r = tree_.node(tree_.root());
|
||||||
|
if (r.state != EXPANDED) return 0;
|
||||||
|
int changed = 0;
|
||||||
|
std::vector<u64> keys = history_;
|
||||||
|
for (u32 i = 0; i < r.num_edges; i++) {
|
||||||
|
Edge& e = tree_.edge(r.first_edge + i);
|
||||||
|
if (!e.visits) continue;
|
||||||
|
Position child = root;
|
||||||
|
child.make_move(Move::from_raw(e.move));
|
||||||
|
keys.push_back(child.key);
|
||||||
|
const bool drawn = root_child_drawn(child, keys);
|
||||||
|
keys.pop_back();
|
||||||
|
if (drawn && e.draws != e.visits) {
|
||||||
|
e.draws = e.visits;
|
||||||
|
changed++;
|
||||||
|
} else if (!drawn && e.draws) {
|
||||||
|
r.visits -= e.draws;
|
||||||
|
e.visits -= e.draws;
|
||||||
|
e.draws = 0;
|
||||||
|
changed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changed) recompute_q(r);
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
void Searcher::clear_tree(const Position& root) {
|
void Searcher::clear_tree(const Position& root) {
|
||||||
// The root is created like any node and evaluated once; its own value
|
// The root is created like any node and evaluated once; its own value
|
||||||
// takes part in its Q with weight 1, as at every other node.
|
// takes part in its Q with weight 1, as at every other node.
|
||||||
@@ -486,6 +526,17 @@ void Searcher::verify_tree(const std::vector<u64>& history, bool collected) cons
|
|||||||
if (it == legal.end() || legal_seen[it - legal.begin()]) fail(idx, pos, "illegal or repeated edge move");
|
if (it == legal.end() || legal_seen[it - legal.begin()]) fail(idx, pos, "illegal or repeated edge move");
|
||||||
legal_seen[it - legal.begin()] = true;
|
legal_seen[it - legal.begin()] = true;
|
||||||
if (e.draws > e.visits) fail(idx, pos, "edge with more draws than visits");
|
if (e.draws > e.visits) fail(idx, pos, "edge with more draws than visits");
|
||||||
|
if (idx == root && e.visits) {
|
||||||
|
// The game history is common to every path from the root, so a
|
||||||
|
// root edge is all draws or none.
|
||||||
|
Position child = pos;
|
||||||
|
child.make_move(Move::from_raw(e.move));
|
||||||
|
std::vector<u64> keys = history;
|
||||||
|
keys.push_back(child.key);
|
||||||
|
if (e.draws != (root_child_drawn(child, keys) ? e.visits : 0))
|
||||||
|
fail(idx, pos, "root edge " + pos.uci(Move::from_raw(e.move)) + " has " +
|
||||||
|
std::to_string(e.draws) + " draws of " + std::to_string(e.visits));
|
||||||
|
}
|
||||||
if (e.child >= tree_.nodes_used()) fail(idx, pos, "edge child out of range");
|
if (e.child >= tree_.nodes_used()) fail(idx, pos, "edge child out of range");
|
||||||
if (e.visits > e.draws && !e.child) fail(idx, pos, "edge with non-draw visits and no child");
|
if (e.visits > e.draws && !e.child) fail(idx, pos, "edge with non-draw visits and no child");
|
||||||
edge_visits += e.visits;
|
edge_visits += e.visits;
|
||||||
@@ -864,10 +915,13 @@ SearchResult Searcher::search(const Position& root, const std::vector<u64>& hist
|
|||||||
// rests on the 80-bit key and check; the root is checked in full.
|
// rests on the 80-bit key and check; the root is checked in full.
|
||||||
if (reused && !root_edges_valid(root)) reused = 0;
|
if (reused && !root_edges_valid(root)) reused = 0;
|
||||||
if (!reused) clear_tree(root);
|
if (!reused) clear_tree(root);
|
||||||
|
const int reconciled = reused ? reconcile_root_edges(root) : 0;
|
||||||
#ifdef RIGBY_VERIFY_TREE
|
#ifdef RIGBY_VERIFY_TREE
|
||||||
if (reused) verify_tree(history_);
|
if (reused) verify_tree(history_);
|
||||||
#endif
|
#endif
|
||||||
if (print && !pretty && reused) uci_io::send("info string reused " + std::to_string(reused) + " nodes");
|
if (print && !pretty && reused) uci_io::send("info string reused " + std::to_string(reused) + " nodes");
|
||||||
|
if (print && !pretty && reconciled)
|
||||||
|
uci_io::send("info string reconciled " + std::to_string(reconciled) + " root edges");
|
||||||
iterations_ = 0;
|
iterations_ = 0;
|
||||||
depth_sum_ = 0;
|
depth_sum_ = 0;
|
||||||
seldepth_ = 0;
|
seldepth_ = 0;
|
||||||
@@ -1145,14 +1199,16 @@ void Searcher::self_test() {
|
|||||||
const size_t count = compare(before, false, pruned_max, kept_min);
|
const size_t count = compare(before, false, pruned_max, kept_min);
|
||||||
if (count != before.size() || tree_.nodes_used() != nodes_before || tree_.edges_used() != edges_before)
|
if (count != before.size() || tree_.nodes_used() != nodes_before || tree_.edges_used() != edges_before)
|
||||||
self_test_failed("reroot changed the graph");
|
self_test_failed("reroot changed the graph");
|
||||||
root_pos_ = pos;
|
|
||||||
verify_tree(history);
|
|
||||||
// The next collection (with room for everything) keeps exactly what the
|
// The next collection (with room for everything) keeps exactly what the
|
||||||
// new root reaches, unchanged.
|
// new root reaches, unchanged.
|
||||||
tree_.collect_garbage(tree_.node_capacity(), tree_.edge_capacity());
|
tree_.collect_garbage(tree_.node_capacity(), tree_.edge_capacity());
|
||||||
const size_t kept = compare(before, false, pruned_max, kept_min);
|
const size_t kept = compare(before, false, pruned_max, kept_min);
|
||||||
if (kept != before.size() || kept != tree_.nodes_used() - 1)
|
if (kept != before.size() || kept != tree_.nodes_used() - 1)
|
||||||
self_test_failed("collection after a reroot kept the wrong nodes");
|
self_test_failed("collection after a reroot kept the wrong nodes");
|
||||||
|
// As search does after reuse: the root's edges follow the game history.
|
||||||
|
root_pos_ = pos;
|
||||||
|
history_ = history;
|
||||||
|
reconcile_root_edges(pos);
|
||||||
verify_tree(history, true);
|
verify_tree(history, true);
|
||||||
uci_io::send("info string verify (b) reroot " + std::string(fen) + ": " + std::to_string(nodes_before - 1) +
|
uci_io::send("info string verify (b) reroot " + std::string(fen) + ": " + std::to_string(nodes_before - 1) +
|
||||||
" nodes, " + std::to_string(count) + " reachable from the new root, collected to " +
|
" nodes, " + std::to_string(count) + " reachable from the new root, collected to " +
|
||||||
|
|||||||
@@ -342,6 +342,14 @@ private:
|
|||||||
size_t reuse_tree(const Position& root);
|
size_t reuse_tree(const Position& root);
|
||||||
// True when the root node's edges are exactly the legal moves of `root`.
|
// True when the root node's edges are exactly the legal moves of `root`.
|
||||||
bool root_edges_valid(const Position& root) const;
|
bool root_edges_valid(const Position& root) const;
|
||||||
|
// After reuse the game history is common to every path, so whether a
|
||||||
|
// root move is a draw by repetition or the 50-move rule is exact. Makes
|
||||||
|
// each root edge all draws or no draws accordingly (plan 3.6.7). Returns
|
||||||
|
// the number of edges changed.
|
||||||
|
int reconcile_root_edges(const Position& root);
|
||||||
|
// Whether `child`, reached from the root, is a draw of the game history
|
||||||
|
// `keys` (which ends with the child's key).
|
||||||
|
static bool root_child_drawn(const Position& child, const std::vector<u64>& keys);
|
||||||
// Empties the graph, leaving an evaluated, unexpanded root for `root`.
|
// Empties the graph, leaving an evaluated, unexpanded root for `root`.
|
||||||
void clear_tree(const Position& root);
|
void clear_tree(const Position& root);
|
||||||
#ifdef RIGBY_VERIFY_TREE
|
#ifdef RIGBY_VERIFY_TREE
|
||||||
|
|||||||
Reference in new issue
Block a user