[BugFix][310p]Fix Triton kernel in block_table crash that caused failures - #8085
Conversation
…ures running on 310p Signed-off-by: Tflowers-0129 <2906339855@qq.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical runtime crash occurring on 310P devices caused by the incorrect invocation of Triton kernels. By introducing a dedicated block table management system for 310P, the PR ensures that the execution path remains compatible with the hardware's limitations, effectively bypassing unsupported kernel calls while maintaining correct KV cache slot mapping. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new block table management system for 310P hardware, comprising BlockTable and MultiGroupBlockTable classes to handle physical/logical block mapping, distributed processing, and KV cache interleaving. The NPUModelRunner310 is updated to integrate this new system, and comprehensive unit tests are added for the BlockTable's compute_slot_mapping method. Feedback includes a high-severity suggestion to optimize the _convert_physical_to_logical_blocks method using NumPy broadcasting for improved efficiency, and another high-severity comment addressing a potential bug in MultiGroupBlockTable's constructor due to shallow copying of mutable lists.
I am having trouble creating individual review comments. Click here to see my feedback.
vllm_ascend/_310p/block_table.py (203-208)
The current implementation for converting physical to logical blocks uses a Python loop and list appends, which can be inefficient for large arrays. You can achieve the same result more efficiently using NumPy broadcasting, which is significantly faster as it operates in compiled C code.
# Reshape for broadcasting
physical_blocks_col = physical_blocks.reshape(-1, 1)
# Create offsets for each physical block
offsets = np.arange(self.blocks_per_phys_block, dtype=np.int32)
# Broadcast and flatten
return (physical_blocks_col * self.blocks_per_phys_block + offsets).ravel()
vllm_ascend/_310p/block_table.py (239-246)
Using * to multiply a list containing mutable objects (like lists) creates shallow copies. This means that all elements in the resulting list will reference the same object.
For example:
[[0]] * len(block_sizes)on line 240 creates a list where all elements are the same[0]list object.kernel_sizes * len(block_sizes)on line 242 does the same ifkernel_sizesis[[...]].
If any of these inner lists are modified later, it will affect all of them, leading to unexpected bugs.
To prevent this, you should use list comprehensions to create new list objects for each element.
if kernel_sizes is None:
kernel_sizes = [[0] for _ in range(len(block_sizes))]
elif len(kernel_sizes) == 1 and len(block_sizes) > 1:
kernel_sizes = [list(kernel_sizes[0]) for _ in range(len(block_sizes))]
elif len(kernel_sizes) != len(block_sizes):
raise ValueError(
f"kernel_sizes length ({len(kernel_sizes)}) must match block_sizes length ({len(block_sizes)})"
)
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. |
adb2bcb to
d97cd1e
Compare
…ures (vllm-project#8085) ### What this PR does / why we need it? 310P devices do not support Triton kernels. Due to incomplete CI coverage, the 310P execution path can incorrectly enter Triton kernels, causing runtime crashes on 310P. This PR fixes the issue. - vLLM version: - vLLM main: https://github.com/vllm-project/vllm/commit/v0.19.0 --------- Signed-off-by: Tflowers-0129 <2906339855@qq.com>
…ures (vllm-project#8085) ### What this PR does / why we need it? 310P devices do not support Triton kernels. Due to incomplete CI coverage, the 310P execution path can incorrectly enter Triton kernels, causing runtime crashes on 310P. This PR fixes the issue. - vLLM version: - vLLM main: https://github.com/vllm-project/vllm/commit/v0.19.0 --------- Signed-off-by: Tflowers-0129 <2906339855@qq.com> Signed-off-by: guxin108 <1252896542@qq.com>
…ures (vllm-project#8085) ### What this PR does / why we need it? 310P devices do not support Triton kernels. Due to incomplete CI coverage, the 310P execution path can incorrectly enter Triton kernels, causing runtime crashes on 310P. This PR fixes the issue. - vLLM version: - vLLM main: https://github.com/vllm-project/vllm/commit/v0.19.0 --------- Signed-off-by: Tflowers-0129 <2906339855@qq.com> Signed-off-by: zouyida2052 <zouyida2002@gmail.com>
…ures (vllm-project#8085) ### What this PR does / why we need it? 310P devices do not support Triton kernels. Due to incomplete CI coverage, the 310P execution path can incorrectly enter Triton kernels, causing runtime crashes on 310P. This PR fixes the issue. - vLLM version: - vLLM main: https://github.com/vllm-project/vllm/commit/v0.19.0 --------- Signed-off-by: Tflowers-0129 <2906339855@qq.com>
…ures (vllm-project#8085) ### What this PR does / why we need it? 310P devices do not support Triton kernels. Due to incomplete CI coverage, the 310P execution path can incorrectly enter Triton kernels, causing runtime crashes on 310P. This PR fixes the issue. - vLLM version: - vLLM main: https://github.com/vllm-project/vllm/commit/v0.19.0 --------- Signed-off-by: Tflowers-0129 <2906339855@qq.com> Signed-off-by: nanxing <1014662416@qq.com>
…ures (vllm-project#8085) ### What this PR does / why we need it? 310P devices do not support Triton kernels. Due to incomplete CI coverage, the 310P execution path can incorrectly enter Triton kernels, causing runtime crashes on 310P. This PR fixes the issue. - vLLM version: - vLLM main: https://github.com/vllm-project/vllm/commit/v0.19.0 --------- Signed-off-by: Tflowers-0129 <2906339855@qq.com>
…ures (vllm-project#8085) ### What this PR does / why we need it? 310P devices do not support Triton kernels. Due to incomplete CI coverage, the 310P execution path can incorrectly enter Triton kernels, causing runtime crashes on 310P. This PR fixes the issue. - vLLM version: - vLLM main: https://github.com/vllm-project/vllm/commit/v0.19.0 --------- Signed-off-by: Tflowers-0129 <2906339855@qq.com>
What this PR does / why we need it?
310P devices do not support Triton kernels. Due to incomplete CI coverage, the 310P execution path can incorrectly enter Triton kernels, causing runtime crashes on 310P. This PR fixes the issue.
Does this PR introduce any user-facing change?
NA
How was this patch tested?
ut and e2e tests