Skip to content

Conversation

@andrewor14
Copy link
Contributor

Summary: The previous convert path through QATConfig did not swap NVFP4FakeQuantizedLinear back to torch.nn.Linear. The numerics tests still passed because this fake quantized linear happen to match the PTQ numerics exactly.

Test Plan:

python test/quantization/test_qat.py -k test_qat_nvfp4

**Summary:** The previous convert path through `QATConfig` did
not swap `NVFP4FakeQuantizedLinear` back to `torch.nn.Linear`.
The numerics tests still passed because this fake quantized
linear happen to match the PTQ numerics exactly.

**Test Plan:**
```
python test/quantization/test_qat.py -k test_qat_nvfp4
```
@andrewor14 andrewor14 requested a review from vkuzo December 5, 2025 20:26
@pytorch-bot
Copy link

pytorch-bot bot commented Dec 5, 2025

🔗 Helpful Links

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

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 048568f with merge base aa21b80 (image):
💚 Looks good so far! There are no failures yet. 💚

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

@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 Dec 5, 2025
@andrewor14 andrewor14 requested a review from jerryzh168 December 5, 2025 20:26
@andrewor14 andrewor14 added the topic: improvement Use this tag if this PR is an improvement (doesn't fit into any of the other categories) label Dec 5, 2025
@meta-codesync
Copy link

meta-codesync bot commented Dec 5, 2025

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

sqnr = compute_error(out, baseline_out).item()
self.assertGreaterEqual(sqnr, float("inf"))

# Compare converted values
Copy link
Contributor

Choose a reason for hiding this comment

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

oh we didn't compare convert results before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's tested here:

def test_quantize_api_nvfp4(self, use_per_tensor_scale: bool):

We just never explicitly checked it's using tensor subclasses after convert (tests still passed because QAT prepare mimics PTQ exactly)

@andrewor14 andrewor14 merged commit 51fd90e into main Dec 7, 2025
23 of 25 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