#!/bin/bash # Runs ON a RunPod pod. Executes a stride-slice of the (deficit-end W, seed) grid, uploads each # result JSON as it lands, then self-terminates. Same durability rule as the clone stage: the pod # owns delivery, nothing depends on a Mac-side watcher surviving. # # bash cp_sweep_bootstrap.sh # # Grid is defined here so every pod agrees on it without extra plumbing. W=0 is the fresh # baseline. Ends are log-spaced from below the 3-body acquisition point (100 steps) to 20x past # the 33-body one (1000), which is the range the toy W-sweep says the effect turns on and peaks in. set -x JOBS=${1:?job indices, comma-separated}; N_JOBS=${2:?n jobs}; ORDER=${3:-9}; STEPS=${4:-100000} WD=${5:-0.1}; WS=${6:-"0 250 500 1000 2000 5000 10000 20000"}; SEEDS=${7:-"0 1 2"} POST=${8:-0}; CORPUS=${9:-} TAG=$(echo "$JOBS-wd$WD-post$POST-c$CORPUS" | tr "," "-") # one pod may cover several stride slices when GPU # capacity is scarce -- see the SUPPLY_CONSTRAINT note case "$ORDER" in 3) NL=2;; 9) NL=4;; 33) NL=6;; *) echo "bad order"; exit 1;; esac cd /root apt-get update -qq && apt-get install -y -qq tmux >/dev/null 2>&1 pip install -q huggingface_hub numpy python - "$NL" "$ORDER" "$CORPUS" <<'PY' import os, sys, shutil, glob from huggingface_hub import hf_hub_download, HfApi nl, order = sys.argv[1], sys.argv[2] os.makedirs("/root/results/nlp_cp", exist_ok=True) for f in ["train.npy", "test.npy", f"factored{nl}.pt", "clone_factored2_sweep20.npy", "clone_factored4_sweep20.npy", "clone_factored6_sweep20.npy"]: p = hf_hub_download("bgradowhite/rende-nlp-fig1", f"results/{f}", repo_type="dataset", local_dir="/root/dl") shutil.copy(p, f"/root/results/nlp_cp/{os.path.basename(f)}") # every clone shard for this order api = HfApi() files = api.list_repo_files("bgradowhite/rende-nlp-cp", repo_type="dataset") corpus = sys.argv[3] if len(sys.argv) > 3 else "" shards = [f for f in files if f.startswith(f"clone{order}{corpus}_shard") and f.endswith(".npy")] assert shards, f"no clone shards on HF for order {order}" for f in shards: p = hf_hub_download("bgradowhite/rende-nlp-cp", f, repo_type="dataset", local_dir="/root/dl2") shutil.copy(p, f"/root/results/nlp_cp/{os.path.basename(f)}") print(f"data ready: {len(shards)} clone shards") PY nvidia-smi --query-gpu=name,ecc.errors.uncorrected.volatile.total --format=csv python -c "import torch;assert torch.cuda.is_available();print('cuda OK',torch.cuda.get_device_name(0))" || { echo "GPU UNUSABLE - self-terminating"; runpodctl remove pod "$RUNPOD_POD_ID"; exit 1; } i=0 for w in $WS; do for s in $SEEDS; do r=$((i % N_JOBS)) case ",$JOBS," in *",$r,"*) echo "=== running W=$w seed=$s ===" PYTHONUNBUFFERED=1 python -u nlp_cp_sweep.py sweep --deficit-end "$w" --seed "$s" \ --order "$ORDER" --total-steps "$STEPS" --wd "$WD" --post-steps "$POST" --corpus "$CORPUS" --outdir /root/results/nlp_cp \ 2>&1 | tee -a /root/job$TAG.log ;; esac i=$((i+1)) done done python - "$TAG" <<'PY' import sys from huggingface_hub import HfApi api = HfApi() try: api.upload_file(path_or_fileobj=f"/root/job{sys.argv[1]}.log", path_in_repo=f"logs/sweep_job{sys.argv[1]}.log", repo_id="bgradowhite/rende-nlp-cp", repo_type="dataset") except Exception as e: print("log upload failed", e) PY runpodctl remove pod "$RUNPOD_POD_ID"