1#!/bin/bash2# Run the SAT scaling grids (3a preimage, 3b collision) on cluster node M3U96b and bring the results back.3# ./run_cluster.sh setup # venv (uv, python 3.12) + copy kissat/cadical binaries + smoke test4# ./run_cluster.sh launch # rsync src/ + experiments/reduced_round_sha256/ and start both drivers (nohup)5# ./run_cluster.sh status # tail the driver logs6# ./run_cluster.sh fetch # rsync results back into results/reduced_round_sha256/7# Workers: 14 (preimage) + 10 (collision) = 24 concurrent single-thread solver processes. Deadline: no new cell8# after DEADLINE seconds (cells are ordered seed-0-first then by cost, so the largest cells lose seeds first).9set -euo pipefail10NODE=${NODE:-M3U96b}11REMOTE=~/wp3412HERE="$(cd "$(dirname "$0")" && pwd)"13ROOT="$(cd "$HERE/../.." && pwd)"14DEADLINE=${DEADLINE:-7200}15PY='~/wp34/venv/bin/python'16case "${1:-}" in17 setup)18 ssh $NODE "mkdir -p $REMOTE/bin $REMOTE/results && cd $REMOTE && uv venv venv --python 3.12 -q && uv pip install --python venv/bin/python -q python-sat numpy z3-solver scipy"19 scp -q /opt/homebrew/bin/kissat /opt/homebrew/bin/cadical $NODE:$REMOTE/bin/20 ssh $NODE "$REMOTE/bin/kissat --version && $REMOTE/bin/cadical --version && $PY -c 'import pysat, z3, numpy; print(\"venv ok\")'"21 ;;22 launch)23 rsync -az --delete --exclude '__pycache__' "$ROOT/src/" $NODE:$REMOTE/src/24 rsync -az --delete --exclude '__pycache__' "$HERE/" $NODE:$REMOTE/experiments/reduced_round_sha256/25 ssh $NODE "cd $REMOTE && PYTHONPATH=$REMOTE/src $PY experiments/reduced_round_sha256/cnf_sha256.py --selftest | tail -2"26 ssh $NODE "cd $REMOTE && export PYTHONPATH=$REMOTE/src KISSAT_BIN=$REMOTE/bin/kissat; \27 nohup $PY experiments/reduced_round_sha256/cluster_driver.py --script preimage_sat.py \28 --cells-dir results/cells_preimage --out results/preimage_sat_scaling.json --workers ${W_PRE:-14} --deadline $DEADLINE \29 > results/driver_preimage.log 2>&1 & \30 nohup $PY experiments/reduced_round_sha256/cluster_driver.py --script collision_sat.py \31 --cells-dir results/cells_collision --out results/collision_sat.json --workers ${W_COL:-10} --deadline $DEADLINE \32 > results/driver_collision.log 2>&1 & \33 sleep 2; echo launched; pgrep -fl cluster_driver | head"34 ;;35 status)36 ssh $NODE "cd $REMOTE/results && tail -n 4 driver_preimage.log driver_collision.log; echo; ls cells_preimage | wc -l; ls cells_collision | wc -l; uptime"37 ;;38 fetch)39 mkdir -p "$ROOT/results/reduced_round_sha256"40 rsync -az $NODE:$REMOTE/results/ "$ROOT/results/reduced_round_sha256/m3u96b/"41 for f in preimage_sat_scaling.json collision_sat.json; do42 [ -f "$ROOT/results/reduced_round_sha256/m3u96b/$f" ] && cp "$ROOT/results/reduced_round_sha256/m3u96b/$f" "$ROOT/results/reduced_round_sha256/$f"43 done44 ls -la "$ROOT/results/reduced_round_sha256/"45 ;;46 *) echo "usage: $0 setup|launch|status|fetch"; exit 1;;47esac48