[PyTorch] Change arguments order in triton kernels to make jax-triton work#2416
Merged
Conversation
Signed-off-by: tdophung <tdophung@nvidia.com>
Signed-off-by: tdophung <tdophung@nvidia.com>
Collaborator
|
/te-ci L0 |
Contributor
Greptile OverviewGreptile SummaryThis PR reorders arguments in Triton kernels to comply with jax-triton requirements: output pointers now appear after input pointers and strides but before
All PyTorch wrapper calls were updated to pass arguments in the new order, maintaining consistency between kernel signatures and invocations. Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User as User Code
participant PW as PyTorch Wrapper
participant TK as Triton Kernel
Note over User,TK: Example: permute_with_mask_map
User->>PW: permute_with_mask_map(inp, row_id_map, probs, scale, ...)
Note over PW: Prepare arguments in new order:<br/>1. Input pointers<br/>2. Sizes & strides<br/>3. Output pointers<br/>4. tl.constexpr params
PW->>TK: _permute_kernel(<br/> inp, row_id_map, probs, scale, permuted_scale,<br/> scale_hidden_dim, strides...,<br/> output, permuted_probs,<br/> num_experts, hidden_size, flags...)
Note over TK: Execute with jax-triton<br/>compatible argument order
TK-->>PW: Execution complete
PW-->>User: output, permuted_scale, permuted_probs
|
Collaborator
|
LGTM, thanks! but will wait for someone on the TE/PyTorch side to approve |
yaox12
approved these changes
Nov 25, 2025
Member
yaox12
left a comment
There was a problem hiding this comment.
LGTM. This only changes the arguments order of triton kernels, and leave the PyTorch API untouched. So it should be fine on the PyTorch side.
phu0ngng
approved these changes
Nov 25, 2025
13 tasks
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.
Description
Jax-triton needs to have a specific order of arguments for it to work. Specifically, output pointers need to be at the end of the list of arguments, but before all tl.constexpr. This PR changes this order in the common triton kernels and make sure the Pytorch wrappers still work. A different PR will be send out for the Jax side implementation
Fixes # (issue)
Type of change
Changes
Checklist: