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

float8 training: fix bug with AC + compile #1329

Merged
merged 1 commit into from
Nov 22, 2024
Merged

Conversation

vkuzo
Copy link
Contributor

@vkuzo vkuzo commented Nov 22, 2024

Summary:

In #1306 I accidentally broke torchtitan + float8 + AC + compile.

I don't have a non-torchtitan repro now, putting up the fix first to ensure torchtitan still works, and we should follow-up later with adding test coverage to torchao to prevent similar breakages in the future.

What broke:

  • in the forward of Float8Linear, we were setting an attribute on the module
  • ^ is not supported with compile + something how torchtitan specifically calls AC

The fix: remove this attribute setting altogether. Unfortunately this breaks an edge case feature for ensuring scales are reprensentable in float16. Since float16 training is not commonly used with float8 and this feature was added during very early testing, removing this for now is fine.

If we need to add this feature back in the future, I'd advocate for doing it via explicit configuration such as config.set_scale_upper_bound and avoiding the stateful hacks, which are usually not compiler friendly.

Test Plan:

// this repo
./test/float8/test_everything.sh

// torchtitan - broken before this PR, works after this PR
with-proxy CONFIG_FILE="./train_configs/llama3_8b.toml" ./run_llama_train.sh --float8.enable_float8_linear --training.compile

Reviewers:

Subscribers:

Tasks:

Tags:

Summary:

In #1306 I accidentally broke
torchtitan + float8 + AC + compile.

I don't have a non-torchtitan repro now, putting up the fix first
to ensure torchtitan still works, and we should follow-up later
with adding test coverage to torchao to prevent similar breakages in the
future.

What broke:
* in the forward of `Float8Linear`, we were setting an attribute on
  the module
* ^ is not supported with compile + something how torchtitan
  specifically calls AC

The fix: remove this attribute setting altogether. Unfortunately this
breaks an edge case feature for ensuring scales are reprensentable in
`float16`.  Since `float16` training is not commonly used with `float8`
and this feature was added during very early testing, removing this for
now is fine.

If we need to add this feature back in the future, I'd advocate for
doing it via explicit configuration such as `config.set_scale_upper_bound`
and avoiding the stateful hacks, which are usually not compiler
friendly.

Test Plan:

```
// this repo
./test/float8/test_everything.sh

// torchtitan - broken before this PR, works after this PR
with-proxy CONFIG_FILE="./train_configs/llama3_8b.toml" ./run_llama_train.sh --float8.enable_float8_linear --training.compile
```

Reviewers:

Subscribers:

Tasks:

Tags:
Copy link

pytorch-bot bot commented Nov 22, 2024

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit a8ccff4 with merge base 7489c7d (image):
💚 Looks good so far! There are no failures yet. 💚

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

@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 Nov 22, 2024
@vkuzo vkuzo added topic: bug fix Use this tag for PRs that fix bugs and removed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Nov 22, 2024
@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 Nov 22, 2024
@vkuzo vkuzo merged commit f3c1a00 into main Nov 22, 2024
22 checks passed
sunjiweiswift pushed a commit to sunjiweiswift/ao that referenced this pull request Nov 25, 2024
Summary:

In pytorch#1306 I accidentally broke
torchtitan + float8 + AC + compile.

I don't have a non-torchtitan repro now, putting up the fix first
to ensure torchtitan still works, and we should follow-up later
with adding test coverage to torchao to prevent similar breakages in the
future.

What broke:
* in the forward of `Float8Linear`, we were setting an attribute on
  the module
* ^ is not supported with compile + something how torchtitan
  specifically calls AC

The fix: remove this attribute setting altogether. Unfortunately this
breaks an edge case feature for ensuring scales are reprensentable in
`float16`.  Since `float16` training is not commonly used with `float8`
and this feature was added during very early testing, removing this for
now is fine.

If we need to add this feature back in the future, I'd advocate for
doing it via explicit configuration such as `config.set_scale_upper_bound`
and avoiding the stateful hacks, which are usually not compiler
friendly.

Test Plan:

```
// this repo
./test/float8/test_everything.sh

// torchtitan - broken before this PR, works after this PR
with-proxy CONFIG_FILE="./train_configs/llama3_8b.toml" ./run_llama_train.sh --float8.enable_float8_linear --training.compile
```

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. topic: bug fix Use this tag for PRs that fix bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants