Skip to content

Commit 0d54217

Browse files
committed
feat: add vLLM setup script for modular installation
Add scripts/setup_vllm.sh to support vLLM installation and configuration within containers. This script: - Downloads vLLM source from GitHub when not mounted as a volume - Installs build dependencies for vLLM compilation - Supports installing vLLM wheels from PyPI (release, nightly) - Provides flexible configuration via INSTALL_VLLM environment variable The script supports multiple installation modes: - source: Build from source (with auto-download if not mounted) - release/nightly: Install wheels from PyPI - skip: Skip vLLM installation This is part of the modular script architecture introduced in PR #115. Signed-off-by: Craig Magina <[email protected]>
1 parent ab0ce06 commit 0d54217

9 files changed

Lines changed: 227 additions & 1 deletion

File tree

.github/workflows/amd-image.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ on: # yamllint disable-line rule:truthy
1515
- scripts/setup_torch.sh
1616
- scripts/setup_triton.sh
1717
- scripts/setup_user.sh
18+
- scripts/setup_vllm.sh
1819
- scripts/setup.sh
1920
pull_request:
2021
paths:
@@ -27,6 +28,7 @@ on: # yamllint disable-line rule:truthy
2728
- scripts/setup_helion.sh
2829
- scripts/setup_torch.sh
2930
- scripts/setup_triton.sh
31+
- scripts/setup_vllm.sh
3032
- scripts/setup_user.sh
3133
- scripts/setup.sh
3234
schedule:

.github/workflows/cpu-image.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on: # yamllint disable-line rule:truthy
1414
- scripts/setup_helion.sh
1515
- scripts/setup_torch.sh
1616
- scripts/setup_triton.sh
17+
- scripts/setup_vllm.sh
1718
- scripts/setup_user.sh
1819
- scripts/setup.sh
1920
pull_request:
@@ -27,6 +28,7 @@ on: # yamllint disable-line rule:truthy
2728
- scripts/setup_helion.sh
2829
- scripts/setup_torch.sh
2930
- scripts/setup_triton.sh
31+
- scripts/setup_vllm.sh
3032
- scripts/setup_user.sh
3133
- scripts/setup.sh
3234
schedule:

.github/workflows/nvidia-image.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on: # yamllint disable-line rule:truthy
1414
- scripts/setup_helion.sh
1515
- scripts/setup_torch.sh
1616
- scripts/setup_triton.sh
17+
- scripts/setup_vllm.sh
1718
- scripts/setup_user.sh
1819
- scripts/setup.sh
1920
pull_request:
@@ -27,6 +28,7 @@ on: # yamllint disable-line rule:truthy
2728
- scripts/setup_helion.sh
2829
- scripts/setup_torch.sh
2930
- scripts/setup_triton.sh
31+
- scripts/setup_vllm.sh
3032
- scripts/setup_user.sh
3133
- scripts/setup.sh
3234
schedule:

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ INSTALL_NSIGHT ?=false
4646
llvm_path ?=
4747
helion_path ?=
4848
torch_path ?=
49+
vllm_path ?=
4950
user_path ?=
5051
INSTALL_HELION ?= skip # Options: release, source, skip
5152
INSTALL_LLVM ?= skip # Options: source, skip
5253
INSTALL_TORCH ?= skip # Options: nightly, release, source, skip, test
5354
INSTALL_TRITON ?= source # Options: release, source, skip
55+
INSTALL_VLLM ?= skip # Options: nightly, release, source, skip
5456
INSTALL_JUPYTER ?= true
5557
USE_CCACHE ?= 0
5658
CUDA_VERSION ?= 12-8
@@ -129,6 +131,9 @@ define run_container
129131
if [ -n "$(torch_path)" ]; then \
130132
volume_arg+=" -v $(torch_path):/workspace/torch$(SELINUXFLAG)"; \
131133
fi; \
134+
if [ -n "$(vllm_path)" ]; then \
135+
volume_arg+=" -v $(vllm_path):/workspace/vllm$(SELINUXFLAG)"; \
136+
fi; \
132137
if [ -n "$(user_path)" ]; then \
133138
volume_arg+=" -v $(user_path):/workspace/user$(SELINUXFLAG)"; \
134139
fi; \
@@ -170,7 +175,7 @@ define run_container
170175
if [ "$(CUSTOM_LLVM)" = "false" ]; then \
171176
install_llvm="-e INSTALL_LLVM=$(INSTALL_LLVM)"; \
172177
fi; \
173-
env_vars="-e USERNAME=$(USER) -e TORCH_VERSION=$(torch_version) -e CUSTOM_LLVM=$(CUSTOM_LLVM) -e INSTALL_TOOLS=$(DEMO_TOOLS) -e INSTALL_JUPYTER=$(INSTALL_JUPYTER) -e NOTEBOOK_PORT=$(NOTEBOOK_PORT) -e INSTALL_HELION=$(INSTALL_HELION) -e INSTALL_TORCH=$(INSTALL_TORCH) -e INSTALL_TRITON=$(INSTALL_TRITON) -e USE_CCACHE=$(USE_CCACHE) -e MAX_JOBS=$(MAX_JOBS)"; \
178+
env_vars="-e USERNAME=$(USER) -e TORCH_VERSION=$(torch_version) -e CUSTOM_LLVM=$(CUSTOM_LLVM) -e INSTALL_TOOLS=$(DEMO_TOOLS) -e INSTALL_JUPYTER=$(INSTALL_JUPYTER) -e NOTEBOOK_PORT=$(NOTEBOOK_PORT) -e INSTALL_HELION=$(INSTALL_HELION) -e INSTALL_TORCH=$(INSTALL_TORCH) -e INSTALL_TRITON=$(INSTALL_TRITON) -e INSTALL_VLLM=$(INSTALL_VLLM) -e USE_CCACHE=$(USE_CCACHE) -e MAX_JOBS=$(MAX_JOBS)"; \
174179
if [ "$(create_user)" = "true" ]; then \
175180
$(CTR_CMD) run -e CREATE_USER=$(create_user) $$env_vars $$install_llvm $$port_arg \
176181
-e USER_UID=`id -u $(USER)` -e USER_GID=`id -g $(USER)` $$gpu_args $$profiling_args $$keep_ns_arg \

