#!/bin/bash # Runs ON a RunPod pod. Builds the CLEAN (low-order-faithful) clone corpus with a causal # factored-attention generator and exact ancestral sampling, then self-terminates. # # bash cp_causal_bootstrap.sh train # bash cp_causal_bootstrap.sh sample # # Two modes on purpose: the generator is trained ONCE and its weights uploaded, then many pods # sample from that single generator. If every pod trained its own, the corpus would be a mixture # of slightly different distributions -- small, but exactly the kind of contamination this whole # exercise exists to remove. set -x MODE=${1:?train|sample}; ORDER=${2:-9} 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 - <<'PY' import os, shutil from huggingface_hub import hf_hub_download os.makedirs("/root/results/nlp_cp", exist_ok=True) for repo, f, dest in [("bgradowhite/rende-nlp-fig1", "results/train.npy", "train.npy"), ("bgradowhite/rende-nlp-fig1", "results/test.npy", "test.npy")]: p = hf_hub_download(repo, f, repo_type="dataset", local_dir="/root/dl") shutil.copy(p, f"/root/results/nlp_cp/{dest}") print("data ready") 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"; runpodctl remove pod "$RUNPOD_POD_ID"; exit 1; } if [ "$MODE" = "train" ]; then STEPS=${3:-12000} python -u causal_factored.py --data /root/results/nlp_cp/train.npy --layers "$NL" \ --steps "$STEPS" --batch 128 --n-sample 2000 --save /root/causal_k$ORDER.pt \ --out /root/results/causal 2>&1 | tee /root/train_k$ORDER.log python - <