itstheraj commited on
Commit
5f1f102
·
verified ·
1 Parent(s): d1ddb75

Update TabArena EC2 runner scripts (ec2_run.sh)

Browse files
Files changed (1) hide show
  1. benchmark/tabarena/ec2_run.sh +112 -0
benchmark/tabarena/ec2_run.sh ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # FelaTab x TabArena full benchmark driver for a plain Linux box (EC2 c7i.8xlarge, Ubuntu 24.04).
3
+ #
4
+ # Replaces the unreliable HF Jobs path (hf_job.sh). Runs setup once, then one or more
5
+ # benchmark phases (e.g. lite shakedown -> full) sharing a single results cache, so the
6
+ # full run resumes on top of the lite shakedown instead of recomputing split 0.
7
+ #
8
+ # Env (all set by launch_ec2.py user-data):
9
+ # HF_TOKEN write token for lowdown-labs (artifact upload) [required]
10
+ # PHASES comma list: any of lite,full [default: lite,full]
11
+ # RUN_NAME results cache + eval dir name [default: felatab_ec2]
12
+ # DATASETS optional csv shard of dataset names (full mode only)
13
+ # WITH_LGBM 1 = also run the LightGBM cross-check [default: 0]
14
+ # SELF_TERMINATE 1 = poweroff when done (instance shutdown behavior = terminate) [default: 1]
15
+ set -euxo pipefail
16
+
17
+ export HOME="${HOME:-/root}"
18
+ WORK=/work
19
+ PHASES="${PHASES:-lite,full}"
20
+ RUN_NAME="${RUN_NAME:-felatab_ec2}"
21
+ DATASETS="${DATASETS:-}"
22
+ WITH_LGBM="${WITH_LGBM:-0}"
23
+ SELF_TERMINATE="${SELF_TERMINATE:-1}"
24
+ RESULTS_REPO="lowdown-labs/fela-tab-tabarena-results"
25
+
26
+ export PATH="$HOME/.local/bin:$PATH"
27
+ command -v uv >/dev/null || { curl -LsSf https://astral.sh/uv/install.sh | sh; export PATH="$HOME/.local/bin:$PATH"; }
28
+
29
+ mkdir -p "$WORK/tmp" "$WORK/logs" && cd "$WORK"
30
+
31
+ upload() { # upload <phase-label>
32
+ "$WORK/bootvenv/bin/python" - <<EOF
33
+ from huggingface_hub import HfApi
34
+ api = HfApi()
35
+ api.create_repo("$RESULTS_REPO", repo_type="dataset", exist_ok=True)
36
+ for src, dst in [
37
+ ("$WORK/logs/$1.log", "logs/${RUN_NAME}_$1.log"),
38
+ ("$WORK/fela-tab/benchmark/tabarena/eval/$RUN_NAME", "eval/$RUN_NAME"),
39
+ ("$WORK/fela-tab/benchmark/tabarena/experiments/$RUN_NAME/data", "raw/$RUN_NAME"),
40
+ ]:
41
+ try:
42
+ if src.endswith(".log"):
43
+ api.upload_file(path_or_fileobj=src, path_in_repo=dst, repo_id="$RESULTS_REPO", repo_type="dataset")
44
+ else:
45
+ api.upload_folder(folder_path=src, path_in_repo=dst, repo_id="$RESULTS_REPO", repo_type="dataset")
46
+ print("uploaded", dst)
47
+ except Exception as e:
48
+ print("upload failed", dst, e)
49
+ EOF
50
+ }
51
+
52
+ finish() { # finish <exit-code>
53
+ sync || true
54
+ if [ "$SELF_TERMINATE" = "1" ]; then poweroff; fi
55
+ exit "$1"
56
+ }
57
+
58
+ # --- one-time setup ---------------------------------------------------------
59
+ uv venv --seed "$WORK/bootvenv" >/dev/null
60
+ uv pip install --python "$WORK/bootvenv/bin/python" -q huggingface_hub
61
+
62
+ # 1) FelaTab repo (model + benchmark code) from HF
63
+ "$WORK/bootvenv/bin/python" - <<'EOF'
64
+ from huggingface_hub import snapshot_download
65
+ snapshot_download(
66
+ "lowdown-labs/fela-tab",
67
+ allow_patterns=[
68
+ "benchmark/**", "modeling.py", "configuration_felatab.py",
69
+ "config*.json", "model_small_int8.safetensors", "model_big_int8.safetensors",
70
+ "model_small.safetensors", "model_big.safetensors",
71
+ ],
72
+ local_dir="/work/fela-tab",
73
+ )
74
+ print("fela-tab snapshot ready")
75
+ EOF
76
+
77
+ # 2) TabArena in its own uv venv (Python 3.12 + pre-release AutoGluon)
78
+ [ -d tabarena ] || git clone --depth 1 https://github.com/autogluon/tabarena.git
79
+ cd tabarena
80
+ uv venv --seed --python 3.12 .venv
81
+ # CPU torch first so nothing pulls the multi-GB CUDA wheels
82
+ uv pip install --python .venv/bin/python -q torch --index-url https://download.pytorch.org/whl/cpu
83
+ uv pip install --python .venv/bin/python -q --prerelease=allow -e "./packages/tabarena[benchmark]"
84
+ uv pip install --python .venv/bin/python -q safetensors tabulate "botocore[crt]"
85
+
86
+ # --- benchmark phases --------------------------------------------------------
87
+ cd "$WORK/fela-tab/benchmark/tabarena"
88
+ SUCCESS=0
89
+ IFS=',' read -ra PHASE_LST <<< "$PHASES"
90
+ for PHASE in "${PHASE_LST[@]}"; do
91
+ if [ "$PHASE" = "full" ]; then SUB_ARG="--full"; else SUB_ARG="--subset lite"; fi
92
+ DS_ARG=""
93
+ if [ -n "$DATASETS" ] && [ "$PHASE" = "full" ]; then DS_ARG="--datasets $DATASETS"; fi
94
+ set +e
95
+ TMPDIR="$WORK/tmp" AWS_CONFIG_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true WITH_LGBM="$WITH_LGBM" \
96
+ "$WORK/tabarena/.venv/bin/python" -u run_tabarena.py $SUB_ARG $DS_ARG --run-name "$RUN_NAME" \
97
+ 2>&1 | tee "$WORK/logs/$PHASE.log"
98
+ RC=${PIPESTATUS[0]}
99
+ set -e
100
+ # count cumulative successes from the runner's progress lines
101
+ SUCCESS=$(grep -oP '\d+(?= success \|)' "$WORK/logs/$PHASE.log" | tail -1 || true)
102
+ SUCCESS=${SUCCESS:-0}
103
+ echo "phase=$PHASE rc=$RC successes=$SUCCESS"
104
+ upload "$PHASE" || true
105
+ if [ "$RC" != "0" ] || [ "$SUCCESS" = "0" ]; then
106
+ echo "phase $PHASE failed (rc=$RC successes=$SUCCESS); aborting before any later phase"
107
+ finish 1
108
+ fi
109
+ done
110
+
111
+ echo "ALL_PHASES_DONE"
112
+ finish 0