| #!/bin/bash |
| |
| |
| |
| |
| 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 |
|
|
| python - <<'EOF' || exit 1 |
| import torch, sys |
| if not torch.cuda.is_available(): print("ABORT: no CUDA"); sys.exit(1) |
| try: |
| (torch.zeros(8,8,device="cuda",dtype=torch.bfloat16) @ |
| torch.zeros(8,8,device="cuda",dtype=torch.bfloat16)).cpu() |
| except Exception as e: |
| print(f"ABORT: GPU unusable with torch {torch.__version__}: {e}"); sys.exit(1) |
| print(f"GPU OK: {torch.cuda.get_device_name(0)} torch {torch.__version__}") |
| EOF |
|
|
| python - <<'EOF' |
| from huggingface_hub import HfApi, snapshot_download |
| import glob, shutil |
| HfApi().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') |
| 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 |
|
|
| push () { |
| 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 () { |
| out="outputs/$1"; shift |
| if [ -f "$out" ]; then echo "SKIP $out"; return; fi |
| echo "=========== RUN $out : $* ===========" |
| python scripts/run_eval.py "$@" --out "$out" || echo "!!!!! FAILED: $out" |
| push |
| } |
|
|
| |
| run "c4full_he_baseline.json" --task humaneval --method baseline --limit 164 --temperature 0.0 --top-p 0.9 |
| run "c4full_he_ccd.json" --task humaneval --method ccd --limit 164 --temperature 0.0 --top-p 0.9 |
|
|
| echo "=================== HE FULL DONE ===================" |
| python - <<'EOF' |
| import json |
| b = json.load(open("outputs/c4full_he_baseline.json")) |
| c = json.load(open("outputs/c4full_he_ccd.json")) |
| import math |
| bs, cs = b["per_example_score"], c["per_example_score"] |
| b01 = sum(1 for x,y in zip(bs,cs) if x==0 and y==1) |
| b10 = sum(1 for x,y in zip(bs,cs) if x==1 and y==0) |
| n = b01+b10; k = min(b01,b10) |
| p = min(1.0, 2*sum(math.comb(n,i) for i in range(k+1))/2**n) if n else 1.0 |
| print(f"baseline {b['score']:.2f} CCD {c['score']:.2f} delta {c['score']-b['score']:+.2f}") |
| print(f"McNemar: win {b01} / lose {b10} -> p = {p:.4f} (paper claims +4.65)") |
| EOF |
| push |
|
|