ccd-repro-code / scripts /job_main.sh
ashishk1331's picture
Eq20 budget diagnostics
02bdb20 verified
Raw
History Blame Contribute Delete
3.7 kB
#!/bin/bash
# Consolidated CCD reproduction run: all four empirical claims in ONE job so the
# 14GB model is downloaded and loaded once. Results are uploaded to the Hub after
# every config, so a timeout/cancel still preserves everything finished so far.
set -uo pipefail
pip install -q "transformers==4.46.2" "huggingface_hub<1.0" "datasets<4" "accelerate" 2>&1 | tail -1
python -c "
from huggingface_hub import snapshot_download
snapshot_download('ashishk1331/ccd-repro-code', repo_type='dataset', local_dir='/work')
"
cd /work
mkdir -p outputs
nvidia-smi --query-gpu=name,memory.total --format=csv
: "${N_TRIP:=60}"
: "${N_HE:=40}"
: "${N_ABL:=40}"
: "${N_TEMP:=25}"
push () { # upload whatever exists so far; never fail the job over an upload
python - <<'EOF' 2>&1 | tail -1 || true
from huggingface_hub import HfApi
HfApi().upload_folder(folder_path="outputs", path_in_repo="outputs",
repo_id="ashishk1331/ccd-repro-results", repo_type="dataset")
print("pushed")
EOF
}
run () { # run() <outfile> <args...>; skip if already done
out="outputs/$1"; shift
if [ -f "$out" ]; then echo "SKIP $out (exists)"; return; fi
echo "=========== RUN $out : $* ==========="
python scripts/run_eval.py "$@" --out "$out" || echo "!!!!! FAILED: $out"
push
}
python - <<'EOF'
# Make the job resumable: pull any results a previous attempt already finished,
# so a relaunch after a timeout/cancel never pays for the same config twice.
from huggingface_hub import HfApi, snapshot_download
api = HfApi()
api.create_repo('ashishk1331/ccd-repro-results', repo_type='dataset', exist_ok=True)
try:
snapshot_download('ashishk1331/ccd-repro-results', repo_type='dataset',
local_dir='/work/_prev')
import glob, shutil, os
n = 0
for f in glob.glob('/work/_prev/outputs/*.json'):
shutil.copy(f, '/work/outputs/'); n += 1
print(f'resumed {n} finished configs')
except Exception as e:
print('no previous results:', e)
EOF
############ Claim 3 — Trip Plan (paper: baseline 15.10 / CCD 16.93 / CCD-DS 19.01 @ 3.48x)
for m in baseline ccd ccd_ds; do
run "c3_trip_${m}.json" --task trip --method $m --limit $N_TRIP
done
############ Claim 4 — HumanEval (paper: 52.66 / 57.31 / 56.71 @ 3.04x)
for m in baseline ccd ccd_ds; do
run "c4_he_${m}.json" --task humaneval --method $m --limit $N_HE
done
############ Claim 5 — buffer-size ablation on the Trip City=3 subset
# The paper's "buffer size" axis is ambiguous: the buffer holds d iterations x
# top-V tokens. We sweep BOTH axes and report which (if either) reproduces the
# reported shape (accuracy peaking at 4; steps falling monotonically).
run "c5_abl_baseline.json" --task trip --method baseline --limit $N_ABL --num-cities 3
for d in 1 2 3 4 5 6; do
run "c5_abl_d${d}.json" --task trip --method ccd_ds --limit $N_ABL --num-cities 3 --history-d $d --buffer-V 4
done
for V in 1 2 3 5 6; do
run "c5_abl_V${V}.json" --task trip --method ccd_ds --limit $N_ABL --num-cities 3 --history-d 3 --buffer-V $V
done
############ Claim 6 — temperature robustness on HumanEval (temp 0.1 reuses Claim 4)
for t in 0.0 0.4 0.7 1.0; do
run "c6_he_baseline_t${t}.json" --task humaneval --method baseline --limit $N_TEMP --temperature $t
run "c6_he_ccd_ds_t${t}.json" --task humaneval --method ccd_ds --limit $N_TEMP --temperature $t
done
echo "=================== ALL DONE ==================="
python - <<'EOF'
import json, glob
for f in sorted(glob.glob("outputs/*.json")):
r = json.load(open(f))
print(f"{f.split('/')[-1]:28s} score={r['score']:6.2f} steps={r['mean_steps']:7.2f} "
f"speedup={r['speedup_vs_uniform']:5.2f}x n={r['n_examples']}")
EOF
push