Skip to content

Conversation

supriyar
Copy link
Contributor

@supriyar supriyar commented Jun 23, 2021

Stack from ghstack:

Summary:
When we do QAT, we swap the FP32 modules with the corresponding quantized modules counterpart by calling qat_swap_modules in prepare.
However when we try to look up using the swapped module type in qconfig_dict, we cannot find a match anymore since the qconfig dict contains the original
module type.

In this PR we update the qconfig_dict to include the modules swapped for QATT

Test Plan:
python test/test_quantization.py TestQuantizeFx.test_qconfig_qat_module_type

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: D29337036

Summary:
When we do QAT, we swap the FP32 modules with the corresponding quantized modules counterpart by calling `qat_swap_modules` in prepare.
However when we try to look up using the swapped module type in qconfig_dict, we cannot find a match anymore since the qconfig dict contains the original
module type.

In this PR we get the list of original `modules` dict from the input model before we do swap for QAT

Test Plan:
python test/test_quantization.py TestQuantizeFx.test_qconfig_qat_module_type

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jun 23, 2021

💊 CI failures summary and remediations

As of commit 001f200 (more details on the Dr. CI page and at hud.pytorch.org/pr/60555):


  • 1/1 failures introduced in this PR

🕵️ 1 new failure recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See GitHub Actions build Lint / mypy (1/1)

Step: "Run mypy" (full log | diagnosis details | 🔁 rerun)

2021-06-23T18:27:32.7286395Z torch/utils/benchm...ction "median" in typed context [no-untyped-call]
2021-06-23T18:27:18.9159931Z env:
2021-06-23T18:27:18.9160499Z   pythonLocation: /opt/hostedtoolcache/Python/3.8.10/x64
2021-06-23T18:27:18.9161239Z   LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.8.10/x64/lib
2021-06-23T18:27:18.9161782Z ##[endgroup]
2021-06-23T18:27:18.9309022Z + for CONFIG in mypy*.ini
2021-06-23T18:27:18.9310096Z + mypy --config=mypy-strict.ini
2021-06-23T18:27:30.8014769Z torch/utils/benchmark/utils/common.py:166:34: error: Call to untyped function "median" in typed context  [no-untyped-call]
2021-06-23T18:27:30.8019571Z torch/utils/benchmark/utils/common.py:168:31: error: Call to untyped function "percentile" in typed context  [no-untyped-call]
2021-06-23T18:27:30.8021271Z torch/utils/benchmark/utils/common.py:169:31: error: Call to untyped function "percentile" in typed context  [no-untyped-call]
2021-06-23T18:27:30.8022759Z torch/utils/benchmark/utils/common.py:281:18: error: Call to untyped function "round" in typed context  [no-untyped-call]
2021-06-23T18:27:32.7286395Z torch/utils/benchmark/utils/timer.py:304:24: error: Call to untyped function "median" in typed context  [no-untyped-call]
2021-06-23T18:27:36.7090751Z Found 5 errors in 2 files (checked 141 source files)
2021-06-23T18:27:37.7701263Z ##[error]Process completed with exit code 1.
2021-06-23T18:27:37.7790749Z Post job cleanup.
2021-06-23T18:27:37.8757757Z [command]/usr/bin/git version
2021-06-23T18:27:37.8812920Z git version 2.32.0
2021-06-23T18:27:37.8847535Z [command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
2021-06-23T18:27:37.8891276Z [command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
2021-06-23T18:27:37.9153449Z [command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/github\.com\/\.extraheader
2021-06-23T18:27:37.9193087Z http.https://github.com/.extraheader
2021-06-23T18:27:37.9204555Z [command]/usr/bin/git config --local --unset-all http.https://github.com/.extraheader

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

Summary:
When we do QAT, we swap the FP32 modules with the corresponding quantized modules counterpart by calling `qat_swap_modules` in prepare.
However when we try to look up using the swapped module type in qconfig_dict, we cannot find a match anymore since the qconfig dict contains the original
module type.

In this PR we get the list of original `modules` dict from the input model before we do swap for QAT

Test Plan:
python test/test_quantization.py TestQuantizeFx.test_qconfig_qat_module_type

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
Summary:
When we do QAT, we swap the FP32 modules with the corresponding quantized modules counterpart by calling `qat_swap_modules` in prepare.
However when we try to look up using the swapped module type in qconfig_dict, we cannot find a match anymore since the qconfig dict contains the original
module type.

In this PR we get the list of original `modules` dict from the input model before we do swap for QAT

Test Plan:
python test/test_quantization.py TestQuantizeFx.test_qconfig_qat_module_type

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
Summary:
When we do QAT, we swap the FP32 modules with the corresponding quantized modules counterpart by calling `qat_swap_modules` in prepare.
However when we try to look up using the swapped module type in qconfig_dict, we cannot find a match anymore since the qconfig dict contains the original
module type.

In this PR we get the list of original `modules` dict from the input model before we do swap for QAT

Test Plan:
python test/test_quantization.py TestQuantizeFx.test_qconfig_qat_module_type

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
supriyar added a commit that referenced this pull request Jun 23, 2021
Summary:
When we do QAT, we swap the FP32 modules with the corresponding quantized modules counterpart by calling `qat_swap_modules` in prepare.
However when we try to look up using the swapped module type in qconfig_dict, we cannot find a match anymore since the qconfig dict contains the original
module type.

In this PR we update the qconfig_dict to include the modules swapped for QATT

Test Plan:
python test/test_quantization.py TestQuantizeFx.test_qconfig_qat_module_type

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: c74cb9a
Pull Request resolved: #60555
@supriyar supriyar requested review from jerryzh168 and vkuzo June 23, 2021 18:26
@supriyar
Copy link
Contributor Author

@supriyar has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@jerryzh168 jerryzh168 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lg, thanks!

@codecov
Copy link

codecov bot commented Jun 23, 2021

Codecov Report

Merging #60555 (001f200) into gh/supriyar/235/base (a5d5fd8) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@                   Coverage Diff                    @@
##           gh/supriyar/235/base   #60555      +/-   ##
========================================================
- Coverage                 76.24%   76.23%   -0.01%     
========================================================
  Files                      2054     2054              
  Lines                    205027   205035       +8     
========================================================
- Hits                     156322   156310      -12     
- Misses                    48705    48725      +20     

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 1120a1b.

@facebook-github-bot facebook-github-bot deleted the gh/supriyar/235/head branch June 27, 2021 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants