fix grid for large uncontiguous input#3666
Open
nastya236 wants to merge 1 commit into
Open
Conversation
zcbenz
approved these changes
Jun 12, 2026
zcbenz
left a comment
Collaborator
There was a problem hiding this comment.
Nice fix!
I think it is worth adding a new utility function to compute the dims, like the get_launch_args but for noncontiguous ones.
Also the test is allocating a large buffer that crashes CI, and likely would also be too slow to run locally. I remember there is a slow test set that run separately, we should move it there, not sure if it is still a thing though @angeloskath
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.
CUDA kernels for non-contiguous tensor operations used a 2D launch grid where y covered all rest dimensions. CUDA limits gridDim.y <= 65,535. This results in errors for large noncontiguous arrays for binary, copy and some unary ops.
For example, for a tensor of shape (16, 8192, 32, 128) -- queries of batch size 16 for qwen 4B:
->
RuntimeError: cudaGraphAddKernelNode(&node, graph_, NULL, 0, ¶ms) failed: invalid argument. Same will be formx.exp(x)and #3659.I split the overflow to
gridDim.z.