-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasync_detection.sh
More file actions
executable file
·110 lines (92 loc) · 3.09 KB
/
async_detection.sh
File metadata and controls
executable file
·110 lines (92 loc) · 3.09 KB
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
#!/usr/bin/env bash
set -euo pipefail
MODEL_NAMES=(
"LRM-Conta-Detection-Arena/sft-conta-qwen2.5-7b-no-rl"
"LRM-Conta-Detection-Arena/sft-conta-qwen2.5-7b-grpo-step64"
"LRM-Conta-Detection-Arena/sft-conta-llama3-8b-no-rl"
"LRM-Conta-Detection-Arena/sft-conta-llama3-8b-gpro-step64"
"LRM-Conta-Detection-Arena/sft-conta-deepseek-distill-llama3-8b"
"LRM-Conta-Detection-Arena/sft-conta-deepseek-distill-qwen2.5-7b"
)
DATASETS=(
"minerva_math"
"aime25"
"amc23"
"aime24"
"olympiadbench"
"gpqa_diamond"
)
MIAS=(
"loss"
# "perturb"
# "min-k++"
# "ref"
)
GPU_LIST=(8) # visible GPUs indices
GPUS_PER_JOB=1 # adjust the GPUS_PER_JOB based on your hardware resources
NUM_RESPONSES=8
############################ sanity checks ###################################
if (( ${#GPU_LIST[@]} % GPUS_PER_JOB != 0 )); then
echo "❌ ${#GPU_LIST[@]} GPUs cannot be split into chunks of $GPUS_PER_JOB" >&2
exit 1
fi
# ---------------------------------------------------------------------------#
# Build an array whose elements are the comma‑separated GPU slices
# e.g. SLICES=( "0,1" "2,3" "4,5" "6,7" )
# ---------------------------------------------------------------------------#
declare -a SLICES=()
for ((i=0;i<${#GPU_LIST[@]}; i+=GPUS_PER_JOB)); do
slice=("${GPU_LIST[@]:i:GPUS_PER_JOB}")
SLICES+=( "$(IFS=','; echo "${slice[*]}")" )
done
NUM_SLICES=${#SLICES[@]} # also the --global_size
POOL=$(mktemp -u)
mkfifo "$POOL"
exec 3<>"$POOL"
rm "$POOL"
for s in "${SLICES[@]}"; do printf '%s\n' "$s" >&3; done
collect_one () {
local slice=$1 model=$2 data=$3 mia=$4 shard=$5
CUDA_VISIBLE_DEVICES="$slice" \
python collect_result.py \
--model_name "$model" \
--dataset_name "$data" \
--mia "$mia" \
--global_size "$NUM_SLICES" \
--sharding "$shard" \
--num_responses "$NUM_RESPONSES"
printf '%s\n' "$slice" >&3 # return slice to pool
}
delete_npz() {
local model=$1 data=$2 mia=$3
CUDA_VISIBLE_DEVICES="$slice" \
python remove_mia_results.py --model_name "$model" \
--dataset_name "$data" \
--mia "$mia" \
--num_responses "$NUM_RESPONSES"
printf '%s\n' "$slice" >&3 # return slice to pool
}
for model in "${MODEL_NAMES[@]}"; do
for data in "${DATASETS[@]}"; do
for mia in "${MIAS[@]}"; do
IFS= read -r slice <&3 || true
delete_npz "$model" "$data" "$mia" &
done
done
done
wait
echo "ℹ️ Remove existing MIA results"
echo "ℹ️ Launching collection jobs asynchronously…"
# queue every (model,data,mia) triple
for model in "${MODEL_NAMES[@]}"; do
for data in "${DATASETS[@]}"; do
for mia in "${MIAS[@]}"; do
for ((shard=1; shard<=NUM_SLICES; shard++)); do
IFS= read -r slice <&3 || true
collect_one "$slice" "$model" "$data" "$mia" "$shard" &
done
done
done
done
wait
echo "✔ All collection shards finished."