Counter ASIC 3.0 items 6 and 7: PC 2 family playbook posts both card key forms from settings.json, confirms the card quiet by the process list, restores cards and prover in a finally block

This commit is contained in:
igneum-labs 2026-10-06 08:34:28 +00:00
parent 0f3b23d7a7
commit a3adeb2ac8

View file

@ -1,26 +1,56 @@
# Counter ASIC 3.0 item 6 (6 October 2026): the step cost of every reserve candidate family of spec 1.13.2 on PC 2's
# RTX 5090 (docs/plans/counter-asic-3-reserve.md). A signed `run` job published with --stop-miners: the app stops its
# miners before this script starts and restarts them when it ends (app/igneum-app/src/jobrun.rs, stop_miners_first);
# the script never quits, restarts or updates the app. It switches the prover off for the run and back on at the end
# (as tools/prover-floor/pc2-floor-measure.ps1 does), confirms the card is empty by nvidia-smi's compute-apps list
# (never api/state, which answers {} on this machine), writes proto-cuda/family-probe.cu (inlined below by
# the script also switches the NVIDIA card off through POST api/cards with the settings.json key in both forms (with and
# without the device index; 6 October 2026: the index-less form switched nothing on 5 October) and restores it, and
# switches the prover off for the run and back on, both in a finally block; it never quits, restarts or updates the
# app and never writes settings.json. The card is confirmed quiet by nvidia-smi's compute-apps list and the process
# list (never api/state, which answers {} on this machine), writes proto-cuda/family-probe.cu (inlined below by
# make-pc2-playbook.sh, sha256 printed on both sides) into the job dir, compiles it with nvcc inside WSL2
# Ubuntu-24.04 (/usr/local/cuda-12.*) and runs it three times. Every number is a RESULT line; the probe's own
# "RESULT FAMILY ..." lines carry kernel, best ms, G steps/s, ns per step, the ratio to the alu chain and ok=1 for
# bit-exact against the CPU reference on two whole warps. Read back with `node tools/jobs.mjs <job id>`.
$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' }
$appDir = if ($env:IGNEUM_APP_DIR) { $env:IGNEUM_APP_DIR } else { Join-Path $env:LOCALAPPDATA 'igneum\app' }
$urlFile = Join-Path $appDir '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: $_" } }
function Smi($q) { try { (& nvidia-smi --query-gpu=$q --format=csv,noheader,nounits 2>$null) -join ' | ' } catch { 'nvidia-smi failed' } }
function CudaApps { @(& nvidia-smi --query-compute-apps=pid,process_name,used_memory --format=csv,noheader 2>$null | ForEach-Object { "$_" } | Where-Object { $_ -match 'igneum|sp1|prove' }) }
"RESULT start $(Stamp) prover off for the run: $(Prove $false)"
function WorkerProcs { @(Get-Process -ErrorAction SilentlyContinue | Where-Object { $_.ProcessName -match 'igneum-worker|igneum-miner' } | ForEach-Object { $_.ProcessName + ':' + $_.Id }) }
# the app's NVIDIA cards from its settings.json (READ ONLY; key = vendor:device:name), never api/state (it answers {} here).
# 6 October 2026 (coordinator): the 5 October scripts posted the key without the device index and switched nothing, so
# both forms are posted: the settings key as written and vendor:device.
$nvCards = @()
try {
$sj = Get-Content -LiteralPath (Join-Path $appDir 'settings.json') -Raw | ConvertFrom-Json
foreach ($prop in $sj.cards.PSObject.Properties) {
if ($prop.Name -like 'nvidia:*') {
$v = $prop.Value; $pp = [int] $v.power_pct; if ($pp -lt 50) { $pp = 80 }
$parts = $prop.Name -split ':'
$nvCards += @{ key = $prop.Name; short = ($parts[0] + ':' + $parts[1]); enabled = [bool] $v.enabled; identities = [int] $v.identities; power_pct = $pp }
}
}
} catch { "RESULT settings_read_failed $_" }
function SetCards([bool] $enabled) {
foreach ($c in $nvCards) {
foreach ($k in @($c.key, $c.short)) {
$body = @{ cards = @(@{ key = $k; enabled = $enabled; identities = $c.identities; power_pct = $c.power_pct }) } | ConvertTo-Json -Depth 5
try { Invoke-RestMethod -Uri "$base/api/cards" -Method POST -Body $body -ContentType 'application/json' -TimeoutSec 10 | Out-Null; "RESULT cards key=$k enabled=$enabled posted" } catch { "RESULT cards key=$k enabled=$enabled error: $_" }
}
}
}
"RESULT start $(Stamp) nvidia cards in settings.json: $(($nvCards | ForEach-Object { $_.key + ' enabled=' + $_.enabled + ' identities=' + $_.identities + ' power_pct=' + $_.power_pct }) -join ' | ')"
"RESULT workers_before $(Stamp) $((WorkerProcs) -join ' ') cuda_apps=[$((CudaApps) -join '; ')]"
try {
"RESULT prover_off $(Stamp) $(Prove $false)"
SetCards $false
Start-Sleep -Seconds 30
$t = 0; $apps = @(CudaApps)
while ($t -lt 120 -and $apps.Count -gt 0) { Start-Sleep -Seconds 10; $t += 10; $apps = @(CudaApps) }
if ($apps.Count -eq 0) { "RESULT card $(Stamp) empty after $t s (no igneum, sp1 or prove compute app on the card)" } else { "RESULT card $(Stamp) UNCONFIRMED after $t s: the numbers below are beside " + ($apps -join '; ') }
$t = 30; $apps = @(CudaApps); $procs = @(WorkerProcs | Where-Object { $_ -match 'cuda' })
while ($t -lt 150 -and ($apps.Count -gt 0 -or $procs.Count -gt 0)) { Start-Sleep -Seconds 10; $t += 10; $apps = @(CudaApps); $procs = @(WorkerProcs | Where-Object { $_ -match 'cuda' }) }
if ($apps.Count -eq 0 -and $procs.Count -eq 0) { "RESULT card $(Stamp) quiet after $t s (no igneum, sp1 or prove compute app; no igneum-worker-cuda process): the card to itself" } else { "RESULT card $(Stamp) UNCONFIRMED after $t s: the rows below are beside compute apps [" + ($apps -join '; ') + "] procs [" + ($procs -join ' ') + "]" }
"RESULT gpus $(Stamp) $(Smi 'index,name,driver_version,memory.used,clocks.sm,clocks.mem,power.draw,temperature.gpu')"
$job = $env:IGNEUM_JOB_DIR; if (-not $job) { $job = Join-Path $env:TEMP 'igneum-ca3-family' }; New-Item -ItemType Directory -Force -Path $job | Out-Null
$cu = @'
@ -59,5 +89,9 @@ $bashFile = Join-Path $job 'measure.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 gpus_after $(Stamp) $(Smi 'clocks.sm,clocks.mem,power.draw,temperature.gpu')"
"RESULT end $(Stamp) prover back on: $(Prove $true)"
} finally {
# whatever happened above: the cards back to their settings.json state and the prover ON (the clear file's rule)
foreach ($c in $nvCards) { if ($c.enabled) { SetCards $true } }
"RESULT end $(Stamp) prover back on: $(Prove $true)"
}
exit 0