fix: remove force nt path in tensorwise grouped gemm - #437
Open
RuibinCheung wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR simplifies the FP8 grouped GEMM (TENSORWISE) autograd path by removing the MI350/MI450-era backward workaround that forced an NT-layout code path. It standardizes backward grad_a computation to always use the original call form (trans_b=not ctx.trans_b) and always saves the untransposed quantized weight for backward.
Changes:
- Removed the architecture-gated
_deter_use_nt_layout_gemm_in_bwdhelper and the related gfx942 check/import. - Simplified
FP8GroupedGemmTensorFunc.forwardto always savequantized_b(dropping the transposed-weight cache branch). - Simplified
FP8GroupedGemmTensorFunc.backwardto a singlegrad_acall path usingtrans_b=not ctx.trans_b.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
The non-NT layout grouped GEMM backends (triton and flydsl) are now performant enough on MI350 , so this workaround is no longer needed. This PR removes it and lets TENSORWISE grouped GEMM take the original code path on all architectures: the backward
grad_ais computed directly from the untransposed weight withtrans_b=not ctx.trans_b, matching what gfx942 has been doing all along.This is a pure code-path simplification for the TENSORWISE granularity. The ROWWISE, BLOCKWISE and MX_BLOCKWISE paths are untouched, and the identically named helper in
gemm_fp8.py(non-grouped GEMM) is intentionally left in place. Keeping non-NT layout in gemm because we still use hipblaslt backend in gemm. And the non-NT layout performance is not good enough in hipbalslt backend.Fixes # (issue)
Type of change
Changes
Please list the changes introduced in this PR:
_deter_use_nt_layout_gemm_in_bwdhelper fromprimus_turbo/pytorch/ops/grouped_gemm_fp8.py, together with the now-unusedis_gfx942import.FP8GroupedGemmTensorFunc.forward: dropped the transposed-weight cache branch (both theb_treuse and thetranspose(-1, -2).contiguous()fallback), and now always saves the untransposedquantized_bfor backward. Theb_targument is unused and annotated as such, consistent witha_t.FP8GroupedGemmTensorFunc.forward: no longer storesuse_nt_layout_gemm_in_bwdonctx.FP8GroupedGemmTensorFunc.backward: collapsed the twograd_abranches into the single original call withtrans_b=not ctx.trans_b. Thegrad_b(variable-K wgrad) call is unchanged.Checklist: