CUDA: support non-contiguous rows in L2_NORM#26026
Open
MagicalFlames wants to merge 1 commit into
Open
Conversation
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
The L2_NORM CUDA kernel assumed contiguous rows: it read
x[col]directly and was guarded byGGML_ASSERT(nb00 == ts0)plusggml_is_contiguous_rowsinsupports_op. As a result,test-backend-opscases withnoncontig_rows=1were reported as not supported.This PR adds an inner-row stride to the kernel so it indexes elements via
x[col*stride_col], passes the stride down fromggml_cuda_op_l2_norm, and relaxes the support check forL2_NORM.Additional information
Testing with
test-backend-ops test -o L2_NORMon an RTX 3050 (sm_86, CUDA 13.0) shows improvement from 20/20 tests (with 10noncontig_rowscases skipped as not supported) to 30/30 passed, including allnoncontig_rows=1cases.Requirements