-
Notifications
You must be signed in to change notification settings - Fork 24k
add the torch.float8_e8m0fnu
dtype to PyTorch
#147466
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
Conversation
Summary: Adds the `torch.float8_e8m0fnu` dtype to PyTorch, as detailed in #146414 Not ready for review yet. Test Plan: ``` pytest test/quantization/core/experimental/test_float8.py -s ``` Reviewers: Subscribers: Tasks: Tags: ghstack-comment-id: 2634707334
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/147466
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit d635775 with merge base 303ad19 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
torch.float8_e8m0fnu
dtype to PyTorch
@pytorchbot merge |
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 |
Merge failedReason: 1 jobs have failed, first few of them are: linux-binary-manywheel / manywheel-py3_9-cuda11_8-build / build Details for Dev Infra teamRaised by workflow job |
@pytorchbot merge |
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 |
false alarm my bad |
Summary: Continuing the work from #146427 Adds the `torch.float8_e8m0fnu` dtype to PyTorch, as detailed in #146414 . Please see the issue for a detailed definition of the format. Example of basic functionality: ```python import torch # round trip x0 = torch.randn(4, 4, dtype=torch.float32) x1 = x0.to(torch.float8_e8m0fnu) # RNE rounding x2 = x1.to(torch.float32) # 2 ** exponent # creation with empty x0 = torch.empty(4, 4, dtype=torch.float8_e8m0fnu) # printing print(x0) ``` Done in this PR: * numerical correctness * op coverage (except for `torch._scaled_mm`): create tensor, cast to/from float32 * printing a tensor works For future PRs: * performance optimizations for casting * torch._scaled_mm * PT2 * various cleanups (detailed in comments with issue numbers) Test Plan: ``` pytest test/quantization/core/experimental/test_float8.py -s ``` Reviewers: Subscribers: Tasks: Tags: Pull Request resolved: #147466 Approved by: https://github.com/drisspg
Summary: Continuing the work from #146427 Adds the `torch.float8_e8m0fnu` dtype to PyTorch, as detailed in #146414 . Please see the issue for a detailed definition of the format. Example of basic functionality: ```python import torch # round trip x0 = torch.randn(4, 4, dtype=torch.float32) x1 = x0.to(torch.float8_e8m0fnu) # RNE rounding x2 = x1.to(torch.float32) # 2 ** exponent # creation with empty x0 = torch.empty(4, 4, dtype=torch.float8_e8m0fnu) # printing print(x0) ``` Done in this PR: * numerical correctness * op coverage (except for `torch._scaled_mm`): create tensor, cast to/from float32 * printing a tensor works For future PRs: * performance optimizations for casting * torch._scaled_mm * PT2 * various cleanups (detailed in comments with issue numbers) Test Plan: ``` pytest test/quantization/core/experimental/test_float8.py -s ``` Reviewers: Subscribers: Tasks: Tags: Pull Request resolved: #147466 Approved by: https://github.com/drisspg
Summary: Continuing the work from pytorch#146427 Adds the `torch.float8_e8m0fnu` dtype to PyTorch, as detailed in pytorch#146414 . Please see the issue for a detailed definition of the format. Example of basic functionality: ```python import torch # round trip x0 = torch.randn(4, 4, dtype=torch.float32) x1 = x0.to(torch.float8_e8m0fnu) # RNE rounding x2 = x1.to(torch.float32) # 2 ** exponent # creation with empty x0 = torch.empty(4, 4, dtype=torch.float8_e8m0fnu) # printing print(x0) ``` Done in this PR: * numerical correctness * op coverage (except for `torch._scaled_mm`): create tensor, cast to/from float32 * printing a tensor works For future PRs: * performance optimizations for casting * torch._scaled_mm * PT2 * various cleanups (detailed in comments with issue numbers) Test Plan: ``` pytest test/quantization/core/experimental/test_float8.py -s ``` Reviewers: Subscribers: Tasks: Tags: Pull Request resolved: pytorch#147466 Approved by: https://github.com/drisspg
…)" This reverts commit 382fbcc.
…)" This reverts commit 382fbcc.
Summary: Continuing the work from pytorch#146427 Adds the `torch.float8_e8m0fnu` dtype to PyTorch, as detailed in pytorch#146414 . Please see the issue for a detailed definition of the format. Example of basic functionality: ```python import torch # round trip x0 = torch.randn(4, 4, dtype=torch.float32) x1 = x0.to(torch.float8_e8m0fnu) # RNE rounding x2 = x1.to(torch.float32) # 2 ** exponent # creation with empty x0 = torch.empty(4, 4, dtype=torch.float8_e8m0fnu) # printing print(x0) ``` Done in this PR: * numerical correctness * op coverage (except for `torch._scaled_mm`): create tensor, cast to/from float32 * printing a tensor works For future PRs: * performance optimizations for casting * torch._scaled_mm * PT2 * various cleanups (detailed in comments with issue numbers) Test Plan: ``` pytest test/quantization/core/experimental/test_float8.py -s ``` Reviewers: Subscribers: Tasks: Tags: Pull Request resolved: pytorch#147466 Approved by: https://github.com/drisspg
Hi @vkuzo are you still working on the problem ? I think the way you used MXFP8_E8M0_FNU could be discussed. The number is used inside No mantssa and speical number should be taken careful because exponent itself is unsigned. We don't need to care about it.
The second problem is that this mxfp8_e8m0_fnu will be shared by a group consecutive 32 (group) elements (no exponent, only mantissa w/wo implict-1). (because mantissa multiply the exponent is the fp32). Note fp8 scalar multiple a fp8 data type is as easy as Here is my implementation :
|
Summary:
Continuing the work from #146427
Adds the
torch.float8_e8m0fnu
dtype to PyTorch, as detailed in#146414 . Please see the issue for a detailed definition of the format. Example of basic functionality:
Done in this PR:
torch._scaled_mm
): create tensor, cast to/from float32For future PRs:
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10