Skip to content
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

[misc][installation] build from source without compilation #8818

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions docs/source/getting_started/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,41 @@ You can install vLLM using pip:
$ # export VLLM_COMMIT=...
$ # pip install https://vllm-wheels.s3.us-west-2.amazonaws.com/${VLLM_COMMIT}/vllm-${VLLM_VERSION}-cp38-abi3-manylinux1_x86_64.whl

Build from source (without compilation)
---------------------------------------

If you want to develop vLLM, and you only need to change the Python code, you can build vLLM without compilation.

The first step is to follow the previous instructions to install the latest vLLM wheel:

.. code-block:: console

$ export VLLM_VERSION=0.6.1.post1
$ pip install https://vllm-wheels.s3.us-west-2.amazonaws.com/nightly/vllm-${VLLM_VERSION}-cp38-abi3-manylinux1_x86_64.whl
Comment on lines +70 to +71
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could find a way to make this a little easier -- either by wrapping this in a script that's version invariant, or maybe we could always upload the latest wheel to https://vllm-wheels.s3.us-west-2.amazonaws.com/nightly/vllm-latest-cp38-abi3-manylinux1_x86_64.whl

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @simon-mo @khluu if this is possible

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe push to nightly during the scheduled build at 9PM daily? or we can push to latest/vllm-{VLLM_VERSION}... for every commit

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we shouldn't have to update this when we put a new version out, and ideally users could have one command that always. works.

Isn't export VLLM_VERSION=0.6.1.post1 already out of date, btw?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastest is always pushed. but the version string will always be there. a thing I have known worked in the pass is to set dev versions something like v1.0.0.dev0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we omit the version in the wheel name? i.e. a unified link that always points to the latest wheel. an url re-direction should work I think.


After verifying that the installation is successful, we have a script for you to copy and link directories, so that you can edit the Python code directly:

.. code-block:: console

$ git clone https://github.com/vllm-project/vllm.git
$ cd vllm
$ python python_only_dev.py

It will:

- Find the installed vLLM in the current environment.
- Copy built files to the current directory.
- Rename the installed vLLM
- Symbolically link the current directory to the installed vLLM.

This way, you can edit the Python code in the current directory, and the changes will be reflected in the installed vLLM.

.. _build_from_source:

Build from source
-----------------
Build from source (with compilation)
------------------------------------

You can also build and install vLLM from source:
If you need to touch the C++ or CUDA code, you need to build vLLM from source:

.. code-block:: console

Expand Down
54 changes: 54 additions & 0 deletions python_only_dev.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# enable python only development
# copy compiled files to the current directory directly

import os
import shutil
import subprocess
import sys

# 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)

assert output.returncode == 0, "vllm is not installed"

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/_core_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
]

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}")
os.rename(pre_built_vllm_path, tmp_path)

print(f"linking {current_vllm_path} to {pre_built_vllm_path}")
os.symlink(current_vllm_path, pre_built_vllm_path)
Loading