Skip to content

Fix diff_attn_swa plugin int attribute under TRT 10.16 / NumPy 2.x#49

Draft
ryanontheinside wants to merge 1 commit into
Stability-AI:mainfrom
ryanontheinside:fix/diff-attn-plugin-numpy-attr
Draft

Fix diff_attn_swa plugin int attribute under TRT 10.16 / NumPy 2.x#49
ryanontheinside wants to merge 1 commit into
Stability-AI:mainfrom
ryanontheinside:fix/diff-attn-plugin-numpy-attr

Conversation

@ryanontheinside

Copy link
Copy Markdown

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant