Skip to content

Commit f35f8e2

Browse files
authored
[Build] Make sure local main branch is synced when VLLM_USE_PRECOMPILED=1 (#13921)
Signed-off-by: Cody Yu <[email protected]>
1 parent b87c21f commit f35f8e2

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

setup.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import ctypes
44
import importlib.util
5+
import json
56
import logging
67
import os
78
import re
@@ -269,16 +270,41 @@ class repackage_wheel(build_ext):
269270
"""Extracts libraries and other files from an existing wheel."""
270271

271272
def get_base_commit_in_main_branch(self) -> str:
272-
import subprocess
273+
# Force to use the nightly wheel. This is mainly used for CI testing.
274+
if envs.VLLM_TEST_USE_PRECOMPILED_NIGHTLY_WHEEL:
275+
return "nightly"
273276

274277
try:
278+
# Get the latest commit hash of the upstream main branch.
279+
resp_json = subprocess.check_output([
280+
"curl", "-s",
281+
"https://api.github.com/repos/vllm-project/vllm/commits/main"
282+
]).decode("utf-8")
283+
upstream_main_commit = json.loads(resp_json)["sha"]
284+
285+
# Check if the local main branch is up-to-date. This is to ensure
286+
# the base commit we found is the most recent commit on the main
287+
# branch.
288+
local_main_commit = subprocess.check_output(
289+
["git", "rev-parse", "main"]).decode("utf-8").strip()
290+
if local_main_commit != upstream_main_commit:
291+
raise ValueError(
292+
f"Local main branch ({local_main_commit}) is not "
293+
"up-to-date with upstream main branch "
294+
f"({upstream_main_commit}). Please pull the latest "
295+
"changes from upstream main branch first.")
296+
297+
# Then get the commit hash of the current branch that is the same as
298+
# the upstream main commit.
275299
current_branch = subprocess.check_output(
276300
["git", "branch", "--show-current"]).decode("utf-8").strip()
277301

278302
base_commit = subprocess.check_output(
279303
["git", "merge-base", "main",
280304
current_branch]).decode("utf-8").strip()
281305
return base_commit
306+
except ValueError as err:
307+
raise ValueError(err) from None
282308
except Exception as err:
283309
logger.warning(
284310
"Failed to get the base commit in the main branch. "

tests/standalone_tests/python_only_compile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ apt autoremove -y
1818

1919
echo 'import os; os.system("touch /tmp/changed.file")' >> vllm/__init__.py
2020

21-
VLLM_USE_PRECOMPILED=1 pip3 install -vvv -e .
21+
VLLM_TEST_USE_PRECOMPILED_NIGHTLY_WHEEL=1 VLLM_USE_PRECOMPILED=1 pip3 install -vvv -e .
2222

2323
# Run the script
2424
python3 -c 'import vllm'

vllm/envs.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@
6060
MAX_JOBS: Optional[str] = None
6161
NVCC_THREADS: Optional[str] = None
6262
VLLM_USE_PRECOMPILED: bool = False
63+
VLLM_TEST_USE_PRECOMPILED_NIGHTLY_WHEEL: bool = False
6364
VLLM_NO_DEPRECATION_WARNING: bool = False
6465
VLLM_KEEP_ALIVE_ON_ENGINE_DEATH: bool = False
6566
CMAKE_BUILD_TYPE: Optional[str] = None
6667
VERBOSE: bool = False
6768
VLLM_ALLOW_LONG_MAX_MODEL_LEN: bool = False
68-
VLLM_TEST_FORCE_FP8_MARLIN: bool = False
6969
VLLM_RPC_TIMEOUT: int = 10000 # ms
7070
VLLM_PLUGINS: Optional[list[str]] = None
7171
VLLM_TORCH_PROFILER_DIR: Optional[str] = None
@@ -148,6 +148,12 @@ def maybe_convert_int(value: Optional[str]) -> Optional[int]:
148148
lambda: bool(os.environ.get("VLLM_USE_PRECOMPILED")) or bool(
149149
os.environ.get("VLLM_PRECOMPILED_WHEEL_LOCATION")),
150150

151+
# Whether to force using nightly wheel in python build.
152+
# This is used for testing the nightly wheel in python build.
153+
"VLLM_TEST_USE_PRECOMPILED_NIGHTLY_WHEEL":
154+
lambda: bool(int(os.getenv("VLLM_TEST_USE_PRECOMPILED_NIGHTLY_WHEEL", "0"))
155+
),
156+
151157
# CMake build type
152158
# If not set, defaults to "Debug" or "RelWithDebInfo"
153159
# Available options: "Debug", "Release", "RelWithDebInfo"

0 commit comments

Comments
 (0)