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

[quant][pt2e] Support conv bn fusion in convert step for QAT flow #100442

Closed
wants to merge 1 commit into from

Conversation

jerryzh168
Copy link
Contributor

@jerryzh168 jerryzh168 commented May 2, 2023

Summary:
This PR adds support for folding bn weights into conv for QAT flow, this is equivalent
to the QAT branch of from_float in eager mode quantized conv module: https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/quantized/modules/conv.py#L223

Items that needs followup:

  • there are some workaround I did because quantize_per_tensor is using float/int args and dynamo does not support these args, need to fix after we change the quantized model representation and also change these args to Tensor

Test Plan: buck2 test @//mode/opt //caffe2/test:quantization_pt2e -- --exact 'caffe2/test:quantization_pt2e - test_convert_qat_conv_bn_fusion (quantization.pt2e.test_quantize_pt2e.TestQuantizePT2E)'

Reviewed By: andrewor14

Differential Revision: D45344281

cc @soumith @voznesenskym @penguinwu @anijain2305 @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @Xia-Weiwen @wenzhe-nrv @jiayisunx @desertfire

@pytorch-bot pytorch-bot bot added the release notes: quantization release notes category label May 2, 2023
@pytorch-bot
Copy link

pytorch-bot bot commented May 2, 2023

🔗 Helpful Links

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

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

✅ No Failures

As of commit 25f6957:
💚 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
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

jerryzh168 added a commit to jerryzh168/pytorch that referenced this pull request May 3, 2023
…torch#100442)

Summary:
Pull Request resolved: pytorch#100442

This PR adds support for folding bn weights into conv for QAT flow, this is equivalent
to the QAT branch of `from_float` in eager mode quantized conv module: https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/quantized/modules/conv.py#L223

Items that needs followup:
* there are some workaround I did because quantize_per_tensor is using float/int args and dynamo does not support these args, need to fix after we change the quantized model representation and also change these args to Tensor

Test Plan: buck2 test @//mode/opt //caffe2/test:quantization_pt2e -- --exact 'caffe2/test:quantization_pt2e - test_convert_qat_conv_bn_fusion (quantization.pt2e.test_quantize_pt2e.TestQuantizePT2E)'

Differential Revision: D45344281

fbshipit-source-id: 36a85a4ba990c3c533f334c8b9f9b3baa9f501ca
@facebook-github-bot
Copy link
Contributor

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

jerryzh168 added a commit to jerryzh168/pytorch that referenced this pull request May 3, 2023
…torch#100442)

Summary:
Pull Request resolved: pytorch#100442

This PR adds support for folding bn weights into conv for QAT flow, this is equivalent
to the QAT branch of `from_float` in eager mode quantized conv module: https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/quantized/modules/conv.py#L223

Items that needs followup:
* there is a workaround that removes overload (.Tensor) for q/dq ops for the match pattern graph that we get from torchdynamo export, we can remove it after we change the quantized model representation

Test Plan: buck2 test @//mode/opt //caffe2/test:quantization_pt2e -- --exact 'caffe2/test:quantization_pt2e - test_convert_qat_conv_bn_fusion (quantization.pt2e.test_quantize_pt2e.TestQuantizePT2E)'

Differential Revision: D45344281

fbshipit-source-id: 92d4a6694c91ccce5050202b367daf40c6cef6d9
@jerryzh168 jerryzh168 force-pushed the export-D45344281 branch 2 times, most recently from eb07ccc to e3887f2 Compare May 4, 2023 00:54
jerryzh168 added a commit to jerryzh168/pytorch that referenced this pull request May 4, 2023
…torch#100442)

Summary:
Pull Request resolved: pytorch#100442

This PR adds support for folding bn weights into conv for QAT flow, this is equivalent
to the QAT branch of `from_float` in eager mode quantized conv module: https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/quantized/modules/conv.py#L223

Items that needs followup:
* there is a workaround that removes overload (.Tensor) for q/dq ops for the match pattern graph that we get from torchdynamo export, we can remove it after we change the quantized model representation

