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

Adds utility to replace Q/DQ ops with torchao quantized linear ops #1967

Merged
merged 4 commits into from
Apr 5, 2025

Conversation

metascroy
Copy link
Contributor

@metascroy metascroy commented Mar 26, 2025

This utility is for export scenarios in which people quantize with Q/DQ layout, and then later want to fuse the ops.

Copy link

pytorch-bot bot commented Mar 26, 2025

🔗 Helpful Links

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

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

❌ 1 New Failure

As of commit 74f209e with merge base 3bbf42a (image):

NEW FAILURE - The following job has failed:

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 Mar 26, 2025

eager_results = model(activations)

unwrap_tensor_subclass(model)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me double check. I thought without it, the exported graph didn't decompose into the Q/DQ ops.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed unwrap_tensor_subclass

return pattern, replacement


def replace_q_dq_with_torchao_quantized_linear_ops(
Copy link
Contributor

@jerryzh168 jerryzh168 Mar 26, 2025

Choose a reason for hiding this comment

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

can you add a bit context on when this is used in the docstring of the function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added context in doc string

@metascroy metascroy force-pushed the add-q-dq-pass-utils branch from ca5e688 to 74f209e Compare April 4, 2025 22:04
Copy link
Contributor

@jerryzh168 jerryzh168 left a comment

Choose a reason for hiding this comment

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

looks good, maybe also add some context in the summary about when do we use this, why people first use QDQLayout and then do the fusion instead of generating these ops directly with some other layout

@metascroy metascroy merged commit 5ded23c into main Apr 5, 2025
17 of 18 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants