Skip to content

enable Docker-aware precompiled wheel setup #22106

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

Conversation

dougbtv
Copy link
Contributor

@dougbtv dougbtv commented Aug 1, 2025

  • Enables VLLM_USE_PRECOMPILED in Docker builds by exposing it as a build arg
  • Adds VLLM_DOCKER_BUILD_CONTEXT env + Dockerfile arg for safe wheel fallback
  • Replaces old repackage_wheel class with precompiled_build_ext to avoid triggering build_ext during pip install -e . with precompiled binaries
  • Refactors wheel unpacking to run before setup() and patch package_data
  • Fixes truthiness of VLLM_USE_PRECOMPILED and new VLLM_DOCKER_BUILD_CONTEXT in envs.py (e.g. VLLM_USE_PRECOMPILED=0 no longer evaluates True)
    Follow up to: Revert precompile wheel changes #22055

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.

Purpose

Improve build times in CI by using precompiled wheels in docker build when necessary (and fix up previous ifs-ands-and-buts as described in header)

Test Plan

  • Docker build with VLLM_USE_PRECOMPILED and VLLM_DOCKER_BUILD_CONTEXT, validate that
  • Validate that the Python-only installation works.

Test Result

Testing steps...

Previously in #22025, the Python-only installation test was failing, see this example build

This improves on #22025, which removed the repackage_wheel method which implemented a build_ext override to use a new method precompiled_build_ext

Built test image target and run:

 $ docker build --file docker/Dockerfile --target test  --build-arg max_jobs=16 --build-arg VLLM_USE_PRECOMPILED=1 --build-arg VLLM_DOCKER_BUILD_CONTEXT=1 --build-arg USE_FLASHINFER_PREBUILT_WHEEL=true --tag localhost/dougbtv/vllm:checkpyinstall-mod-b .
 $ docker run --rm -it --entrypoint=/bin/bash localhost/dougbtv/vllm:checkpyinstall-mod-b
root@10f85567ffd1:/vllm-workspace# ./tests/standalone_tests/python_only_compile.sh 
[...snip...]
Successfully built vllm
Installing collected packages: vllm

  changing mode of /usr/local/bin/vllm to 755
Successfully installed vllm-0.10.1.dev280+g17e6fbe93.d20250801.precompiled
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.
Remote version of pip: 25.2
Local version of pip:  25.2
Was pip installed by pip? True
Removed build tracker: '/tmp/pip-build-tracker-5bgvw0wd'
+ python3 -c 'import vllm'
+ '[' '!' -f /tmp/changed.file ']'
root@10f85567ffd1:/vllm-workspace# echo $?
0

Confirmed docker build contains modified python files, to avoid stale wheel used in previous commits.

Steps:

Modified a file in the local clone...

doug@stimsonmt:~/vllm$ git diff | grep -iP "^[\-\+]"
--- a/vllm/config.py
+++ b/vllm/config.py
-                "Using fp8 data type to store kv cache. It reduces the GPU "
+                "Using fp8 data type to store kv cache. It reduces the GPU !bang"

Built the image:

doug@stimsonmt:~/vllm$ docker build --file docker/Dockerfile --build-arg max_jobs=16 --build-arg VLLM_USE_PRECOMPILED=1 --build-arg VLLM_DOCKER_BUILD_CONTEXT=1 --build-arg USE_FLASHINFER_PREBUILT_WHEEL=true --tag dougbtv/vllm:checkwheel-with-python-install-fixed .

Ran the image and validated the file is present, as well as expected .so binaries from precompiled wheel.

doug@stimsonmt:~/vllm$ docker run --rm -it --entrypoint=/bin/bash dougbtv/vllm:checkwheel-with-python-install-fixed
root@ed8aee6d725a:/vllm-workspace# grep "bang" /usr/local/lib/python3.12/dist-packages/vllm/config.py
                "Using fp8 data type to store kv cache. It reduces the GPU !bang"
root@ed8aee6d725a:/vllm-workspace# find /usr/local/lib/python3.12/dist-packages/vllm/ | grep -i "\.so"
/usr/local/lib/python3.12/dist-packages/vllm/_C.abi3.so
/usr/local/lib/python3.12/dist-packages/vllm/_flashmla_C.abi3.so
/usr/local/lib/python3.12/dist-packages/vllm/_moe_C.abi3.so
/usr/local/lib/python3.12/dist-packages/vllm/cumem_allocator.abi3.so
/usr/local/lib/python3.12/dist-packages/vllm/vllm_flash_attn/_vllm_fa2_C.abi3.so
/usr/local/lib/python3.12/dist-packages/vllm/vllm_flash_attn/_vllm_fa3_C.abi3.so

- Enables `VLLM_USE_PRECOMPILED` in Docker builds by exposing it as a build arg
- Adds `VLLM_DOCKER_BUILD_CONTEXT` env + Dockerfile arg for safe wheel fallback
- Replaces old `repackage_wheel` class with `precompiled_build_ext` to avoid
  triggering `build_ext` during `pip install -e .` with precompiled binaries
- Refactors wheel unpacking to run before `setup()` and patch `package_data`
- Fixes truthiness of `VLLM_USE_PRECOMPILED` and new `VLLM_DOCKER_BUILD_CONTEXT`
  in `envs.py` (e.g. `VLLM_USE_PRECOMPILED=0` no longer evaluates True)

Signed-off-by: dougbtv <[email protected]>
Copy link

github-actions bot commented Aug 1, 2025

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added the ci/build label Aug 1, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly improves the build process by enabling Docker-aware precompiled wheel setups. The refactoring to handle wheel unpacking before setup() and replacing repackage_wheel with precompiled_build_ext are excellent changes that will improve maintainability and fix issues with editable installs. The fixes for environment variable truthiness are also a welcome improvement for robustness.

@mgoin mgoin added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 2, 2025
@dougbtv
Copy link
Contributor Author

dougbtv commented Aug 6, 2025

I believe ci/pr is failing in this run due to a known issue with quant testing, #19458

@simon-mo simon-mo merged commit d1af8b7 into vllm-project:main Aug 10, 2025
82 of 84 checks passed
jingyu-ml pushed a commit to jingyu-ml/vllm that referenced this pull request Aug 11, 2025
aarnphm pushed a commit to aarnphm/vllm that referenced this pull request Aug 13, 2025
paulpak58 pushed a commit to paulpak58/vllm that referenced this pull request Aug 13, 2025
taneem-ibrahim pushed a commit to taneem-ibrahim/vllm that referenced this pull request Aug 14, 2025
BoyuanFeng pushed a commit to BoyuanFeng/vllm that referenced this pull request Aug 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/build ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants