[CUDA] Fix qmm_naive K-tail dispatch for FP quantized kernels#3445
Open
Lyxot wants to merge 2 commits intoml-explore:mainfrom
Open
[CUDA] Fix qmm_naive K-tail dispatch for FP quantized kernels#3445Lyxot wants to merge 2 commits intoml-explore:mainfrom
Lyxot wants to merge 2 commits intoml-explore:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a CUDA quantized-matmul (qmm_naive) dispatch bug where the wrong K-tail specialization was chosen for FP-quantized modes by aligning the residue check with the kernel’s actual K tiling (max(64, group_size)), addressing issue #3444.
Changes:
- Compute
tile_k = max(64, group_size)insideqmm_naive. - Change the
HasKResiduedispatch condition fromk % group_sizetok % tile_k.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Fixes: #3444
Root Cause
In qmm.cu,
qmm_naiveselected theHasKResiduespecialization using:but the kernel tiles the K dimension using
max(64, group_size).For FP quantization modes:
mxfp4/mxfp8usegroup_size = 32nvfp4usesgroup_size = 16So shapes like
K=544satisfy:K % group_size == 0K % 64 != 0The old dispatch therefore selected the no-residue specialization even when the kernel still had a real K tail.
Fix
Change the residue check to match the kernel's actual K tiling