optimize mxfp4 cast/transpose#664
Open
matthiasdiener wants to merge 2 commits into
Open
Conversation
Claude reviewReviewed the two-commit optimization in
Copyright headers: OK (both files carry |
|
|
||
| __shared__ uint16_t smem_tile[MXFP4_BLOCK_SIZE][MXFP4_BLOCK_SIZE + SMEM_PADDING]; | ||
|
|
||
| // Staging buffer for the *plain* (unshuffled) columnwise FP4 store. Writing |
Collaborator
There was a problem hiding this comment.
shuffled means shuffled by Hadamard transform?
Contributor
Author
There was a problem hiding this comment.
No, shuffled is the swizzling for the Gemm here.
Collaborator
There was a problem hiding this comment.
Oh, it was that the mxfp4 GEMM in AITER need preshuffled B?
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
Implements two optimizations on the cast/transpose kernel, targeting the inefficient paths:
1. Coalesced columnwise store: The plain (backward) columnwise transpose store was a scattered 16-bit-per-thread write, hitting ~35% write efficiency. It's now staged through LDS (smem_col) and flushed as full 128-bit (uint4) contiguous writes. Gated to the plain-colwise instantiations only (COLWISE_TO_LDS = USE_COLWISE && !SHUFFLE_COLWISE_FP4); rowwise and shuffled-forward paths are unaffected.
2. DPP cross-lane reductions: __shfl_xor was lowering to the LDS-path ds_bpermute on gfx950. Replaced the xor1/xor2 lanes in the amax reduction (warp_reduce_max_8_dpp) and the Hadamard butterfly (hadamard16_inplace) with __builtin_amdgcn_update_dpp permute intrinsics, which fuse into the VALU datapath.
Also fixes a missing columnwise usage flag for MXFP4.
Fixes https://github.com/ROCm/frameworks-internal/issues/16628
Performance results are in https://github.com/ROCm/frameworks-internal/issues/16628#issuecomment-4916784356
Type of change
Changes
Checklist: