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

mx: add ceil and RNE rounding modes to the cast from fp32 to e8m0 #1643

Merged
merged 5 commits into from
Feb 10, 2025

Conversation

vkuzo
Copy link
Contributor

@vkuzo vkuzo commented Jan 30, 2025

Summary:

Why we want this: the MX spec describes floor rounding, which isn't always the most accurate. It is good to have more options to experiment with.

This is a copy-pasta of #516 with the
modifications being keeping FLOOR the default more, and removing e3m0, credit
to NicoleMayer for the original code. I don't have a way to check bitwise
equivalency with the most recent cuBLAS version yet, but will come back
and add tests when I do.

Test Plan:

pytest test/prototype/mx_formats/ -s -x

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
@vkuzo
Copy link
Contributor Author

vkuzo commented Jan 30, 2025

Copy link

pytorch-bot bot commented Jan 30, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit 0220b19 with merge base 4d1c774 (image):
💚 Looks good so far! There are no failures yet. 💚

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

vkuzo added a commit that referenced this pull request Jan 30, 2025
Summary:

Why we want this: in the newly released cuBLAS 12.8 documentation, the
RNE rounding mode is used for the cast to e8m0. We want to properly
emulate this cast.

This is a copy-pasta of #516 with the
modifications being keeping FLOOR the default more, and removing e3m0, credit
to NicoleMayer for the original code. I don't have a way to check bitwise
equivalency with the most recent cuBLAS version yet, but will come back
and add tests when I do.

Test Plan:

```
pytest test/prototype/mx_formats/ -s -x
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-comment-id: 2613597310

ghstack-source-id: 267dc2222b6469f2e86b5bd928554ae44018b9dc
ghstack-comment-id: 2623497069
Pull Request resolved: #1643
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jan 30, 2025
@vkuzo vkuzo added the topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories) label Jan 30, 2025
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Jan 30, 2025
Summary:

Why we want this: in the newly released cuBLAS 12.8 documentation, the
RNE rounding mode is used for the cast to e8m0. We want to properly
emulate this cast.

This is a copy-pasta of #516 with the
modifications being keeping FLOOR the default more, and removing e3m0, credit
to NicoleMayer for the original code. I don't have a way to check bitwise
equivalency with the most recent cuBLAS version yet, but will come back
and add tests when I do.

Test Plan:

```
pytest test/prototype/mx_formats/ -s -x
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-comment-id: 2613597310

ghstack-source-id: 0999376e5c37815c28483adaaef451b01e75c330
ghstack-comment-id: 2623497069
Pull Request resolved: #1643
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Jan 30, 2025
Summary:

Why we want this: in the newly released cuBLAS 12.8 documentation, the
RNE rounding mode is used for the cast to e8m0. We want to properly
emulate this cast.

This is a copy-pasta of #516 with the
modifications being keeping FLOOR the default more, and removing e3m0, credit
to NicoleMayer for the original code. I don't have a way to check bitwise
equivalency with the most recent cuBLAS version yet, but will come back
and add tests when I do.

Test Plan:

```
pytest test/prototype/mx_formats/ -s -x
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-comment-id: 2613597310

ghstack-source-id: a160d4c9320301e0d3d62128ad386b7e0c985d59
ghstack-comment-id: 2623497069
Pull Request resolved: #1643
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Feb 10, 2025
Summary:

Why we want this: in the newly released cuBLAS 12.8 documentation, the
RNE rounding mode is used for the cast to e8m0. We want to properly
emulate this cast.

This is a copy-pasta of #516 with the
modifications being keeping FLOOR the default more, and removing e3m0, credit
to NicoleMayer for the original code. I don't have a way to check bitwise
equivalency with the most recent cuBLAS version yet, but will come back
and add tests when I do.

Test Plan:

```
pytest test/prototype/mx_formats/ -s -x
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-comment-id: 2613597310

ghstack-source-id: e52136a40ad0b4fdd00aa089c3f38141a21d0f56
ghstack-comment-id: 2623497069
Pull Request resolved: #1643
[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Feb 10, 2025
Summary:

Why we want this: in the newly released cuBLAS 12.8 documentation, the
RNE rounding mode is used for the cast to e8m0. We want to properly
emulate this cast.

This is a copy-pasta of #516 with the
modifications being keeping FLOOR the default more, and removing e3m0, credit
to NicoleMayer for the original code. I don't have a way to check bitwise
equivalency with the most recent cuBLAS version yet, but will come back
and add tests when I do.

Test Plan:

```
pytest test/prototype/mx_formats/ -s -x
```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-comment-id: 2613597310

ghstack-source-id: c607b6cc89726159f370dcb3d03e107ace1c80f4
ghstack-comment-id: 2623497069
Pull Request resolved: #1643
@vkuzo vkuzo merged commit bae41d1 into main Feb 10, 2025
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants