75 lines
4.3 KiB
Bash
Executable file
75 lines
4.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Igneum proving: proves one fixture block inside WSL2, GPU first (SP1_PROVER=cuda, mode all: shard 0 in all three
|
|
# stages, then the block end to end) then CPU for comparison, prints the RESULT lines and uploads the log to the
|
|
# Igneum log intake. Run by PROVE-BLOCK.bat. For the shard fixtures at S_p use prove-shard.sh.
|
|
# Usage: prove-block.sh [fixture name without .json, default block-78-increment] [cpu mode, default shard]
|
|
set -uo pipefail
|
|
HERE="$(cd "$(dirname "$0")" && pwd)"
|
|
FIXTURE="${1:-block-78-increment}"
|
|
CPU_MODES="${2:-shard}"
|
|
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:-}"
|
|
DEST="$HOME/igneum-prove"
|
|
STAMP="$(date -u +%Y%m%d-%H%M%S)"
|
|
LOG="$HERE/prove-$FIXTURE-$STAMP.log"
|
|
RUN_ID="prove-$(hostname)-$STAMP"
|
|
exec > >(tee -a "$LOG") 2>&1
|
|
echo "igneum proving v0, run $RUN_ID, $(date -u +%FT%TZ), host $(hostname), fixture $FIXTURE"
|
|
nvidia-smi --query-gpu=name,memory.total,driver_version --format=csv,noheader 2>/dev/null || echo "nvidia-smi not available in WSL"
|
|
echo "cpu: $(nproc) cores, ram: $(free -g | awk '/Mem:/ {print $2}') GB visible to WSL"
|
|
|
|
upload() {
|
|
# Last 256 KB of the log to the intake (log uploads only); key and URL from the environment, see below.
|
|
python3 - "$LOG" "$RUN_ID" <<'PY'
|
|
import json, os, socket, sys, urllib.request
|
|
path, run_id = sys.argv[1], sys.argv[2]
|
|
# the key and the intake come from the environment (the app's job runner sets IGNEUM_INTAKE_KEY and IGNEUM_INTAKE_URL;
|
|
# by hand: export them, or IGNEUM_INTAKE_KEY_FILE naming a file); no key literal lives in the repository
|
|
key = os.environ.get("IGNEUM_INTAKE_KEY", "").strip()
|
|
if not key and os.environ.get("IGNEUM_INTAKE_KEY_FILE"):
|
|
try: key = open(os.environ["IGNEUM_INTAKE_KEY_FILE"]).read().strip()
|
|
except OSError: key = ""
|
|
if not key:
|
|
print("upload skipped: no IGNEUM_INTAKE_KEY in the environment"); sys.exit(0)
|
|
url = os.environ.get("IGNEUM_INTAKE_URL", "").strip() or "https://igneum-six.vercel.app/api/log"
|
|
data = open(path, 'rb').read()[-262144:].decode('utf-8', 'replace')
|
|
body = json.dumps({"label": "prove-" + socket.gethostname(), "machine": socket.gethostname(), "run_id": run_id, "lines": data}).encode()
|
|
req = urllib.request.Request(url, data=body, headers={"Content-Type": "application/json", "x-igneum-key": key})
|
|
try:
|
|
with urllib.request.urlopen(req, timeout=60) as r:
|
|
print("upload:", r.status, r.read()[:200].decode('utf-8', 'replace'))
|
|
except Exception as e:
|
|
print("upload failed:", e)
|
|
PY
|
|
}
|
|
|
|
# Fresh sources from the package (edits on the Windows side are picked up), build with the cuda feature.
|
|
mkdir -p "$DEST"
|
|
rsync -a --delete --exclude target "$HERE/package/" "$DEST/" 2>/dev/null || cp -r "$HERE/package/." "$DEST/"
|
|
# Re-stamp every copied source: rsync keeps the Mac's dates and cargo rebuilds by mtime, so a file older than the last build
|
|
# here would be taken as unchanged (the stale-build class, 4 and 5 October 2026).
|
|
find "$DEST" -name target -prune -o -type f -exec touch {} + 2>/dev/null || true
|
|
cd "$DEST/proving/igneum-prove"
|
|
echo "building (first time: 10 to 30 minutes, approximate; both guests are compiled by cargo-prove inside the host build)"
|
|
if ! cargo build --release -p igneum-prove-host --features igneum-prove-host/cuda 2>&1 | tail -3; then
|
|
echo "BUILD FAILED"; upload; exit 1
|
|
fi
|
|
HOST="$DEST/proving/igneum-prove/target/release/igneum-prove-host"
|
|
FIX="$DEST/proving/fixtures/$FIXTURE.json"
|
|
mkdir -p "$HERE/results"
|
|
|
|
|
|
echo "=== GPU run: SP1_PROVER=cuda, mode all (shard 0: execute + core + compressed; then the block: shard proofs + aggregation); the first run downloads sp1-gpu-server, about 134 MB ==="
|
|
SP1_PROVER=cuda RUST_LOG=info "$HOST" "$FIX" --mode all --out "$HERE/results/$FIXTURE-cuda-$STAMP.json"
|
|
echo "gpu run exit $?"
|
|
upload
|
|
|
|
echo "=== CPU run: SP1_PROVER=cpu, mode $CPU_MODES (for comparison; a shard on the CPU can take many minutes) ==="
|
|
SP1_PROVER=cpu RUST_LOG=info "$HOST" "$FIX" --mode "$CPU_MODES" --out "$HERE/results/$FIXTURE-cpu-$STAMP.json"
|
|
echo "cpu run exit $?"
|
|
|
|
echo "=== SUMMARY (RESULT lines) ==="
|
|
grep -h '^RESULT\|^fixture\|exit' "$LOG" | sed 's/^/ /'
|
|
upload
|
|
echo "log: $LOG (uploaded as run_id $RUN_ID; on the Mac: node tools/logs.mjs $RUN_ID)"
|