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.
What this fixes
TensorRT 10.16 supplies ONNX integer plugin attributes as one-element NumPy arrays. With
num_heads: int, plugin construction effectively callsint(np.array([H])), which NumPy 2.x rejects:Annotate
num_headsasnpt.NDArray[np.int64], then explicitly extract the Python scalar inside the implementation.Refresh against current main
This PR originally fixed the JIT-only plugin. Since then, upstream added the AOT/PTX and AOT/MMA implementations in #85. I rebased the branch onto current
mainand applied the same conversion at every use boundary:The public plugin attribute remains the ndarray type TensorRT actually supplies; kernel helpers continue receiving ordinary Python integers.
Verification
Tested on Windows with:
10.16.1.112.4.42.9.1+cu128dec_dynamic_triton_swa.onnxCurrent
mainfails during ONNX parsing with the scalar-arrayTypeError. This branch gets through plugin creation, builds the AOT/MMA SAME-L decoder successfully (1.196 GB, dynamic profile 32/56/96), and executes it successfully. Runtime checks covered finite/non-silent output, bit-identical repeat decode of one latent, and distinct output for a different latent.