You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Swap the FlashMLA combine kernel launch grid from [batch_size, s_q, h_q / BLOCK_SIZE_M] to [s_q, batch_size, h_q / BLOCK_SIZE_M].
Update the kernel's blockIdx interpretation to preserve the same logical (batch, query, head-block) mapping.
Motivation
This avoids putting large query-token counts on gridDim.y, which can exceed CUDA's grid Y dimension limit for long prefill/decode-style query batches and trigger an invalid launch configuration.
This change, which puts params.b to gridDim.y, may cause really large batches (and I wouldn't rule out someone actually running them, since people have all kinds of weird use cases) being failed to run, I'd prefer to use b * s_q as gridDim.x instead of putting b into gridDim.y as it is now. Would it be convenient for you to make that change?
This change, which puts params.b to gridDim.y, may cause really large batches (and I wouldn't rule out someone actually running them, since people have all kinds of weird use cases) being failed to run, I'd prefer to use b * s_q as gridDim.x instead of putting b into gridDim.y as it is now. Would it be convenient for you to make that change?
sure, that is a simple change. we can also use a static persistent kernel (loop inside), but it doesn't make too much difference currently. I will use what you have suggested for now.
This change, which puts params.b to gridDim.y, may cause really large batches (and I wouldn't rule out someone actually running them, since people have all kinds of weird use cases) being failed to run, I'd prefer to use b * s_q as gridDim.x instead of putting b into gridDim.y as it is now. Would it be convenient for you to make that change?
sure, that is a simple change. we can also use a static persistent kernel (loop inside), but it doesn't make too much difference currently. I will use what you have suggested for now.
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
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.
Summary
[batch_size, s_q, h_q / BLOCK_SIZE_M]to[s_q, batch_size, h_q / BLOCK_SIZE_M].blockIdxinterpretation to preserve the same logical(batch, query, head-block)mapping.Motivation
This avoids putting large query-token counts on
gridDim.y, which can exceed CUDA's grid Y dimension limit for long prefill/decode-style query batches and trigger an invalid launch configuration.Related vLLM issue: vllm-project/vllm#27043
Tests
git diff --check