Repository navigation
perf(kernels): let triton_op kernels assume TensorRT's tensor alignment - #4875
Open
narendasan wants to merge 1 commit into
Open
narendasan wants to merge 1 commit into
narendasan wants to merge 1 commit into
Conversation
This was referenced Oct 19, 2026
`compile_triton_to_ptx` built its `ASTSource` without `attrs`, so Triton compiled every pointer parameter as possibly unaligned. Under the JIT, any tensor whose `data_ptr()` is 16-byte aligned gets `tt.divisibility=16`, and that specialization is what allows vectorized global loads and stores; the AOT path silently lost it. Memory-bound kernels pay for it: an NVFP4 GEMV that unpacks uint8 weights compiled to `ld.global.b8` and ran ~1.5x slower inside the engine (14.0 us average per call) than the same kernel under the JIT (9.5 us); with this change it matches the JIT, taking a 4B-parameter decode step from 5.21 ms to 4.13 ms on an RTX 5090. The specialization is safe because it is TensorRT's contract: addresses passed to `IExecutionContext::setTensorAddress` must be at least 256-byte aligned, and TensorRT allocates the engine's internal tensors itself. Integer arguments are left unspecialized since nothing guarantees their divisibility. Tests: the ISA-capping stubs now pass a kernel with real argument names (the attrs are keyed by position in the full parameter list, constexprs included), a stub test asserts exactly the pointer parameters are marked, and a real compile asserts an unmasked copy emits `ld.global.v4`. Both new tests fail without the change. `pytest tests/py/kernels`: 247 passed, 34 skipped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
narendasan
force-pushed
the
narendasan/triton-op-alignment
branch
from
November 23, 2026 23:06
d623644 to
36a5d91
Compare
This branch has not been deployed
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.
Summary
compile_triton_to_ptxbuilt Triton'sASTSourcewithoutattrs, so AOT-compiledtriton_opkernels treated every pointer parameter as possibly unaligned. Under the JIT, a tensor whosedata_ptr()is 16-byte aligned getstt.divisibility=16, and that specialization is what allows vectorized global loads and stores; the AOT path silently lost it.IExecutionContext::setTensorAddressmust be at least 256-byte aligned, and TensorRT allocates the engine's internal tensors itself. Integer arguments stay unspecialized, since nothing guarantees their divisibility.ld.global.b8and averaged 14.0 us per call inside the engine vs 9.5 us under the JIT. With this change it matches the JIT, and a 4B-parameter decode step (Nemotron-Labs Dory, RTX 5090) drops from 5.21 ms to 4.13 ms.Tests
pytest tests/py/kernels: 247 passed, 34 skipped.test_pointer_args_specialized_as_aligned(stub: exactly the pointer parameters are marked, at their positions in the full signature) andtest_aot_ptx_uses_vector_loads(real compile: an unmasked copy emitsld.global.v4). Both fail without the change._FakeKernelwith real argument names instead ofobject(), because the attrs are computed fromkernel.arg_names.pytest tests/py/kernels tests/py/dynamo/automatic_plugin/test_automatic_plugin_shape_exprs.pygives 250 passed, 34 skipped.🤖 Generated with Claude Code