meta registration for torch._scaled_mm with mxfp8#148461
Closed
vkuzo wants to merge 5 commits into
Closed
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/148461
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (4 Unrelated Failures)As of commit 5e38d0b with merge base 23183fe ( BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
UNSTABLE - The following jobs are marked as unstable, possibly due to flakiness on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
vkuzo
added a commit
that referenced
this pull request
Mar 4, 2025
Summary: Adds the meta registration logic for torch.compile to work with `torch._scaled_mm` with mxfp8, with `aot_eager` backend. Note that we need #147873 for inductor to work. Test Plan: ``` pytest test/test_matmul_cuda.py -k test_blockwise_mxfp8_compile -s ``` Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 248830a Pull Request resolved: #148461
vkuzo
added a commit
to pytorch/ao
that referenced
this pull request
Mar 5, 2025
Summary: This PR enables `MXLinear` with `mxfp8_cublas` recipe to use torch.compile. The current approach is a short term workaround until pytorch/pytorch#148461 is done. Since we can't use e8m0 in torchinductor or triton yet, we create a custom op wrapper around `torch._scaled_mm` which takes `uint8` scales and does the cast to e8m0 inside the wrapper, where torchinductor can't see it. Test Plan: ``` // this now works (although performance is not ideal due to #1788) python benchmarks/float8/profile_lowp_training.py ~/local/tmp/20250305_test --mx_recipe_name mxfp8_cublas // we can also uncomment the hardware check and run the unit test pytest test/prototype/mx_formats -s -k test_linear_compile ``` Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 033d817 ghstack-comment-id: 2701679811 Pull Request resolved: #1841
vkuzo
commented
Mar 11, 2025
| C_ref = A_ref @ B_ref.t() | ||
|
|
||
| # TODO(#147873): switch to inductor backend after e8m0 is supported there | ||
| compiled_scaled_mm = torch.compile(torch._scaled_mm, backend="aot_eager") |
Contributor
Author
There was a problem hiding this comment.
when I rebase past https://github.com/pytorch/pytorch/pull/148722/files and then change the backend in this code to inductor, I see https://www.internalfb.com/phabricator/paste/view/P1753483593 . cc @eellison
vkuzo
added a commit
that referenced
this pull request
Mar 13, 2025
Summary: Adds the meta registration logic for torch.compile to work with `torch._scaled_mm` with mxfp8, with `aot_eager` backend. Note that we need #147873 for inductor to work. Test Plan: ``` pytest test/test_matmul_cuda.py -k test_blockwise_mxfp8_compile -s ``` Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 67791ed Pull Request resolved: #148461
vkuzo
added a commit
that referenced
this pull request
Mar 13, 2025
Summary: Adds the meta registration logic for torch.compile to work with `torch._scaled_mm` with mxfp8, with `aot_eager` backend. Note that we need #147873 for inductor to work. Test Plan: ``` pytest test/test_matmul_cuda.py -k test_blockwise_mxfp8_compile -s ``` Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: ea7eb2f Pull Request resolved: #148461
drisspg
approved these changes
Mar 13, 2025
eellison
approved these changes
Mar 13, 2025
This was referenced Mar 26, 2025
vkuzo
added a commit
to pytorch/ao
that referenced
this pull request
Mar 26, 2025
Summary: After pytorch/pytorch#148461 lands, we can use `torch.float8_e8m0fnu` throughout our codebase and compile will still work, removing the workarounds. Test Plan: ``` pytest test/prototype/mx_formats/ -s -x ``` Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 278117b ghstack-comment-id: 2755728114 Pull Request resolved: #1966
vkuzo
added a commit
that referenced
this pull request
Mar 26, 2025
Summary: Adds the meta registration logic for torch.compile to work with `torch._scaled_mm` with mxfp8, with `aot_eager` backend. Note that we need #147873 for inductor to work. Test Plan: ``` pytest test/test_matmul_cuda.py -k test_blockwise_mxfp8_compile -s ``` Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 2c22e77 Pull Request resolved: #148461
vkuzo
added a commit
to pytorch/ao
that referenced
this pull request
Mar 26, 2025
Summary: After pytorch/pytorch#148461 lands, we can use `torch.float8_e8m0fnu` throughout our codebase and compile will still work, removing the workarounds. Test Plan: ``` pytest test/prototype/mx_formats/ -s -x ``` Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 278117b ghstack-comment-id: 2755728114 Pull Request resolved: #1966
Contributor
Author
|
@pytorchbot merge |
Collaborator
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
amathewc
pushed a commit
to amathewc/pytorch
that referenced
this pull request
Apr 17, 2025
Summary: Adds the meta registration logic for torch.compile to work with `torch._scaled_mm` with mxfp8. Thanks to @eellison for the pointer to make inductor work with this. Test Plan: ``` pytest test/test_matmul_cuda.py -k test_blockwise_mxfp8_compile -s ``` Reviewers: Subscribers: Tasks: Tags: Pull Request resolved: pytorch#148461 Approved by: https://github.com/drisspg, https://github.com/eellison
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.
Stack from ghstack (oldest at bottom):
Summary:
Adds the meta registration logic for torch.compile to work with
torch._scaled_mmwith mxfp8. Thanks to @eellison for the pointer to make inductor work with this.Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @chenyang78 @kadeng @muchulee8 @amjames @chauhang @aakhundov