Skip to content

Conversation

andrewor14
Copy link
Contributor

@andrewor14 andrewor14 commented Aug 5, 2025

Summary: Previously, we call assert_and_get_unqiue_device once per node in both prepare and convert. This is expensive and unnecessary since the model device is the same across all nodes, so we should just call this once in the beginning and reuse the same model device across all the nodes.

torchao version of pytorch/pytorch#159901

Note: The prepare path is not completely done yet, since we are blocked on the pytorch PR on being merged. It's different from convert since it still calls utility functions from torch.ao.quantization.fx.

Test Plan:

python test/quantization/pt2e/test_quantize_pt2e.py

Copy link

pytorch-bot bot commented Aug 5, 2025

🔗 Helpful Links

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

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

✅ No Failures

As of commit cd57f54 with merge base 183068e (image):
💚 Looks good so far! There are no failures yet. 💚

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

@andrewor14 andrewor14 requested a review from jerryzh168 August 5, 2025 21:24
@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 5, 2025
@andrewor14 andrewor14 requested a review from HDCharles August 5, 2025 21:24
@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 Aug 5, 2025
@andrewor14 andrewor14 force-pushed the pt2e-cache-model-device branch from 4a08e16 to 4040192 Compare August 5, 2025 21:46
@andrewor14 andrewor14 force-pushed the pt2e-cache-model-device branch from 4040192 to ae3264e Compare August 6, 2025 15:57
@andrewor14 andrewor14 force-pushed the pt2e-cache-model-device branch from ae3264e to 12a1c44 Compare September 2, 2025 21:40
model.graph,
"_scale",
scale,
scale.device,
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like scale could be non-Tensor as well, so here we'd need a device from model instead, same for zero_point

**Summary:** Previously, we call `assert_and_get_unqiue_device`
once per node in both prepare and convert. This is expensive and
unnecessary since the model device is the same across all nodes,
so we should just call this once in the beginning and reuse the
same model device across all the nodes.

torchao version of pytorch/pytorch#159901

Note: The prepare path is not completely done yet, since we are
blocked on the pytorch PR on being merged. It's different from
convert since it still calls utility functions from
`torch.ao.quantization.fx`.

**Test Plan:**
```
python test/quantization/pt2e/test_quantize_pt2e.py
```
@andrewor14 andrewor14 force-pushed the pt2e-cache-model-device branch from 12a1c44 to cd57f54 Compare September 3, 2025 14:44
@andrewor14 andrewor14 merged commit 870284f into main Sep 3, 2025
18 checks passed
@andrewor14 andrewor14 deleted the pt2e-cache-model-device branch September 3, 2025 19:21
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.

2 participants