Test Plan: buck2 test @//mode/opt //caffe2/test:quantization_pt2e -- --exact 'caffe2/test:quantization_pt2e - test_convert_qat_conv_bn_fusion (quantization.pt2e.test_quantize_pt2e.TestQuantizePT2E)'

Differential Revision: D45344281

fbshipit-source-id: 942ff42df3a66ed5a8d408dc3da791b567286c9d
@facebook-github-bot
Copy link
Contributor

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

jerryzh168 added a commit to jerryzh168/pytorch that referenced this pull request May 4, 2023
…torch#100442)

Summary:
Pull Request resolved: pytorch#100442

This PR adds support for folding bn weights into conv for QAT flow, this is equivalent
to the QAT branch of `from_float` in eager mode quantized conv module: https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/quantized/modules/conv.py#L223

Items that needs followup:
* there is a workaround that removes overload (.Tensor) for q/dq ops for the match pattern graph that we get from torchdynamo export, we can remove it after we change the quantized model representation

Test Plan: buck2 test @//mode/opt //caffe2/test:quantization_pt2e -- --exact 'caffe2/test:quantization_pt2e - test_convert_qat_conv_bn_fusion (quantization.pt2e.test_quantize_pt2e.TestQuantizePT2E)'

Differential Revision: D45344281

fbshipit-source-id: 93955601ece05f7286b1dbfb3285f6ff460162d5
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

jerryzh168 added a commit to jerryzh168/pytorch that referenced this pull request May 8, 2023
…torch#100442)

Summary:
Pull Request resolved: pytorch#100442

This PR adds support for folding bn weights into conv for QAT flow, this is equivalent
to the QAT branch of `from_float` in eager mode quantized conv module: https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/quantized/modules/conv.py#L223

Items that needs followup:
* there is a workaround that removes overload (.Tensor) for q/dq ops for the match pattern graph that we get from torchdynamo export, we can remove it after we change the quantized model representation

Test Plan: buck2 test @//mode/opt //caffe2/test:quantization_pt2e -- --exact 'caffe2/test:quantization_pt2e - test_convert_qat_conv_bn_fusion (quantization.pt2e.test_quantize_pt2e.TestQuantizePT2E)'

Reviewed By: kimishpatel

Differential Revision: D45344281

fbshipit-source-id: ea11bd8187325031aaaace9a6368bac8e44d28d7
jerryzh168 added a commit to jerryzh168/pytorch that referenced this pull request May 8, 2023
…torch#100442)

Summary:
Pull Request resolved: pytorch#100442

This PR adds support for folding bn weights into conv for QAT flow, this is equivalent
to the QAT branch of `from_float` in eager mode quantized conv module: https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/quantized/modules/conv.py#L223

Items that needs followup:
* there is a workaround that removes overload (.Tensor) for q/dq ops for the match pattern graph that we get from torchdynamo export, we can remove it after we change the quantized model representation

Test Plan: buck2 test @//mode/opt //caffe2/test:quantization_pt2e -- --exact 'caffe2/test:quantization_pt2e - test_convert_qat_conv_bn_fusion (quantization.pt2e.test_quantize_pt2e.TestQuantizePT2E)'

Reviewed By: kimishpatel

Differential Revision: D45344281

fbshipit-source-id: 55252875f4189d9f26154c528b2d03d19808f2d6
@facebook-github-bot
Copy link
Contributor

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

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

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

jerryzh168 added a commit to jerryzh168/pytorch that referenced this pull request May 8, 2023
…torch#100442)

Summary:
Pull Request resolved: pytorch#100442

This PR adds support for folding bn weights into conv for QAT flow, this is equivalent
to the QAT branch of `from_float` in eager mode quantized conv module: https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/quantized/modules/conv.py#L223

Items that needs followup:
* there is a workaround that removes overload (.Tensor) for q/dq ops for the match pattern graph that we get from torchdynamo export, we can remove it after we change the quantized model representation

Test Plan: buck2 test @//mode/opt //caffe2/test:quantization_pt2e -- --exact 'caffe2/test:quantization_pt2e - test_convert_qat_conv_bn_fusion (quantization.pt2e.test_quantize_pt2e.TestQuantizePT2E)'

Reviewed By: kimishpatel

