Skip to content

Commit 1d6d59e

Browse files
comaniacshreyankg
authored andcommitted
[Build] Automatically use the wheel of the base commit with Python-only build (vllm-project#13178)
1 parent cd660af commit 1d6d59e

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

docs/source/getting_started/installation/gpu/cuda.inc.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,22 @@ cd vllm
8989
VLLM_USE_PRECOMPILED=1 pip install --editable .
9090
```
9191

92-
This will download the [latest nightly wheel](https://wheels.vllm.ai/nightly/vllm-1.0.0.dev-cp38-abi3-manylinux1_x86_64.whl) and use the compiled libraries from there in the installation.
92+
This command will do the following:
93+
1. Look for the current branch in your vLLM clone.
94+
2. Identify the corresponding base commit in the main branch.
95+
3. Download the pre-built wheel of the base commit.
96+
4. Use its compiled libraries in the installation.
9397

94-
The `VLLM_PRECOMPILED_WHEEL_LOCATION` environment variable can be used instead of `VLLM_USE_PRECOMPILED` to specify a custom path or URL to the wheel file. For example, to use the [0.6.1.post1 PyPi wheel](https://pypi.org/project/vllm/#files):
98+
:::{note}
99+
1. If you change C++ or kernel code, you cannot use Python-only build; otherwise you will see an import error about library not found or undefined symbol.
100+
2. If you rebase your dev branch, it is recommended to uninstall vllm and re-run the above command to make sure your libraries are up to date.
101+
:::
102+
103+
In case you see an error about wheel not found when running the above command, it might be because the commit you based on in the main branch was just merged and the wheel is being built. In this case, you can wait for around an hour to try again, or manually assign the previous commit in the installation using the `VLLM_PRECOMPILED_WHEEL_LOCATION` environment variable.
95104

96105
```console
97-
export VLLM_PRECOMPILED_WHEEL_LOCATION=https://files.pythonhosted.org/packages/4a/4c/ee65ba33467a4c0de350ce29fbae39b9d0e7fcd887cc756fa993654d1228/vllm-0.6.3.post1-cp38-abi3-manylinux1_x86_64.whl
106+
export VLLM_COMMIT=72d9c316d3f6ede485146fe5aabd4e61dbc59069 # use full commit hash from the main branch
107+
export VLLM_PRECOMPILED_WHEEL_LOCATION=https://wheels.vllm.ai/${VLLM_COMMIT}/vllm-1.0.0.dev-cp38-abi3-manylinux1_x86_64.whl
98108
pip install --editable .
99109
```
100110

setup.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,15 +264,34 @@ def run(self):
264264

265265
class repackage_wheel(build_ext):
266266
"""Extracts libraries and other files from an existing wheel."""
267-
default_wheel = "https://wheels.vllm.ai/nightly/vllm-1.0.0.dev-cp38-abi3-manylinux1_x86_64.whl"
268267

269-
def run(self) -> None:
270-
wheel_location = os.getenv("VLLM_PRECOMPILED_WHEEL_LOCATION",
271-
self.default_wheel)
268+
def get_base_commit_in_main_branch(self) -> str:
269+
import subprocess
270+
271+
try:
272+
current_branch = subprocess.check_output(
273+
["git", "branch", "--show-current"]).decode("utf-8").strip()
274+
275+
base_commit = subprocess.check_output(
276+
["git", "merge-base", "main",
277+
current_branch]).decode("utf-8").strip()
278+
return base_commit
279+
except Exception as err:
280+
logger.warning(
281+
"Failed to get the base commit in the main branch. "
282+
"Using the nightly wheel. The libraries in this "
283+
"wheel may not be compatible with your dev branch: %s", err)
284+
return "nightly"
272285

286+
def run(self) -> None:
273287
assert _is_cuda(
274288
), "VLLM_USE_PRECOMPILED is only supported for CUDA builds"
275289

290+
wheel_location = os.getenv("VLLM_PRECOMPILED_WHEEL_LOCATION", None)
291+
if wheel_location is None:
292+
base_commit = self.get_base_commit_in_main_branch()
293+
wheel_location = f"https://wheels.vllm.ai/{base_commit}/vllm-1.0.0.dev-cp38-abi3-manylinux1_x86_64.whl"
294+
276295
import zipfile
277296

278297
if os.path.isfile(wheel_location):

0 commit comments

Comments
 (0)