dockerfiles/Dockerfile.triton

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ COPY scripts/setup_helion.sh setup_helion.sh
6969
COPY scripts/setup_llvm.sh setup_llvm.sh
7070
COPY scripts/setup_torch.sh setup_torch.sh
7171
COPY scripts/setup_triton.sh setup_triton.sh
72+
COPY scripts/setup_vllm.sh setup_vllm.sh
7273
COPY scripts/setup_user.sh setup_user.sh
7374
COPY scripts/setup.sh setup.sh
7475
COPY scripts/install_software.sh install_software.sh

dockerfiles/Dockerfile.triton-amd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ COPY scripts/setup_helion.sh setup_helion.sh
8787
COPY scripts/setup_llvm.sh setup_llvm.sh
8888
COPY scripts/setup_torch.sh setup_torch.sh
8989
COPY scripts/setup_triton.sh setup_triton.sh
90+
COPY scripts/setup_vllm.sh setup_vllm.sh
9091
COPY scripts/setup_user.sh setup_user.sh
9192
COPY scripts/setup.sh setup.sh
9293
COPY scripts/install_software.sh install_software.sh

dockerfiles/Dockerfile.triton-cpu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ COPY scripts/setup_helion.sh setup_helion.sh
6666
COPY scripts/setup_llvm.sh setup_llvm.sh
6767
COPY scripts/setup_torch.sh setup_torch.sh
6868
COPY scripts/setup_triton.sh setup_triton.sh
69+
COPY scripts/setup_vllm.sh setup_vllm.sh
6970
COPY scripts/setup_user.sh setup_user.sh
7071
COPY scripts/setup.sh setup.sh
7172
COPY scripts/install_software.sh install_software.sh

