executorch icon indicating copy to clipboard operation
executorch copied to clipboard

Convert scalar to tensor before quantizer annoate

Open cccclai opened this issue 1 year ago • 6 comments

Stack from ghstack (oldest at bottom):

  • -> #2958
  • #2957

Differential Revision: D55946527

cccclai avatar Apr 10 '24 00:04 cccclai

:link: Helpful Links

:test_tube: See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/2958

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

:x: 2 New Failures, 1 Unrelated Failure

As of commit de04834d9e8b8ab9bc7c5847368f16a3b16a3eca with merge base e733f2db37fba68f61211a942d9cf272f67f2f83 (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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

pytorch-bot[bot] avatar Apr 10 '24 00:04 pytorch-bot[bot]

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

facebook-github-bot avatar Apr 10 '24 00:04 facebook-github-bot

@shewu-quic @haowhsu-quic

chiwwang avatar Apr 10 '24 01:04 chiwwang

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

facebook-github-bot avatar Apr 10 '24 21:04 facebook-github-bot

It seems to convert the scalar node of the binary op into a tensor node and allow the node to be quantized. Maybe the following two passes are also to achieve this thing. https://github.com/pytorch/executorch/blob/d761f99f6fc952975835f4807a12319c121c4b90/backends/qualcomm/passes/annotate_and_quant_scalar.py#L19 https://github.com/pytorch/executorch/blob/d761f99f6fc952975835f4807a12319c121c4b90/backends/qualcomm/passes/convert_binary_op_with_scalar.py#L15

shewu-quic avatar Apr 11 '24 01:04 shewu-quic

It seems to convert the scalar node of the binary op into a tensor node and allow the node to be quantized. Maybe the following two passes are also to achieve this thing.

https://github.com/pytorch/executorch/blob/d761f99f6fc952975835f4807a12319c121c4b90/backends/qualcomm/passes/annotate_and_quant_scalar.py#L19

https://github.com/pytorch/executorch/blob/d761f99f6fc952975835f4807a12319c121c4b90/backends/qualcomm/passes/convert_binary_op_with_scalar.py#L15

Oh I see what's going. The convert_binary_op_with_scalar pass runs after quantization process, however we need to run this pass before the quantizer starts annotating, otherwise the scalar may not have an accurate quantization params.

cccclai avatar Apr 12 '24 19:04 cccclai