Differential Revision: D45344281

fbshipit-source-id: 5a8988a70a6bc71a608a780bda78b105c2843963
@facebook-github-bot
Copy link
Contributor

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

jerryzh168 added a commit to jerryzh168/pytorch that referenced this pull request May 8, 2023
…torch#100442)

Summary:
Pull Request resolved: pytorch#100442

This PR adds support for folding bn weights into conv for QAT flow, this is equivalent
to the QAT branch of `from_float` in eager mode quantized conv module: https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/quantized/modules/conv.py#L223

Items that needs followup:
* there is a workaround that removes overload (.Tensor) for q/dq ops for the match pattern graph that we get from torchdynamo export, we can remove it after we change the quantized model representation

Test Plan: buck2 test @//mode/opt //caffe2/test:quantization_pt2e -- --exact 'caffe2/test:quantization_pt2e - test_convert_qat_conv_bn_fusion (quantization.pt2e.test_quantize_pt2e.TestQuantizePT2E)'

Reviewed By: kimishpatel

Differential Revision: D45344281

fbshipit-source-id: d0369f7d5e23a7b30d4cbee55a04394ba106f55f
jerryzh168 added a commit to jerryzh168/pytorch that referenced this pull request May 8, 2023
…torch#100442)

Summary:
Pull Request resolved: pytorch#100442

This PR adds support for folding bn weights into conv for QAT flow, this is equivalent
to the QAT branch of `from_float` in eager mode quantized conv module: https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/quantized/modules/conv.py#L223

Items that needs followup:
* there is a workaround that removes overload (.Tensor) for q/dq ops for the match pattern graph that we get from torchdynamo export, we can remove it after we change the quantized model representation

Test Plan: buck2 test @//mode/opt //caffe2/test:quantization_pt2e -- --exact 'caffe2/test:quantization_pt2e - test_convert_qat_conv_bn_fusion (quantization.pt2e.test_quantize_pt2e.TestQuantizePT2E)'

Reviewed By: kimishpatel

Differential Revision: D45344281

fbshipit-source-id: 5381416f9b16d2cac4976d168d25210fe2dfdc1f
@facebook-github-bot
Copy link
Contributor

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

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

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

jerryzh168 added a commit to jerryzh168/pytorch that referenced this pull request May 8, 2023
…torch#100442)

Summary:
Pull Request resolved: pytorch#100442

This PR adds support for folding bn weights into conv for QAT flow, this is equivalent
to the QAT branch of `from_float` in eager mode quantized conv module: https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/quantized/modules/conv.py#L223

Items that needs followup:
* there is a workaround that removes overload (.Tensor) for q/dq ops for the match pattern graph that we get from torchdynamo export, we can remove it after we change the quantized model representation

Test Plan: buck2 test @//mode/opt //caffe2/test:quantization_pt2e -- --exact 'caffe2/test:quantization_pt2e - test_convert_qat_conv_bn_fusion (quantization.pt2e.test_quantize_pt2e.TestQuantizePT2E)'

Reviewed By: kimishpatel

Differential Revision: D45344281

fbshipit-source-id: e5f1edc45ae9606695040469596bb0365f53c4d0
…torch#100442)

Summary:
Pull Request resolved: pytorch#100442

This PR adds support for folding bn weights into conv for QAT flow, this is equivalent
to the QAT branch of `from_float` in eager mode quantized conv module: https://github.com/pytorch/pytorch/blob/main/torch/ao/nn/quantized/modules/conv.py#L223

Items that needs followup:
* there is a workaround that removes overload (.Tensor) for q/dq ops for the match pattern graph that we get from torchdynamo export, we can remove it after we change the quantized model representation

Test Plan: buck2 test @//mode/opt //caffe2/test:quantization_pt2e -- --exact 'caffe2/test:quantization_pt2e - test_convert_qat_conv_bn_fusion (quantization.pt2e.test_quantize_pt2e.TestQuantizePT2E)'

Reviewed By: kimishpatel

Differential Revision: D45344281

fbshipit-source-id: 40c9600220a811a140c3bf1c23851aa3d00766de
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label May 9, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in c3f3cb5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants