81 lines
7.3 KiB
PowerShell
81 lines
7.3 KiB
PowerShell
# AMD proving question (5 October 2026, the project lead: "test proving on the amd card?"): the SP1 CPU prover on PC 1 (machine
|
|
# ae432dc7, RTX 5090 + RX 9070 XT on the eGPU), as a signed `run` job (shell powershell, not elevated, the miners keep
|
|
# mining on BOTH cards; the job never touches a card: SP1_PROVER=cpu, the host built WITHOUT the cuda feature).
|
|
# No zkVM proves on AMD today (docs/analysis/amd-proving.md), so the CPU path is the only prover an AMD-only machine has.
|
|
# 1. downloads the hosted prover package (igneum-prove-wsl2-pv1b.zip, sha256 checked) into the job folder
|
|
# 2. inside WSL2 (root, Ubuntu-24.04): package -> ~/igneum-prove-cpu, every file re-stamped, the host built
|
|
# with `cargo build --release -p igneum-prove-host` (no cuda feature; the guests are pinned, no Succinct toolchain)
|
|
# 3. for each fixture in $FIXTURES: `--mode shard --shard 0` (execute, core, compressed, each verified) under
|
|
# /usr/bin/time -v for the wall time, the peak resident set and the CPU percentage; a 1-s sampler of
|
|
# /proc/loadavg and nvidia-smi utilisation underneath (the 5090's utilisation stays at the miner's level: the
|
|
# job did not touch it; the 9070 XT is not visible to nvidia-smi)
|
|
# Every number is a RESULT line. The results JSON per fixture is printed at the end (RESULTS-JSON <name> ... END).
|
|
$ErrorActionPreference = 'Continue'
|
|
$FIXTURES = 'block-338-shard1'
|
|
$ZIP_URL = '__ZIP_URL__' # filled at publish time from the downloads folder (the dl token never enters the repository)
|
|
$ZIP_SHA = '__ZIP_SHA__'
|
|
function Stamp { (Get-Date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ssZ') }
|
|
$job = $env:IGNEUM_JOB_DIR
|
|
if (-not $job) { $job = Join-Path $env:TEMP 'igneum-cpu-prove' }
|
|
New-Item -ItemType Directory -Force -Path $job | Out-Null
|
|
"RESULT start $(Stamp) machine=$env:IGNEUM_MACHINE_ID fixtures=$FIXTURES"
|
|
# 1. the package
|
|
$zip = Join-Path $job 'igneum-prove-wsl2-pv1b.zip'
|
|
& curl.exe -s -S -L -m 600 -o $zip $ZIP_URL 2>&1 | ForEach-Object { "curl: $_" }
|
|
if (-not (Test-Path $zip)) { "RESULT package FAILED: no download"; exit 1 }
|
|
$sha = (Get-FileHash -Algorithm SHA256 $zip).Hash.ToLower()
|
|
if ($sha -ne $ZIP_SHA) { "RESULT package FAILED: sha256 $sha is not $ZIP_SHA"; exit 1 }
|
|
$pkg = Join-Path $job 'pkg'
|
|
if (Test-Path $pkg) { Remove-Item -Recurse -Force $pkg }
|
|
Expand-Archive -Path $zip -DestinationPath $pkg -Force
|
|
$pkgRoot = Get-ChildItem -Path $pkg -Directory | Select-Object -First 1
|
|
"RESULT package $(Stamp) $((Get-Item $zip).Length) bytes, sha256 ok, extracted to $($pkgRoot.FullName)"
|
|
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 '\\', '/') } }
|
|
$pkgW = WslPath $pkgRoot.FullName; $jobW = WslPath $job
|
|
$bash = @"
|
|
set -uo pipefail
|
|
export PATH="`$HOME/.cargo/bin:`$PATH"; [ -f "`$HOME/.cargo/env" ] && . "`$HOME/.cargo/env"
|
|
stamp() { date -u +%Y-%m-%dT%H:%M:%SZ; }
|
|
PKG='$pkgW'; JOB='$jobW'; DEST="`$HOME/igneum-prove-cpu"
|
|
echo "RESULT wsl `$(stamp) host `$(hostname) user `$(id -un) cores `$(nproc) ram_total_mb `$(free -m | awk '/Mem:/ {print `$2}') ram_used_mb `$(free -m | awk '/Mem:/ {print `$3}') loadavg `$(cut -d' ' -f1-3 /proc/loadavg) cargo `$(command -v cargo || echo MISSING)"
|
|
nvidia-smi --query-gpu=name,memory.total,utilization.gpu --format=csv,noheader 2>/dev/null | sed 's/^/RESULT gpu-before /' || echo "RESULT gpu-before nvidia-smi not available"
|
|
# tools the build and the measurement need (the node build on this distro had the compilers; protoc and GNU time may be missing)
|
|
command -v protoc >/dev/null && command -v /usr/bin/time >/dev/null || { apt-get update -qq >/dev/null 2>&1; DEBIAN_FRONTEND=noninteractive apt-get install -y -qq protobuf-compiler time pkg-config libssl-dev >/dev/null 2>&1 || echo "RESULT apt FAILED (continuing)"; }
|
|
echo "RESULT tools protoc `$(command -v protoc || echo MISSING) time `$(command -v /usr/bin/time || echo MISSING)"
|
|
mkdir -p "`$DEST"
|
|
rsync -a --delete --exclude target "`$PKG/package/" "`$DEST/" 2>/dev/null || { rm -rf "`$DEST"; mkdir -p "`$DEST"; cp -r "`$PKG/package/." "`$DEST/"; }
|
|
# re-stamp every copied file: cargo rebuilds by mtime and this side keeps its target dir (the stale-build class, 4 and 5 October 2026)
|
|
find "`$DEST" -name target -prune -o -type f -exec touch {} + 2>/dev/null
|
|
grep -o '"program_id": "0x[0-9a-f]*"' "`$DEST/proving/igneum-prove/elf/manifest.json" | sed 's/^/RESULT manifest /'
|
|
cd "`$DEST/proving/igneum-prove"
|
|
echo "RESULT build start `$(stamp) (no cuda feature; cold target dir unless this job ran before)"
|
|
t0=`$(date +%s)
|
|
if ! cargo build --release -p igneum-prove-host 2>&1 | tail -3; then echo "RESULT build FAILED"; exit 1; fi
|
|
echo "RESULT build `$(stamp) exit 0 in `$(( `$(date +%s) - t0 )) s"
|
|
H="`$DEST/proving/igneum-prove/target/release/igneum-prove-host"
|
|
`$H --mode id | sed 's/^/RESULT cpu-host /'
|
|
mkdir -p "`$JOB/results"
|
|
for FX in $FIXTURES; do
|
|
F="`$DEST/proving/fixtures/`$FX.json"
|
|
[ -f "`$F" ] || { echo "RESULT `$FX FAILED: no fixture `$F"; continue; }
|
|
`$H "`$F" --mode native 2>&1 | grep -E "^RESULT (native|plan)" | sed "s/^/`$FX /"
|
|
# the samplers: load average and the 5090's utilisation, one line a second
|
|
( while true; do echo "`$(date -u +%H:%M:%S) `$(cut -d' ' -f1 /proc/loadavg) `$(nvidia-smi --query-gpu=utilization.gpu,memory.used --format=csv,noheader,nounits 2>/dev/null | head -1 | tr -d ' ')"; sleep 1; done ) > "`$JOB/results/`$FX-sampler.txt" 2>/dev/null &
|
|
S=`$!
|
|
echo "RESULT `$FX prove start `$(stamp) SP1_PROVER=cpu mode shard --shard 0"
|
|
SP1_PROVER=cpu RUST_LOG=off /usr/bin/time -v -o "`$JOB/results/`$FX-time.txt" `$H "`$F" --mode shard --shard 0 --out "`$JOB/results/`$FX-cpu.json" 2>&1 | grep -E "^(RESULT|STAGE|igneum-prove-host sources)" | sed "s/^/`$FX: /"
|
|
echo "RESULT `$FX prove end `$(stamp) exit `${PIPESTATUS[0]}"
|
|
kill `$S 2>/dev/null; sleep 1
|
|
awk -v fx="`$FX" '/Elapsed .wall clock./ {w=`$NF} /Maximum resident set size/ {r=`$NF} /Percent of CPU this job got/ {c=`$NF} /User time/ {u=`$NF} /System time/ {s=`$NF} END {print "RESULT " fx " time wall=" w " max_rss_kb=" r " cpu_percent=" c " user_s=" u " sys_s=" s}' "`$JOB/results/`$FX-time.txt"
|
|
awk -v fx="`$FX" -F'[ ,]' 'NF>=2 { n++; if (`$2+0 > lmax) lmax=`$2+0; if (`$3 != "") { gs += `$3+0; gn++; if (`$3+0 < gmin || gn==1) gmin=`$3+0 } } END { printf "RESULT %s sampler samples=%d loadavg_max=%.1f gpu0_util_mean=%.0f gpu0_util_min=%d (the level of the miner: the job did not use the card)\n", fx, n, lmax, (gn? gs/gn : -1), gmin }' "`$JOB/results/`$FX-sampler.txt"
|
|
done
|
|
free -m | awk '/Mem:/ {print "RESULT wsl_ram_after total_mb=" `$2 " used_mb=" `$3}'
|
|
nvidia-smi --query-gpu=name,utilization.gpu --format=csv,noheader 2>/dev/null | sed 's/^/RESULT gpu-after /'
|
|
for FX in $FIXTURES; do [ -f "`$JOB/results/`$FX-cpu.json" ] && { echo "RESULTS-JSON `$FX"; cat "`$JOB/results/`$FX-cpu.json"; echo; echo "END"; }; done
|
|
echo "RESULT done `$(stamp)"
|
|
"@
|
|
$bashFile = Join-Path $job 'cpu-prove.sh'
|
|
[IO.File]::WriteAllText($bashFile, ($bash -replace "`r`n", "`n"), (New-Object System.Text.UTF8Encoding $false))
|
|
$chk = (& wsl.exe -d Ubuntu-24.04 -u root -- bash -n (WslPath $bashFile) 2>&1 | ForEach-Object { ($_ -replace "`0", "") }); if ($LASTEXITCODE -ne 0) { "RESULT syntax FAILED: $chk"; exit 1 } else { "RESULT syntax ok (bash -n)" }
|
|
& wsl.exe -d Ubuntu-24.04 -u root -- bash (WslPath $bashFile) 2>&1 | ForEach-Object { ($_ -replace "`0", '') }
|
|
"RESULT end $(Stamp)"
|