Skip to content

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

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

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

@ryanontheinside ryanontheinside commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

What this fixes

TensorRT 10.16 supplies ONNX integer plugin attributes as one-element NumPy arrays. With num_heads: int, plugin construction effectively calls int(np.array([H])), which NumPy 2.x rejects:

TypeError: only 0-dimensional arrays can be converted to Python scalars

Annotate num_heads as npt.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 main and applied the same conversion at every use boundary:

  • plugin descriptor
  • JIT implementation
  • AOT implementation, before selecting/building either MMA or scalar PTX

The public plugin attribute remains the ndarray type TensorRT actually supplies; kernel helpers continue receiving ordinary Python integers.

Verification

Tested on Windows with:

  • TensorRT 10.16.1.11
  • NumPy 2.4.4
  • PyTorch 2.9.1+cu128
  • RTX 5090 / SM 12.0
  • official dec_dynamic_triton_swa.onnx

Current main fails during ONNX parsing with the scalar-array TypeError. 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.

@ryanontheinside
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.
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