Skip to content

Add a pass to remove certain redundant branched quant/dequant nodes #8896

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

Vysarat
Copy link
Contributor

@Vysarat Vysarat commented Mar 3, 2025

Summary:
This pass addresses situations like this, where the quantize and dequantize nodes have the same parameters:

      some_op0
         |
      quantize
      /      \
some_op1    dequantize
                 |
              some_op2

. We can eliminate dequantize like so:

       some_op0
         /    \
    quantize  some_op2
     /
some_op1

The same logic is applied when the order of quantize and dequantized is reversed.

Situations where the some_op1 branch doesn't exist are handled by FuseQuantDequantToRequantizePass, but branched scenarios require different logic.

Differential Revision: D69947096

@Vysarat Vysarat requested a review from tarun292 as a code owner March 3, 2025 19:47
Copy link

pytorch-bot bot commented Mar 3, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/8896

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

✅ No Failures

As of commit a77b024 with merge base 24671a9 (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 CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported labels Mar 3, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69947096

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69947096

…ytorch#8896)

Summary:

This pass addresses situations like this, where the `quantize` and `dequantize` nodes have the same parameters:
```
      some_op0
         |
      quantize
      /      \
some_op1    dequantize
                 |
              some_op2
```
. We can eliminate `dequantize` like so:
```
       some_op0
         /    \
    quantize  some_op2
     /
some_op1

```
The same logic is applied when the order of `quantize` and `dequantized` is reversed.


Situations where the `some_op1` branch doesn't exist are handled by `FuseQuantDequantToRequantizePass`, but branched scenarios require different logic.

Differential Revision: D69947096
@Vysarat Vysarat force-pushed the export-D69947096 branch from d533abd to a77b024 Compare March 3, 2025 22:19
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69947096

# for free to join this conversation on GitHub. Already have an account? # 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. fb-exported topic: not user facing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants