Files
Rigby/train/policy/train.ps1
rektdieandclaude 1c9d2beec3 feat: policy network trainer on Lc0 visit distributions
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>
2026-11-15 21:27:08 +01:00

26 lines
1.1 KiB
PowerShell

# Trains Rigby's policy network. Run from anywhere:
# powershell -ExecutionPolicy Bypass -File C:\Users\rektd\repos\Rigby\train\policy\train.ps1
# Extra arguments go to the trainer, e.g.:
# ... train.ps1 --superbatches 60 --hidden 4096 --id rigby-policy-v2
# ... train.ps1 --check checkpoints\rigby-policy-40
# Data: ..\data\lc0\policy.binpack, made by fetch.ps1 (or by lc02monty + interleave).
param([Parameter(ValueFromRemainingArguments = $true)] [string[]] $TrainerArgs)
# Native tools report through exit codes; 'Stop' would turn cargo's progress
# output on stderr into errors under Windows PowerShell.
$ErrorActionPreference = 'Continue'
Set-Location $PSScriptRoot
. .\env.ps1
if (-not ($TrainerArgs -contains '--data') -and -not ($TrainerArgs -contains '--check') -and
-not (Test-Path '..\data\lc0\policy.binpack')) {
throw 'No training data: ..\data\lc0\policy.binpack is missing (run fetch.ps1)'
}
cargo build --release --bin rigby-policy
if ($LASTEXITCODE -ne 0) { throw 'build failed' }
& .\target\release\rigby-policy.exe @TrainerArgs
exit $LASTEXITCODE