File size: 3,747 Bytes
fca4fc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# Debug script for MDPO training in VSCode
# This script sets up the environment and runs the training with debugging support

# Environment Variables
export RANK=1
export MASTER_PORT=29571

# Training Arguments 
export LOCAL_BATCH_SIZE=2
export GRADIENT_ACCUMULATION_STEPS=4

# Path Arguments
export TRANSFORMERS_OFFLINE=1
export WANDB_PROJECT=vtimellm
export MODEL_VERSION=vicuna-v1-5-7b
export OUTPUT_DIR=./outputs/
export STAGE4=./outputs/vtimellm-vicuna-v1-5-7b-activitynet-stage4
export RUN_NAME=vtimellm-$MODEL_VERSION-activitynet-stage5

# Debug environment variables
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
export CUDA_VISIBLE_DEVICES=1
export TORCH_USE_CUDA_DSA=1

# Enable debug logging
export TRANSFORMERS_VERBOSITY=info
export TOKENIZERS_PARALLELISM=false

# Create output directory if it doesn't exist
mkdir -p $OUTPUT_DIR/$RUN_NAME

echo "=== Debug Environment Setup ==="
echo "RANK: $RANK"
echo "MASTER_PORT: $MASTER_PORT"
echo "CUDA_VISIBLE_DEVICES: $CUDA_VISIBLE_DEVICES"
echo "PYTHONPATH: $PYTHONPATH"
echo "OUTPUT_DIR: $OUTPUT_DIR/$RUN_NAME"
echo "================================"

# Check if required files exist
echo "=== Checking Required Files ==="
required_files=(
    "./checkpoints/vicuna-7b-v1.5"
    "./data/activitynet/mdpo-train.json"
    "./data/activitynet/videos/train"
    "./data/activitynet/clipvitl14-vtimellm.pth"
    "./checkpoints/vtimellm-vicuna-v1-5-7b-stage1/mm_projector.bin"
    "./checkpoints/vtimellm-vicuna-v1-5-7b-stage2"
    "./checkpoints/vtimellm-vicuna-v1-5-7b-stage3"
    "./checkpoints/vtimellm-vicuna-v1-5-7b-activitynet-stage4"
    "./scripts/zero2.json"
)

for file in "${required_files[@]}"; do
    if [ -e "$file" ]; then
        echo "✓ Found: $file"
    else
        echo "✗ Missing: $file"
    fi
done
echo "================================"

# Check GPU availability
echo "=== GPU Information ==="
nvidia-smi --query-gpu=name,memory.total,memory.free --format=csv,noheader,nounits
echo "================================"

# Run the training with debugging support
echo "=== Starting Debug Training ==="
echo "Command: deepspeed --include localhost:$RANK --master_port $MASTER_PORT vtimellm/train/train_dpo_mem.py [args...]"
echo "================================"

# Execute the training command
deepspeed --include localhost:$RANK --master_port $MASTER_PORT vtimellm/train/train_dpo_mem.py \
  --deepspeed ./scripts/zero2.json \
  --lora_enable True --lora_r 8 --lora_alpha 128 \
  --training_stage 3 --finetuning True \
  --model_name_or_path ./checkpoints/vicuna-7b-v1.5 \
  --version v1 \
  --data_path ./data/activitynet/mdpo-train.json \
  --data_folder ./data/activitynet/videos/train \
  --feat_folder ./data/activitynet/clipvitl14-vtimellm.pth \
  --pretrain_mm_mlp_adapter ./checkpoints/vtimellm-vicuna-v1-5-7b-stage1/mm_projector.bin \
  --stage2_path ./checkpoints/vtimellm-vicuna-v1-5-7b-stage2 \
  --stage3_path ./checkpoints/vtimellm-vicuna-v1-5-7b-stage3 \
  --stage4_path checkpoints/vtimellm-vicuna-v1-5-7b-activitynet-stage4 \
  --output_dir $OUTPUT_DIR/$RUN_NAME \
  --bf16 True \
  --max_steps 100 \
  --per_device_train_batch_size $LOCAL_BATCH_SIZE \
  --gradient_accumulation_steps $GRADIENT_ACCUMULATION_STEPS \
  --evaluation_strategy "no" \
  --save_strategy "no" \
  --save_steps 50000 \
  --save_total_limit 10 \
  --learning_rate 1e-6 \
  --freeze_mm_mlp_adapter True \
  --weight_decay 0. --warmup_ratio 0.1 --lr_scheduler_type "cosine" \
  --logging_steps 1 \
  --tf32 True \
  --model_max_length 2048 \
  --gradient_checkpointing True \
  --dataloader_num_workers 4 \
  --lazy_preprocess True \
  --report_to "none" \
  --run_name $RUN_NAME \
  --gamma 0.0 --beta 0.5 --dpo_alpha 1.0 --train4dpo

echo "=== Training Completed ==="