vllm-xpu-kernels
AGENTS.md80 starsChanged 2 months agoApache-2.0View on GitHub
This file is the shared guidance for AI coding agents working in this repository. Keep tool-specific entry points, such as CLAUDE.md, thin and point them here so the project rules do not drift. vllm-xpu-kernels is a vLLM component that provides optimized custom kernels for Intel GPUs (XPU). Kernels are written in SYCL/DPC++ and use oneDNN and SYCL-TLA where appropriate. The package registers PyTorch custom ops that vLLM can dispatch on Intel GPU hardware. - Prefer current build metadata over stale…
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,774 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
18 rules. About 0 are common, 8 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
Prefer current build metadata over stale docs when versions disagree: pyproject.toml, setup.py, CMakeLists.txt, and tools/envs.py.
- Very specific: line 29
Do not use system python3 or bare pip for project work.
- Very specific: line 31
Create the environment with uv venv --python 3.12 unless a task explicitly targets another supported interpreter.
- Very specific: line 33
Use .venv/bin/python in non-interactive commands because shell activation does not persist across tool calls.
- Distinctive: line 43
Run targeted tests with:
- Distinctive: line 49
Run all pre-commit hooks with:
- Very specific: line 98
If either config variable is unset, CMake currently defaults to the matching *_full.conf preset.
- Distinctive: line 128
Prefer the smallest test that covers the touched kernel, wrapper, or build path.
- Very specific: line 130
Use .venv/bin/python -m pytest ...
- Distinctive: line 141
Keep changes focused and consistent with nearby code.
- Very specific: line 145
All SYCL compilations force-include csrc/sycl_first.h.
- Distinctive: line 147
Avoid broad refactors when adding or fixing a kernel.
- Very specific: line 152
Update KERNEL_CONFIGURATION.md when changing attention kernel config presets, config syntax, or build-time selection behavior.
- Distinctive: line 154
Update README.md only for user-facing behavior or setup changes.
- Distinctive: line 163
Do not revert changes you did not make.
- Distinctive: line 164
Do not commit, create branches, or run destructive git commands unless the user explicitly asks.
- Very specific: line 166
Always sign off commits with git commit -s or an equivalent Signed-off-by: trailer.
- Very specific: line 168
If the user asks for commit text, include appropriate trailers such as Co-authored-by: GitHub Copilot only when requested or consistent …
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file is the shared guidance for AI coding agents working in this
repository. Keep tool-specific entry points, such as CLAUDE.md, thin and point
them here so the project rules do not drift.
Project Overview
vllm-xpu-kernels is a vLLM component that provides optimized custom kernels
for Intel GPUs (XPU). Kernels are written in SYCL/DPC++ and use oneDNN and
SYCL-TLA where appropriate. The package registers PyTorch custom ops that vLLM
can dispatch on Intel GPU hardware.
Source Of Truth
- Prefer current build metadata over stale docs when versions disagree:
pyproject.toml,setup.py,CMakeLists.txt, andtools/envs.py. - Python package metadata currently requires Python
>=3.9,<3.14; CMake still searches3.9through3.12, so verify interpreter support before changing build behavior. - PyTorch XPU support is currently
2.15.0+xpuinpyproject.toml, with CMake expecting torch2.15.0for XPU. Install fromhttps://download.pytorch.org/whl/xpu. - oneAPI 2026.0 is the expected toolchain. Source
/opt/intel/oneapi/setvars.shbefore building native extensions.
Environment And Commands
- Do not use system
python3or barepipfor project work. Useuvand the repository virtualenv. - Create the environment with
uv venv --python 3.12unless a task explicitly targets another supported interpreter. - Use
.venv/bin/pythonin non-interactive commands because shell activation does not persist across tool calls. - Install lint tooling with
uv pip install pre-commitand runpre-commit installwhen setting up a fresh checkout. - For editable development installs, use:
uv pip install --no-build-isolation -e .- Run targeted tests with:
.venv/bin/python -m pytest tests/path/to/test_file.py -v- Run all pre-commit hooks with:
pre-commit run --all-filesBuild System
setup.pydrives CMake through a customcmake_build_extcommand.CMakeLists.txtdefines extension targets and native SYCL/SYCL-TLA build options.pyproject.tomldefines Python metadata, build dependencies, and formatter or lint configuration.- Native builds require CMake
>=3.26, Ninja, oneAPIicx/icpx, PyTorch XPU, and sufficient memory. The build estimates parallel jobs assuming about 8 GB per compile process.
Important build environment variables:
MAX_JOBS: override compile parallelism.CMAKE_BUILD_TYPE:Debug,Release, orRelWithDebInfo.VLLM_USE_PRECOMPILED=1: extract precompiled shared objects instead of building from source.VLLM_PRECOMPILED_WHEEL_LOCATION: local or remote wheel for precompiled extraction.VERBOSE=1: enable verbose CMake makefile output.BUILD_SYCL_TLA_KERNELS: enable or disable SYCL-TLA based kernels.VLLM_XPU_ENABLE_XE2andVLLM_XPU_ENABLE_XE3P: architecture-family toggles.BASIC_KERNELS_ENABLED,FA2_KERNELS_ENABLED,MOE_KERNELS_ENABLED,GDN_KERNELS_ENABLED,MQA_LOGITS_KERNELS_ENABLED,XPU_SPECIFIC_KERNELS_ENABLED,XPUMEM_ALLOCATOR_ENABLED: extension or kernel-family toggles forwarded fromsetup.pyto CMake.VLLM_XPU_ENABLE_ONEDNN: enable or disable the oneDNN-backed GEMM kernels in the_xpu_Cextension (fp8/int4/fp4 GEMM ops andget_onednn_version). When disabled, oneDNN is not fetched or linked and the ops are still registered but raise a runtime error instructing the user to rebuild withVLLM_XPU_ENABLE_ONEDNN=ON.VLLM_CHUNK_PREFILL_CONFIG: selects the chunk prefill attention kernel config used for prompt processing. Accepts a preset name with or without the.confsuffix fromcsrc/xpu/attn/kernel_configs/, or an absolute path to a custom config file. Current presets arechunk_prefill_default.conffor common Llama, Qwen, DeepSeek, and Falcon coverage, andchunk_prefill_full.conffor all supported variants.VLLM_PAGED_DECODE_CONFIG: selects the paged decode attention kernel config used for token generation. It follows the same preset-name or absolute-path rules. Current presets arepaged_decode_default.conffor common Llama, Qwen, DeepSeek, and Falcon coverage, andpaged_decode_full.conffor all supported variants.- If either config variable is unset, CMake currently defaults to the matching
*_full.confpreset. Use the*_default.confpresets to reduce compile time when broad model coverage is not needed. VLLM_XPU_AOT_DEVICESandVLLM_XPU_XE2_AOT_DEVICES: override AOT target devices. Empty values intentionally disable AOT for the corresponding set.VLLM_CUTLASS_SRC_DIR: use a local SYCL-TLA checkout instead of FetchContent.
Architecture Notes
The build produces Python extension modules under vllm_xpu_kernels/:
| Module | Main sources | Purpose |
_C | csrc/*.cpp, csrc/quantization/** | Core ops such as RMS norm, activations, RoPE, cache ops, quantization, tensor utilities, memory info, and top-k per row. |
_vllm_fa2_C | csrc/flash_attn/*.cpp, csrc/xpu/attn/** | Flash attention and variable-length attention interfaces. |
_moe_C | csrc/moe/*.cpp | MoE ops such as align, gather, sum, grouped top-k, and fused grouped top-k. |
_xpu_C | csrc/xpu/*.cpp and subdirectories | XPU-specific ops such as LoRA, grouped GEMM, GDN attention, MQA logits, samplers, and RoPE variants. |
xpumem_allocator | csrc/utils/mem_alloc.cpp | XPU memory allocator hooks with Python callbacks. |
Op registration generally follows this pattern:
- Declare signatures in
csrc/ops.hor the relevant module header. - Implement CPU-hosted binding logic and SYCL kernels in
csrc/**. - Register schemas and dispatch with
TORCH_LIBRARY_EXPANDor related PyTorch dispatcher macros intorch_bindings.cppfiles. - Exercise Python-facing behavior through
torch.ops._C.*,torch.ops._xpu_C.*, or wrapper modules invllm_xpu_kernels/.
Testing Guidance
- Prefer the smallest test that covers the touched kernel, wrapper, or build path.
- Use
.venv/bin/python -m pytest ...for Python tests. - GPU tests may require Intel hardware and Level Zero access; if unavailable, state that clearly instead of treating failures as code failures.
- Useful test environment variables include
ZE_AFFINITY_MASK,SKIP_HANG_KERNEL=1,SKIP_ACC_ERROR_KERNEL=1, andXPU_KERNEL_PYTEST_PROFILER=MINI. tests/register_ops.pyis useful for checking op registration and dispatch expectations.
Code Style
- Keep changes focused and consistent with nearby code.
- Python uses yapf and ruff with an 80-column target from
pyproject.toml. - C++ and SYCL code use the repository
.clang-formatconfiguration. - CMake is checked by cmake-format and cmake-lint.
- All SYCL compilations force-include
csrc/sycl_first.h; keep direct SYCL include changes compatible with that setup. - Avoid broad refactors when adding or fixing a kernel. Update tests and docs only where they directly support the change.
Documentation And Release Notes
- Update
KERNEL_CONFIGURATION.mdwhen changing attention kernel config presets, config syntax, or build-time selection behavior. - Update
README.mdonly for user-facing behavior or setup changes. - Release-note files are version-specific; do not edit old release notes unless the task explicitly asks for it.
custom-kernels-inventory.mdtracks registered custom kernels. Update it when adding, removing, or renaming Python-visible ops.
Git Hygiene
- The working tree may contain unrelated user changes or generated artifacts. Do not revert changes you did not make.
- Do not commit, create branches, or run destructive git commands unless the user explicitly asks.
- Always sign off commits with
git commit -sor an equivalentSigned-off-by:trailer. - If the user asks for commit text, include appropriate trailers such as
Co-authored-by: GitHub Copilotonly when requested or consistent with their workflow.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

