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>
This commit is contained in:
rektdieandclaude committed 2026-11-15 04:12:52 +01:00
1 parent 530c4d67ed
commit 30b0c36cd5
14 files changed
+700 -68

No files matched your search

+19 -2
View File
@@ -38,8 +38,25 @@ Inputs (bullet's `Chess768`): `64 * piece + square`, with pieces relative to the
accumulator's side (own pawn = 0 ... own king = 5, their pawn = 6 ... their king = 11)
and squares flipped vertically for black. The side to move's accumulator comes first.
Output: `((sum screlu(acc) * w) / QA + b) * 400 / (QA * QB)` in centipawns, side to
move. The engine should map it to Q with the same 400 scale:
`q = 2 * sigmoid(cp / 400) - 1` (engine inference is not written yet).
move. The engine maps it to Q with the same 400 scale:
`q = 2 * sigmoid(cp / 400) - 1 = tanh(cp / 800)` (`src/nnue.cpp`, `src/eval.cpp`).
### Checking the engine's inference
```
cargo run --release -- --check checkpoints/<id>-<superbatch>
```
prints bullet's own (float) evaluation of fixed positions; the engine's `evalfens`
command prints the same positions with the quantised network. Expect agreement
within a few centipawns (quantisation); a wrong feature mapping shows up as
differences of hundreds.
### Networks
| File | Data | Superbatches | Final loss |
| --- | --- | --- | --- |
| `networks/rigby-value-v1.bin` | test80 2024-02 | 40 (10 min) | 0.0220 |
### Data