| #!/usr/bin/env bash |
| |
|
|
| |
| |
| |
| N_PROMPTS=5000 |
| MAX_TOKENS=500 |
| GPU_MEM=0.85 |
| SIGMAS="0.001,0.01,0.1,1.0" |
| SUPPORT_SIZE=1000 |
| MAX_THRESHOLDS=500 |
| MAX_MODEL_LEN=8192 |
|
|
| |
| export HF_HUB_ENABLE_GIT_XET=0 |
| export GIT_XET=0 |
| export HF_HUB_ENABLE_HF_TRANSFER=1 |
| export HF_HUB_DISABLE_TELEMETRY=1 |
|
|
| |
| export PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512 |
|
|
| |
| TIMESTAMP=$(date +"%Y%m%d_%H%M%S") |
| SWEEP_DIR="multi_model_sweep_${TIMESTAMP}" |
| mkdir -p "$SWEEP_DIR" |
|
|
| echo "========================================================================" |
| echo "Running multi-model Gumbel experiments" |
| echo "Sweep directory: $SWEEP_DIR" |
| echo "Sigmas: $SIGMAS" |
| echo "N_prompts: $N_PROMPTS, Max_tokens: $MAX_TOKENS" |
| echo "========================================================================" |
|
|
| |
| |
| |
| declare -a MODELS=( |
| "Qwen/Qwen3-30B-A3B" |
| |
| |
| "meta-llama/Llama-3.2-3B-Instruct" |
| "meta-llama/Llama-3.1-8B-Instruct" |
| ) |
|
|
| |
| |
| |
| run_analysis() { |
| local model_dir="$1" |
| local model_id="$2" |
|
|
| echo "Running analysis..." |
| |
| local results_dir |
| results_dir=$(ls -td "${model_dir}/gumbel_cgs_analysis_results/"* 2>/dev/null | head -1) |
| if [[ -z "$results_dir" ]]; then |
| results_dir="${model_dir}/results" |
| fi |
|
|
| if [[ ! -d "$results_dir" ]]; then |
| echo "β No results folder found for ${model_id} (looked in ${model_dir})" |
| return 1 |
| fi |
|
|
| python adam_analyze_thresholds.py \ |
| --folder "$results_dir" \ |
| --max-thresholds "$MAX_THRESHOLDS" \ |
| --skip-logistic-regression |
|
|
| if [[ $? -ne 0 ]]; then |
| echo "β Analysis failed for ${model_id}" |
| return 1 |
| fi |
| echo "β Successfully completed analysis for ${model_id}" |
|
|
| echo "Running two-step classifier analysis..." |
| python adam_analyze_two_step_classifier.py \ |
| --folder "$results_dir" \ |
| --max-thresholds "$MAX_THRESHOLDS" \ |
| --rank-threshold 4 |
|
|
| if [[ $? -ne 0 ]]; then |
| echo "β Two-step classifier analysis failed for ${model_id}" |
| return 1 |
| fi |
| echo "β Successfully completed two-step classifier analysis for ${model_id}" |
| } |
|
|
| |
| |
| |
| for MODEL in "${MODELS[@]}"; do |
| echo "" |
| echo "========================================================================" |
| echo "Processing model: $MODEL" |
| echo "========================================================================" |
|
|
| |
| MODEL_NAME=$(echo "$MODEL" | tr '/' '_') |
| MODEL_DIR="${SWEEP_DIR}/${MODEL_NAME}" |
| mkdir -p "$MODEL_DIR" |
| LOG_FILE="${MODEL_DIR}/run.log" |
|
|
| |
| |
|
|
| |
| python run_gumbel_and_cgs_recording_adam_fast.py \ |
| --model "$MODEL" \ |
| --n-prompts "$N_PROMPTS" \ |
| --max-tokens "$MAX_TOKENS" \ |
| --gpu-memory-utilization "$GPU_MEM" \ |
| --gumbel-sigmas "$SIGMAS" \ |
| --sweep-dir "$MODEL_DIR" \ |
| --support-size "$SUPPORT_SIZE" \ |
| --max-model-len "$MAX_MODEL_LEN" \ |
| 2>&1 | tee "$LOG_FILE" |
|
|
| if [[ ${PIPESTATUS[0]} -eq 0 ]]; then |
| echo "β Successfully completed experiment for $MODEL" |
| run_analysis "$MODEL_DIR" "$MODEL" |
| else |
| echo "β Experiment failed for $MODEL (see log: $LOG_FILE)" |
| fi |
| done |
|
|
| echo "" |
| echo "========================================================================" |
| echo "All experiments complete!" |
| echo "Results saved to: $SWEEP_DIR" |
| echo "========================================================================" |
| echo "" |
| echo "To create combined plots, run:" |
| echo "python plot_multi_model_comparison.py --sweep-dir $SWEEP_DIR" |
|
|