-
Notifications
You must be signed in to change notification settings - Fork 608
Add pass for replacing dq-q patterns with rescale #8415
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/8415
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit 1c39228 with merge base 8d96d74 ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
When an int8 op meets an int32 op, the int8 is first dequantized to a float which is then quantized to the desired int8 dtype. This produces a (int8 dq -> q int32) pattern that we can replace with a TOSA.RESCALE since they are approximately mathematically equivalent, differing only in how the rounding is done. This requires a few changes: - Introduce custom rescale op - Create pass to replace the dq-q pattern with the rescale op - Implement node_visitor for rescale op The change makes it possible to mix int8 and int32 quantization, as showcased in the new test_add_i32_tosa_BI test. Signed-off-by: Erik Lundell <[email protected]> Change-Id: Ifd475ade488fbbeb8395ac883986b19f8edfae5a
06d343f
to
1c39228
Compare
@@ -9,13 +9,19 @@ | |||
from typing import Tuple | |||
|
|||
import torch | |||
from executorch.backends.arm.arm_backend import get_tosa_version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to have broken the unittest-arm job:
https://github.com/pytorch/executorch/actions/runs/13311971065/job/37176555490#step:15:11475
_______________________ ERROR collecting ops/test_add.py _______________________
ImportError while importing test module '/pytorch/executorch/backends/arm/test/ops/test_add.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/conda/envs/py_3.10/lib/python3.10/importlib/__init__.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
backends/arm/test/ops/test_add.py:12: in <module>
from executorch.backends.arm.arm_backend import get_tosa_version
E ImportError: cannot import name 'get_tosa_version' from 'executorch.backends.arm.arm_backend' (/opt/conda/envs/py_3.10/lib/python3.10/site-packages/executorch/backends/arm/arm_backend.py)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes i also think it did, sorry for the messup. I confirm with a revert to make sure it fixes it. If so lets merge the revert and fix/retry this PR again later.
When an int8 op meets an int32 op, the int8 is first dequantized to a float which is then quantized to the desired int8 dtype.
This produces a (int8 dq -> q int32) pattern that
we can replace with a TOSA.RESCALE since they are approximately mathematically equivalent, differing only in how the rounding is done.
This requires a few changes:
The change makes it possible to mix int8 and int32 quantization, as showcased in the new test_add_i32_tosa_BI test.
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218