Fix diff_attn_swa plugin int attribute under TRT 10.16 / NumPy 2.x#49
Draft
ryanontheinside wants to merge 1 commit into
Draft
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
TensorRT serializes plugin attributes as 1-element numpy arrays and calls
the annotated type on them when instantiating the plugin. With the
`num_heads: int` annotation this hits `int(np.array([H]))`, which NumPy
(>=1.25 deprecation, error in 2.x) rejects:
tensorrt_bindings/plugin/_lib.py:279, in create_plugin
attrs[f.name] = attr_type_annot(f.data)
TypeError: only 0-dimensional arrays can be converted to Python scalars
so any build or load of an engine using samel::diff_attn_swa (the SAME-L
decoder) crashes. Annotate the attribute as npt.NDArray[np.int64] and
coerce to a Python int inside the impl. Verified end-to-end on TRT
10.16.1.11 + NumPy 2.4.4: the attr arrives as ndarray, the kernel output
is unchanged.
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.
TensorRT serializes plugin attributes as 1-element numpy arrays and calls the annotated type on them when instantiating the plugin. With the
num_heads: intannotation this hitsint(np.array([H])), which NumPy (>=1.25 deprecation, error in 2.x) rejects:so any build or load of an engine using samel::diff_attn_swa (the SAME-L decoder) crashes. Annotate the attribute as npt.NDArray[np.int64] and coerce to a Python int inside the impl. Verified end-to-end on TRT 10.16.1.11 + NumPy 2.4.4: the attr arrives as ndarray, the kernel output is unchanged.