Skip to content

Add pre build wheel install for better development experience#188

Open
jikunshang wants to merge 3 commits intovllm-project:mainfrom
jikunshang:kunshang/pre-build
Open

Add pre build wheel install for better development experience#188
jikunshang wants to merge 3 commits intovllm-project:mainfrom
jikunshang:kunshang/pre-build

Conversation

@jikunshang
Copy link
Collaborator

Essential Elements of an Effective PR Description Checklist

  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

PLEASE FILL IN THE PR DESCRIPTION HERE ENSURING ALL CHECKLIST ITEMS ABOVE HAVE BEEN CONSIDERED.

Purpose

reopen #67

usage:

  1. build wheel and install this wheel with dev install
pip wheel --no-build-isolation  . -v 
VLLM_USE_PRECOMPILED=1  pip install --no-build-isolation -e . -v
  1. install a pre build wheel by VLLM_PRECOMPILED_WHEEL_LOCATION
VLLM_USE_PRECOMPILED=1 VLLM_PRECOMPILED_WHEEL_LOCATION=./vllm_xpu_kernels-0.0.1-cp312-cp312-linux_x86_64.whl pip install --no-build-isolation -e . -v

Test Plan

Test Result

(Optional) Documentation Update

BEFORE SUBMITTING, PLEASE READ https://docs.vllm.ai/en/latest/contributing (anything written below this line will be removed by GitHub Actions)

Signed-off-by: Kunshang Ji <kunshang.ji@intel.com>
Signed-off-by: Kunshang Ji <kunshang.ji@intel.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for using pre-built wheels during development installation of vllm-xpu-kernels, allowing developers to skip the compilation step by either specifying a local wheel path or having the setup script download one automatically.

Changes:

  • Adds VLLM_USE_PRECOMPILED and VLLM_PRECOMPILED_WHEEL_LOCATION environment variable support in tools/envs.py
  • Adds precompiled_wheel_utils class and precompiled_build_ext class to setup.py to extract .so files from an existing wheel and bypass CMake builds
  • Moves ext_modules and cmdclass initialization after the precompiled logic block

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
tools/envs.py Defines VLLM_USE_PRECOMPILED env var, auto-enabling it when VLLM_PRECOMPILED_WHEEL_LOCATION is set
setup.py Adds utilities and logic for extracting precompiled binaries from a wheel and skipping the CMake build

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

wheel_filename = wheel_url_or_path.split("/")[-1]
temp_dir = tempfile.mkdtemp(prefix="vllm-wheels")
wheel_path = os.path.join(temp_dir, wheel_filename)
print(f"Downloading wheel from {wheel_url_or_path}"
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

Missing space between the two f-strings — the output will read "...from to " without a space separating the two parts.

Suggested change
print(f"Downloading wheel from {wheel_url_or_path}"
print(f"Downloading wheel from {wheel_url_or_path} "

Copilot uses AI. Check for mistakes.
Comment on lines +427 to +430
print(f"version: get_vllm_version()={get_vllm_version()}")
wheel_location = os.getenv(
"VLLM_PRECOMPILED_WHEEL_LOCATION",
f"./vllm_xpu_kernels-{get_vllm_version()}-cp312-cp312-linux_x86_64.whl"
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

This debug print statement calls get_vllm_version() a second time (it's called again on line 430), which may trigger side effects (e.g., writing _version.py). Consider capturing the result in a variable and printing it instead.

Suggested change
print(f"version: get_vllm_version()={get_vllm_version()}")
wheel_location = os.getenv(
"VLLM_PRECOMPILED_WHEEL_LOCATION",
f"./vllm_xpu_kernels-{get_vllm_version()}-cp312-cp312-linux_x86_64.whl"
vllm_version = get_vllm_version()
print(f"version: get_vllm_version()={vllm_version}")
wheel_location = os.getenv(
"VLLM_PRECOMPILED_WHEEL_LOCATION",
f"./vllm_xpu_kernels-{vllm_version}-cp312-cp312-linux_x86_64.whl"

Copilot uses AI. Check for mistakes.
Comment on lines +428 to +432
wheel_location = os.getenv(
"VLLM_PRECOMPILED_WHEEL_LOCATION",
f"./vllm_xpu_kernels-{get_vllm_version()}-cp312-cp312-linux_x86_64.whl"
)
if wheel_location is not None:
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

os.getenv() with a default value never returns None — when VLLM_PRECOMPILED_WHEEL_LOCATION is not set, it returns the hardcoded default path instead of None. This means the else branch (lines 435–456) that handles downloading from a remote URL is dead code and will never execute.

Suggested change
wheel_location = os.getenv(
"VLLM_PRECOMPILED_WHEEL_LOCATION",
f"./vllm_xpu_kernels-{get_vllm_version()}-cp312-cp312-linux_x86_64.whl"
)
if wheel_location is not None:
wheel_location = os.getenv("VLLM_PRECOMPILED_WHEEL_LOCATION")
if wheel_location:

Copilot uses AI. Check for mistakes.
print(f"version: get_vllm_version()={get_vllm_version()}")
wheel_location = os.getenv(
"VLLM_PRECOMPILED_WHEEL_LOCATION",
f"./vllm_xpu_kernels-{get_vllm_version()}-cp312-cp312-linux_x86_64.whl"
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

The Python version tag cp312-cp312 is hardcoded in the default wheel filename. This will silently use the wrong file on Python 3.11 or other versions. Consider deriving the tag dynamically using sysconfig or sys.version_info.

Copilot uses AI. Check for mistakes.
print(f"Removing temporary directory {temp_dir}")
shutil.rmtree(temp_dir)

# TODO: not used currently.
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

The method is annotated with # TODO: not used currently but is still called on line 444 inside the dead else branch (see Comment 3). This is confusing — the TODO comment and the actual usage are inconsistent. The comment should be removed or updated to reflect the actual intent.

Suggested change
# TODO: not used currently.

Copilot uses AI. Check for mistakes.


ext_modules = []
class precompiled_wheel_utils:
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

Class names should use CapWords (PascalCase) per PEP 8. This class should be named PrecompiledWheelUtils.

Suggested change
class precompiled_wheel_utils:
class PrecompiledWheelUtils:

Copilot uses AI. Check for mistakes.
]).decode("utf-8").strip())
return base_commit
except ValueError as err:
raise ValueError(err) from None
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

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

Re-raising a ValueError while suppressing the original exception chain (from None) discards the original traceback, making debugging harder. Consider using raise to re-raise or raise ValueError(...) from err to preserve the cause.

Suggested change
raise ValueError(err) from None
raise ValueError(err) from err

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@xinyu-intel xinyu-intel left a comment

Choose a reason for hiding this comment

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

fix pre-commit

Signed-off-by: Kunshang Ji <kunshang.ji@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants