Support block_ptr/TensorDescriptor with extra_mask for loads#1768
Merged
jansel merged 16 commits intopytorch:mainfrom Mar 26, 2026
Merged
Support block_ptr/TensorDescriptor with extra_mask for loads#1768jansel merged 16 commits intopytorch:mainfrom
jansel merged 16 commits intopytorch:mainfrom
Conversation
5f730cf to
09ecc7c
Compare
jansel
requested changes
Mar 20, 2026
Contributor
jansel
left a comment
There was a problem hiding this comment.
I think if we always decompose these it will be a performance regression for non-block ptrs.
I also worry this will interact badly with the existing mask_to op and optimizations to remove masks. (We propagate masking information.)
Maybe we should also do this pass at codegen time and only if block pointers are chosen for the given op.
Collaborator
Author
|
These are all very good points and I appreciate the broader context. Sounds to me like next steps in the right direction would be:
anything you would like to add? |
Collaborator
Author
|
Made changes based on your feedback @jansel. Assuming this looks good, would you want me to add support to lower rank masks in a future PR? e.g. |
Collaborator
Author
|
@jansel all tests are passing. |
jansel
approved these changes
Mar 26, 2026
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.
Addresses #97
This is definitely somewhat of a new area for me and changes are based on my interpretation of the #97 description. Looking for some valuable feedback here to ensure there isn't something I missed or should approach from a different angle.
Approach
This enables
block_ptrandTensorDescriptorsupport forhl.load(..., extra_mask=...). Previously, this would fallback to pointer indexing but this approach decomposes the mask into a separate epilogue (along withaten.viewfor cases where rank differs).Before:
After:
For non-matching mask rank
Before:
After: