[GPU] fix to embedding_bag_ref kernel - #37371
Draft
Roszczyk wants to merge 2 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes indexing/offset handling in the Intel GPU OpenCL reference kernel for embedding_bag, addressing incorrect double-application of INPUT1_OFFSET in offsets-based mode and incorrect offset selection for per-sample weights in segments-based mode.
Changes:
- Fix
OFFSETS_SUMstart/end range computation to avoid addingINPUT1_OFFSETtwice. - Fix
SEGMENTS_SUMper-sample weights indexing to useINPUT4_OFFSET(weights input) instead ofINPUT3_OFFSET.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/plugins/intel_gpu/src/kernel_selector/cl_kernels/embedding_bag_ref.cl:122
- [HIGH] Add a weighted
segments_sumregression test where the weights tensor has a different physical offset from input 3. The current weighted test uses dense tensors (embedding_bag_gpu_test.cpp:776-777), making both offsets zero, so it cannot distinguishINPUT3_OFFSETfromINPUT4_OFFSETand would not catch the original bug.
uint weight_index = INPUT4_OFFSET + i;
src/plugins/intel_gpu/src/kernel_selector/cl_kernels/embedding_bag_ref.cl:56
- [HIGH] Add a regression test that runs
offsets_sumwith a non-zero physical offset on the indices tensor. The existing GPU tests allocate dense, unpadded indices (for example,embedding_bag_gpu_test.cpp:376), soINPUT1_OFFSETis zero and they pass with both the old double-offset calculation and this fix. A padded/cropped indices input is needed to prove the corrected addressing and prevent this bug from returning.
uint start_indices = offsets[offsets_ind];
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.
Details:
INPUT1_OFFSETwas added twice. First, tostart_indicesand toend_indices, which are the range of the for loop and later toiin the same for loop. So finallyindices_indexwas equal2*INPUT1_OFFSET+offsets[offsets_ind]INPUT3_OFFSETwas used to calculateweight_indexwhileINPUT4_OFFSETrepresents the offset for weights. SettingINPUT3is not required, and the check is set only to checking ifINPUT4is set, so it even might result in some crashes (INPUT3_OFFSETnot declared).Tickets:
AI