Repository navigation
CUDA : fix PAD for more than 65535 rows or slices - #30102
Closed
pskrunner14 wants to merge 1 commit into
Closed
pskrunner14 wants to merge 1 commit into
pskrunner14 wants to merge 1 commit into
Conversation
Contributor
|
This is overengineered, just always do the looped version for ops that aren't performance critical. |
Contributor
Author
|
@JohannesGaessler understood. I'll submit the looped version |
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.
Overview
CUDA
GGML_OP_PADkernel puts the output's row count ingridDim.yand its slice count (ne2*ne3) ingridDim.z. CUDA limits both to 65535. When a padded tensor exceeds either limit, the launch fails withinvalid configuration argumentand ggml aborts. The CPU backend handles the same shapes correctly.ggml/src/ggml-cuda/pad.cu,pad_f32_cuda():The kernel reads
i1 = blockIdx.yandi2/i3fromblockIdx.z, so the grid has to cover the tensor exactly. Anyne1 > 65535orne2*ne3 > 65535(counted on the padded output) cannot be launched.The fix in this PR:
Additional information
How to reproduce
Environment: RTX A5000 (sm_86), driver 580.173, CUDA 12.8, at upstream
926862e.New
test-backend-opseval cases:On unmodified
master,build/bin/test-backend-ops -o PAD -b CUDA0passes the existing cases, then aborts on the first new one:How we hit this bug
Nemotron speech encoder's causal conv subsampling pads a [T, F, 256, B] tensor (256 conv channels, batch B). Batch 255 is the largest that launches on master, batch 256 gives
ne2 * ne3 = 65536and aborts.Perf Impact
Rows narrower than a block get 5-10% faster because out of range threads now exit before computing the slice index.
Correctness: all 37 PAD cases pass on CUDA0 (compared against CPU), including the 3 new ones.
Requirements