Fix diff_attn_swa plugin int attribute under TRT 10.16 / NumPy 2.x - #49
Open
ryanontheinside wants to merge 1 commit into
Open
Fix diff_attn_swa plugin int attribute under TRT 10.16 / NumPy 2.x#49ryanontheinside wants to merge 1 commit into
ryanontheinside wants to merge 1 commit into
Conversation
ryanontheinside
marked this pull request as ready for review
July 10, 2026 11:38
TensorRT 10.16 supplies ONNX integer attributes as one-element NumPy arrays. Annotating num_heads as int therefore asks NumPy 2.x to convert a non-scalar array directly and plugin creation fails before the ONNX can be parsed. Keep the ndarray annotation TensorRT expects and explicitly extract the Python integer inside both the JIT and newer AOT implementations. This rebases the original fix onto current main after the AOT/MMA plugin work.
ryanontheinside
force-pushed
the
fix/diff-attn-plugin-numpy-attr
branch
from
August 3, 2026 14:24
145a538 to
c076985
Compare
This was referenced Aug 3, 2026
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.
Summary
Under TensorRT 10.16 / NumPy 2.x, scalar ONNX integer attributes deserialize
as one-element NumPy arrays. The sliding-window-attention plugin annotates
num_headsasint, so plugin construction fails while parsing the officialsame-L decoder ONNX, before any engine can be built. This change accepts the
serialized NumPy representation and converts it to a Python int in both the
JIT and AOT plugin implementations.
Scope
Plugin attribute handling only: no change to the attention math, engine
profiles, ONNX graph, or outputs. Branch is based on current
main.Validation
Environment: Windows 11, RTX 5090 (SM120), TensorRT 10.16.1.11, NumPy 2.4.4,
PyTorch 2.9.1+cu128, official
same-l/dec_dynamic_triton_swa.onnx.mainreproduces the failure viabuild_from_onnx.py same-l-decoder:TypeError: only 0-dimensional arrays can be converted to Python scalars(28 s, 1196 MB),
SA3_SWA_AOT=ptx, andSA3_SWA_PLUGIN=jitand T=1292/4096: finite, non-constant, bit-identical on repeat,
sensitive to changed input
rel_rms ~6e-3; AOT/MMA vs JIT ~9e-3; each <=1.4e-2 vs the eager
reference decoder
tensorrt-cu12-libsfor10.15.1.29; left to CI/maintainers)