summaryrefslogtreecommitdiff
path: root/collaborativeagents/slurm/run_rag_vector_llm_test.sh
blob: 01d9c5825e38bf0c8f46cc15662879da15515401 (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
#!/bin/bash
#SBATCH --job-name=rvec_llm
#SBATCH --account=bfqt-delta-gpu
#SBATCH --partition=gpuH200x8
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=32
#SBATCH --gres=gpu:h200:4
#SBATCH --mem=200G
#SBATCH --time=1:00:00
#SBATCH --output=rvec_llm_%j.out
#SBATCH --error=rvec_llm_%j.err

set -e
cd /projects/bfqt/users/yurenh2/ml-projects/personalization-user-model
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}/src:${PWD}/collaborativeagents:${PYTHONPATH}"
export NCCL_P2P_DISABLE=1

# Load OpenAI API key
set -a
source .env
set +a

# Install openai if not present
pip install --quiet openai python-dotenv

MODEL_70B="meta-llama/Llama-3.1-70B-Instruct"
MODEL_8B="/projects/bfqt/users/yurenh2/ml-projects/personalization-user-model/models/llama-3.1-8b-instruct"

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

# 70B user simulator on GPUs 0,1
CUDA_VISIBLE_DEVICES=0,1 python -m vllm.entrypoints.openai.api_server \
    --model $MODEL_70B --port 8004 --tensor-parallel-size 2 \
    --gpu-memory-utilization 0.95 --max-model-len 16384 \
    --download-dir $HF_HOME --dtype bfloat16 --disable-log-requests &

# 8B agent on GPUs 2,3 with 40% memory (leaving room for embedding + reranker)
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.40 --max-model-len 16384 \
    --dtype bfloat16 --disable-log-requests &

# Wait for servers
for i in $(seq 1 120); do
    R1=$(curl -s http://localhost:8004/health > /dev/null 2>&1 && echo 1 || echo 0)
    R2=$(curl -s http://localhost:8003/health > /dev/null 2>&1 && echo 1 || echo 0)
    [ "$R1" = "1" ] && [ "$R2" = "1" ] && break
    sleep 3
done

echo "vLLM servers ready."

cd collaborativeagents/scripts

# Small test: 2 profiles, 5 sessions each
python run_experiments.py \
    --methods rag_vector_llm \
    --datasets math-hard \
    --n-profiles 2 \
    --n-sessions 5 \
    --use-vllm \
    --vllm-user-url http://localhost:8004/v1 \
    --vllm-agent-url http://localhost:8003/v1 \
    --parallel-profiles 2 \
    --profile-path ../data/complex_profiles_v2/profiles_200.jsonl \
    --output-dir ../results/rag_vector_llm_test_$(date +%Y%m%d_%H%M%S)

echo "Test complete!"

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