fix: download Lc0 tars over 32 connections across days
storage.lczero.org limits each connection to about 2.3 MB/s but not the number of connections: 8 give 23 MB/s, 16 give 43 MB/s, 32 give 72 MB/s. fetch.ps1 downloaded one day (about 24 tars) at a time, which capped it at 24 connections; it now fills batches of whole days with about two tars per connection, downloads them with -Parallel 32 by default, then converts and deletes each day as before. Checked: Nov 14-15 (45 tars, 2.9 GB) in one batch at 32 MB/s, 13.9M positions, no record dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
15258f952a
commit
05fd552e0b
2 files changed
+49
-21
No files matched your search
+3
-1
@@ -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`.
|
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
|
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
|
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:
|
Tars downloaded by hand can be converted directly:
|
||||||
|
|
||||||
|
|||||||
+46
-20
@@ -1,18 +1,21 @@
|
|||||||
# Downloads Lc0 self-play data and converts it to montyformat for the policy trainer.
|
# 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
|
# 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).
|
# 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
|
# The server limits each connection to about 2.3 MB/s but not their number
|
||||||
# converted into data\lc0\monty\<run>-<day>.binpack and deleted, so the disk
|
# (32 connections: ~72 MB/s), so tars are downloaded -Parallel at a time, in
|
||||||
# only ever holds one day of tars. Days already converted are skipped, so an
|
# batches of whole days (about two tars per connection) into data\lc0\staging.
|
||||||
# interrupted run can simply be started again. At the end every day file is
|
# Each day of a batch is then converted into data\lc0\monty\<run>-<day>.binpack
|
||||||
# shuffled into data\lc0\policy.binpack, which is what train.ps1 reads.
|
# 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(
|
param(
|
||||||
[string] $From = (Get-Date).AddDays(-21).ToString('yyyyMMdd'),
|
[string] $From = (Get-Date).AddDays(-21).ToString('yyyyMMdd'),
|
||||||
[string] $To = (Get-Date -Format 'yyyyMMdd'),
|
[string] $To = (Get-Date -Format 'yyyyMMdd'),
|
||||||
[string] $Run = 'test91',
|
[string] $Run = 'test91',
|
||||||
[int] $Parallel = 8,
|
[int] $Parallel = 32,
|
||||||
[switch] $NoInterleave
|
[switch] $NoInterleave
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -42,25 +45,48 @@ $days = $tars | Group-Object Day | Sort-Object Name
|
|||||||
$totalGb = ($tars | Measure-Object Size -Sum).Sum / 1e9
|
$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)
|
Write-Host ("{0} tars over {1} days, {2:N1} GB to download" -f $tars.Count, $days.Count, $totalGb)
|
||||||
|
|
||||||
foreach ($day in $days) {
|
$pending = @($days | Where-Object { -not (Test-Path (Join-Path $monty "$Run-$($_.Name).binpack")) })
|
||||||
$out = Join-Path $monty "$Run-$($day.Name).binpack"
|
$done = $days.Count - $pending.Count
|
||||||
if (Test-Path $out) { continue }
|
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'
|
$config = Join-Path $staging 'curl.txt'
|
||||||
# Forward slashes: curl reads backslashes in a config file as escapes.
|
# Forward slashes: curl reads backslashes in a config file as escapes.
|
||||||
$day.Group | ForEach-Object { "url = `"$base$($_.Name)`"`noutput = `"$((Join-Path $staging $_.Name) -replace '\\', '/')`"" } |
|
$lines = foreach ($day in $batch) {
|
||||||
Set-Content -Encoding ascii $config
|
$dir = Join-Path $staging $day.Name
|
||||||
$gb = ($day.Group | Measure-Object Size -Sum).Sum / 1e9
|
New-Item -ItemType Directory -Force $dir | Out-Null
|
||||||
Write-Host ("{0}: downloading {1} tars ({2:N2} GB)" -f $day.Name, $day.Group.Count, $gb)
|
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
|
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
|
foreach ($day in $batch) {
|
||||||
& .\target\release\lc02monty.exe "$out.part" $staging --delete | Select-Object -Last 9
|
$out = Join-Path $monty "$Run-$($day.Name).binpack"
|
||||||
if ($LASTEXITCODE -ne 0) { throw "conversion failed for $($day.Name)" }
|
& .\target\release\lc02monty.exe "$out.part" (Join-Path $staging $day.Name) --delete | Select-Object -Last 9
|
||||||
Move-Item "$out.part" $out
|
if ($LASTEXITCODE -ne 0) { throw "conversion failed for $($day.Name)" }
|
||||||
|
Move-Item -Force "$out.part" $out
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (Test-Path $staging) { Remove-Item -Recurse -Force $staging }
|
||||||
|
|
||||||
if (-not $NoInterleave) {
|
if (-not $NoInterleave) {
|
||||||
$policy = Join-Path $data 'lc0\policy.binpack'
|
$policy = Join-Path $data 'lc0\policy.binpack'
|
||||||
|
|||||||
Reference in new issue
Block a user