Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR #17440: Inject desired pattern for handling Transpose for fp8 gemm rewrite #17798

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented Oct 1, 2024

PR #17440: Inject desired pattern for handling Transpose for fp8 gemm rewrite

Imported from GitHub PR #17440

Related to #17276 and #16975.
This PR updates the GemmRewriter to handle the transpose of non-descending layouts directly, eliminating the need for the layout_normalization pass to correct this error-prone pattern post-rewrite. The desired transformation is now injected into GemmRewriter, ensuring the problematic layout is handled internally. This PR transforms the following error-prone pattern, where the transpose of a non-descending layout is the issue:

a = f8e4m3fn[x,y]{0,1} xxx
transpose.0 = f8e4m3fn[y,x]{0,1} transpose(a), dimensions=(1,0)
custom-call(a,...)

to

a = f8e4m3fn[x,y]{0,1} xxx
bt = f8e4m3fn[y,x]{1,0} bitcast(a)
transpose.1 = f8e4m3fn[x,y]{1,0} transpose(bt), dimensions=(1,0)
bt.1= f8e4m3fn[y,x]{0,1} bitcast(transpose.1)
custom-call(bt.1,...)

Copybara import of the project:

--
237c032 by shuw [email protected]:

Improve TransposeMatrix

--
508cd69 by Shu Wang [email protected]:

Fix bug of permutation.

c55e8a9 by shuw [email protected]:

clang format

--
ad0a4ba by Shu Wang [email protected]:

Add unittest.

1d45b4d by Shu Wang [email protected]:

Remove uncessary space.

7837845 by Shu Wang [email protected]:

Update unittest.

--
b479c21 by shuw [email protected]:

Improve TransposeMatrix

--
b633184 by Shu Wang [email protected]:

Update unittest shape and BUILD file.

Merging this change closes #17440

FUTURE_COPYBARA_INTEGRATE_REVIEW=#17440 from wenscarl:fp8_regulate_transpose b633184

@copybara-service copybara-service bot force-pushed the test_680886834 branch 13 times, most recently from 8d04204 to fbc78e4 Compare October 2, 2024 19:03
… rewrite

Imported from GitHub PR #17440

Related to #17276 and #16975.
This PR updates the GemmRewriter to handle the transpose of non-descending layouts directly, eliminating the need for the layout_normalization pass to correct this error-prone pattern post-rewrite. The desired transformation is now injected into GemmRewriter, ensuring the problematic layout is handled internally. This PR transforms the following error-prone pattern, where the transpose of a non-descending layout is the issue:
```
a = f8e4m3fn[x,y]{0,1} xxx
transpose.0 = f8e4m3fn[y,x]{0,1} transpose(a), dimensions=(1,0)
custom-call(a,...)
```
to
```
a = f8e4m3fn[x,y]{0,1} xxx
bt = f8e4m3fn[y,x]{1,0} bitcast(a)
transpose.1 = f8e4m3fn[x,y]{1,0} transpose(bt), dimensions=(1,0)
bt.1= f8e4m3fn[y,x]{0,1} bitcast(transpose.1)
custom-call(bt.1,...)
```
Copybara import of the project:

--
237c032 by shuw <[email protected]>:

Improve TransposeMatrix

--
508cd69 by Shu Wang <[email protected]>:

Fix bug of permutation.
--
c55e8a9 by shuw <[email protected]>:

clang format

--
ad0a4ba by Shu Wang <[email protected]>:

Add unittest.
--
1d45b4d by Shu Wang <[email protected]>:

Remove uncessary space.
--
7837845 by Shu Wang <[email protected]>:

Update unittest.

--
b479c21 by shuw <[email protected]>:

Improve TransposeMatrix

--
b633184 by Shu Wang <[email protected]>:

Update unittest shape and BUILD file.

Merging this change closes #17440

COPYBARA_INTEGRATE_REVIEW=#17440 from wenscarl:fp8_regulate_transpose b633184
PiperOrigin-RevId: 681551009
@copybara-service copybara-service bot merged commit 7d4740a into main Oct 2, 2024
@copybara-service copybara-service bot deleted the test_680886834 branch October 2, 2024 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant