[Add] add sycl implementation for dequantize_and_gather_k_cache#447
Open
wangshier108 wants to merge 1 commit into
Open
[Add] add sycl implementation for dequantize_and_gather_k_cache#447wangshier108 wants to merge 1 commit into
wangshier108 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new XPU (SYCL) implementation of dequantize_and_gather_k_cache to support DeepseekV4 SWA prefill, including op registration plus a correctness test and a benchmarking script for Triton vs SYCL comparisons.
Changes:
- Implemented and registered the SYCL kernel and dispatcher entry for
dequantize_and_gather_k_cacheunder_C_cache_ops. - Added a reference implementation + pytest to validate correctness across block sizes and optional
gather_lens. - Added a benchmark script to compare Triton and SYCL performance for representative DeepseekV4 scenarios.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
csrc/cache.cpp |
Adds the SYCL kernel implementation and host-side argument validation/dispatch. |
csrc/ops.h |
Declares the new cache op C++ signature. |
csrc/torch_bindings.cpp |
Registers the new op schema and XPU implementation in PyTorch dispatcher. |
tests/register_ops.py |
Exposes a Python wrapper for calling the new _C_cache_ops op. |
tests/test_cache.py |
Adds a CPU reference + pytest for dequantize_and_gather_k_cache. |
benchmark/bench_xpu_dequantize_and_gather_k_kernel.py |
New benchmark comparing Triton vs SYCL, with optional SYCL validation. |
bench_xpu_dequantize_and_gather_k_kernel.py |
Present as an empty file in the PR context (purpose unclear). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1309
to
+1314
| TORCH_CHECK(offset >= 0, "offset must be >= 0"); | ||
| TORCH_CHECK(offset <= out.size(1), "offset exceeds out token dimension"); | ||
|
|
||
| const int64_t min_block_bytes = | ||
| block_size * vllm::kDeepseekV4TokenDataBytes + | ||
| block_size * vllm::kDeepseekV4ScaleDim; |
Comment on lines
+1
to
+3
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright contributors to the vLLM project | ||
| """Benchmark DeepseekV4 dequantize_and_gather_k_cache on XPU. |
Comment on lines
+23
to
+25
| REPO_ROOT = Path(__file__).resolve().parents[2] | ||
| if str(REPO_ROOT) not in sys.path: | ||
| sys.path.insert(0, str(REPO_ROOT)) |
Comment on lines
+45
to
+52
| sycl_root_arg = _peek_cli_value(argv, "--sycl-kernels-root") | ||
| candidate_root = ( | ||
| REPO_ROOT.parent / "applications.ai.gpu.vllm-xpu-kernels" | ||
| if sycl_root_arg is None | ||
| else Path(sycl_root_arg).resolve() | ||
| ) | ||
| if candidate_root.exists() and str(candidate_root) not in sys.path: | ||
| sys.path.insert(0, str(candidate_root)) |
Comment on lines
+150
to
+152
| def _default_sycl_kernels_root() -> Path | None: | ||
| p = REPO_ROOT.parent / "applications.ai.gpu.vllm-xpu-kernels" | ||
| return p if p.exists() else None |
Comment on lines
+66
to
+69
| from vllm.v1.attention.ops.deepseek_v4_ops.cache_utils import ( | ||
| _dequantize_and_gather_k_kernel, | ||
| dequantize_and_gather_k_cache, | ||
| ) |
Comment on lines
+83
to
+86
| KERNEL_NAME_SUBSTRING = "dequantize_and_gather" | ||
| B60_PEAK_BANDWIDTH_GBPS = 456.0 | ||
| B60_CACHE_SIZE_MB = 512 | ||
|
|
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.
Purpose
Adds SYCL implementation of xpu_v4_gather_k_cache_bf16 used by DeepseekV4 SWA prefill on Intel XPU.
Test Plan
Testing
Benchmark
Test Result
SWA-only (compress_ratio=1, block_size=64)
C4 compressed full gather (compress_ratio=4, block_size=64)
C128 compressed full gather (compress_ratio=128, block_size=2)