-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CI/Build] improve python-only dev setup #9621
Merged
youkaichao
merged 23 commits into
vllm-project:main
from
dtrifiro:improve-python-only-dev-setup
Dec 4, 2024
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
78d16eb
[CI/Build] improve dev setup
dtrifiro 548433b
remove python_only_dev.py script, update docs
dtrifiro 75f2a2a
bump python version in installation guide
dtrifiro bb14531
docs: add sccache section
dtrifiro 6675435
docs: fix VLLM_USE_PRECOMPILED env var usage, fix typos/rewording
dtrifiro 8076513
fix inclusion of vllm_flash_attn python/compiled files
dtrifiro f83ade0
fix build isolation
dtrifiro ff364ae
fixup
dtrifiro 9c41aba
extract pre-compiled wheel logic into repackage_wheel()
dtrifiro 94a2fac
use files_to_copy
dtrifiro 0acb1b2
allow to set VLLM_PRECOMPILED_WHEEL_LOCATION for custom wheel location
dtrifiro b17f15b
setup.py: use use wheel location instead of wheel filename
dtrifiro 42c9a45
fix docs linting complaints
dtrifiro 83dcfb6
explicit files to copy
youkaichao 400d1e2
use wheel_path
youkaichao 60532e4
use member
youkaichao 4c0c89b
fix format
youkaichao c129f9c
add notes
youkaichao 69e6c4e
setup.py: refactor repackage_wheel into custom build_ext class
dtrifiro 73c07fc
setup.py: use vllm-wheels prefix for nightly wheels download dir
dtrifiro cef112a
remove verbose flag
youkaichao b7f0c3b
Merge branch 'main' into improve-python-only-dev-setup
youkaichao 57ee0c1
remove super run
youkaichao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,14 @@ | ||
# enable python only development | ||
# copy compiled files to the current directory directly | ||
msg = """Old style python only build (without compilation) is deprecated, please check https://docs.vllm.ai/en/latest/getting_started/installation.html#python-only-build-without-compilation for the new way to do python only build (without compilation). | ||
|
||
dtrifiro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import argparse | ||
import os | ||
import shutil | ||
import subprocess | ||
import sys | ||
import warnings | ||
TL;DR: | ||
|
||
parser = argparse.ArgumentParser( | ||
description="Development mode for python-only code") | ||
parser.add_argument('-q', | ||
'--quit-dev', | ||
action='store_true', | ||
help='Set the flag to quit development mode') | ||
args = parser.parse_args() | ||
VLLM_USE_PRECOMPILED=1 pip install -e . | ||
|
||
# cannot directly `import vllm` , because it will try to | ||
# import from the current directory | ||
output = subprocess.run([sys.executable, "-m", "pip", "show", "vllm"], | ||
capture_output=True) | ||
or | ||
|
||
assert output.returncode == 0, "vllm is not installed" | ||
export VLLM_COMMIT=33f460b17a54acb3b6cc0b03f4a17876cff5eafd # use full commit hash from the main branch | ||
export VLLM_PRECOMPILED_WHEEL_LOCATION=https://vllm-wheels.s3.us-west-2.amazonaws.com/${VLLM_COMMIT}/vllm-1.0.0.dev-cp38-abi3-manylinux1_x86_64.whl | ||
pip install -e . | ||
""" # noqa | ||
|
||
text = output.stdout.decode("utf-8") | ||
|
||
package_path = None | ||
for line in text.split("\n"): | ||
if line.startswith("Location: "): | ||
package_path = line.split(": ")[1] | ||
break | ||
|
||
assert package_path is not None, "could not find package path" | ||
|
||
cwd = os.getcwd() | ||
|
||
assert cwd != package_path, "should not import from the current directory" | ||
|
||
files_to_copy = [ | ||
"vllm/_C.abi3.so", | ||
"vllm/_moe_C.abi3.so", | ||
"vllm/vllm_flash_attn/vllm_flash_attn_c.abi3.so", | ||
"vllm/vllm_flash_attn/flash_attn_interface.py", | ||
"vllm/vllm_flash_attn/__init__.py", | ||
# "vllm/_version.py", # not available in nightly wheels yet | ||
] | ||
|
||
# Try to create _version.py to avoid version related warning | ||
# Refer to https://github.com/vllm-project/vllm/pull/8771 | ||
try: | ||
from setuptools_scm import get_version | ||
get_version(write_to="vllm/_version.py") | ||
except ImportError: | ||
warnings.warn( | ||
"To avoid warnings related to vllm._version, " | ||
"you should install setuptools-scm by `pip install setuptools-scm`", | ||
stacklevel=2) | ||
|
||
if not args.quit_dev: | ||
for file in files_to_copy: | ||
src = os.path.join(package_path, file) | ||
dst = file | ||
print(f"Copying {src} to {dst}") | ||
shutil.copyfile(src, dst) | ||
|
||
pre_built_vllm_path = os.path.join(package_path, "vllm") | ||
tmp_path = os.path.join(package_path, "vllm_pre_built") | ||
current_vllm_path = os.path.join(cwd, "vllm") | ||
|
||
print(f"Renaming {pre_built_vllm_path} to {tmp_path} for backup") | ||
shutil.copytree(pre_built_vllm_path, tmp_path) | ||
shutil.rmtree(pre_built_vllm_path) | ||
|
||
print(f"Linking {current_vllm_path} to {pre_built_vllm_path}") | ||
os.symlink(current_vllm_path, pre_built_vllm_path) | ||
else: | ||
vllm_symlink_path = os.path.join(package_path, "vllm") | ||
vllm_backup_path = os.path.join(package_path, "vllm_pre_built") | ||
current_vllm_path = os.path.join(cwd, "vllm") | ||
|
||
print(f"Unlinking {current_vllm_path} to {vllm_symlink_path}") | ||
assert os.path.islink( | ||
vllm_symlink_path | ||
), f"not in dev mode: {vllm_symlink_path} is not a symbolic link" | ||
assert current_vllm_path == os.readlink( | ||
vllm_symlink_path | ||
), "current directory is not the source code of package" | ||
os.unlink(vllm_symlink_path) | ||
|
||
print(f"Recovering backup from {vllm_backup_path} to {vllm_symlink_path}") | ||
os.rename(vllm_backup_path, vllm_symlink_path) | ||
print(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we unify these two env vars into one
VLLM_PRECOMPILED_WHEEL=location
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I updated the workflow so that if
VLLM_PRECOMPILED_WHEEL_LOCATION
is set, there's no need to also provideVLLM_USE_PRECOMPILED
. IfVLLM_USE_PRECOMPILED
is provided but the location is unset, it will use the default nightly url.