#!/bin/bash # v10 + R2 (strict_edge): sub-second boundary precision reward. # # Replaces the failed probe-based binary_probing reward from v10_r1 (whose # reward stayed flat at ~0.08 throughout training — frozen base Qwen had no # usable forgery signal). Net effect of v10_r1 on ckpt956: mIoU −0.82, # F1@0.5 −0.53, F1@0.7 +0.08 vs v10_full → noise, not signal. # # v10's eval gap: F1@0.7=48 → F1@0.85=26 → F1@0.95=10. strict_boundary @ # τ∈{0.3,0.5,0.7} saturates at IoU>0.7 and gives no gradient into that gap. # strict_edge adds a per-Hungarian-match boundary-distance term with σ=0.5s # (product form), which only starts paying out near sub-second edge alignment # — exactly where strict_boundary is silent. export WANDB_PROJECT=Forensics-GRPO export WANDB_NAME="${WANDB_NAME:-AF_v10_r2_6ep}" export PYTHONPATH=".:$PYTHONPATH" export DEBUG_MODE="true" export LOG_PATH="./qwen2.5_7b_vl_forensics_v10_r2_6ep.txt" export PATH="/mnt/local-fast/zhangt/torch_env/bin:$PATH" export LD_LIBRARY_PATH="/opt/conda/lib:${LD_LIBRARY_PATH}" # === v10 baseline (do not edit) ============================================ export FORENSICS_COT=false export FORENSICS_FORGERY_AWARE=false export FORENSICS_HUNGARIAN_DECOMP=true export FORENSICS_HUNGARIAN_MAXK=8 export FORENSICS_BOUNDARY_WEIGHT=0.3 export FORENSICS_BOUNDARY_TAU=2.0 export FORENSICS_SPI_AUG=true export FORENSICS_SPI_PROB=0.25 export FORENSICS_SPI_CHUNK_S=2.5 export FORENSICS_SPI_SAFETY_S=0.5 export FORENSICS_FBR_AUG=true export FORENSICS_FBR_PROB=0.15 export FORENSICS_STRICT_TAUS="0.3,0.5,0.7" unset FORENSICS_COT_CONSIS_WEIGHT unset FORENSICS_COT_CF_WEIGHT unset FORENSICS_COT_ALIGN_WEIGHT unset FORENSICS_K_REQUIRE_TIMESTEP unset FORENSICS_IOU_REQUIRE_THINK # ============================================================================ # === R2: strict_edge ======================================================== # σ controls tolerance. 0.5s → bonus decays e-fold per 0.5s of edge error. # Reward is product over the two boundaries: both must hit to score. export FORENSICS_STRICT_EDGE_SIGMA=0.5 # ============================================================================ # 6-epoch run (was 4ep). New OUTDIR so the 4-epoch baseline at # outputs_forensics/v10_r2 (ckpt956 = the comparison point) is preserved. OUTDIR="${OUTDIR:-outputs_forensics/v10_r2_6ep}" MODEL_PATH="${MODEL_PATH:-/mnt/local-fast/zhangt/Qwen2.5-VL-7B-Instruct}" PREPROCESSED="${PREPROCESSED:-/mnt/local-fast/zhangt/forensics_grpo_cache_uniform3584_fps2.0}" cd "$(dirname "$0")/.." torchrun --nproc_per_node="8" \ --nnodes="1" \ --node_rank="0" \ --master_addr="127.0.0.1" \ --master_port="12370" \ src/open_r1/grpo_forensics.py \ --deepspeed scripts/zero3_offload.json \ --output_dir "$OUTDIR" \ --model_name_or_path "$MODEL_PATH" \ --annot_dir /mnt/local-fast/zhangt/annot/annot \ --video_root /mnt/local-fast/zhangt/video \ --preprocessed_data_path "$PREPROCESSED" \ --reward_funcs iou strict_boundary strict_edge \ --dataset_name activityforensics \ --max_prompt_length 8192 \ --max_completion_length 512 \ --num_generations 4 \ --per_device_train_batch_size 1 \ --gradient_accumulation_steps 2 \ --logging_steps 1 \ --bf16 \ --torch_dtype bfloat16 \ --data_seed 42 \ --gradient_checkpointing true \ --attn_implementation flash_attention_2 \ --num_train_epochs 6 \ --run_name "$WANDB_NAME" \ --report_to none \ --save_steps 30 \ --learning_rate 1e-6 \ --save_only_model true