Repository navigation
[PyTorch] Fuse BHSD permute and GEMM swizzle of MXFP8 attention scales - #3757
Open
sraman-rgb wants to merge 1 commit into
Open
sraman-rgb wants to merge 1 commit into
sraman-rgb wants to merge 1 commit into
Conversation
mxfp8_transpose_swizzle permutes the MXFP8 scales of the attention inputs from SBHD/BSHD to BHSD with multi_tensor_transpose_to_bhsd and then swizzles them for the GEMM with multi_tensor_swizzle_scales_for_gemm_, two kernels per direction. A Triton kernel per direction now reads the source layout and writes the swizzled BHSD layout directly, for up to three tensors in one launch, with byte-identical scales. The fused kernels are used when Triton is available, there are at most three tensors, the sequence length is a multiple of 128 and the columnwise scale rows are a multiple of 4; otherwise the existing kernels run. Signed-off-by: Siddhartha Raman S <sraman@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryThis PR combines the BHSD transpose and GEMM swizzle of MXFP8 attention scales to reduce kernel launches.
No actionable issues were found. Tests were inspected but not run. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[MXFP8 attention scales] --> B{Triton available and shapes supported?}
B -->|Yes| C[Fused BHSD transpose and swizzle]
B -->|No| D[Existing BHSD transpose]
D --> E[Existing GEMM swizzle]
C --> F[Swizzled scales for attention]
E --> F
Reviews (1) · Last reviewed commit: "[PyTorch] Fuse BHSD permute and GEMM swi..." · Reviewed by Greptile |
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.
mxfp8_transpose_swizzle permutes the MXFP8 scales of the attention inputs from SBHD/BSHD to BHSD with multi_tensor_transpose_to_bhsd and then swizzles them for the GEMM with multi_tensor_swizzle_scales_for_gemm_, two kernels per direction. A Triton kernel per direction now reads the source layout and writes the swizzled BHSD layout directly, for up to three tensors in one launch, with byte-identical scales.
The fused kernels are used when Triton is available, there are at most three tensors, the sequence length is a multiple of 128 and the columnwise scale rows are a multiple of 4; otherwise the existing kernels run.
Description
Please include a brief summary of the changes, relevant motivation and context.
Fixes # (issue)
Type of change
Changes
Please list the changes introduced in this PR:
Checklist: