Skip to content

Conversation

@kwen2501
Copy link
Collaborator

@kwen2501 kwen2501 commented Sep 13, 2024

@pytorch-bot
Copy link

pytorch-bot bot commented Sep 13, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/135961

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (2 Unrelated Failures)

As of commit 183947e with merge base 0216936 (image):

FLAKY - The following jobs failed but were likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added oncall: distributed Add this issue/PR to distributed oncall triage queue release notes: distributed (c10d) release notes category labels Sep 13, 2024
kwen2501 added a commit that referenced this pull request Sep 13, 2024
ghstack-source-id: a54c14e
Pull Request resolved: #135961
// x[i] = 0x7f - (x[i] + 0x01)
// (3) Only leave the sign bit by masking with 0x80.
// (4) If any x[i] is negative, then the whole x != 0.
#define CHECK_8_FLOAT8_E4M3FN(x) \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we do this for the other float8 dtypes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I will add support for e5m2 in another PR :)

Copy link

Choose a reason for hiding this comment

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

You should consider doing it for the float16 types as well. You'll will be reducing the number of SASS instructions considerably.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @jbachan. Will do.

// x[i] = 0x7f - (x[i] + 0x01)
// (3) Only leave the sign bit by masking with 0x80.
// (4) If any x[i] is negative, then the whole x != 0.
#define CHECK_8_FLOAT8_E4M3FN(x) \
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest making this a function/template specialization (e.g. has_nan_vectorized) for type safety. Also it would help organizing similar optimizations for other scalar types.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, changed it to inline function now.

Comment on lines 92 to 93
// (2) If the result is 0x7f (is nan), then the following would be a negative number:
// x[i] = 0x7f - (x[i] + 0x01)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel doing x[i] = x[i] + 0x01 and checking the most significant bit is a bit easier to understand.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, changed now :)

Copy link
Collaborator

@yifuwang yifuwang left a comment

Choose a reason for hiding this comment

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

Awesome work!

We check 8 x FP8 simultaneously, at size of 8 bytes.

cc XilunWu H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k c-p-i-o

[ghstack-poisoned]
kwen2501 added a commit that referenced this pull request Sep 13, 2024
ghstack-source-id: a600fcb
Pull Request resolved: #135961
@kwen2501
Copy link
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Sep 13, 2024
@pytorchmergebot
Copy link
Collaborator

Merge started

Your 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

Advanced Debugging
Check the merge workflow status
here

pytorchmergebot pushed a commit that referenced this pull request Sep 15, 2024
Add support for Float8_e5m2, following similar algorithm used for Float8_e4m3fn (i.e. overflow check).

Made `HasNanFP8x8` a template so that it is extendable based on dtype.

Pull Request resolved: #136115
Approved by: https://github.com/Skylion007
ghstack dependencies: #135891, #135961
Chao1Han pushed a commit to Chao1Han/pytorch that referenced this pull request Sep 20, 2024
Add support for Float8_e5m2, following similar algorithm used for Float8_e4m3fn (i.e. overflow check).

Made `HasNanFP8x8` a template so that it is extendable based on dtype.

Pull Request resolved: pytorch#136115
Approved by: https://github.com/Skylion007
ghstack dependencies: pytorch#135891, pytorch#135961
@github-actions github-actions bot deleted the gh/kwen2501/60/head branch October 14, 2024 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged oncall: distributed Add this issue/PR to distributed oncall triage queue release notes: distributed (c10d) release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants