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

[wip] Python-only float8 data type + bare bones UEX #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

vkuzo
Copy link

@vkuzo vkuzo commented May 10, 2023

Summary:

This is a lightweight example of how a Float8Tensor could be build out of core, and how it could hook up with a scaling UEX based on module swapping. The Float8Tensor here is the important part. The Float8Linear part is just an example to demonstrate e2e - I'd expect framework owners to create their own UEX for now. Float8Tensor should ideally hook into the existing TransformerEngine cleanly and simplify things.

Note: Ready for initial review, but things might change after we add distributed support.

Note: this is WIP and does not represent PyTorch's opinion on how we will integrate float8. At this point, this is a prototype to get some light feedback.

TODOs that need to be implemented before review of this PR / sending to NVIDIA:

  • [done] emulated float8 casts to and from float32
  • [done] move https://github.com/albanD/subclass_zoo/blob/fp8_v2/fp8_subclass_v2.py here and hook up to accurate casts
  • [done] basic dynamic scaling (with the assumption that the real UEX can switch to delayed scaling)
  • [50%] numerical testing that this all works for fw + bw with a toy model - it's very "toy" at the moment
  • [not done] example of how an integration with distributed would work - this may change things

What is out of scope for this POC
a. hooking up to real float8 ops (saved for later, just needs someone to do it)
b. real UEX (saved for later and will need a lot of design discussion)

Test plan:

python protoquant/float8/test.py

@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 May 10, 2023
Summary:

Note: this is WIP and does not represent PyTorch's opinion on how we
will integrate float8. At this point, this is a prototype to get some light
feedback.

TODOs that need to be implemented before review of this PR:
* [done] emulated float8 casts to and from float32
* [not done] move https://github.com/albanD/subclass_zoo/blob/fp8_v2/fp8_subclass_v2.py here and hook up to accurate casts
* [not done] basic dynamic scaling (with the assumption that the real UEX can switch to delayed scaling)
* [not done] numerical testing that this all works for fw + bw with a toy model

TODOs to be done in next couple of PRs before sending to NVIDIA:
* [not done] example of how an integration with distributed would work

What is out of scope for this POC
a. hooking up to real float8 ops (saved for later, just needs someone to do it)
b. real UEX (saved for later and will need a lot of design discussion)

Test plan:

```
python protoquant/float8/test.py
```
vkuzo added a commit to pytorch-labs/float8_experimental that referenced this pull request Jul 19, 2023
Summary:

This is a copy of
facebookexperimental/protoquant#23

Many things will change based on recent discussions!

Test Plan:

```
python float8_playground/test.py
```

Reviewers:

Subscribers:

Tasks:

Tags:
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants