Repository navigation
Conversation
SID-6921
requested review from
kevinch-nv and
pkisfaludi-nv
and
a balanced review from Copilot
October 28, 2026 16:00
Author
|
Checking in. This has been open about a week with no review yet. Happy to address any feedback. |
The plugin's own README documents axis as accepting a negative value counting from the back ([-r, r-1]), and ScatterElementsPlugin_PluginConfig.yaml declares axis=-1 as a tested attribute value. But mAxis is stored and passed straight into the kernel with no normalization anywhere in either the current (IPluginV3) or legacy (IPluginV2DynamicExt) implementation. In dispatchScatterElementsKernel, axis=-1 makes the nB loop (bounded by `i < axis`) never run (0 < -1 is false, nB silently stays 1 instead of the correct product of leading dims), and Dims::d[axis] becomes an out-of-bounds read one slot before the fixed-size array instead of the true last-dim size. The result is silent data corruption, not a crash, for any user who scatters along the last axis with axis=-1 -- a common PyTorch/ONNX idiom. Resolve axis to [0, r-1] in enqueue() before use, the same way the sibling topkLastDimPlugin's resolveAxis() already does for this exact hazard. Verified the fix against a hand-traced reference for a rank-3 (2,3,4) tensor with axis=-1 (expected nB=6, nE=4; old code gave nB=1). No CUDA toolchain available in this environment to compile/run the existing plugin test suite; verified via static code reading (confirmed no other normalization exists anywhere in the call chain) and the standalone index-arithmetic reference check described above. Signed-off-by: Siddhardha Nanda <[email protected]>
SID-6921
force-pushed
the
fix/scatter-elements-negative-axis
branch
from
November 19, 2026 03:33
efafe3e to
def4244
Compare
Author
|
Rebased in def4244. The V3 plugin's half of this fix (scatterElementsPlugin.cpp) landed independently in the 11.5 OSS release, with an added bounds-validation check this PR didn't have, so I dropped my duplicate there and kept main's version as-is. The legacy V2 plugin (scatterElementsPluginLegacy.cpp) still passes the unresolved negative axis straight into the kernel, so that fix is still needed and is now the only change left in this PR. |
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.
The plugin's own README documents axis as accepting a negative value counting from the back ([-r, r-1]), and ScatterElementsPlugin_PluginConfig.yaml declares axis=-1 as a tested attribute value. But mAxis is stored and passed straight into the kernel with no normalization anywhere in either the current (IPluginV3) or legacy (IPluginV2DynamicExt) implementation.
In dispatchScatterElementsKernel, axis=-1 makes the nB loop (bounded by
i < axis) never run (0 < -1 is false, nB silently stays 1 instead of the correct product of leading dims), and Dims::d[axis] becomes an out-of-bounds read one slot before the fixed-size array instead of the true last-dim size. The result is silent data corruption, not a crash, for any user who scatters along the last axis with axis=-1 -- a common PyTorch/ONNX idiom.Resolve axis to [0, r-1] in enqueue() before use, the same way the sibling topkLastDimPlugin's resolveAxis() already does for this exact hazard. Verified the fix against a hand-traced reference for a rank-3 (2,3,4) tensor with axis=-1 (expected nB=6, nE=4; old code gave nB=1).
No CUDA toolchain available in this environment to compile/run the existing plugin test suite; verified via static code reading (confirmed no other normalization exists anywhere in the call chain) and the standalone index-arithmetic reference check described above.