Skip to content

Add add-relu fusion in the quantizer#19077

Merged
meta-codesync[bot] merged 1 commit intomainfrom
export-D102189156
Apr 23, 2026
Merged

Add add-relu fusion in the quantizer#19077
meta-codesync[bot] merged 1 commit intomainfrom
export-D102189156

Conversation

@mcremon-meta
Copy link
Copy Markdown
Contributor

Summary:
Fold ReLU into add in the quantizer, the same way we already fold it into convolutions.

The quantized_add op already performs requantization, so when an add is followed by a relu, we can use the output quant params directly (with zero point at min range) instead of emitting a separate quantized_relu. This saves one op in the quantized graph.

Changes:

  • Add AddReluBasePattern, AddReluPattern0, and AddReluPattern1 in patterns.py
  • Handle AddRelu patterns in QuantFusion.call() in fusion_pass.py, reusing get_args_and_kwargs_add
  • Register the patterns in CadenceFusedConvReluQuantizer before standalone AddPattern so the fused pattern matches first
  • Add annotation test for the fused add+relu pattern

Reviewed By: khazaei

Differential Revision: D102189156

Summary:
Fold ReLU into add in the quantizer, the same way we already fold it into convolutions.

The `quantized_add` op already performs requantization, so when an add is followed by a relu, we can use the output quant params directly (with zero point at min range) instead of emitting a separate `quantized_relu`. This saves one op in the quantized graph.

Changes:
- Add `AddReluBasePattern`, `AddReluPattern0`, and `AddReluPattern1` in `patterns.py`
- Handle AddRelu patterns in `QuantFusion.call()` in `fusion_pass.py`, reusing `get_args_and_kwargs_add`
- Register the patterns in `CadenceFusedConvReluQuantizer` before standalone `AddPattern` so the fused pattern matches first
- Add annotation test for the fused add+relu pattern

Reviewed By: khazaei

Differential Revision: D102189156
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Apr 23, 2026

🔗 Helpful Links

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

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:

❌ 1 New Failure, 2 Cancelled Jobs

As of commit e598914 with merge base e7b38a3 (image):

NEW FAILURE - The following job has failed:

CANCELLED JOBS - The following jobs were cancelled. Please retry:

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 Apr 23, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Apr 23, 2026

@mcremon-meta has exported this pull request. If you are a Meta employee, you can view the originating Diff in D102189156.

@github-actions
Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@meta-codesync meta-codesync Bot merged commit 7b5dcc1 into main Apr 23, 2026
178 of 184 checks passed
@meta-codesync meta-codesync Bot deleted the export-D102189156 branch April 23, 2026 21:49
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. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants