train: value network trainer on Lc0 data

A bullet trainer for a (768 -> 128)x2 -> 1 SCReLU value network, reading
linrock's Lc0-derived Stockfish binpacks directly (no conversion). The
target blends the game result (0.4) with the search score; 40
superbatches by default, about 12 minutes on an RTX 3070.

train/value/train.ps1 sets up CUDA 13.3 and cargo, unpacks the default
binpack if needed, builds and runs. train/README.md documents the data,
the setup and the network file layout for the engine side.

No engine change.

Bench: 546127

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rektdieandclaude committed 2026-11-15 03:57:51 +01:00
1 parent 241ad4a546
commit 530c4d67ed
6 files changed
+844

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
# Training
## Value network (`value/`)
A small `(768 -> 128)x2 -> 1` SCReLU network trained with
[bullet](https://github.com/jw1912/bullet) on Lc0 self-play data.
### Run
```
powershell -ExecutionPolicy Bypass -File C:\Users\rektd\repos\Rigby\train\value\train.ps1
```
Default: 40 superbatches of 100M positions, about 12 minutes on the RTX 3070
(5.8M positions/s). Arguments are passed to the trainer:
| Argument | Default | Meaning |
| --- | --- | --- |
| `--superbatches N` | 40 | Training length; the learning rate decays to the end |
| `--id NAME` | `rigby-value` | Checkpoint name |
| `--data FILE` | the test80 Feb 2024 binpack | Repeatable; several files are read one after the other |
Output: `value/checkpoints/<id>-<superbatch>/quantised.bin` every 10 superbatches
and at the end. That file is what the engine loads.
### Network format
`quantised.bin` (197,440 bytes for 128 hidden), little-endian `i16`:
| Part | Shape | Quantisation |
| --- | --- | --- |
| `l0w` | 768 x 128, feature-major (`[feature][hidden]`) | QA = 255 |
| `l0b` | 128 | QA |
| `l1w` | 2 x 128 (side to move first, then the other side) | QB = 64 |
| `l1b` | 1 | QA * QB |
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).
### Data
Lc0 self-play data converted to Stockfish binpacks by linrock
([huggingface.co/datasets/linrock](https://huggingface.co/datasets/linrock)), here
`test80-2024-02-feb-2tb7p.min-v2.v6.binpack` (6.9 GB zstd, 8.3 GB unpacked).
bullet reads binpacks directly (`SfBinpackLoader`); no conversion is needed.
The filter keeps positions from ply 16 on that are not in check, with a quiet best
move and |score| <= 10000. Training target: `0.4 * result + 0.6 * sigmoid(score / 400)`.
Data lives in `train/data/` and is not committed.
### Setup on a new machine
1. Rust via rustup (MSVC toolchain), Visual Studio C++ build tools.
2. CUDA Toolkit 13.3 with `cudart`, `nvrtc`, `cublas` (bullet compiles its kernels at
runtime with NVRTC, no nvcc needed).
3. `git clone https://github.com/jw1912/bullet` next to this repo.
4. `pip install zstandard` and a binpack from linrock's datasets in `train/data/`.