scripts/setup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ declare -a SAVE_VARS=(
3030
"INSTALL_TOOLS"
3131
"INSTALL_TORCH"
3232
"INSTALL_TRITON"
33+
"INSTALL_VLLM"
3334
"MAX_JOBS"
3435
"PIP_TRITON_VERSION"
3536
"ROCM_VERSION"
@@ -77,6 +78,10 @@ if [ "${INSTALL_TRITON:-skip}" != "skip" ]; then
7778
run_as_user ./setup_triton.sh "$INSTALL_TRITON"
7879
fi
7980

81+
if [ "${INSTALL_VLLM:-skip}" != "skip" ]; then
82+
run_as_user ./setup_vllm.sh "$INSTALL_VLLM"
83+
fi
84+
8085
if [ "${INSTALL_TORCH:-skip}" != "skip" ]; then
8186
run_as_user ./setup_torch.sh "$INSTALL_TORCH"
8287
fi

scripts/setup_vllm.sh

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
#! /bin/bash -e
2+
3+
trap "echo -e '\nScript interrupted. Exiting gracefully.'; exit 1" SIGINT
4+
5+
# Copyright (C) 2024-2025 Red Hat, Inc.
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
# SPDX-License-Identifier: Apache-2.0
20+
set -euo pipefail
21+
22+
WORKSPACE=${WORKSPACE:-${HOME}}
23+
24+
VLLM_REPO=https://github.com/vllm-project/vllm.git
25+
VLLM_DIR="${WORKSPACE}/vllm"
26+
27+
declare -a PIP_INSTALL_ARGS
28+
PIP_VLLM_INDEX_URL_BASE=https://wheels.vllm.ai
29+
30+
pip_install() {
31+
if command -v uv &>/dev/null; then
32+
uv pip install "$@"
33+
else
34+
pip install "$@"
35+
fi
36+
}
37+
38+
# Extract the major.minor version from ROCM_VERSION, e.g. 6.4 from 6.4.4
39+
get_rocm_version() {
40+
[[ "$ROCM_VERSION" =~ ^([0-9]+\.[0-9]+) ]] && echo "${BASH_REMATCH[1]}" ||
41+
echo "$ROCM_VERSION"
42+
}
43+
44+
setup_src() {
45+
if [ ! -d "${VLLM_DIR}" ]; then
46+
echo "Cloning the vLLM repo $VLLM_REPO to $VLLM_DIR ..."
47+
git clone "$VLLM_REPO" "$VLLM_DIR"
48+
49+
if [ ! -d "$VLLM_DIR" ]; then
50+
echo "$VLLM_DIR not found. ERROR Cloning repository..."
51+
exit 1
52+
else
53+
pushd "$VLLM_DIR" 1>/dev/null || exit 1
54+
git submodule sync
55+
git submodule update --init --recursive
56+
57+
if [ -n "${VLLM_GITREF:-}" ]; then
58+
git checkout "$VLLM_GITREF"
59+
fi
60+
61+
echo "Install pre-commit hooks into your local vLLM git repo (one-time)"
62+
pip_install pre-commit
63+
pre-commit install
64+
popd 1>/dev/null
65+
fi
66+
else
67+
echo "vLLM repo already present, not cloning ..."
68+
fi
69+
}
70+
71+
install_build_deps() {
72+
pushd "$VLLM_DIR" 1>/dev/null || exit 1
73+
74+
if [ "${INSTALL_TORCH:-}" = "source" ]; then
75+
echo "Using existing torch source build ..."
76+
python use_existing_torch.py
77+
else
78+
echo "Installing Torch as a vLLM dependency ..."
79+
"${WORKSPACE}"/setup_torch.sh release
80+
fi
81+
82+
if [ -n "${CUDA_VERSION:-}" ]; then
83+
VLLM_TARGET_DEVICE=cuda
84+
85+
if [ -e requirements/cuda.txt ]; then
86+
echo "Installing vLLM CUDA build dependencies ..."
87+
pip_install --prerelease=allow -r requirements/cuda.txt
88+
fi
89+
elif [ -n "${ROCM_VERSION:-}" ]; then
90+
VLLM_TARGET_DEVICE=rocm
91+
92+
pip_install --upgrade numba \
93+
scipy \
94+
"huggingface-hub[cli,hf_transfer]" \
95+
setuptools_scm
96+
97+
pip_install "numpy<2"
98+
99+
if [ -e requirements/rocm.txt ]; then
100+
echo "Installing vLLM ROCm build dependencies ..."
101+
pip_install --prerelease=allow -r requirements/rocm.txt
102+
fi
103+
elif [ "${TRITON_CPU_BACKEND:-0}" -eq 1 ]; then
104+
VLLM_TARGET_DEVICE=cpu
105+
106+
if [ -e requirements/cpu.txt ]; then
107+
echo "Installing vLLM CPU build dependencies ..."
108+
pip_install --prerelease=allow -r requirements/cpu.txt
109+
fi
110+
fi
111+
112+
if [ -f requirements/build.txt ]; then
113+
echo "Installing vLLM build dependencies ..."
114+
pip_install --prerelease=allow -r requirements/build.txt
115+
fi
116+
117+
popd 1>/dev/null
118+
119+
echo "Set the target device for vLLM build ..."
120+
tee -a "${HOME}/.bashrc" <<EOF
121+
122+
# Target device for vLLM build
123+
export VLLM_TARGET_DEVICE=$VLLM_TARGET_DEVICE
124+
EOF
125+
echo "Run 'source ${HOME}/.bashrc' before building vLLM"
126+
}
127+
128+
install_whl() {
129+
echo "Installing vLLM from PyPI ..."
130+
131+
if [ -n "${PIP_VLLM_EXTRA_INDEX_URL:-}" ]; then
132+
echo "Using the specified index, $PIP_VLLM_EXTRA_INDEX_URL"
133+
PIP_INSTALL_ARGS+=("--index-url" "$PIP_VLLM_EXTRA_INDEX_URL")
134+
elif [ -n "${VLLM_COMMIT:-}" ]; then
135+
echo "Using the build from commit $VLLM_COMMIT ..."
136+
PIP_VLLM_EXTRA_INDEX_URL="--extra-index-url ${PIP_VLLM_INDEX_URL_BASE}/${VLLM_COMMIT}"
137+
elif command -v uv &>/dev/null; then
138+
if [ -n "${UV_TORCH_BACKEND:-}" ]; then
139+
echo "Using the specified uv backend, $UV_TORCH_BACKEND"
140+
elif [ -n "${ROCM_VERSION:-}" ]; then
141+
echo "Using the torch ROCm version $ROCM_VERSION backend"
142+
UV_TORCH_BACKEND="rocm$(get_rocm_version)"
143+
elif ((${TRITON_CPU_BACKEND:-0} == 1)); then
144+
echo "Using the torch CPU backend"
145+
UV_TORCH_BACKEND=cpu
146+
elif [ -n "${CUDA_VERSION:-}" ]; then
147+
echo "Using the torch CUDA version $CUDA_VERSION backend"
148+
UV_TORCH_BACKEND="cu${CUDA_VERSION/[.-]/}"
149+
else
150+
echo "Using the torch auto backend"
151+
UV_TORCH_BACKEND=auto
152+
fi
153+
154+
PIP_INSTALL_ARGS+=("--torch-backend" "$UV_TORCH_BACKEND")
155+
elif ! command -v uv &>/dev/null && [ -n "${UV_TORCH_BACKEND:-}" ]; then
156+
echo "Error: UV_TORCH_BACKEND is set to $UV_TORCH_BACKEND but uv is not available."
157+
exit 1
158+
fi
159+
160+
if [ -n "${PIP_VLLM_VERSION:-}" ]; then
161+
echo "Installing specified version $PIP_VLLM_VERSION"
162+
PIP_VLLM_VERSION="==$PIP_VLLM_VERSION"
163+
fi
164+
165+
pip_install -U --force-reinstall "${PIP_INSTALL_ARGS[@]}" "vllm${PIP_VLLM_VERSION:-}" \
166+
167+
# Fix up LD_LIBRARY_PATH for CUDA
168+
"${WORKSPACE}"/ldpretend.sh
169+
}
170+
171+
usage() {
172+
cat >&2 <<EOF
173+
Usage: $(basename "$0") [COMMAND]
174+
source Download vLLM's source (if needed) and install the build deps
175+
release Install vLLM
176+
nightly Install the vLLM nightly wheel
177+
EOF
178+
}
179+
180+
##
181+
## Main
182+
##
183+
184+
if [ $# -ne 1 ]; then
185+
usage
186+
exit 1
187+
fi
188+
189+
COMMAND=${1,,}
190+
191+
case $COMMAND in
192+
source)
193+
setup_src
194+
install_build_deps
195+
;;
196+
release)
197+
install_whl
198+
;;
199+
nightly)
200+
PIP_VLLM_EXTRA_INDEX_URL="--extra-index-url ${PIP_VLLM_INDEX_URL_BASE}/nightly"
201+
install_whl
202+
;;
203+
*)
204+
usage
205+
exit 1
206+
;;
207+
esac

0 commit comments

Comments
 (0)