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

[RFC] Add a new type to StableHLO: E4M3B11FNUZ #1308

Merged
merged 1 commit into from
Mar 24, 2023

Conversation

majnemer
Copy link
Contributor

@majnemer majnemer commented Mar 10, 2023

This is a proposal to add a new floating point type to StableHLO, please see rfcs/20230309-e4m3b11.md for more details.

@burmako burmako self-assigned this Mar 10, 2023
@burmako burmako added the RFC label Mar 10, 2023
@majnemer majnemer changed the title Propose adding a new type to StableHLO: E4M3B11FNUZ [RFC] Add a new type to StableHLO: E4M3B11FNUZ Mar 10, 2023
majnemer added a commit to majnemer/llvm-project that referenced this pull request Mar 20, 2023
X. Sun et al. (https://dl.acm.org/doi/10.5555/3454287.3454728) published
a paper showing that an FP format with 4 bits of exponent, 3 bits of
significand and an exponent bias of 11 would work quite well for ML
applications.

Google hardware supports a variant of this format where 0x80 is used to
represent NaN, as in the Float8E4M3FNUZ format. Just like the
Float8E4M3FNUZ format, this format does not support -0 and values which
would map to it will become +0.

This format is proposed for inclusion in OpenXLA's StableHLO dialect: openxla/stablehlo#1308

As part of inclusion in that dialect, APFloat needs to know how to
handle this format.
@majnemer
Copy link
Contributor Author

APFloat and related changes are posted for review here.

@sherhut
Copy link

sherhut commented Mar 21, 2023

Adding this type makes sense to me and I expect that we will see more requests of this kind as the use of different floating point formats proliferates across hardware. We need to be able to target these different floating point types from stablehlo.

At some point we will need to start thinking about optionality/portability of fp8 formats and whether we want to have some sort of hierarchy so that compilers can chose a specific implementation type for a specified type at the stablehlo level. We already have the concept of a precision_config but that is fairly coarse grained and not well specified. However, we should not gate landing this on the larger design question, as I expect that we'll need a way to target specific types anyway, e.g., for numeric reasons where that matters.

majnemer added a commit to llvm/llvm-project that referenced this pull request Mar 24, 2023
X. Sun et al. (https://dl.acm.org/doi/10.5555/3454287.3454728) published
a paper showing that an FP format with 4 bits of exponent, 3 bits of
significand and an exponent bias of 11 would work quite well for ML
applications.

Google hardware supports a variant of this format where 0x80 is used to
represent NaN, as in the Float8E4M3FNUZ format. Just like the
Float8E4M3FNUZ format, this format does not support -0 and values which
would map to it will become +0.

This format is proposed for inclusion in OpenXLA's StableHLO dialect: openxla/stablehlo#1308

As part of inclusion in that dialect, APFloat needs to know how to
handle this format.

Differential Revision: https://reviews.llvm.org/D146441
@burmako
Copy link
Contributor

burmako commented Mar 24, 2023

As discussed at the community meeting on Tuesday 3/21, the review period for this RFC closes today. There is support for introducing this new type to StableHLO, and we haven't received any blocking feedback, so the RFC is now approved.

@burmako burmako merged commit 4664754 into openxla:main Mar 24, 2023
@burmako burmako mentioned this pull request Apr 13, 2023
@majnemer majnemer deleted the e4m3b11 branch May 1, 2023 21:24
majnemer added a commit to majnemer/stablehlo that referenced this pull request May 1, 2023
As proposed in [RFC: E4M3B11FNUZ in XLA](https://github.com/openxla/stablehlo/blob/main/rfcs/20230309-e4m3b11.md) (openxla#1308),
this change adds support for this type to StableHLO.

This includes the type definitions, vhlo, and interpreter support. The
testing approach mirrors the Float8E4M3FNUZ tests, since it is also a
"non-standard" floating point type supported by StableHLO.
majnemer added a commit to majnemer/stablehlo that referenced this pull request May 2, 2023
As proposed in [RFC: E4M3B11FNUZ in XLA](https://github.com/openxla/stablehlo/blob/main/rfcs/20230309-e4m3b11.md) (openxla#1308),
this change adds support for this type to StableHLO.

This includes the type definitions, vhlo, and interpreter support. The
testing approach mirrors the Float8E4M3FNUZ tests, since it is also a
"non-standard" floating point type supported by StableHLO.
burmako pushed a commit that referenced this pull request May 2, 2023
As proposed in [RFC: E4M3B11FNUZ in
XLA](https://github.com/openxla/stablehlo/blob/main/rfcs/20230309-e4m3b11.md)
(#1308), this change adds support for these types to StableHLO.

This includes the type definitions, vhlo, and interpreter support. The
testing approach mirrors the Float8E4M3FNUZ tests, since it is also a
"non-standard" floating point type supported by StableHLO.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants