feat: collect the tree when the node arena is full
Tree reuse keeps most of the previous tree, so the arena fills up fast. In a 240-move self-play diagnostic of main at 8+0.08 with Hash=64, the reused subtree alone was often 3.0-3.3M of the 3.35M nodes, and the tree was full on 90 moves (37%). A full tree cannot expand anything any more; for the rest of the move it only re-evaluates leaves. Now a failed allocation triggers a collection after the playout. The children of every node below a visit threshold are dropped (the node keeps its visits and Q and becomes a leaf again, expanded anew on its next visit), and the rest is packed in place with the same block compaction as tree reuse. The threshold is the smallest one that brings the tree down to half the arena; visits only shrink going down, so one pass over the tree gives the size kept for every threshold. In the same diagnostic with this change the tree was collected on 27 of 158 moves, once each, and search kept expanding afterwards; a collection of a full 64 MB tree costs about 20-30 ms. Checked: the -DRIGBY_VERIFY_TREE build verifies the tree after every collection; UCI-driven self-play passed 700 checks / 428 collections with 1 MB Hash and 476 checks / 205 collections with 16 MB, including repeated searches of the same position and a root at halfmove 99. uci, go wtime/nodes/infinite, stop and quit work. The bench is unchanged because the bench never fills the tree. Rebased from the earlier tree-gc branch onto main with the value network and second-visit expansion. Bench: 546018 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0d5713f7f0
commit
967e0e0b90
3 files changed
+76
-11
No files matched your search
@@ -19,6 +19,9 @@ Every change is validated with SPRT on OpenBench.
|
||||
promotions, checks, pawn threats) until a policy network exists.
|
||||
- Tree reuse between moves: the subtree of the new position is packed to the
|
||||
front of the node arena in place, so it costs no extra memory.
|
||||
- When the arena is full, the least visited parts of the tree are cut back to
|
||||
leaves (keeping their visits and Q) and the rest is packed, so search never
|
||||
stops expanding.
|
||||
- Single-threaded.
|
||||
|
||||
## Building
|
||||
@@ -35,8 +38,8 @@ make EVALFILE=path/to/quantised.bin
|
||||
`EVALFILE` defaults to `networks/rigby-value-v1.bin`.
|
||||
|
||||
Compiling with `-DRIGBY_VERIFY_TREE` checks the whole tree before and after every
|
||||
reuse (legal moves, visit counts) and aborts on the first inconsistency. It is slow,
|
||||
for debugging only.
|
||||
reuse and after every collection (legal moves, visit counts) and aborts on the first
|
||||
inconsistency. It is slow, for debugging only.
|
||||
|
||||
## UCI
|
||||
|
||||
|
||||
Reference in new issue
Block a user