summaryrefslogtreecommitdiff
path: root/collaborativeagents/scripts/test_all_h200.sbatch
blob: cc37a394230f908ea8cc8b25e006dd3798f9d5ca (plain)
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
125
126
#!/bin/bash
#SBATCH --job-name=test_all_h200
#SBATCH --account=bfqt-delta-gpu
#SBATCH --partition=gpuH200x8-interactive
#SBATCH --gres=gpu:4
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=32
#SBATCH --mem=256G
#SBATCH --time=01:00:00
#SBATCH --output=/projects/bfqt/users/yurenh2/ml-projects/personalization-user-model/test_all_h200-%j.out
#SBATCH --error=/projects/bfqt/users/yurenh2/ml-projects/personalization-user-model/test_all_h200-%j.err

set -e
cd /projects/bfqt/users/yurenh2/ml-projects/personalization-user-model/collaborativeagents
source /u/yurenh2/miniforge3/etc/profile.d/conda.sh
conda activate eval

export HF_HOME=/projects/bfqt/users/yurenh2/hf_cache/huggingface
export PYTHONPATH="${PWD}:${PWD}/scripts:${PWD}/../src:${PYTHONPATH}"

MODEL_8B="/projects/bfqt/users/yurenh2/ml-projects/personalization-user-model/models/llama-3.1-8b-instruct"
PROFILE_PATH="/projects/bfqt/users/yurenh2/ml-projects/personalization-user-model/collaborativeagents/data/complex_profiles_v2/profiles_200.jsonl"

echo "=== Parallel Speed Test: ALL 6 METHODS (H200) ==="
echo "Scale: 10 profiles × 3 sessions = 30 sessions per method"
echo "vLLM memory: 45% (leaves room for embedding+reranker)"
date
nvidia-smi --query-gpu=index,name,memory.total --format=csv

pkill -f "vllm.entrypoints" 2>/dev/null || true
sleep 2

# Start TWO vLLM servers with REDUCED memory (45%) to leave room for embedding+reranker
echo ""
echo "Starting vLLM servers (45% GPU memory)..."
CUDA_VISIBLE_DEVICES=0,1 python -m vllm.entrypoints.openai.api_server \
    --model $MODEL_8B --port 8004 --tensor-parallel-size 2 \
    --gpu-memory-utilization 0.45 --max-model-len 8192 \
    --disable-log-requests --dtype bfloat16 &

CUDA_VISIBLE_DEVICES=2,3 python -m vllm.entrypoints.openai.api_server \
    --model $MODEL_8B --port 8003 --tensor-parallel-size 2 \
    --gpu-memory-utilization 0.45 --max-model-len 8192 \
    --disable-log-requests --dtype bfloat16 &

for i in $(seq 1 120); do
    u=$(curl -s http://localhost:8004/health > /dev/null 2>&1 && echo 1 || echo 0)
    a=$(curl -s http://localhost:8003/health > /dev/null 2>&1 && echo 1 || echo 0)
    [ "$u" = "1" ] && [ "$a" = "1" ] && echo "Both servers ready after $((i*2))s" && break
    sleep 2
done

sleep 30
echo "Starting experiments..."

# All methods can now run in parallel thanks to shared model singletons
# Shared models: embedding (8B) and reranker (8B) are loaded ONCE and shared across all parallel workers
COMMON_ARGS="--datasets math-hard --n-profiles 10 --n-sessions 3 --max-turns 10 --use-vllm --parallel-profiles 10 --no-batch-processing --output-dir ../results/test_h200 --profile-path $PROFILE_PATH"

# Test 1: vanilla (batch processing)
echo ""
echo "=== TEST 1: vanilla (batch processing) ==="
START=$(date +%s)
python scripts/run_experiments.py \
    --methods vanilla \
    --datasets math-hard \
    --n-profiles 10 --n-sessions 3 --max-turns 10 \
    --use-vllm --parallel-profiles 10 \
    --use-batch-processing --batch-size 30 \
    --output-dir ../results/test_h200 \
    --profile-path "$PROFILE_PATH"
END=$(date +%s)
ELAPSED=$((END - START))
echo ">>> vanilla: 30 sessions in ${ELAPSED}s = $((30 * 3600 / ELAPSED)) sessions/hr"

# Test 2: contextual
echo ""
echo "=== TEST 2: contextual ==="
START=$(date +%s)
python scripts/run_experiments.py --methods contextual $COMMON_ARGS
END=$(date +%s)
ELAPSED=$((END - START))
echo ">>> contextual: 30 sessions in ${ELAPSED}s = $((30 * 3600 / ELAPSED)) sessions/hr"

# Test 3: reflection
echo ""
echo "=== TEST 3: reflection ==="
START=$(date +%s)
python scripts/run_experiments.py --methods reflection $COMMON_ARGS
END=$(date +%s)
ELAPSED=$((END - START))
echo ">>> reflection: 30 sessions in ${ELAPSED}s = $((30 * 3600 / ELAPSED)) sessions/hr"

# Test 4: all_memory (parallel with shared models)
echo ""
echo "=== TEST 4: all_memory (parallel with shared models) ==="
START=$(date +%s)
python scripts/run_experiments.py --methods all_memory $COMMON_ARGS
END=$(date +%s)
ELAPSED=$((END - START))
echo ">>> all_memory: 30 sessions in ${ELAPSED}s = $((30 * 3600 / ELAPSED)) sessions/hr"

# Test 5: rag (parallel with shared models)
echo ""
echo "=== TEST 5: rag (parallel with shared models) ==="
START=$(date +%s)
python scripts/run_experiments.py --methods rag $COMMON_ARGS
END=$(date +%s)
ELAPSED=$((END - START))
echo ">>> rag: 30 sessions in ${ELAPSED}s = $((30 * 3600 / ELAPSED)) sessions/hr"

# Test 6: rag_vector (parallel with shared models)
echo ""
echo "=== TEST 6: rag_vector (parallel with shared models) ==="
START=$(date +%s)
python scripts/run_experiments.py --methods rag_vector $COMMON_ARGS
END=$(date +%s)
ELAPSED=$((END - START))
echo ">>> rag_vector: 30 sessions in ${ELAPSED}s = $((30 * 3600 / ELAPSED)) sessions/hr"

pkill -f "vllm.entrypoints" 2>/dev/null || true

echo ""
echo "=== ALL SPEED TESTS COMPLETE ==="
date