Skip to content

[Fix][TOPI] Fuse GPU sort grid dimensions to avoid CUDA launch failures on large inputs#19938

Open
bujjibabukatta wants to merge 1 commit into
apache:mainfrom
bujjibabukatta:fix/19549-fuse-sort-grid-dims
Open

[Fix][TOPI] Fuse GPU sort grid dimensions to avoid CUDA launch failures on large inputs#19938
bujjibabukatta wants to merge 1 commit into
apache:mainfrom
bujjibabukatta:fix/19549-fuse-sort-grid-dims

Conversation

@bujjibabukatta

Copy link
Copy Markdown

The GPU sort/topk kernels currently map nthread_bx to blockIdx.x and nthread_by to blockIdx.y. For large inputs (e.g. topk on a tensor of shape (60, 1000, 1000)), the product nthread_by * nbz can easily exceed 65535 which is the hardware limit for gridDim.y on CUDA, causing CUDA_ERROR_INVALID_VALUE at kernel launch.

This patch fuses the two block dimensions into a single blockIdx.x axis (limit 2^31-1) and reconstructs virtual bx/by indices inside the kernel with modulo and integer division. All five call sites of _get_threads are updated consistently.

Fixes #19549

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug][Relax][CUDA] topk on large input launches kernel with invalid gridDim.y and fails with CUDA_ERROR_INVALID_VALUE

1 participant