Skip to content

Conversation

rivos-shreeasish
Copy link
Contributor

@rivos-shreeasish rivos-shreeasish commented Sep 15, 2025

Purpose

The GroupReduceMax function causes Undefined Behavior. Existing mask specifies a half-warp causing UB for the upper 16 half of the threads in a warp.

Use threadIdx.x to select the correct mask at runtime.

This change follows a patch to SGLang for the same kernel.

Test Plan

Existing tests cover this kernel.

Test Result

Existing tests including CI should continue passing.


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors.

You ask your reviewers to trigger select CI tests on top of fastcheck CI.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

🚀

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an undefined behavior bug in the GroupReduceMax CUDA function. The original implementation used a fixed mask for __shfl_xor_sync that was only valid for threads in the lower half of a warp, causing UB for threads in the upper half. The fix correctly computes the mask at runtime based on the thread's lane ID within its warp, ensuring that the shuffle operation is always valid. The change also removes an unused parameter from the function signature. The fix is correct and effectively resolves the reported issue. The changes are well-targeted and I have no further suggestions.

@rivos-shreeasish rivos-shreeasish force-pushed the shreeasish/fix-ub-sync branch 4 times, most recently from af95a41 to c5075c1 Compare September 15, 2025 21:05
@simon-mo simon-mo enabled auto-merge (squash) September 17, 2025 01:47
@github-actions github-actions bot added the ready ONLY add when PR is ready to merge/full CI is needed label Sep 17, 2025
auto-merge was automatically disabled September 19, 2025 19:12

Head branch was pushed to by a user without write access

@rivos-shreeasish rivos-shreeasish force-pushed the shreeasish/fix-ub-sync branch 8 times, most recently from 9e57436 to 408a074 Compare September 19, 2025 20:21
The GroupReduceMax function causes Undefined Behavior. Existing mask
specifies a half-warp causing UB for the upper 16 half of the threads in
a warp.

Use threadIdx.x to select the correct mask at runtime.

Signed-off-by: Shreeasish Kumar <shreeasish@rivosinc.com>
@simon-mo simon-mo merged commit 2357480 into vllm-project:main Sep 23, 2025
78 checks passed
FeiDaLI pushed a commit to FeiDaLI/vllm that referenced this pull request Sep 25, 2025
Signed-off-by: Shreeasish Kumar <shreeasish@rivosinc.com>
yewentao256 pushed a commit that referenced this pull request Oct 3, 2025
Signed-off-by: Shreeasish Kumar <shreeasish@rivosinc.com>
Signed-off-by: yewentao256 <zhyanwentao@126.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants