Compare commits
2
Commits
15258f952a
...
c4f65b2632
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4f65b2632 | ||
|
|
05fd552e0b |
No files matched your search
@@ -1,6 +1,7 @@
|
||||
# Rigby - MCTS chess engine
|
||||
# OpenBench calls: make EXE=<name> [EVALFILE=<net>] [CXX=<compiler>]
|
||||
# A policy network is built in with POLICYFILE=<net> (default: none).
|
||||
# POLICYFILE=<net> picks the built-in policy network; POLICYFILE= builds none
|
||||
# (move heuristics).
|
||||
|
||||
SRC_DIR := src
|
||||
OBJ_DIR := obj
|
||||
@@ -8,8 +9,8 @@ OBJ_DIR := obj
|
||||
EXE ?= Rigby
|
||||
# The value network embedded into the binary
|
||||
EVALFILE ?= networks/rigby-value-v1.bin
|
||||
# The policy network embedded into the binary; none means move heuristics
|
||||
POLICYFILE ?=
|
||||
# The policy network embedded into the binary; empty means move heuristics
|
||||
POLICYFILE ?= networks/rigby-policy-v1.bin
|
||||
CXX ?= clang++
|
||||
ifeq ($(origin CXX),default)
|
||||
CXX := clang++
|
||||
|
||||
@@ -19,9 +19,10 @@ Every change is validated with SPRT on OpenBench.
|
||||
- Value: a `(768 -> 128)x2 -> 1` network trained with bullet on Lc0 data
|
||||
(`networks/rigby-value-v1.bin`, embedded at build time; see `train/README.md`),
|
||||
behind a capture-only quiescence search.
|
||||
- Policy: a network trained on Lc0 visit distributions (`train/policy`), loaded
|
||||
with `PolicyFile` or built in with `POLICYFILE`; without one, move heuristics
|
||||
(captures, promotions, checks, pawn threats).
|
||||
- Policy: a `3072 -> 1024 -> 3920` network trained on Lc0 visit distributions
|
||||
(`networks/rigby-policy-v1.bin`, embedded at build time; see `train/README.md`).
|
||||
Built without one (`POLICYFILE=`), move heuristics (captures, promotions,
|
||||
checks, pawn threats).
|
||||
- Tree reuse between moves: the subtree of the new position is packed to the
|
||||
front of the node arena in place, so it costs no extra memory.
|
||||
- When the arena is full, the least visited parts of the tree are cut back to
|
||||
@@ -40,8 +41,8 @@ make EXE=Rigby-dev
|
||||
make EVALFILE=path/to/quantised.bin
|
||||
```
|
||||
|
||||
`EVALFILE` defaults to `networks/rigby-value-v1.bin`. `POLICYFILE=<net>` builds a
|
||||
policy network in; by default there is none and the move heuristics are used.
|
||||
`EVALFILE` defaults to `networks/rigby-value-v1.bin`. `POLICYFILE` defaults to
|
||||
`networks/rigby-policy-v1.bin`; `POLICYFILE=` builds the move heuristics instead.
|
||||
|
||||
Compiling with `-DRIGBY_VERIFY_TREE` checks the whole tree before and after every
|
||||
reuse and after every collection (legal moves, visit counts) and aborts on the first
|
||||
@@ -91,7 +92,7 @@ terminal).
|
||||
| FPUReduction | 30 | First-play urgency reduction x100. |
|
||||
| PolicyTemp | 100 | Policy softmax temperature x100. |
|
||||
| UCI_Chess960 | false | Write and read castling as the king taking its rook (`e1h1`). |
|
||||
| PolicyFile | `<empty>` | Policy network file to use instead of the built-in one or the heuristics. |
|
||||
| PolicyFile | `<empty>` | Policy network file to use instead of the built-in one. |
|
||||
|
||||
## Bench
|
||||
|
||||
|
||||
Binary file not shown.
+11
-2
@@ -99,7 +99,9 @@ its tars are deleted. Days already converted are skipped, so an interrupted run
|
||||
be restarted. Finally every day file is shuffled into `data/lc0/policy.binpack`.
|
||||
One hourly tar (~73 MB) holds ~350k positions, which take ~12 MB converted; about
|
||||
three weeks of test91 (~40 GB of tars, ~190M positions) is plenty for a
|
||||
10-superbatch run. With 8 connections the download runs at ~12 MB/s.
|
||||
10-superbatch run. The server limits each connection to ~2.3 MB/s (what a browser
|
||||
gets) but not their number, so fetch.ps1 downloads 32 tars at a time across days
|
||||
(`-Parallel`): 72 MB/s measured, about 10 minutes for three weeks.
|
||||
|
||||
Tars downloaded by hand can be converted directly:
|
||||
|
||||
@@ -164,7 +166,14 @@ frame. Hidden: `clamp(acc[i], 0, 1) * clamp(acc[i + H/2], 0, 1)`.
|
||||
|
||||
`train.ps1 --check checkpoints\<id>-<superbatch> --hidden <H>` prints the trainer's
|
||||
(float) policy of fixed positions; the engine's `policyfens` command prints the
|
||||
same with the quantised network. They agree to a few tenths of a percent.
|
||||
same with the quantised network. They agree to a few tenths of a percent, a few
|
||||
percent on very sharp distributions (rigby-policy-v1, 1.e4 e5: 80.2% vs 75.3%).
|
||||
|
||||
### Networks
|
||||
|
||||
| File | Data | Hidden | Superbatches | Final loss |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `networks/rigby-policy-v1.bin` | test91 2026-10-25 .. 11-15 (171M positions) | 1024 | 10 (10 min) | 2.296 |
|
||||
|
||||
### Setup
|
||||
|
||||
|
||||
+45
-19
@@ -1,18 +1,21 @@
|
||||
# Downloads Lc0 self-play data and converts it to montyformat for the policy trainer.
|
||||
# powershell -ExecutionPolicy Bypass -File C:\Users\rektd\repos\Rigby\train\policy\fetch.ps1
|
||||
# ... fetch.ps1 -From 20261025 -To 20261115 -Run test91 -Parallel 12
|
||||
# ... fetch.ps1 -From 20261025 -To 20261115 -Run test91 -Parallel 32
|
||||
# Default: the last three weeks of test91 (about 40 GB of tars, 190M positions).
|
||||
#
|
||||
# Works one day at a time: that day's hourly tars go to data\lc0\staging, are
|
||||
# converted into data\lc0\monty\<run>-<day>.binpack and deleted, so the disk
|
||||
# only ever holds one day of tars. Days already converted are skipped, so an
|
||||
# interrupted run can simply be started again. At the end every day file is
|
||||
# shuffled into data\lc0\policy.binpack, which is what train.ps1 reads.
|
||||
# The server limits each connection to about 2.3 MB/s but not their number
|
||||
# (32 connections: ~72 MB/s), so tars are downloaded -Parallel at a time, in
|
||||
# batches of whole days (about two tars per connection) into data\lc0\staging.
|
||||
# Each day of a batch is then converted into data\lc0\monty\<run>-<day>.binpack
|
||||
# and its tars deleted, so the disk only holds one batch of tars. Days already
|
||||
# converted are skipped, so an interrupted run can simply be started again. At
|
||||
# the end every day file is shuffled into data\lc0\policy.binpack, which is
|
||||
# what train.ps1 reads.
|
||||
param(
|
||||
[string] $From = (Get-Date).AddDays(-21).ToString('yyyyMMdd'),
|
||||
[string] $To = (Get-Date -Format 'yyyyMMdd'),
|
||||
[string] $Run = 'test91',
|
||||
[int] $Parallel = 8,
|
||||
[int] $Parallel = 32,
|
||||
[switch] $NoInterleave
|
||||
)
|
||||
|
||||
@@ -42,25 +45,48 @@ $days = $tars | Group-Object Day | Sort-Object Name
|
||||
$totalGb = ($tars | Measure-Object Size -Sum).Sum / 1e9
|
||||
Write-Host ("{0} tars over {1} days, {2:N1} GB to download" -f $tars.Count, $days.Count, $totalGb)
|
||||
|
||||
foreach ($day in $days) {
|
||||
$out = Join-Path $monty "$Run-$($day.Name).binpack"
|
||||
if (Test-Path $out) { continue }
|
||||
$pending = @($days | Where-Object { -not (Test-Path (Join-Path $monty "$Run-$($_.Name).binpack")) })
|
||||
$done = $days.Count - $pending.Count
|
||||
if ($done) { Write-Host "$done days already converted" }
|
||||
|
||||
Get-ChildItem $staging | Remove-Item -Force
|
||||
while ($pending.Count) {
|
||||
# Whole days until the batch has about two tars per connection.
|
||||
$batch = @()
|
||||
$count = 0
|
||||
while ($pending.Count -and ($batch.Count -eq 0 -or $count -lt 2 * $Parallel)) {
|
||||
$batch += $pending[0]
|
||||
$count += $pending[0].Count
|
||||
$pending = @($pending | Select-Object -Skip 1)
|
||||
}
|
||||
|
||||
if (Test-Path $staging) { Remove-Item -Recurse -Force $staging }
|
||||
New-Item -ItemType Directory -Force $staging | Out-Null
|
||||
$config = Join-Path $staging 'curl.txt'
|
||||
# Forward slashes: curl reads backslashes in a config file as escapes.
|
||||
$day.Group | ForEach-Object { "url = `"$base$($_.Name)`"`noutput = `"$((Join-Path $staging $_.Name) -replace '\\', '/')`"" } |
|
||||
Set-Content -Encoding ascii $config
|
||||
$gb = ($day.Group | Measure-Object Size -Sum).Sum / 1e9
|
||||
Write-Host ("{0}: downloading {1} tars ({2:N2} GB)" -f $day.Name, $day.Group.Count, $gb)
|
||||
$lines = foreach ($day in $batch) {
|
||||
$dir = Join-Path $staging $day.Name
|
||||
New-Item -ItemType Directory -Force $dir | Out-Null
|
||||
foreach ($tar in $day.Group) {
|
||||
"url = `"$base$($tar.Name)`"`noutput = `"$((Join-Path $dir $tar.Name) -replace '\\', '/')`""
|
||||
}
|
||||
}
|
||||
$lines | Set-Content -Encoding ascii $config
|
||||
$gb = ($batch.Group | Measure-Object Size -Sum).Sum / 1e9
|
||||
$start = Get-Date
|
||||
Write-Host ("{0}..{1}: downloading {2} tars ({3:N2} GB)" -f $batch[0].Name, $batch[-1].Name, $count, $gb)
|
||||
curl.exe -sSf --retry 5 -Z --parallel-max $Parallel -K $config
|
||||
if ($LASTEXITCODE -ne 0) { throw "download failed for $($day.Name)" }
|
||||
if ($LASTEXITCODE -ne 0) { throw "download failed for $($batch[0].Name)..$($batch[-1].Name)" }
|
||||
$secs = ((Get-Date) - $start).TotalSeconds
|
||||
Write-Host (" {0:N0} MB/s" -f ($gb * 1000 / [math]::Max($secs, 1)))
|
||||
|
||||
Remove-Item $config
|
||||
& .\target\release\lc02monty.exe "$out.part" $staging --delete | Select-Object -Last 9
|
||||
foreach ($day in $batch) {
|
||||
$out = Join-Path $monty "$Run-$($day.Name).binpack"
|
||||
& .\target\release\lc02monty.exe "$out.part" (Join-Path $staging $day.Name) --delete | Select-Object -Last 9
|
||||
if ($LASTEXITCODE -ne 0) { throw "conversion failed for $($day.Name)" }
|
||||
Move-Item "$out.part" $out
|
||||
Move-Item -Force "$out.part" $out
|
||||
}
|
||||
}
|
||||
if (Test-Path $staging) { Remove-Item -Recurse -Force $staging }
|
||||
|
||||
if (-not $NoInterleave) {
|
||||
$policy = Join-Path $data 'lc0\policy.binpack'
|
||||
|
||||
Reference in new issue
Block a user