-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[ao] Added Equalization QConfig generation to ModelReport class #83698
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
Summary: This adds the capability to generate a QConfigMapping based on the suggestions of the ModelReport API for the user to use. The only dependency of this feature is that the calibration is run before the generation of the QConfigMapping and there is no dependency on the report generation other than that the observers cannot be removed before this is called. This maps module fqns to EqualizationQConfigs instead of regular QConfigs. Example Usage (after callibration): ``` quantization_mapping = mod_report.generate_qconfig_mapping() equalization_mapping = mod_report.generate_equalization_mapping() prepared_model = quantize_fx.prepare_fx(model, mapping, example_input, _equalization_config=equalization_mapping) quantized_model = quantize_fx.convert_fx(prepared) ``` This was tested by ensuring that the suggestions generated in the QConfigMapping are: 1. Correct according to the set backend and data passed through 2. Able to be prepared and converted as a proper config (is a valid config) The test for this is a part of the TestFxModelReportClass test suite. Test Plan: python test/test_quantization.py TestFxModelReportClass.test_equalization_mapping_generation Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
🔗 Helpful links
✅ No Failures (0 Pending)As of commit 0122b5b (more details on the Dr. CI page): Expand to see more💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
…class" Summary: This adds the capability to generate a QConfigMapping based on the suggestions of the ModelReport API for the user to use. The only dependency of this feature is that the calibration is run before the generation of the QConfigMapping and there is no dependency on the report generation other than that the observers cannot be removed before this is called. This maps module fqns to EqualizationQConfigs instead of regular QConfigs. Example Usage (after callibration): ``` quantization_mapping = mod_report.generate_qconfig_mapping() equalization_mapping = mod_report.generate_equalization_mapping() prepared_model = quantize_fx.prepare_fx(model, mapping, example_input, _equalization_config=equalization_mapping) quantized_model = quantize_fx.convert_fx(prepared) ``` This was tested by ensuring that the suggestions generated in the QConfigMapping are: 1. Correct according to the set backend and data passed through 2. Able to be prepared and converted as a proper config (is a valid config) The test for this is a part of the TestFxModelReportClass test suite. Test Plan: python test/test_quantization.py TestFxModelReportClass.test_equalization_mapping_generation Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
…class" Summary: This adds the capability to generate a QConfigMapping based on the suggestions of the ModelReport API for the user to use. The only dependency of this feature is that the calibration is run before the generation of the QConfigMapping and there is no dependency on the report generation other than that the observers cannot be removed before this is called. This maps module fqns to EqualizationQConfigs instead of regular QConfigs. Example Usage (after callibration): ``` quantization_mapping = mod_report.generate_qconfig_mapping() equalization_mapping = mod_report.generate_equalization_mapping() prepared_model = quantize_fx.prepare_fx(model, mapping, example_input, _equalization_config=equalization_mapping) quantized_model = quantize_fx.convert_fx(prepared) ``` This was tested by ensuring that the suggestions generated in the QConfigMapping are: 1. Correct according to the set backend and data passed through 2. Able to be prepared and converted as a proper config (is a valid config) The test for this is a part of the TestFxModelReportClass test suite. Test Plan: python test/test_quantization.py TestFxModelReportClass.test_equalization_mapping_generation Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
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.
looks good
| # return the generated mapping | ||
| return mapping | ||
|
|
||
| def _quantization_config_generator(self, detector_qconfig_info: DetectorQConfigInfo, module: torch.nn.Module) -> QConfig: |
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.
I feel ideally we'd like to remove these one-line functions
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.
I understand that helper functions improves code reuse, but creating too many helper functions will also make the code less readable
|
@pytorchbot merge -g |
|
@pytorchbot successfully started a merge job. Check the current status here. |
|
Merge failed Raised by https://github.com/pytorch/pytorch/actions/runs/2885197830 |
…class" Summary: This adds the capability to generate a QConfigMapping based on the suggestions of the ModelReport API for the user to use. The only dependency of this feature is that the calibration is run before the generation of the QConfigMapping and there is no dependency on the report generation other than that the observers cannot be removed before this is called. This maps module fqns to EqualizationQConfigs instead of regular QConfigs. Example Usage (after callibration): ``` quantization_mapping = mod_report.generate_qconfig_mapping() equalization_mapping = mod_report.generate_equalization_mapping() prepared_model = quantize_fx.prepare_fx(model, mapping, example_input, _equalization_config=equalization_mapping) quantized_model = quantize_fx.convert_fx(prepared) ``` This was tested by ensuring that the suggestions generated in the QConfigMapping are: 1. Correct according to the set backend and data passed through 2. Able to be prepared and converted as a proper config (is a valid config) The test for this is a part of the TestFxModelReportClass test suite. Test Plan: python test/test_quantization.py TestFxModelReportClass.test_equalization_mapping_generation Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
Summary: This adds the capability to generate a QConfigMapping based on the suggestions of the ModelReport API for the user to use. The only dependency of this feature is that the calibration is run before the generation of the QConfigMapping and there is no dependency on the report generation other than that the observers cannot be removed before this is called. This maps module fqns to EqualizationQConfigs instead of regular QConfigs. Example Usage (after callibration): ``` quantization_mapping = mod_report.generate_qconfig_mapping() equalization_mapping = mod_report.generate_equalization_mapping() prepared_model = quantize_fx.prepare_fx(model, mapping, example_input, _equalization_config=equalization_mapping) quantized_model = quantize_fx.convert_fx(prepared) ``` This was tested by ensuring that the suggestions generated in the QConfigMapping are: 1. Correct according to the set backend and data passed through 2. Able to be prepared and converted as a proper config (is a valid config) The test for this is a part of the TestFxModelReportClass test suite. Test Plan: python test/test_quantization.py TestFxModelReportClass.test_equalization_mapping_generation Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 5d4c9dc Pull Request resolved: #83698
|
@pytorchbot merge -g |
|
@pytorchbot successfully started a merge job. Check the current status here. |
…) (#83698) Summary: This adds the capability to generate a QConfigMapping based on the suggestions of the ModelReport API for the user to use. The only dependency of this feature is that the calibration is run before the generation of the QConfigMapping and there is no dependency on the report generation other than that the observers cannot be removed before this is called. This maps module fqns to EqualizationQConfigs instead of regular QConfigs. Example Usage (after callibration): ``` quantization_mapping = mod_report.generate_qconfig_mapping() equalization_mapping = mod_report.generate_equalization_mapping() prepared_model = quantize_fx.prepare_fx(model, mapping, example_input, _equalization_config=equalization_mapping) quantized_model = quantize_fx.convert_fx(prepared) ``` This was tested by ensuring that the suggestions generated in the QConfigMapping are: 1. Correct according to the set backend and data passed through 2. Able to be prepared and converted as a proper config (is a valid config) The test for this is a part of the TestFxModelReportClass test suite. Pull Request resolved: #83698 Approved by: https://github.com/jerryzh168 Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/88e0165d085166ce13ef443991eea003ee86869e Test plan from GitHub: python test/test_quantization.py TestFxModelReportClass.test_equalization_mapping_generation Reviewed By: atalman Differential Revision: D38853641 Pulled By: vspenubarthi fbshipit-source-id: a7f365d62e1e0fbb74b051ef2d3e1bc4b8cf04e2
Stack from ghstack (oldest at bottom):
Summary: This adds the capability to generate a QConfigMapping based on
the suggestions of the ModelReport API for the user to use. The only
dependency of this feature is that the calibration is run before the
generation of the QConfigMapping and there is no dependency on the
report generation other than that the observers cannot be removed before
this is called. This maps module fqns to EqualizationQConfigs instead of regular
QConfigs.
Example Usage (after callibration):
This was tested by ensuring that the suggestions generated in the QConfigMapping are:
1. Correct according to the set backend and data passed through
2. Able to be prepared and converted as a proper config (is a valid config)
The test for this is a part of the TestFxModelReportClass test suite.
Test Plan: python test/test_quantization.py TestFxModelReportClass.test_equalization_mapping_generation
Reviewers:
Subscribers:
Tasks:
Tags: