igneum/tools/proving-v1/pc2-sp-curve.ps1
igneum-labs 11c4426a96 Kill by exact command line or pid file, never by a name: tools/ci/kill-by-name-check.sh in the gate; the 36 pgrep/pkill literals in the tree fixed
The fleet's 22:09 UK incident (a Mac-side pkill -f <log file name> matched nothing, the roll-everything script lived on and wiped a held box) and the day's two pgrep self-matches are one class. The check flags pgrep -f / pkill -f with a plain literal (every one on a line), any pgrep/pkill on a file-name shape, and ps | grep with a literal; it allows the bracket form, -x, -F pidfile, kill $(cat pidfile), a variable and a full path; 11 banned and 16 allowed shapes in its self-test; 0.15 s over the tree. The 25 pkill -f sp1-gpu-server inside bash -c bodies (which matched the calling bash) are pkill -x; the other 11 literals take the bracket form; prover-socket-check accepts both. Row R in the record; the CLAUDE.md rule names the check and covers pkill and file names.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-06 22:10:31 +00:00

80 lines
6.4 KiB
PowerShell

# Proving v1, the S_p curve (5 October 2026, the coordinator: peak GPU memory against shard size against time, full
# shards): one compressed shard proof per point on PC 2's RTX 5090, the pv1b host (--budget re-plans a fixture at a
# test budget), the live prover off for the run, the GPU server killed and its socket unlinked around every point.
# Points: the empty live shard (280 k cycles); block-56 (200 pgas transfer); the v1-budget shard (fees-v1-shards2,
# 30,000 pgas, about 4.7 M cycles); block 344 (27 M pgas, modexp) cut at one transaction (2.25 M pgas, about 20 M
# cycles) and two (about 40 M); the full shard at S_p (block-338-shard1, 60 M). Set MINERS=stopped when published with
# --stop-miners (the title says which); the script only reports what nvidia-smi sees before it starts.
$ErrorActionPreference = 'Continue'
$urlFile = if ($env:IGNEUM_APP_DIR) { Join-Path $env:IGNEUM_APP_DIR 'app.url' } else { Join-Path $env:LOCALAPPDATA 'igneum\app\app.url' }
if (-not (Test-Path $urlFile)) { $urlFile = Join-Path $env:LOCALAPPDATA 'igneum\app\app.url' }
$base = (Get-Content $urlFile -Raw).Trim().TrimEnd('/')
function Stamp { (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ') }
function Prove($on) { try { (Invoke-RestMethod -Method Post -Uri "$base/api/prove" -ContentType 'application/json' -Body (@{on=$on} | ConvertTo-Json -Compress) -TimeoutSec 10) | ConvertTo-Json -Compress } catch { "error: $_" } }
"RESULT start $(Stamp) prover off for the run: $(Prove $false)"
Start-Sleep -Seconds 45
"RESULT gpus $(Stamp) $((& nvidia-smi --query-gpu=index,name,memory.used,memory.total,utilization.gpu,power.draw --format=csv,noheader,nounits 2>$null) -join ' | ')"
$job = $env:IGNEUM_JOB_DIR; if (-not $job) { $job = Join-Path $env:TEMP 'igneum-pv1-sp' }; New-Item -ItemType Directory -Force -Path $job | Out-Null
function WslPath($p) { $w = (& wsl.exe -d Ubuntu-24.04 -u root -- wslpath -a ($p -replace '\\', '/') 2>$null); if ($w) { ($w -replace "`0", '').Trim() } else { '/mnt/c' + ($p.Substring(2) -replace '\\', '/') } }
$jobW = WslPath $job
$kitFile = Join-Path $env:LOCALAPPDATA 'igneum\app\jobs\chain-pc2-pv1c\block-83616.json'
if (-not (Test-Path $kitFile)) { Write-Output "RESULT kit missing: $kitFile; republish the fetch after any app update (C32)"; exit 2 }
$emptyW = WslPath $kitFile
$pkg = Join-Path $env:LOCALAPPDATA 'igneum\prove\igneum-prove-wsl2-pv1b\igneum-prove-wsl2'
if (-not (Test-Path $pkg)) { $pkg = Join-Path $env:LOCALAPPDATA 'igneum\prove\igneum-prove-wsl2-pv1b' }
$pkgW = WslPath $pkg
$bash = @"
set -uo pipefail
export PATH="`$HOME/.cargo/bin:`$HOME/.sp1/bin:`$PATH"
CUDA_DIR="`$(ls -d /usr/local/cuda-12.* 2>/dev/null | sort -V | tail -1 || true)"; [ -n "`$CUDA_DIR" ] && export PATH="`$CUDA_DIR/bin:`$PATH" && export LD_LIBRARY_PATH="`$CUDA_DIR/lib64:/usr/lib/wsl/lib:`${LD_LIBRARY_PATH:-}"
stamp() { date -u +%Y-%m-%dT%H:%M:%SZ; }
JOB='$jobW'; PKG='$pkgW'; DEST="`$HOME/igneum-prove-pv1"; LIVE_TARGET="`$HOME/igneum-prove/proving/igneum-prove/target"
pkill -x sp1-gpu-server 2>/dev/null; sleep 2; rm -f /tmp/sp1-cuda-*.sock
# the pv1b host (--budget) from the fetched package, built against the warm target dir, into /opt/igneum-pv1
rsync -a --delete --exclude target "`$PKG/package/" "`$DEST/"
find "`$DEST" -name target -prune -o -type f -exec touch {} + 2>/dev/null
cd "`$DEST/proving/igneum-prove"
t0=`$(date +%s)
if ! CARGO_TARGET_DIR="`$LIVE_TARGET" cargo build --release -p igneum-prove-host --features igneum-prove-host/cuda 2>&1 | tail -2; then echo "RESULT build FAILED"; exit 1; fi
cp "`$LIVE_TARGET/release/igneum-prove-host" /opt/igneum-pv1/
echo "RESULT build `$(stamp) exit 0 in `$(( `$(date +%s) - t0 )) s; host `$(sha256sum /opt/igneum-pv1/igneum-prove-host | cut -c1-16); live /opt/igneum untouched `$(sha256sum /opt/igneum/igneum-prove-host | cut -c1-16)"
H=/opt/igneum-pv1/igneum-prove-host; FX="`$DEST/proving/fixtures"
echo "RESULT miner_resident_mib `$(nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits | head -1)"
run() { # name fixture budget env...
local name="`$1" fx="`$2" budget="`$3"; shift 3
pkill -x sp1-gpu-server 2>/dev/null; sleep 2; rm -f /tmp/sp1-cuda-*.sock
local tag="`$name-`$(basename `$fx .json)"
local csv="`$JOB/smi-`$tag.csv"
nvidia-smi --query-gpu=timestamp,memory.used,utilization.gpu --format=csv,noheader,nounits -l 1 > "`$csv" 2>/dev/null &
local SMI=`$!
local t0=`$(date +%s)
local barg=""; [ "`$budget" != "0" ] && barg="--budget `$budget"
env SP1_PROVER=cuda RUST_LOG=off "`$@" `$H "`$fx" --mode compressed --shard 0 `$barg --out "`$JOB/res-`$tag.json" > "`$JOB/log-`$tag.txt" 2>&1
local rc=`$?
local wall=`$(( `$(date +%s) - t0 ))
kill `$SMI 2>/dev/null; sleep 1
local peak=`$(awk -F', *' '{ if (`$2+0 > m) m=`$2+0 } END { print m+0 }' "`$csv")
local line=`$(grep -E "^RESULT compressed shard" "`$JOB/log-`$tag.txt" | tail -1 | sed -E 's/.*prove ([0-9.]+) s, proof ([0-9]+) bytes, verify ([0-9.]+) s, ([A-Z ]+);.*/prove_s=\1 verify_s=\3 \4/')
local cyc=`$(grep -E "^RESULT execute shard" "`$JOB/log-`$tag.txt" | tail -1 | sed -E 's/.*: ([0-9]+) cycles.*/\1/')
local plan=`$(grep -E "^RESULT plan:" "`$JOB/log-`$tag.txt" | sed -E 's/RESULT plan: ([0-9]+) shard.*/shards_per_block=\1/')
local sh=`$(grep -E "^RESULT shard 0 native" "`$JOB/log-`$tag.txt" | sed -E 's/.*pgas ([0-9]+).*input ([0-9]+) bytes.*/pgas=\1 witness_bytes=\2/')
local err=`$(grep -iE "^Error|panick|out of memory|OOM" "`$JOB/log-`$tag.txt" | head -1 | cut -c1-160)
echo "RESULT curve cfg=`$name fixture=`$(basename `$fx .json) budget=`$budget `$plan `$sh cycles=`${cyc:-na} peak_mib=`$peak samples=`$(wc -l < "`$csv") wall_s=`$wall `${line:-no_result} exit=`$rc env='`$*' `${err:+err=`$err}"
}
E25="ELEMENT_THRESHOLD=33554432 HEIGHT_THRESHOLD=1048576"
run base '$emptyW' 0
run base "`$FX/block-56-transfers.json" 0
run base "`$FX/fees-v1-shards2.json" 0
run base "`$FX/block-344-shards4.json" 2249264
run base "`$FX/block-344-shards4.json" 4500000
run base "`$FX/block-338-shard1.json" 0
run e25 "`$FX/fees-v1-shards2.json" 0 `$E25
run e25 "`$FX/block-344-shards4.json" 2249264 `$E25
run e25 "`$FX/block-338-shard1.json" 0 `$E25
pkill -x sp1-gpu-server 2>/dev/null; sleep 1; rm -f /tmp/sp1-cuda-*.sock
echo "RESULT curve_end `$(stamp)"
"@
$bashFile = Join-Path $job 'curve.sh'
[IO.File]::WriteAllText($bashFile, ($bash -replace "`r`n", "`n"), (New-Object System.Text.UTF8Encoding $false))
& wsl.exe -d Ubuntu-24.04 -u root -- bash (WslPath $bashFile) 2>&1 | ForEach-Object { ($_ -replace "`0", '') }
"RESULT end $(Stamp) prover back on: $(Prove $true)"