Commit Graph
5 Commits
Author SHA1 Message Date
rektdieandclaude 79c866c77c feat: value network v2, 1024 hidden trained on linrock S2
Replaces the (768 -> 128)x2 value net with (768 -> 1024)x2 -> 1 SCReLU, same
inputs, quantisation and output scale, trained on much more data: the 12 S2
files of huggingface.co/datasets/linrock/bullet-training-data (6.6B positions,
already filtered and shuffled; v1 had one month of test80).

Training: 170 superbatches of 100M positions (17B positions, about 2.6
passes over S2), AdamW, LR 1e-3 cosine to 2.4e-6, target 0.4 * result +
0.6 * sigmoid(score / 400) as in v1. 1h34m on the RTX 3070 at ~3M
positions/s (GPU-bound); final running loss 0.01278 (not comparable to v1's
0.0220, other data). The width was picked for the 2 hour budget: 1024 trains
at 3-4M/s, and in the engine a random 1024 net cost only 16% nps against 128,
thanks to the SIMD kernels.

Trainer (train/value):
- --hidden N (default now 1024) and --batches N for speed tests
- reads bulletformat straight from .bin.zst (src/zstd_reader.rs), so the
  108 GB of S2 never has to be unpacked to 210 GB; training needs ~40 MB/s
  of compressed input, which the HDD holding it gives easily
- also reads raw .bin files (bullet's DirectSequentialDataLoader)

Engine:
- nnue::HIDDEN = 1024, Makefile EVALFILE = networks/rigby-value-v2.bin
- the output layer now sums in blocks of 128 that fit 32 bits and adds
  them up in 64, so it stays exact for any width (the single 32-bit sum was
  only provably safe up to 128)

Checked: evalfens against the trainer's --check on the final checkpoint:
same signs and sizes, within 6 cp on quiet positions and up to 7% on large
evaluations (quantisation; e.g. 553 vs 594 cp). Bench deterministic. UCI:
uci, isready, ucinewgame, go nodes / movetime / infinite + stop.
nps on bench: 4.6M -> 3.5M.

Bench: 663779

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 18:14:52 +01:00
rektdieandclaude c4f65b2632 feat: policy network v1 replaces the move heuristics
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>
2026-11-15 22:16:58 +01:00
rektdieandclaude 15258f952a feat: policy network inference
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>
2026-11-15 21:27:38 +01:00
rektdieandclaude 30b0c36cd5 feat: value network trained on Lc0 data
The static evaluation behind the quiescence search is now a
(768 -> 128)x2 -> 1 SCReLU network instead of the hand-written
evaluation. It was trained with bullet on linrock's Lc0-derived test80
2024-02 binpack, 40 superbatches (10 min on an RTX 3070), final loss
0.0220. The quiescence search itself is unchanged.

The network is embedded with incbin (EVALFILE, default
networks/rigby-value-v1.bin). Q is tanh(cp / 800), the same scale the
network was trained on (sigmoid(cp / 400) = expected score).

Checked: bullet's float evaluation of fixed positions (trainer --check)
and the engine's quantised inference (evalfens) agree within 6 cp; an
integer re-implementation in Python matches the engine exactly. Perft
passes, bench is deterministic.

Bench: 545914

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 04:12:52 +01:00
rektdieandclaude d3044c0b88 feat: minimal MCTS engine with UCI
Bitboard board with fancy magics and fully legal move generation, checked
by a perft suite. PUCT search over a node arena with FPU reduction and
in-tree draw detection. Hand-written value (eval + quiescence) and
heuristic policy stand in until the network is trained. UCI loop with a
search thread, OpenBench-compatible bench and Makefile.

Bench: 546127

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 00:31:20 +01:00