Preserve AxisInfo hints on inlined jit call results - #11150
Open
39ali wants to merge 3 commits into
Open
Conversation
ThomasRaoux
reviewed
Aug 3, 2026
Comment on lines
+1452
to
+1476
| def test_jit_call_result_preserves_hints(device): | ||
|
|
||
| @triton.jit | ||
| def get_ptrs(ptr, offsets): | ||
| return ptr + offsets | ||
|
|
||
| @triton.jit | ||
| def kernel(X, Z, BLOCK_SIZE: tl.constexpr): | ||
| offsets = tl.arange(0, BLOCK_SIZE) | ||
| ptrs = get_ptrs(X, offsets) | ||
| ptrs = tl.multiple_of(ptrs, 16) | ||
| ptrs = tl.max_contiguous(ptrs, 16) | ||
| ptrs = tl.max_constancy(ptrs, 1) | ||
| tl.store(Z + offsets, tl.load(ptrs)) | ||
|
|
||
| block_size = 128 | ||
| x = torch.randn(block_size, device=device, dtype=torch.float32) | ||
| z = torch.empty_like(x) | ||
| compiled = kernel[(1, )](x, z, BLOCK_SIZE=block_size, num_warps=1) | ||
|
|
||
| assert torch.equal(z, x) | ||
| ttir = compiled.asm["ttir"] | ||
| ptrs_line = next(line for line in ttir.splitlines() if re.match(r"\s*%ptrs(?:_\d+)? = tt.addptr", line)) | ||
| for hint in ("tt.divisibility", "tt.contiguity", "tt.constancy"): | ||
| assert hint in ptrs_line, ttir |
Collaborator
There was a problem hiding this comment.
can you replace this by a lit test instead
39ali
force-pushed
the
fix-jit-return-hints
branch
from
August 3, 2026 08:18
9da92a6 to
99b81a1
Compare
ThomasRaoux
enabled auto-merge (squash)
August 6, 2026 16:13
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.
Fixes #8592.
tl.multiple_of,tl.max_contiguous, andtl.max_constancyattach theirhint attributes (
tt.divisibility,tt.contiguity,tt.constancy) to theoperation that defines the hinted value. When that value is returned from a
@triton.jithelper function, the defining operation is thett.call— andthe inliner erases the call without transferring the attributes to the
inlined value. The hints were silently dropped, so
AxisInfocould not seethem and the backend missed optimizations such as vectorized loads. Factoring
pointer arithmetic into a helper function silently degraded generated code
even though the kernel author had provided the hints.
Implement
handleResultonTritonInlinerInterfaceso that, when theinliner replaces a call result with the corresponding inlined value, the
AxisInfo hint attributes on the call are copied onto the inlined value's
defining op. This makes hints on jit-call results survive inlining, matching
the behavior of writing the same code without a helper function.
The added end-to-end test applies all three hints to a value returned from a
jitted helper and asserts they are present on the inlined
tt.addptrinTTIR; it fails without this change.
New contributor declaration
I am not making a trivial change, such as fixing a typo in a comment.
I have written a PR description following these
rules.
I have run
pre-commit run --from-ref origin/main --to-ref HEAD.Select one of the following.
/testforlittests/unittestfor C++ tests/python/testfor end-to-end testsFILL THIS IN.Select one of the following.
littests.littests I have added follow these best practices,including the "tests should be minimal" section. (Usually running Python code
and using the instructions it generates is not minimal.)