cmake: add VLLM_XPU_LIBS_ONLY + prebuilt-kernel-lib hooks#345
Draft
jasonboukheir wants to merge 2 commits into
Draft
cmake: add VLLM_XPU_LIBS_ONLY + prebuilt-kernel-lib hooks#345jasonboukheir wants to merge 2 commits into
jasonboukheir wants to merge 2 commits into
Conversation
Adds two CMake-level affordances for build systems that produce the
per-target kernel .so files outside the upstream cmake build
(distributed CI, sccache shards, Bazel, Buck2, Nix per-derivation
builds):
* VLLM_XPU_LIBS_ONLY (OFF by default): when ON, the build configures
and emits the kernel-library targets (attn_kernels_xe_2, ...) but
skips the host-side Python extension modules. Use case: build just
the .so artifacts for caching / sharing between consumers.
* VLLM_XPU_PREBUILT_<NAME>_LIB: a per-library override that wires an
existing .so in as a SHARED IMPORTED target instead of building it
from source. The downstream extension module then links against the
imported target by name. Use case: assemble the final wheel from a
mix of cached / locally-rebuilt kernel libs.
* setup.py forwards VLLM_XPU_PREBUILT_*_LIB env vars through to
cmake-configure so the same overrides work via pip install.
All defaults are no-ops on existing upstream builds: when no option is
set and no _LIB env var is exported, the build is byte-equivalent to
the unpatched tree.
…*_LIB
Libs supplied via the prebuilt-lib hook (added in the parent commit) are
wired in as SHARED IMPORTED targets in CMakeLists.txt and the
corresponding csrc/.../{lib} subdir is intentionally never
add_subdirectory()'d. The build/temp dir for that subdir therefore
doesn't exist, and `cmake --install --component <lib>` fails when it
tries to chdir there.
Skip the install step when the matching VLLM_XPU_PREBUILT_<NAME>_LIB env
var is set — the .so is already in its final location, no install needed.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds two CMake-level affordances for build systems that produce the per-target kernel
.sofiles outside the upstream cmake build (distributed CI, sccache shards, Bazel, Buck2, Nix per-derivation builds).Changes
Commit 1 —
cmake: add VLLM_XPU_LIBS_ONLY + prebuilt-kernel-lib hooksVLLM_XPU_LIBS_ONLY(OFF by default): when ON, the build configures and emits the kernel-library targets (attn_kernels_xe_2, ...) but skips the host-side Python extension modules. Use case: build just the.soartifacts for caching / sharing between consumers.VLLM_XPU_PREBUILT_<NAME>_LIB: a per-library override that wires an existing.soin as aSHARED IMPORTEDtarget instead of building it from source. The downstream extension module then links against the imported target by name. Use case: assemble the final wheel from a mix of cached / locally-rebuilt kernel libs.setup.pyforwardsVLLM_XPU_PREBUILT_*_LIBenv vars through to cmake-configure so the same overrides work viapip install.Commit 2 —
setup.py: skip cmake-install for libs supplied via VLLM_XPU_PREBUILT_*_LIBLibs supplied via the prebuilt-lib hook are wired in as
SHARED IMPORTEDtargets and the correspondingcsrc/.../{lib}subdir is intentionally neveradd_subdirectory()'d, so its build/temp dir doesn't exist forcmake --installto chdir into. Skip the install step in that case — the.sois already in its final location.Backwards compatibility
All defaults are no-ops on existing upstream builds: when no option is set and no
_LIBenv var is exported, the build is byte-equivalent to the unpatched tree.Motivation
This is the minimum surface needed for a Nix per-derivation build that compiles each kernel library independently and assembles them into the final wheel. The same mechanism is useful for any consumer that wants to cache kernel-lib
.soartifacts across builds.Draft — happy to iterate on naming / option style.