File size: 3,764 Bytes
fbc94ef | 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 | #!/usr/bin/env bash
set -euo pipefail
# GPU1 queue: No-LoRA / token sensitivity / LR scan
# All outputs are saved under results/ablation_study/{checkpoints,runs}
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
GPU_ID="${GPU_ID:-1}"
EPOCHS_ABL="${EPOCHS_ABL:-5}"
MAX_SAMPLES="${MAX_SAMPLES:-10000}"
ABL_ROOT="results/ablation_study"
CKPT_DIR="$ABL_ROOT/checkpoints"
RUN_DIR="$ABL_ROOT/runs"
LOG_DIR="$ABL_ROOT/logs"
mkdir -p "$CKPT_DIR" "$RUN_DIR" "$LOG_DIR"
export PYTHONPATH=.
run() {
local name="$1"
shift
echo
echo "============================================================"
echo "[$(date '+%F %T')] START: $name"
echo "CMD: $*"
echo "============================================================"
"$@"
echo "[$(date '+%F %T')] DONE: $name"
}
# 1) Remove LoRA
run "train_no_lora_256" \
env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/train_compressor.py \
--output_dir "$CKPT_DIR/no_lora_256" \
--disable_lora \
--target_tokens 256 \
--epochs "$EPOCHS_ABL" \
--max_samples "$MAX_SAMPLES" \
--mix_root data \
--mix_images_subdir ref_screenshots \
--mix_gt_subdir gt_html \
--max_html_tokens 8192
run "eval_no_lora_256" \
env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/eval_all.py \
--method uipress \
--checkpoint "$CKPT_DIR/no_lora_256/latest.pt" \
--target_tokens 256 \
--max_samples 50 \
--data_dir data \
--output_dir "$RUN_DIR/no_lora_256"
run "clip_no_lora_256" \
env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/step_clip_batch.py \
--method_dir "$RUN_DIR/no_lora_256/uipress_256" \
--ref_dir data/ref_screenshots \
--clip_device cuda
# 2) Token sensitivity: 64 / 128 / 512
for tok in 64 128 512; do
run "train_token_${tok}" \
env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/train_compressor.py \
--output_dir "$CKPT_DIR/token_${tok}" \
--target_tokens "$tok" \
--epochs "$EPOCHS_ABL" \
--max_samples "$MAX_SAMPLES" \
--mix_root data \
--mix_images_subdir ref_screenshots \
--mix_gt_subdir gt_html \
--max_html_tokens 8192
run "eval_token_${tok}" \
env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/eval_all.py \
--method uipress \
--checkpoint "$CKPT_DIR/token_${tok}/latest.pt" \
--target_tokens "$tok" \
--max_samples 50 \
--data_dir data \
--output_dir "$RUN_DIR/token_${tok}"
run "clip_token_${tok}" \
env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/step_clip_batch.py \
--method_dir "$RUN_DIR/token_${tok}/uipress_${tok}" \
--ref_dir data/ref_screenshots \
--clip_device cuda
done
# 3) Learning-rate scan (compressor LR)
for lr in 1e-4 2e-4 4e-4; do
safe_lr="${lr//./p}"
run "train_lr_${safe_lr}" \
env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/train_compressor.py \
--output_dir "$CKPT_DIR/lr_${safe_lr}" \
--target_tokens 256 \
--lr_compressor "$lr" \
--epochs "$EPOCHS_ABL" \
--max_samples "$MAX_SAMPLES" \
--mix_root data \
--mix_images_subdir ref_screenshots \
--mix_gt_subdir gt_html \
--max_html_tokens 8192
run "eval_lr_${safe_lr}" \
env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/eval_all.py \
--method uipress \
--checkpoint "$CKPT_DIR/lr_${safe_lr}/latest.pt" \
--target_tokens 256 \
--max_samples 50 \
--data_dir data \
--output_dir "$RUN_DIR/lr_${safe_lr}"
run "clip_lr_${safe_lr}" \
env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/step_clip_batch.py \
--method_dir "$RUN_DIR/lr_${safe_lr}/uipress_256" \
--ref_dir data/ref_screenshots \
--clip_device cuda
done
echo
echo "All GPU1 ablation jobs completed at $(date '+%F %T')."
|