vec-inf 0.4.0.post1__py3-none-any.whl → 0.5.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- vec_inf/__init__.py +1 -0
- vec_inf/cli/__init__.py +1 -0
- vec_inf/cli/_cli.py +88 -243
- vec_inf/cli/_config.py +87 -0
- vec_inf/cli/_helper.py +675 -0
- vec_inf/cli/_utils.py +88 -89
- vec_inf/{models → config}/README.md +54 -0
- vec_inf/config/models.yaml +1274 -0
- vec_inf/multinode_vllm.slurm +61 -29
- vec_inf/vllm.slurm +55 -22
- vec_inf-0.5.0.dist-info/METADATA +210 -0
- vec_inf-0.5.0.dist-info/RECORD +17 -0
- {vec_inf-0.4.0.post1.dist-info → vec_inf-0.5.0.dist-info}/WHEEL +1 -1
- vec_inf-0.5.0.dist-info/entry_points.txt +2 -0
- vec_inf/launch_server.sh +0 -126
- vec_inf/models/models.csv +0 -73
- vec_inf-0.4.0.post1.dist-info/METADATA +0 -120
- vec_inf-0.4.0.post1.dist-info/RECORD +0 -16
- vec_inf-0.4.0.post1.dist-info/entry_points.txt +0 -3
- {vec_inf-0.4.0.post1.dist-info → vec_inf-0.5.0.dist-info/licenses}/LICENSE +0 -0
vec_inf/multinode_vllm.slurm
CHANGED
|
@@ -4,15 +4,10 @@
|
|
|
4
4
|
#SBATCH --exclusive
|
|
5
5
|
#SBATCH --tasks-per-node=1
|
|
6
6
|
|
|
7
|
-
# Load CUDA, change to the cuda version on your environment if different
|
|
8
|
-
source /opt/lmod/lmod/init/profile
|
|
9
|
-
module load cuda-12.3
|
|
10
|
-
nvidia-smi
|
|
11
|
-
|
|
12
7
|
source ${SRC_DIR}/find_port.sh
|
|
13
8
|
|
|
14
9
|
if [ "$VENV_BASE" = "singularity" ]; then
|
|
15
|
-
export SINGULARITY_IMAGE=/
|
|
10
|
+
export SINGULARITY_IMAGE=/model-weights/vec-inf-shared/vector-inference_latest.sif
|
|
16
11
|
export VLLM_NCCL_SO_PATH=/vec-inf/nccl/libnccl.so.2.18.1
|
|
17
12
|
module load singularity-ce/3.8.2
|
|
18
13
|
singularity exec $SINGULARITY_IMAGE ray stop
|
|
@@ -36,13 +31,13 @@ echo "IP Head: $ip_head"
|
|
|
36
31
|
echo "Starting HEAD at $head_node"
|
|
37
32
|
if [ "$VENV_BASE" = "singularity" ]; then
|
|
38
33
|
srun --nodes=1 --ntasks=1 -w "$head_node" \
|
|
39
|
-
singularity exec --nv --bind ${
|
|
34
|
+
singularity exec --nv --bind ${MODEL_WEIGHTS}:${MODEL_WEIGHTS} $SINGULARITY_IMAGE \
|
|
40
35
|
ray start --head --node-ip-address="$head_node_ip" --port=$head_node_port \
|
|
41
|
-
--num-cpus "${SLURM_CPUS_PER_TASK}" --num-gpus "${
|
|
36
|
+
--num-cpus "${SLURM_CPUS_PER_TASK}" --num-gpus "${SLURM_GPUS_PER_NODE}" --block &
|
|
42
37
|
else
|
|
43
38
|
srun --nodes=1 --ntasks=1 -w "$head_node" \
|
|
44
39
|
ray start --head --node-ip-address="$head_node_ip" --port=$head_node_port \
|
|
45
|
-
--num-cpus "${SLURM_CPUS_PER_TASK}" --num-gpus "${
|
|
40
|
+
--num-cpus "${SLURM_CPUS_PER_TASK}" --num-gpus "${SLURM_GPUS_PER_NODE}" --block &
|
|
46
41
|
fi
|
|
47
42
|
|
|
48
43
|
# Starting the Ray worker nodes
|
|
@@ -57,13 +52,13 @@ for ((i = 1; i <= worker_num; i++)); do
|
|
|
57
52
|
echo "Starting WORKER $i at $node_i"
|
|
58
53
|
if [ "$VENV_BASE" = "singularity" ]; then
|
|
59
54
|
srun --nodes=1 --ntasks=1 -w "$node_i" \
|
|
60
|
-
singularity exec --nv --bind ${
|
|
55
|
+
singularity exec --nv --bind ${MODEL_WEIGHTS}:${MODEL_WEIGHTS} $SINGULARITY_IMAGE \
|
|
61
56
|
ray start --address "$ip_head" \
|
|
62
|
-
--num-cpus "${SLURM_CPUS_PER_TASK}" --num-gpus "${
|
|
57
|
+
--num-cpus "${SLURM_CPUS_PER_TASK}" --num-gpus "${SLURM_GPUS_PER_NODE}" --block &
|
|
63
58
|
else
|
|
64
59
|
srun --nodes=1 --ntasks=1 -w "$node_i" \
|
|
65
60
|
ray start --address "$ip_head" \
|
|
66
|
-
--num-cpus "${SLURM_CPUS_PER_TASK}" --num-gpus "${
|
|
61
|
+
--num-cpus "${SLURM_CPUS_PER_TASK}" --num-gpus "${SLURM_GPUS_PER_NODE}" --block &
|
|
67
62
|
fi
|
|
68
63
|
|
|
69
64
|
sleep 5
|
|
@@ -72,14 +67,21 @@ done
|
|
|
72
67
|
|
|
73
68
|
vllm_port_number=$(find_available_port $head_node_ip 8080 65535)
|
|
74
69
|
|
|
75
|
-
|
|
70
|
+
SERVER_ADDR="http://${head_node_ip}:${vllm_port_number}/v1"
|
|
71
|
+
echo "Server address: $SERVER_ADDR"
|
|
72
|
+
|
|
73
|
+
jq --arg server_addr "$SERVER_ADDR" \
|
|
74
|
+
'. + {"server_address": $server_addr}' \
|
|
75
|
+
"$LOG_DIR/$MODEL_NAME.$SLURM_JOB_ID/$MODEL_NAME.$SLURM_JOB_ID.json" > temp.json \
|
|
76
|
+
&& mv temp.json "$LOG_DIR/$MODEL_NAME.$SLURM_JOB_ID/$MODEL_NAME.$SLURM_JOB_ID.json" \
|
|
77
|
+
&& rm temp.json
|
|
76
78
|
|
|
77
79
|
if [ "$PIPELINE_PARALLELISM" = "True" ]; then
|
|
78
|
-
export PIPELINE_PARALLEL_SIZE=$
|
|
79
|
-
export TENSOR_PARALLEL_SIZE=$
|
|
80
|
+
export PIPELINE_PARALLEL_SIZE=$SLURM_JOB_NUM_NODES
|
|
81
|
+
export TENSOR_PARALLEL_SIZE=$SLURM_GPUS_PER_NODE
|
|
80
82
|
else
|
|
81
83
|
export PIPELINE_PARALLEL_SIZE=1
|
|
82
|
-
export TENSOR_PARALLEL_SIZE=$((
|
|
84
|
+
export TENSOR_PARALLEL_SIZE=$((SLURM_JOB_NUM_NODES*SLURM_GPUS_PER_NODE))
|
|
83
85
|
fi
|
|
84
86
|
|
|
85
87
|
if [ "$ENFORCE_EAGER" = "True" ]; then
|
|
@@ -88,35 +90,65 @@ else
|
|
|
88
90
|
export ENFORCE_EAGER=""
|
|
89
91
|
fi
|
|
90
92
|
|
|
93
|
+
if [ "$ENABLE_PREFIX_CACHING" = "True" ]; then
|
|
94
|
+
export ENABLE_PREFIX_CACHING="--enable-prefix-caching"
|
|
95
|
+
else
|
|
96
|
+
export ENABLE_PREFIX_CACHING=""
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
if [ "$ENABLE_CHUNKED_PREFILL" = "True" ]; then
|
|
100
|
+
export ENABLE_CHUNKED_PREFILL="--enable-chunked-prefill"
|
|
101
|
+
else
|
|
102
|
+
export ENABLE_CHUNKED_PREFILL=""
|
|
103
|
+
fi
|
|
104
|
+
|
|
105
|
+
if [ -z "$MAX_NUM_BATCHED_TOKENS" ]; then
|
|
106
|
+
export MAX_NUM_BATCHED_TOKENS=""
|
|
107
|
+
else
|
|
108
|
+
export MAX_NUM_BATCHED_TOKENS="--max-num-batched-tokens=$MAX_NUM_BATCHED_TOKENS"
|
|
109
|
+
fi
|
|
110
|
+
|
|
91
111
|
# Activate vllm venv
|
|
92
112
|
if [ "$VENV_BASE" = "singularity" ]; then
|
|
93
|
-
singularity exec --nv --bind ${
|
|
113
|
+
singularity exec --nv --bind ${MODEL_WEIGHTS}:${MODEL_WEIGHTS} $SINGULARITY_IMAGE \
|
|
94
114
|
python3.10 -m vllm.entrypoints.openai.api_server \
|
|
95
|
-
--model ${
|
|
96
|
-
--served-model-name ${
|
|
115
|
+
--model ${MODEL_WEIGHTS} \
|
|
116
|
+
--served-model-name ${MODEL_NAME} \
|
|
97
117
|
--host "0.0.0.0" \
|
|
98
118
|
--port ${vllm_port_number} \
|
|
99
119
|
--pipeline-parallel-size ${PIPELINE_PARALLEL_SIZE} \
|
|
100
120
|
--tensor-parallel-size ${TENSOR_PARALLEL_SIZE} \
|
|
101
|
-
--dtype ${
|
|
121
|
+
--dtype ${DATA_TYPE} \
|
|
102
122
|
--trust-remote-code \
|
|
103
|
-
--max-logprobs ${
|
|
104
|
-
--max-model-len ${
|
|
105
|
-
--max-num-seqs ${
|
|
123
|
+
--max-logprobs ${MAX_LOGPROBS} \
|
|
124
|
+
--max-model-len ${MAX_MODEL_LEN} \
|
|
125
|
+
--max-num-seqs ${MAX_NUM_SEQS} \
|
|
126
|
+
--gpu-memory-utilization ${GPU_MEMORY_UTILIZATION} \
|
|
127
|
+
--compilation-config ${COMPILATION_CONFIG} \
|
|
128
|
+
--task ${TASK} \
|
|
129
|
+
${MAX_NUM_BATCHED_TOKENS} \
|
|
130
|
+
${ENABLE_PREFIX_CACHING} \
|
|
131
|
+
${ENABLE_CHUNKED_PREFILL} \
|
|
106
132
|
${ENFORCE_EAGER}
|
|
107
133
|
else
|
|
108
134
|
source ${VENV_BASE}/bin/activate
|
|
109
135
|
python3 -m vllm.entrypoints.openai.api_server \
|
|
110
|
-
--model ${
|
|
111
|
-
--served-model-name ${
|
|
136
|
+
--model ${MODEL_WEIGHTS} \
|
|
137
|
+
--served-model-name ${MODEL_NAME} \
|
|
112
138
|
--host "0.0.0.0" \
|
|
113
139
|
--port ${vllm_port_number} \
|
|
114
140
|
--pipeline-parallel-size ${PIPELINE_PARALLEL_SIZE} \
|
|
115
141
|
--tensor-parallel-size ${TENSOR_PARALLEL_SIZE} \
|
|
116
|
-
--dtype ${
|
|
142
|
+
--dtype ${DATA_TYPE} \
|
|
117
143
|
--trust-remote-code \
|
|
118
|
-
--max-logprobs ${
|
|
119
|
-
--max-model-len ${
|
|
120
|
-
--max-num-seqs ${
|
|
144
|
+
--max-logprobs ${MAX_LOGPROBS} \
|
|
145
|
+
--max-model-len ${MAX_MODEL_LEN} \
|
|
146
|
+
--max-num-seqs ${MAX_NUM_SEQS} \
|
|
147
|
+
--gpu-memory-utilization ${GPU_MEMORY_UTILIZATION} \
|
|
148
|
+
--compilation-config ${COMPILATION_CONFIG} \
|
|
149
|
+
--task ${TASK} \
|
|
150
|
+
${MAX_NUM_BATCHED_TOKENS} \
|
|
151
|
+
${ENABLE_PREFIX_CACHING} \
|
|
152
|
+
${ENABLE_CHUNKED_PREFILL} \
|
|
121
153
|
${ENFORCE_EAGER}
|
|
122
154
|
fi
|
vec_inf/vllm.slurm
CHANGED
|
@@ -2,18 +2,20 @@
|
|
|
2
2
|
#SBATCH --cpus-per-task=16
|
|
3
3
|
#SBATCH --mem=64G
|
|
4
4
|
|
|
5
|
-
# Load CUDA, change to the cuda version on your environment if different
|
|
6
|
-
source /opt/lmod/lmod/init/profile
|
|
7
|
-
module load cuda-12.3
|
|
8
|
-
nvidia-smi
|
|
9
|
-
|
|
10
5
|
source ${SRC_DIR}/find_port.sh
|
|
11
6
|
|
|
12
7
|
# Write server url to file
|
|
13
8
|
hostname=${SLURMD_NODENAME}
|
|
14
9
|
vllm_port_number=$(find_available_port $hostname 8080 65535)
|
|
15
10
|
|
|
16
|
-
|
|
11
|
+
SERVER_ADDR="http://${hostname}:${vllm_port_number}/v1"
|
|
12
|
+
echo "Server address: $SERVER_ADDR"
|
|
13
|
+
|
|
14
|
+
jq --arg server_addr "$SERVER_ADDR" \
|
|
15
|
+
'. + {"server_address": $server_addr}' \
|
|
16
|
+
"$LOG_DIR/$MODEL_NAME.$SLURM_JOB_ID/$MODEL_NAME.$SLURM_JOB_ID.json" > temp.json \
|
|
17
|
+
&& mv temp.json "$LOG_DIR/$MODEL_NAME.$SLURM_JOB_ID/$MODEL_NAME.$SLURM_JOB_ID.json" \
|
|
18
|
+
&& rm temp.json
|
|
17
19
|
|
|
18
20
|
if [ "$ENFORCE_EAGER" = "True" ]; then
|
|
19
21
|
export ENFORCE_EAGER="--enforce-eager"
|
|
@@ -21,37 +23,68 @@ else
|
|
|
21
23
|
export ENFORCE_EAGER=""
|
|
22
24
|
fi
|
|
23
25
|
|
|
26
|
+
if [ "$ENABLE_PREFIX_CACHING" = "True" ]; then
|
|
27
|
+
export ENABLE_PREFIX_CACHING="--enable-prefix-caching"
|
|
28
|
+
else
|
|
29
|
+
export ENABLE_PREFIX_CACHING=""
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
if [ "$ENABLE_CHUNKED_PREFILL" = "True" ]; then
|
|
33
|
+
export ENABLE_CHUNKED_PREFILL="--enable-chunked-prefill"
|
|
34
|
+
else
|
|
35
|
+
export ENABLE_CHUNKED_PREFILL=""
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
if [ -z "$MAX_NUM_BATCHED_TOKENS" ]; then
|
|
39
|
+
export MAX_NUM_BATCHED_TOKENS=""
|
|
40
|
+
else
|
|
41
|
+
export MAX_NUM_BATCHED_TOKENS="--max-num-batched-tokens=$MAX_NUM_BATCHED_TOKENS"
|
|
42
|
+
fi
|
|
43
|
+
|
|
24
44
|
# Activate vllm venv
|
|
25
45
|
if [ "$VENV_BASE" = "singularity" ]; then
|
|
26
|
-
export SINGULARITY_IMAGE=/
|
|
46
|
+
export SINGULARITY_IMAGE=/model-weights/vec-inf-shared/vector-inference_latest.sif
|
|
27
47
|
export VLLM_NCCL_SO_PATH=/vec-inf/nccl/libnccl.so.2.18.1
|
|
28
48
|
module load singularity-ce/3.8.2
|
|
29
49
|
singularity exec $SINGULARITY_IMAGE ray stop
|
|
30
|
-
singularity exec --nv --bind ${
|
|
50
|
+
singularity exec --nv --bind ${MODEL_WEIGHTS}:${MODEL_WEIGHTS} $SINGULARITY_IMAGE \
|
|
31
51
|
python3.10 -m vllm.entrypoints.openai.api_server \
|
|
32
|
-
--model ${
|
|
33
|
-
--served-model-name ${
|
|
52
|
+
--model ${MODEL_WEIGHTS} \
|
|
53
|
+
--served-model-name ${MODEL_NAME} \
|
|
34
54
|
--host "0.0.0.0" \
|
|
35
55
|
--port ${vllm_port_number} \
|
|
36
|
-
--tensor-parallel-size ${
|
|
37
|
-
--dtype ${
|
|
38
|
-
--max-logprobs ${
|
|
56
|
+
--tensor-parallel-size ${SLURM_GPUS_PER_NODE} \
|
|
57
|
+
--dtype ${DATA_TYPE} \
|
|
58
|
+
--max-logprobs ${MAX_LOGPROBS} \
|
|
39
59
|
--trust-remote-code \
|
|
40
|
-
--max-model-len ${
|
|
41
|
-
--max-num-seqs ${
|
|
60
|
+
--max-model-len ${MAX_MODEL_LEN} \
|
|
61
|
+
--max-num-seqs ${MAX_NUM_SEQS} \
|
|
62
|
+
--gpu-memory-utilization ${GPU_MEMORY_UTILIZATION} \
|
|
63
|
+
--compilation-config ${COMPILATION_CONFIG} \
|
|
64
|
+
--task ${TASK} \
|
|
65
|
+
${MAX_NUM_BATCHED_TOKENS} \
|
|
66
|
+
${ENABLE_PREFIX_CACHING} \
|
|
67
|
+
${ENABLE_CHUNKED_PREFILL} \
|
|
42
68
|
${ENFORCE_EAGER}
|
|
69
|
+
|
|
43
70
|
else
|
|
44
71
|
source ${VENV_BASE}/bin/activate
|
|
45
72
|
python3 -m vllm.entrypoints.openai.api_server \
|
|
46
|
-
--model ${
|
|
47
|
-
--served-model-name ${
|
|
73
|
+
--model ${MODEL_WEIGHTS} \
|
|
74
|
+
--served-model-name ${MODEL_NAME} \
|
|
48
75
|
--host "0.0.0.0" \
|
|
49
76
|
--port ${vllm_port_number} \
|
|
50
|
-
--tensor-parallel-size ${
|
|
51
|
-
--dtype ${
|
|
52
|
-
--max-logprobs ${
|
|
77
|
+
--tensor-parallel-size ${SLURM_GPUS_PER_NODE} \
|
|
78
|
+
--dtype ${DATA_TYPE} \
|
|
79
|
+
--max-logprobs ${MAX_LOGPROBS} \
|
|
53
80
|
--trust-remote-code \
|
|
54
|
-
--max-model-len ${
|
|
55
|
-
--max-num-seqs ${
|
|
81
|
+
--max-model-len ${MAX_MODEL_LEN} \
|
|
82
|
+
--max-num-seqs ${MAX_NUM_SEQS} \
|
|
83
|
+
--gpu-memory-utilization ${GPU_MEMORY_UTILIZATION} \
|
|
84
|
+
--compilation-config ${COMPILATION_CONFIG} \
|
|
85
|
+
--task ${TASK} \
|
|
86
|
+
${MAX_NUM_BATCHED_TOKENS} \
|
|
87
|
+
${ENABLE_PREFIX_CACHING} \
|
|
88
|
+
${ENABLE_CHUNKED_PREFILL} \
|
|
56
89
|
${ENFORCE_EAGER}
|
|
57
90
|
fi
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vec-inf
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Efficient LLM inference on Slurm clusters using vLLM.
|
|
5
|
+
Author-email: Marshall Wang <marshall.wang@vectorinstitute.ai>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: click>=8.1.0
|
|
10
|
+
Requires-Dist: pydantic>=2.10.6
|
|
11
|
+
Requires-Dist: pyyaml>=6.0.2
|
|
12
|
+
Requires-Dist: requests>=2.31.0
|
|
13
|
+
Requires-Dist: rich>=13.7.0
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: cupy-cuda12x==12.1.0; extra == 'dev'
|
|
16
|
+
Requires-Dist: ray>=2.40.0; extra == 'dev'
|
|
17
|
+
Requires-Dist: torch>=2.5.1; extra == 'dev'
|
|
18
|
+
Requires-Dist: vllm-nccl-cu12<2.19,>=2.18; extra == 'dev'
|
|
19
|
+
Requires-Dist: vllm>=0.7.3; extra == 'dev'
|
|
20
|
+
Requires-Dist: xgrammar>=0.1.11; extra == 'dev'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# Vector Inference: Easy inference on Slurm clusters
|
|
24
|
+
|
|
25
|
+
----------------------------------------------------
|
|
26
|
+
|
|
27
|
+
[](https://pypi.org/project/vec-inf)
|
|
28
|
+
[](https://github.com/VectorInstitute/vector-inference/actions/workflows/code_checks.yml)
|
|
29
|
+
[](https://github.com/VectorInstitute/vector-inference/actions/workflows/docs_deploy.yml)
|
|
30
|
+
[](https://app.codecov.io/github/VectorInstitute/vector-inference/tree/develop)
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
This repository provides an easy-to-use solution to run inference servers on [Slurm](https://slurm.schedmd.com/overview.html)-managed computing clusters using [vLLM](https://docs.vllm.ai/en/latest/). **All scripts in this repository runs natively on the Vector Institute cluster environment**. To adapt to other environments, update the environment variables in [`cli/_helper.py`](vec_inf/cli/_helper.py), [`cli/_config.py`](vec_inf/cli/_config.py), [`vllm.slurm`](vec_inf/vllm.slurm), [`multinode_vllm.slurm`](vec_inf/multinode_vllm.slurm) and [`models.yaml`](vec_inf/config/models.yaml) accordingly.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
If you are using the Vector cluster environment, and you don't need any customization to the inference server environment, run the following to install package:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install vec-inf
|
|
40
|
+
```
|
|
41
|
+
Otherwise, we recommend using the provided [`Dockerfile`](Dockerfile) to set up your own environment with the package
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
### `launch` command
|
|
46
|
+
|
|
47
|
+
The `launch` command allows users to deploy a model as a slurm job. If the job successfully launches, a URL endpoint is exposed for the user to send requests for inference.
|
|
48
|
+
|
|
49
|
+
We will use the Llama 3.1 model as example, to launch an OpenAI compatible inference server for Meta-Llama-3.1-8B-Instruct, run:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
vec-inf launch Meta-Llama-3.1-8B-Instruct
|
|
53
|
+
```
|
|
54
|
+
You should see an output like the following:
|
|
55
|
+
|
|
56
|
+
<img width="600" alt="launch_img" src="https://github.com/user-attachments/assets/883e6a5b-8016-4837-8fdf-39097dfb18bf">
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
#### Overrides
|
|
60
|
+
|
|
61
|
+
Models that are already supported by `vec-inf` would be launched using the cached configuration or [default configuration](vec_inf/config/models.yaml). You can override these values by providing additional parameters. Use `vec-inf launch --help` to see the full list of parameters that can be
|
|
62
|
+
overriden. For example, if `qos` is to be overriden:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
vec-inf launch Meta-Llama-3.1-8B-Instruct --qos <new_qos>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### Custom models
|
|
69
|
+
|
|
70
|
+
You can also launch your own custom model as long as the model architecture is [supported by vLLM](https://docs.vllm.ai/en/stable/models/supported_models.html), and make sure to follow the instructions below:
|
|
71
|
+
* Your model weights directory naming convention should follow `$MODEL_FAMILY-$MODEL_VARIANT` ($MODEL_VARIANT is OPTIONAL).
|
|
72
|
+
* Your model weights directory should contain HuggingFace format weights.
|
|
73
|
+
* You should specify your model configuration by:
|
|
74
|
+
* Creating a custom configuration file for your model and specify its path via setting the environment variable `VEC_INF_CONFIG`. Check the [default parameters](vec_inf/config/models.yaml) file for the format of the config file. All the parameters for the model should be specified in that config file.
|
|
75
|
+
* Using launch command options to specify your model setup.
|
|
76
|
+
* For other model launch parameters you can reference the default values for similar models using the [`list` command ](#list-command).
|
|
77
|
+
|
|
78
|
+
Here is an example to deploy a custom [Qwen2.5-7B-Instruct-1M](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct-1M) model which is not
|
|
79
|
+
supported in the default list of models using a user custom config. In this case, the model weights are assumed to be downloaded to
|
|
80
|
+
a `model-weights` directory inside the user's home directory. The weights directory of the model follows the naming convention so it
|
|
81
|
+
would be named `Qwen2.5-7B-Instruct-1M`. The following yaml file would need to be created, lets say it is named `/h/<username>/my-model-config.yaml`.
|
|
82
|
+
|
|
83
|
+
```yaml
|
|
84
|
+
models:
|
|
85
|
+
Qwen2.5-7B-Instruct-1M:
|
|
86
|
+
model_family: Qwen2.5
|
|
87
|
+
model_variant: 7B-Instruct-1M
|
|
88
|
+
model_type: LLM
|
|
89
|
+
gpus_per_node: 1
|
|
90
|
+
num_nodes: 1
|
|
91
|
+
vocab_size: 152064
|
|
92
|
+
max_model_len: 1010000
|
|
93
|
+
max_num_seqs: 256
|
|
94
|
+
pipeline_parallelism: true
|
|
95
|
+
enforce_eager: false
|
|
96
|
+
qos: m2
|
|
97
|
+
time: 08:00:00
|
|
98
|
+
partition: a40
|
|
99
|
+
model_weights_parent_dir: /h/<username>/model-weights
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
You would then set the `VEC_INF_CONFIG` path using:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
export VEC_INF_CONFIG=/h/<username>/my-model-config.yaml
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Note that there are other parameters that can also be added to the config but not shown in this example, such as `data_type` and `log_dir`.
|
|
109
|
+
|
|
110
|
+
### `status` command
|
|
111
|
+
You can check the inference server status by providing the Slurm job ID to the `status` command:
|
|
112
|
+
```bash
|
|
113
|
+
vec-inf status 15373800
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
If the server is pending for resources, you should see an output like this:
|
|
117
|
+
|
|
118
|
+
<img width="400" alt="status_pending_img" src="https://github.com/user-attachments/assets/b659c302-eae1-4560-b7a9-14eb3a822a2f">
|
|
119
|
+
|
|
120
|
+
When the server is ready, you should see an output like this:
|
|
121
|
+
|
|
122
|
+
<img width="400" alt="status_ready_img" src="https://github.com/user-attachments/assets/672986c2-736c-41ce-ac7c-1fb585cdcb0d">
|
|
123
|
+
|
|
124
|
+
There are 5 possible states:
|
|
125
|
+
|
|
126
|
+
* **PENDING**: Job submitted to Slurm, but not executed yet. Job pending reason will be shown.
|
|
127
|
+
* **LAUNCHING**: Job is running but the server is not ready yet.
|
|
128
|
+
* **READY**: Inference server running and ready to take requests.
|
|
129
|
+
* **FAILED**: Inference server in an unhealthy state. Job failed reason will be shown.
|
|
130
|
+
* **SHUTDOWN**: Inference server is shutdown/cancelled.
|
|
131
|
+
|
|
132
|
+
Note that the base URL is only available when model is in `READY` state, and if you've changed the Slurm log directory path, you also need to specify it when using the `status` command.
|
|
133
|
+
|
|
134
|
+
### `metrics` command
|
|
135
|
+
Once your server is ready, you can check performance metrics by providing the Slurm job ID to the `metrics` command:
|
|
136
|
+
```bash
|
|
137
|
+
vec-inf metrics 15373800
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
And you will see the performance metrics streamed to your console, note that the metrics are updated with a 2-second interval.
|
|
141
|
+
|
|
142
|
+
<img width="400" alt="metrics_img" src="https://github.com/user-attachments/assets/3ee143d0-1a71-4944-bbd7-4c3299bf0339">
|
|
143
|
+
|
|
144
|
+
### `shutdown` command
|
|
145
|
+
Finally, when you're finished using a model, you can shut it down by providing the Slurm job ID:
|
|
146
|
+
```bash
|
|
147
|
+
vec-inf shutdown 15373800
|
|
148
|
+
|
|
149
|
+
> Shutting down model with Slurm Job ID: 15373800
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### `list` command
|
|
153
|
+
You call view the full list of available models by running the `list` command:
|
|
154
|
+
```bash
|
|
155
|
+
vec-inf list
|
|
156
|
+
```
|
|
157
|
+
<img width="940" alt="list_img" src="https://github.com/user-attachments/assets/8cf901c4-404c-4398-a52f-0486f00747a3">
|
|
158
|
+
|
|
159
|
+
NOTE: The above screenshot does not represent the full list of models supported.
|
|
160
|
+
|
|
161
|
+
You can also view the default setup for a specific supported model by providing the model name, for example `Meta-Llama-3.1-70B-Instruct`:
|
|
162
|
+
```bash
|
|
163
|
+
vec-inf list Meta-Llama-3.1-70B-Instruct
|
|
164
|
+
```
|
|
165
|
+
<img width="500" alt="list_model_img" src="https://github.com/user-attachments/assets/34e53937-2d86-443e-85f6-34e408653ddb">
|
|
166
|
+
|
|
167
|
+
`launch`, `list`, and `status` command supports `--json-mode`, where the command output would be structured as a JSON string.
|
|
168
|
+
|
|
169
|
+
## Send inference requests
|
|
170
|
+
Once the inference server is ready, you can start sending in inference requests. We provide example scripts for sending inference requests in [`examples`](examples) folder. Make sure to update the model server URL and the model weights location in the scripts. For example, you can run `python examples/inference/llm/chat_completions.py`, and you should expect to see an output like the following:
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"id":"chatcmpl-387c2579231948ffaf66cdda5439d3dc",
|
|
175
|
+
"choices": [
|
|
176
|
+
{
|
|
177
|
+
"finish_reason":"stop",
|
|
178
|
+
"index":0,
|
|
179
|
+
"logprobs":null,
|
|
180
|
+
"message": {
|
|
181
|
+
"content":"Arrr, I be Captain Chatbeard, the scurviest chatbot on the seven seas! Ye be wantin' to know me identity, eh? Well, matey, I be a swashbucklin' AI, here to provide ye with answers and swappin' tales, savvy?",
|
|
182
|
+
"role":"assistant",
|
|
183
|
+
"function_call":null,
|
|
184
|
+
"tool_calls":[],
|
|
185
|
+
"reasoning_content":null
|
|
186
|
+
},
|
|
187
|
+
"stop_reason":null
|
|
188
|
+
}
|
|
189
|
+
],
|
|
190
|
+
"created":1742496683,
|
|
191
|
+
"model":"Meta-Llama-3.1-8B-Instruct",
|
|
192
|
+
"object":"chat.completion",
|
|
193
|
+
"system_fingerprint":null,
|
|
194
|
+
"usage": {
|
|
195
|
+
"completion_tokens":66,
|
|
196
|
+
"prompt_tokens":32,
|
|
197
|
+
"total_tokens":98,
|
|
198
|
+
"prompt_tokens_details":null
|
|
199
|
+
},
|
|
200
|
+
"prompt_logprobs":null
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
**NOTE**: For multimodal models, currently only `ChatCompletion` is available, and only one image can be provided for each prompt.
|
|
204
|
+
|
|
205
|
+
## SSH tunnel from your local device
|
|
206
|
+
If you want to run inference from your local device, you can open a SSH tunnel to your cluster environment like the following:
|
|
207
|
+
```bash
|
|
208
|
+
ssh -L 8081:172.17.8.29:8081 username@v.vectorinstitute.ai -N
|
|
209
|
+
```
|
|
210
|
+
Where the last number in the URL is the GPU number (gpu029 in this case). The example provided above is for the vector cluster, change the variables accordingly for your environment
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
vec_inf/README.md,sha256=dxX0xKfwLioG0mJ2YFv5JJ5q1m5NlWBrVBOap1wuHfQ,624
|
|
2
|
+
vec_inf/__init__.py,sha256=bHwSIz9lebYuxIemni-lP0h3gwJHVbJnwExQKGJWw_Q,23
|
|
3
|
+
vec_inf/find_port.sh,sha256=bGQ6LYSFVSsfDIGatrSg5YvddbZfaPL0R-Bjo4KYD6I,1088
|
|
4
|
+
vec_inf/multinode_vllm.slurm,sha256=V01ayfgObPdxbQqhYvCbNIx0zqpLurDxZhS0UHYNFi0,5210
|
|
5
|
+
vec_inf/vllm.slurm,sha256=VMMTdVUOtX4-Yv43yzgKiEpE56fMwuR0KOLf3Dar_S0,2884
|
|
6
|
+
vec_inf/cli/__init__.py,sha256=5XIvGQCOnaGl73XMkwetjC-Ul3xuXGrWDXdYJ3aUzvU,27
|
|
7
|
+
vec_inf/cli/_cli.py,sha256=8Gk4NRbrY2-3EX0S8_-1UOmGfahzqX0A2sJNVcL7OL8,6525
|
|
8
|
+
vec_inf/cli/_config.py,sha256=pb2ERbxZoRZBa9Ie7-jlzyQiiXYZgqUetbw13Blryho,2841
|
|
9
|
+
vec_inf/cli/_helper.py,sha256=9niBuFoaJfeP2yRHKcrkia4rwCZbAfoz-4s2MVCwA9w,26871
|
|
10
|
+
vec_inf/cli/_utils.py,sha256=i3mffIJ-wBVpe3pz0mYa2W5J42yNRmUG2tQwABhQJDQ,5365
|
|
11
|
+
vec_inf/config/README.md,sha256=3MYYY3hGw7jiMR5A8CMdBkhGFobcdH3Kip5E2saq_T4,18609
|
|
12
|
+
vec_inf/config/models.yaml,sha256=p__omZEmoF93BtVQXQia43xvPX88ALrBT1tMiY2Bdhk,28787
|
|
13
|
+
vec_inf-0.5.0.dist-info/METADATA,sha256=khBhIsW5hFjrp-ZQFU3wa5htLVkp4CH3JnrhLXeHfss,10228
|
|
14
|
+
vec_inf-0.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
15
|
+
vec_inf-0.5.0.dist-info/entry_points.txt,sha256=uNRXjCuJSR2nveEqD3IeMznI9oVI9YLZh5a24cZg6B0,49
|
|
16
|
+
vec_inf-0.5.0.dist-info/licenses/LICENSE,sha256=mq8zeqpvVSF1EsxmydeXcokt8XnEIfSofYn66S2-cJI,1073
|
|
17
|
+
vec_inf-0.5.0.dist-info/RECORD,,
|
vec_inf/launch_server.sh
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# ================================= Read Named Args ======================================
|
|
4
|
-
|
|
5
|
-
while [[ "$#" -gt 0 ]]; do
|
|
6
|
-
case $1 in
|
|
7
|
-
--model-family) model_family="$2"; shift ;;
|
|
8
|
-
--model-variant) model_variant="$2"; shift ;;
|
|
9
|
-
--partition) partition="$2"; shift ;;
|
|
10
|
-
--qos) qos="$2"; shift ;;
|
|
11
|
-
--time) walltime="$2"; shift ;;
|
|
12
|
-
--num-nodes) num_nodes="$2"; shift ;;
|
|
13
|
-
--num-gpus) num_gpus="$2"; shift ;;
|
|
14
|
-
--max-model-len) max_model_len="$2"; shift ;;
|
|
15
|
-
--max-num-seqs) max_num_seqs="$2"; shift ;;
|
|
16
|
-
--vocab-size) vocab_size="$2"; shift ;;
|
|
17
|
-
--data-type) data_type="$2"; shift ;;
|
|
18
|
-
--venv) venv="$2"; shift ;;
|
|
19
|
-
--log-dir) log_dir="$2"; shift ;;
|
|
20
|
-
--model-weights-parent-dir) model_weights_parent_dir="$2"; shift ;;
|
|
21
|
-
--pipeline-parallelism) pipeline_parallelism="$2"; shift ;;
|
|
22
|
-
--enforce-eager) enforce_eager="$2"; shift ;;
|
|
23
|
-
*) echo "Unknown parameter passed: $1"; exit 1 ;;
|
|
24
|
-
esac
|
|
25
|
-
shift
|
|
26
|
-
done
|
|
27
|
-
|
|
28
|
-
required_vars=(model_family model_variant partition qos walltime num_nodes num_gpus max_model_len vocab_size data_type venv log_dir model_weights_parent_dir)
|
|
29
|
-
|
|
30
|
-
for var in "$required_vars[@]"; do
|
|
31
|
-
if [ -z "$!var" ]; then
|
|
32
|
-
echo "Error: Missing required --$var argument."
|
|
33
|
-
exit 1
|
|
34
|
-
fi
|
|
35
|
-
done
|
|
36
|
-
|
|
37
|
-
export MODEL_FAMILY=$model_family
|
|
38
|
-
export MODEL_VARIANT=$model_variant
|
|
39
|
-
export JOB_PARTITION=$partition
|
|
40
|
-
export QOS=$qos
|
|
41
|
-
export WALLTIME=$walltime
|
|
42
|
-
export NUM_NODES=$num_nodes
|
|
43
|
-
export NUM_GPUS=$num_gpus
|
|
44
|
-
export VLLM_MAX_MODEL_LEN=$max_model_len
|
|
45
|
-
export VLLM_MAX_LOGPROBS=$vocab_size
|
|
46
|
-
export VLLM_DATA_TYPE=$data_type
|
|
47
|
-
export VENV_BASE=$venv
|
|
48
|
-
export LOG_DIR=$log_dir
|
|
49
|
-
export MODEL_WEIGHTS_PARENT_DIR=$model_weights_parent_dir
|
|
50
|
-
|
|
51
|
-
if [ -n "$max_num_seqs" ]; then
|
|
52
|
-
export VLLM_MAX_NUM_SEQS=$max_num_seqs
|
|
53
|
-
else
|
|
54
|
-
export VLLM_MAX_NUM_SEQS=256
|
|
55
|
-
fi
|
|
56
|
-
|
|
57
|
-
if [ -n "$pipeline_parallelism" ]; then
|
|
58
|
-
export PIPELINE_PARALLELISM=$pipeline_parallelism
|
|
59
|
-
else
|
|
60
|
-
export PIPELINE_PARALLELISM="False"
|
|
61
|
-
fi
|
|
62
|
-
|
|
63
|
-
if [ -n "$enforce_eager" ]; then
|
|
64
|
-
export ENFORCE_EAGER=$enforce_eager
|
|
65
|
-
else
|
|
66
|
-
export ENFORCE_EAGER="False"
|
|
67
|
-
fi
|
|
68
|
-
|
|
69
|
-
# ================================= Set default environment variables ======================================
|
|
70
|
-
# Slurm job configuration
|
|
71
|
-
export JOB_NAME="$MODEL_FAMILY-$MODEL_VARIANT"
|
|
72
|
-
if [ "$LOG_DIR" = "default" ]; then
|
|
73
|
-
export LOG_DIR="$HOME/.vec-inf-logs/$MODEL_FAMILY"
|
|
74
|
-
fi
|
|
75
|
-
mkdir -p $LOG_DIR
|
|
76
|
-
|
|
77
|
-
# Model and entrypoint configuration. API Server URL (host, port) are set automatically based on the
|
|
78
|
-
# SLURM job
|
|
79
|
-
export SRC_DIR="$(dirname "$0")"
|
|
80
|
-
export MODEL_DIR="${SRC_DIR}/models/${MODEL_FAMILY}"
|
|
81
|
-
|
|
82
|
-
# Variables specific to your working environment, below are examples for the Vector cluster
|
|
83
|
-
export VLLM_MODEL_WEIGHTS="${MODEL_WEIGHTS_PARENT_DIR}/${JOB_NAME}"
|
|
84
|
-
export LD_LIBRARY_PATH="/scratch/ssd001/pkgs/cudnn-11.7-v8.5.0.96/lib/:/scratch/ssd001/pkgs/cuda-11.7/targets/x86_64-linux/lib/"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
# ================================ Validate Inputs & Launch Server =================================
|
|
88
|
-
|
|
89
|
-
# Set data type to fp16 instead of bf16 for non-Ampere GPUs
|
|
90
|
-
fp16_partitions="t4v1 t4v2"
|
|
91
|
-
|
|
92
|
-
# choose from 'auto', 'half', 'float16', 'bfloat16', 'float', 'float32'
|
|
93
|
-
if [[ $fp16_partitions =~ $JOB_PARTITION ]]; then
|
|
94
|
-
export VLLM_DATA_TYPE="float16"
|
|
95
|
-
echo "Data type set to due to non-Ampere GPUs used: $VLLM_DATA_TYPE"
|
|
96
|
-
fi
|
|
97
|
-
|
|
98
|
-
echo Job Name: $JOB_NAME
|
|
99
|
-
echo Partition: $JOB_PARTITION
|
|
100
|
-
echo Num Nodes: $NUM_NODES
|
|
101
|
-
echo GPUs per Node: $NUM_GPUS
|
|
102
|
-
echo QOS: $QOS
|
|
103
|
-
echo Walltime: $WALLTIME
|
|
104
|
-
echo Data Type: $VLLM_DATA_TYPE
|
|
105
|
-
echo Max Model Length: $VLLM_MAX_MODEL_LEN
|
|
106
|
-
echo Max Num Seqs: $VLLM_MAX_NUM_SEQS
|
|
107
|
-
echo Vocabulary Size: $VLLM_MAX_LOGPROBS
|
|
108
|
-
echo Pipeline Parallelism: $PIPELINE_PARALLELISM
|
|
109
|
-
echo Enforce Eager: $ENFORCE_EAGER
|
|
110
|
-
echo Log Directory: $LOG_DIR
|
|
111
|
-
echo Model Weights Parent Directory: $MODEL_WEIGHTS_PARENT_DIR
|
|
112
|
-
|
|
113
|
-
is_special=""
|
|
114
|
-
if [ "$NUM_NODES" -gt 1 ]; then
|
|
115
|
-
is_special="multinode_"
|
|
116
|
-
fi
|
|
117
|
-
|
|
118
|
-
sbatch --job-name $JOB_NAME \
|
|
119
|
-
--partition $JOB_PARTITION \
|
|
120
|
-
--nodes $NUM_NODES \
|
|
121
|
-
--gres gpu:$NUM_GPUS \
|
|
122
|
-
--qos $QOS \
|
|
123
|
-
--time $WALLTIME \
|
|
124
|
-
--output $LOG_DIR/$JOB_NAME.%j.out \
|
|
125
|
-
--error $LOG_DIR/$JOB_NAME.%j.err \
|
|
126
|
-
$SRC_DIR/${is_special}vllm.slurm
|