Skip to content

[not for land] debug accuracy logging for float8 training #2701

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vkuzo
Copy link
Contributor

@vkuzo vkuzo commented Aug 6, 2025

Summary:

A lightweight logging flag to log the SQNR between the float8 gemm
output and the bf16 gemm output.

two step usage:

  1. set the _enable_debug_logging option on Float8LinearConfig
  2. after model is converted to float8, call _populate_debug_fqns to populate debug FQN names

example usage:

import torch
import torch.nn as nn
from torchao.float8.config import Float8LinearConfig
from torchao.float8.float8_linear_utils import _populate_debug_fqns, convert_to_float8_training

x = torch.randn(1, 16, 16, device="cuda", dtype=torch.bfloat16)
m = nn.Sequential(
    nn.Linear(16, 32, bias=False, device="cuda", dtype=torch.bfloat16),
    nn.Sequential(
        nn.ReLU(),
        nn.Linear(32, 64, bias=False, device="cuda", dtype=torch.bfloat16),
    ),
)   
config = Float8LinearConfig.from_recipe_name(recipe_name)
object.__setattr__(config, "_enable_debug_logging", True)
m = convert_to_float8_training(m, config=config)
_populate_debug_fqns(m)
m = torch.compile(m)
y = m(x)
y.sum().backward()

Test Plan:

> pytest test/float8/test_base.py -s -x -k test_debug_logging
...
test/float8/test_base.py fqn: 0, gemm_name: output, sqnr: 29.125                    
fqn: 1.1, gemm_name: output, sqnr: 28.5                                                                          
fqn: 1.1, gemm_name: grad_input, sqnr: 33.5                                                                      
fqn: 1.1, gemm_name: grad_weight, sqnr: 38.5                                                                     
fqn: 0, gemm_name: grad_input, sqnr: 22.5                                                                        
fqn: 0, gemm_name: grad_weight, sqnr: 23.875              

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
@vkuzo
Copy link
Contributor Author

vkuzo commented Aug 6, 2025

Stack from ghstack (oldest at bottom):

Copy link

pytorch-bot bot commented Aug 6, 2025

🔗 Helpful Links

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

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

❌ 10 New Failures

As of commit 1bbffe7 with merge base 5d99ce4 (image):

NEW FAILURES - The following jobs have failed:

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

vkuzo added a commit that referenced this pull request Aug 6, 2025
Summary:

A lightweight logging flag to log the SQNR between the float8 gemm
output and the bf16 gemm output.

Test Plan:

```bash

```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: f419ea2
ghstack-comment-id: 3160382784
Pull Request resolved: #2701
@meta-cla meta-cla 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 Aug 6, 2025
@vkuzo vkuzo added the topic: not user facing Use this tag if you don't want this PR to show up in release notes label Aug 6, 2025
@facebook-github-bot
Copy link
Contributor

@vkuzo has imported this pull request. If you are a Meta employee, you can view this in D79724877.

[ghstack-poisoned]
vkuzo added a commit that referenced this pull request Aug 6, 2025
Summary:

A lightweight logging flag to log the SQNR between the float8 gemm
output and the bf16 gemm output.

Test Plan:

```bash

```

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: dce0fc9
ghstack-comment-id: 3160382784
Pull Request resolved: #2701
@facebook-github-bot
Copy link
Contributor

@vkuzo has imported this pull request. If you are a Meta employee, you can view this in D79724877.

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: not user facing Use this tag if you don't want this PR to show up in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants