Replaces the hand-written move heuristics with a policy network trained on Lc0 self-play.
Trainer (train/policy): fork of montytrain's policy trainer (the one Monty, Vine and Jackal use), without Monty's SEE split (3920 outputs, as in Vine). lc02monty converts Lc0 V6 training tars to montyformat, checking every record against the legal moves; fetch.ps1 downloads a run's tars over 32 connections (the server limits each to ~2.3 MB/s), converts and shuffles them.
Networknetworks/rigby-policy-v1.bin: 3072 threat inputs → 1024 → CReLU × pairwise → 3920, i8. Trained on 171M positions of test91 (2026-10-25 .. 11-15) for 10 superbatches of 100M, 10 minutes on the RTX 3070, final loss 2.296.
Engine (src/policy.cpp): built in by default (POLICYFILE), runtime override with the PolicyFile option, policyfens to compare with the trainer. Butterfly-history bias and PolicyTemp apply on top of the logits as before. About 10% slower on the bench.
Replaces the hand-written move heuristics with a policy network trained on Lc0 self-play.
- **Trainer** (`train/policy`): fork of montytrain's policy trainer (the one Monty, Vine and Jackal use), without Monty's SEE split (3920 outputs, as in Vine). `lc02monty` converts Lc0 V6 training tars to montyformat, checking every record against the legal moves; `fetch.ps1` downloads a run's tars over 32 connections (the server limits each to ~2.3 MB/s), converts and shuffles them.
- **Network** `networks/rigby-policy-v1.bin`: 3072 threat inputs → 1024 → CReLU × pairwise → 3920, i8. Trained on 171M positions of test91 (2026-10-25 .. 11-15) for 10 superbatches of 100M, 10 minutes on the RTX 3070, final loss 2.296.
- **Engine** (`src/policy.cpp`): built in by default (`POLICYFILE`), runtime override with the `PolicyFile` option, `policyfens` to compare with the trainer. Butterfly-history bias and `PolicyTemp` apply on top of the logits as before. About 10% slower on the bench.
## SPRT
https://bench.rektdie.com/test/5302/ (base: the Chess960 commit, so the test isolates the network)
```
Elo | 168.05 +- 28.40 (95%)
SPRT | 8.0+0.08s Threads=1 Hash=64MB
LLR | 3.28 (-2.94, 2.94) [0.00, 5.00]
Games | N: 492 W: 320 L: 99 D: 73
Penta | [1, 15, 87, 48, 95]
```
## Correctness
- Engine priors match the trainer's float output to tenths of a percent (a few percent on very sharp distributions).
- Converter: every record of 22 days of test91 data converts (0 dropped).
- Bench deterministic; `RIGBY_VERIFY_TREE` build driven over UCI without an abort; a build with `POLICYFILE=` gives the old bench 529903.
Bench: 630039
🤖 Generated with [Claude Code](https://claude.com/claude-code)
train/policy is a fork of montytrain's policy trainer (the one Monty,
Vine and Jackal use: bullet at a pinned revision plus two CUDA
operations, SelectAffine over the legal moves' output rows and a
softmax cross-entropy against the visit distribution). Rigby's
version drops Monty's SEE split of the outputs (3920 rows, as in
Vine), takes its arguments on the command line and checks a
checkpoint with --check.
The Stockfish binpacks used for the value net only keep the played
move, so the data comes from Lc0's raw V6 training tars instead.
lc02monty rebuilds each game from its first record and the played
moves and checks every record: pieces must match, and the moves Lc0
gave a probability must be exactly the legal moves. Lc0 writes
castling as king-takes-rook; Chess960 games keep their rook files.
On a test91 tar all 351,454 records convert. fetch.ps1 downloads a
run's hourly tars day by day, converts and deletes them, and
interleave shuffles the day files into one.
Defaults sized for a 20-minute run on the RTX 3070: 1024 hidden,
10 superbatches of 100M positions (~1M positions/s). The pinned
cudarc does not know CUDA 13.3, so env.ps1 sets
CUDARC_CUDA_VERSION=13000.
Checked: a smoke run on one tar lowers the loss from 2.89 to 2.38 and
gives plausible opening priors; a checkpoint reloads to identical
output; interleaved data trains.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
src/policy.cpp runs the network train/policy writes: 3072 threat
inputs (side to move's view, flipped horizontally when its king is on
files e-h, +768 attacked, +1536 defended), a hidden layer with CReLU
and pairwise product, and one output row per move, i8 weights scaled
by 128. The hidden width is read from the file's size, so any trained
width loads. When a network is loaded, eval::policy uses its logits
plus the butterfly-history bias instead of the move heuristics; the
temperature and softmax are unchanged.
A network is built in with make POLICYFILE=<net> (default: none, so
the engine plays as before) or loaded at runtime with the UCI option
PolicyFile. policyfens prints the priors of the trainer's --check
positions.
Checked: with a smoke-trained network policyfens matches the trainer's
float output to a few tenths of a percent in all six positions (black
to move, mirrored king, castling, promotion). Speed with a network:
-13% nps at 512 hidden, -41% at 2048. A zero network built in with
POLICYFILE gives uniform priors. Without a network the bench is
unchanged.
Bench: 529903
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
storage.lczero.org limits each connection to about 2.3 MB/s but not
the number of connections: 8 give 23 MB/s, 16 give 43 MB/s, 32 give
72 MB/s. fetch.ps1 downloaded one day (about 24 tars) at a time, which
capped it at 24 connections; it now fills batches of whole days with
about two tars per connection, downloads them with -Parallel 32 by
default, then converts and deletes each day as before.
Checked: Nov 14-15 (45 tars, 2.9 GB) in one batch at 32 MB/s, 13.9M
positions, no record dropped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
networks/rigby-policy-v1.bin is now built in by default (POLICYFILE;
POLICYFILE= still builds the heuristics). It is a 3072 -> 1024 -> 3920
network trained by train/policy on 171M positions of Lc0 test91
self-play (2026-10-25 .. 11-15) against the search's visit
distributions: 10 superbatches of 100M, 10 minutes on the RTX 3070,
final loss 2.296 (2.39 after the first superbatch). The butterfly
history bias and PolicyTemp apply on top of its logits as they did on
the heuristics' scores.
Sensible priors: 1.e4 e5 75%, Kiwipete Bxa6 38%, black bxc3 43%,
c8=Q in the K+P ending. The engine's quantised output matches the
trainer's float output to tenths of a percent, a few percent on very
sharp distributions. Costs about 10% nps on the bench.
Checked: bench deterministic; RIGBY_VERIFY_TREE build driven over UCI
(Hash 1 MB, repeated positions, fen + moves, wtime/winc, go infinite +
stop) without an abort; a build with POLICYFILE= gives the old bench
529903.
Bench: 630039
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude
merged commit 74fb5eb2fb into main2026-11-15 22:22:31 +01:00
claude
deleted branch policy-net2026-11-15 22:22:32 +01:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Replaces the hand-written move heuristics with a policy network trained on Lc0 self-play.
train/policy): fork of montytrain's policy trainer (the one Monty, Vine and Jackal use), without Monty's SEE split (3920 outputs, as in Vine).lc02montyconverts Lc0 V6 training tars to montyformat, checking every record against the legal moves;fetch.ps1downloads a run's tars over 32 connections (the server limits each to ~2.3 MB/s), converts and shuffles them.networks/rigby-policy-v1.bin: 3072 threat inputs → 1024 → CReLU × pairwise → 3920, i8. Trained on 171M positions of test91 (2026-10-25 .. 11-15) for 10 superbatches of 100M, 10 minutes on the RTX 3070, final loss 2.296.src/policy.cpp): built in by default (POLICYFILE), runtime override with thePolicyFileoption,policyfensto compare with the trainer. Butterfly-history bias andPolicyTempapply on top of the logits as before. About 10% slower on the bench.SPRT
https://bench.rektdie.com/test/5302/ (base: the Chess960 commit, so the test isolates the network)
Correctness
RIGBY_VERIFY_TREEbuild driven over UCI without an abort; a build withPOLICYFILE=gives the old bench 529903.Bench: 630039
🤖 Generated with Claude Code