File size: 4,912 Bytes
e22bfc2 | 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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | #!/usr/bin/env bash
set -euo pipefail
if [[ $# -lt 4 || $# -gt 5 ]]; then
echo "Usage: $0 <train-launch-tag> <eval-launch-tag> <real-level> <fake-level> [all-seeds-space-separated]" >&2
exit 2
fi
TRAIN_TAG="$1"
EVAL_TAG="$2"
REAL_LEVEL="$3"
FAKE_LEVEL="$4"
ALL_SEEDS_RAW="${5:-}"
PERSIST_ROOT="${PERSIST_ROOT:-/mnt/bn/search-aipf-haoyu/wenhaowang/ScaleDF_rebuttal}"
EVAL_LAUNCHER="${EVAL_LAUNCHER:-$PERSIST_ROOT/launch_rebuttal_eval_flex.sh}"
SEEDS_RAW="${SEEDS:-0 1 2 3 4 5 6 7 8 9}"
SEED_LABEL="${SEED_LABEL:-0_9}"
EVAL_ROOT="${EVAL_ROOT:-$PERSIST_ROOT/eval/noqcpt_fixed500k_seed${SEED_LABEL}_benchmark_eval_${EVAL_TAG}}"
HOST_NAME="$(hostname)"
export PERSIST_ROOT
export PACKAGE_ROOT="${PACKAGE_ROOT:-/tmp/ScaleDF_repro_20260724}"
export SCALEDF_DATA="${SCALEDF_DATA:-/dev/shm/scaledf_bind_storage/ScaleDF}"
export BENCHMARK_ROOT="${BENCHMARK_ROOT:-/dev/shm/scaledf_bind_storage/Established_benchmarks_eval_names}"
export SKIP_MISSING_BENCHMARKS="${SKIP_MISSING_BENCHMARKS:-1}"
export BATCH_PER_GPU="${BATCH_PER_GPU:-256}"
export NPROC_PER_NODE="${NPROC_PER_NODE:-8}"
export PYTHONUNBUFFERED="${PYTHONUNBUFFERED:-1}"
find_axis_checkpoint() {
local family="$1"
local level="$2"
local seed="$3"
local pattern
if [[ "$seed" == "0" ]]; then
pattern="noqcpt_fixed500000_${family}_n${level}_classseed0_*_${TRAIN_TAG}"
else
pattern="noqcpt_fixed500000_${family}_n${level}_classseed${seed}_resampled_*_${TRAIN_TAG}"
fi
local run_dir
run_dir="$(find "$PERSIST_ROOT/runs" -maxdepth 1 -type d -name "$pattern" | sort | tail -n 1)"
if [[ -z "$run_dir" ]]; then
echo "missing run dir for pattern=$pattern" >&2
exit 3
fi
if [[ ! -f "$run_dir/best_checkpoint.pth" ]]; then
echo "missing checkpoint: $run_dir/best_checkpoint.pth" >&2
exit 4
fi
printf "%s/best_checkpoint.pth" "$run_dir"
}
find_all_checkpoint() {
local seed="$1"
local pattern="noqcpt_fixed500000_all_46real_91fake_seed${seed}_*_${TRAIN_TAG}"
local run_dir
run_dir="$(find "$PERSIST_ROOT/runs" -maxdepth 1 -type d -name "$pattern" | sort | tail -n 1)"
if [[ -z "$run_dir" ]]; then
echo "missing all run dir for pattern=$pattern" >&2
exit 3
fi
if [[ ! -f "$run_dir/best_checkpoint.pth" ]]; then
echo "missing all checkpoint: $run_dir/best_checkpoint.pth" >&2
exit 4
fi
printf "%s/best_checkpoint.pth" "$run_dir"
}
eval_complete() {
local eval_log="$1"
[[ -f "$eval_log" ]] && [[ "$(grep -c 'Accuracy of the network on' "$eval_log" || true)" -ge 7 ]]
}
run_one_eval() {
local checkpoint="$1"
local tag="$2"
local output_root="$EVAL_ROOT/$tag"
local eval_log="$output_root/eval.log"
local lock_dir="$output_root/.eval.lock"
if eval_complete "$eval_log"; then
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] eval_skip tag=$tag reason=complete output_root=$output_root"
return
fi
mkdir -p "$output_root"
while ! mkdir "$lock_dir" 2>/dev/null; do
if eval_complete "$eval_log"; then
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] eval_skip tag=$tag reason=complete_after_wait output_root=$output_root"
return
fi
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] eval_wait tag=$tag reason=locked output_root=$output_root"
sleep 60
done
if eval_complete "$eval_log"; then
rmdir "$lock_dir" 2>/dev/null || true
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] eval_skip tag=$tag reason=complete_after_lock output_root=$output_root"
return
fi
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] eval_start tag=$tag checkpoint=$checkpoint"
if OUTPUT_ROOT="$output_root" RUN_NAME="$tag" "$EVAL_LAUNCHER" "$checkpoint" deit_base_patch16_LS benchmarks; then
rmdir "$lock_dir" 2>/dev/null || true
else
rmdir "$lock_dir" 2>/dev/null || true
return 1
fi
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] eval_done tag=$tag"
}
run_axis_eval() {
local axis_short="$1"
local family="$2"
local level="$3"
local seed="$4"
local checkpoint
checkpoint="$(find_axis_checkpoint "$family" "$level" "$seed")"
local suffix=""
[[ "$seed" != "0" ]] && suffix="_resampled"
run_one_eval "$checkpoint" "fixed500k_${axis_short}_n${level}_seed${seed}${suffix}_noqcpt"
}
run_all_eval() {
local seed="$1"
local checkpoint
checkpoint="$(find_all_checkpoint "$seed")"
run_one_eval "$checkpoint" "fixed500k_all_46real_91fake_seed${seed}_noqcpt"
}
echo "eval_queue_started_utc=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
echo "hostname=$HOST_NAME"
echo "train_tag=$TRAIN_TAG"
echo "eval_tag=$EVAL_TAG"
echo "real_level=$REAL_LEVEL"
echo "fake_level=$FAKE_LEVEL"
echo "eval_root=$EVAL_ROOT"
echo "batch_per_gpu=$BATCH_PER_GPU"
echo "seeds=$SEEDS_RAW"
echo "all_seeds=$ALL_SEEDS_RAW"
for seed in $SEEDS_RAW; do
run_axis_eval real real_domains "$REAL_LEVEL" "$seed"
run_axis_eval fake fake_methods "$FAKE_LEVEL" "$seed"
done
for seed in $ALL_SEEDS_RAW; do
run_all_eval "$seed"
done
echo "eval_queue_done_utc=$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|