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

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_heads as int, so plugin construction fails while parsing the official
same-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.

  • Unmodified main reproduces the failure via
    build_from_onnx.py same-l-decoder:
    TypeError: only 0-dimensional arrays can be converted to Python scalars
  • This branch builds the official same-L decoder with default AOT/MMA
    (28 s, 1196 MB), SA3_SWA_AOT=ptx, and SA3_SWA_PLUGIN=jit
  • All three engines execute at latent T=32/56/96 (real SA3-medium latent)
    and T=1292/4096: finite, non-constant, bit-identical on repeat,
    sensitive to changed input
  • Cross-implementation numerics on real latents: AOT/MMA vs AOT/PTX
    rel_rms ~6e-3; AOT/MMA vs JIT ~9e-3; each <=1.4e-2 vs the eager
    reference decoder
  • Ruff clean
  • TensorRT 10.15 (pip publishes no Windows tensorrt-cu12-libs for
    10.15.1.29; left to CI/maintainers)
  • SM90/Hopper JIT (no Hopper hardware available here)
  • CUDA-graph capture/replay across changing inputs

@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