Skip to content

cmake: add VLLM_XPU_LIBS_ONLY + prebuilt-kernel-lib hooks#345

Draft
jasonboukheir wants to merge 2 commits into
vllm-project:mainfrom
jasonboukheir:split-kernel-libs
Draft

cmake: add VLLM_XPU_LIBS_ONLY + prebuilt-kernel-lib hooks#345
jasonboukheir wants to merge 2 commits into
vllm-project:mainfrom
jasonboukheir:split-kernel-libs

Conversation

@jasonboukheir
Copy link
Copy Markdown
Contributor

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

Changes

Commit 1 — cmake: add VLLM_XPU_LIBS_ONLY + prebuilt-kernel-lib hooks

  • 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.

Commit 2 — setup.py: skip cmake-install for libs supplied via VLLM_XPU_PREBUILT_*_LIB

Libs supplied via the prebuilt-lib hook are wired in as SHARED IMPORTED targets and the corresponding csrc/.../{lib} subdir is intentionally never add_subdirectory()'d, so its build/temp dir doesn't exist for cmake --install to chdir into. Skip the install step in that case — the .so is already in its final location.

Backwards compatibility

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.

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 .so artifacts across builds.

Draft — happy to iterate on naming / option style.

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.
@jasonboukheir jasonboukheir marked this pull request as ready for review May 13, 2026 21:21
@jasonboukheir jasonboukheir marked this pull request as draft May 14, 2026 06:19
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.

1 participant