File size: 3,432 Bytes
33569f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash
# ActivityForensics GRPO — v10 full bundle.
#
# v9_full eval (cot=false, max_new_tokens=64, 1565 test videos):
#   stage1_decomp  mIoU=43.28  F1@0.5=45.94  F1@0.7=27.07
#   v8_ckpt200     mIoU=41.66  F1@0.5=44.48  F1@0.7=25.18
#   v9_ckpt240     mIoU=45.99  F1@0.5=51.02  F1@0.7=29.75   (epoch 1 end)
#   v9_ckpt478     mIoU=49.16  F1@0.5=56.63  F1@0.7=35.29   (epoch 2 end, +5.9pt vs stage1)
#
# v9 beat stage1 by ~6pt and was still climbing (240→478: +3.17 mIoU). Curve
# did not saturate, so v10 doubles training to 4 epochs.
#
# Augmentation bump: SPI 0.2 → 0.25, FBR 0.1 → 0.15 (P[any aug] 28% → 36%).
# Motivation: with 2x training steps, forward-distribution overfit risk
# rises; a modest aug bump regularises without reversing fix (1) — 36% is
# still well below v8's 62.5% that caused the original regression.
# Expected capacity cost vs v9: <0.5pt.
#
# Other config (reward stack, taus, gradient accumulation, decomp/boundary)
# unchanged from v9. See v9 script comment block for the original three-fix
# root-cause analysis (capacity / strict_boundary bipolar reward / batch).
#
export WANDB_PROJECT=Forensics-GRPO
export WANDB_NAME="${WANDB_NAME:-AF_v10_full}"

export PYTHONPATH=".:$PYTHONPATH"
export DEBUG_MODE="true"
export LOG_PATH="./qwen2.5_7b_vl_forensics_v10_full.txt"

export PATH="/mnt/local-fast/zhangt/torch_env/bin:$PATH"
export LD_LIBRARY_PATH="/opt/conda/lib:${LD_LIBRARY_PATH}"

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

# === v10 changes vs v9 ===
# Augmentation bumped: P[any aug] 28% → 36%.
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

# Same wider thresholds with built-in curriculum (kept from v9).
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

OUTDIR="${OUTDIR:-outputs_forensics/v10_full}"
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 \
    --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 4 \
    --run_name "$WANDB_NAME" \
    --report_to none \
    --save_steps 30 \
    --learning_rate 1e-6 \
    --save_only_model true