File size: 2,913 Bytes
cb5f642
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# Master watcher: chains all remaining work after ckpt-5950 full eval finishes.
#
# Pipeline:
#   1. Wait for ckpt-5950 eval (PIDs 22637-22644) to finish
#   2. Merge ckpt-5950 shards
#   3. Run 20-model active-cases eval in parallel (8 GPUs Γ— 3 rounds)
#   4. Run compare_results.py to generate summary table
#   5. Run 3-checkpoint train-data eval (resume_train_eval.sh)

PYTHON=/mlx/users/jiashuo.fan/miniconda3/envs/abbie/bin/python3
EXP_BASE=/mnt/bn/bohanzhainas1/jiashuo/exp
SCRIPT_DIR=/mlx/users/jiashuo.fan/playground/inference
ACTIVE_DIR=$SCRIPT_DIR/active_cases
MERGE_SCRIPT=$SCRIPT_DIR/merge_results.py
LOG_DIR=$SCRIPT_DIR/logs

exec >> "$LOG_DIR/post_eval_watcher.log" 2>&1
echo "============================================"
echo "[watcher] Started: $(date)"

# ── helpers ──────────────────────────────────────────────────────────────────

wait_pids() {
    local pids=("$@")
    echo "[watcher] Waiting for PIDs: ${pids[*]}"
    while true; do
        local alive=0
        for pid in "${pids[@]}"; do
            kill -0 "$pid" 2>/dev/null && alive=1 && break
        done
        [ $alive -eq 0 ] && break
        sleep 30
    done
    echo "[watcher] PIDs done: $(date)"
}

# ── Step 1: wait for ckpt-5950 ───────────────────────────────────────────────

CKPT5950_PIDS=(22637 22638 22639 22640 22641 22642 22643 22644)
wait_pids "${CKPT5950_PIDS[@]}"

# ── Step 2: merge ckpt-5950 shards ──────────────────────────────────────────

echo "[watcher] Merging ckpt-5950 results..."
$PYTHON -u "$MERGE_SCRIPT" --prefix "$EXP_BASE/eval_ckpt5950_full" --num-shards 8
echo "[watcher] ckpt-5950 merge done: $(date)"

# Print quick summary
for f in "$EXP_BASE"/eval_ckpt*_merged.json; do
    [ -f "$f" ] || continue
    $PYTHON -c "
import json, sys
d = json.load(open('$f'))
print(f'  {sys.argv[1]}: acc={d[\"accuracy\"]:.4f} ({d[\"correct\"]}/{d[\"evaluated\"]})')
" "$f"
done

# ── Step 3: 20-model active-cases eval ───────────────────────────────────────

echo "[watcher] Starting 20-model active-cases eval: $(date)"
bash "$ACTIVE_DIR/run_parallel_models.sh" --skip-extract
echo "[watcher] Active-cases eval done: $(date)"

# ── Step 4: 3-checkpoint train-data eval ─────────────────────────────────────

echo "[watcher] Starting 3-checkpoint train-data eval: $(date)"
bash "$SCRIPT_DIR/resume_train_eval.sh"
echo "[watcher] 3-checkpoint eval done: $(date)"

echo "[watcher] ALL TASKS COMPLETE: $(date)"