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

Add NANOO FP8 Support #2695

Open
wants to merge 21 commits into
base: develop-upstream
Choose a base branch
from
Open

Add NANOO FP8 Support #2695

wants to merge 21 commits into from

Conversation

ScXfjiang
Copy link

@ScXfjiang ScXfjiang commented Sep 30, 2024

This PR adds tf.experimental.float8_e4m3fnuz and tf.experimental.float8_e5m2fnuz as public tensorflow data types.

similar work:

@ScXfjiang ScXfjiang marked this pull request as ready for review October 1, 2024 21:16
@@ -563,6 +563,14 @@ struct ProtoHelper<float8_e5m2> : public Float8ProtoHelper<float8_e5m2> {};
template <>
struct ProtoHelper<float8_e4m3fn> : public Float8ProtoHelper<float8_e4m3fn> {};

template <>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Format the code the same way as that for ocp fp8?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -271,8 +271,8 @@ def testBfloat16(self):
def testFloat8e5m2(self):
test_type = dtypes.float8_e5m2.as_numpy_dtype
t = tensor_util.make_tensor_proto(np.array([10.0, 20.0], dtype=test_type))
# 10.0: "I" = 73 = 10010 01: 2^(18 - 15) * (1 + 1/4)
# 20.0: "M" = 77 = 10011 01: 2^(19 - 15) * (1 + 1/4)
# 10.0: "I" = 73 = 0 10010 01: 2^(18 - 15) * (1 + 1/4)
Copy link

@wenchenvincent wenchenvincent Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Why do we need the extra 0 here? For more clarity?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. (I just wanted to display all bit positions of FP8. But I agree that our repo should be consistent with the upstream repo as possible as we can, for less pain in the weekly sync.)

Copy link

@wenchenvincent wenchenvincent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

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.

2 participants