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

QuantizationModifier refactor #1183

Merged
merged 19 commits into from
Dec 19, 2022
Merged

QuantizationModifier refactor #1183

merged 19 commits into from
Dec 19, 2022

Conversation

bfineran
Copy link
Member

@bfineran bfineran commented Nov 28, 2022

Main feature branch for the QuantizationModifier refactor project. Goal of the project is to create a new interface that provides more flexibility (via the QuantizationScheme config) while including default targets that protect more against future torch default changes.

UX

Users have full control over what gets quantized through a default scheme, overriding defaults for module types or submodules with scheme_overrides, and skipping module types or submodules with ignore

sample config:

!QuantizationModifier
    start_epoch: 0.0
    scheme:
        input_activations:
            num_bits: 8
            symmetric: False
        weights:
            num_bits: 8
            symmetric: True
    scheme_overrides:
        feature_extractor: "default"
        classifier:
            input_activations:
                num_bits: 8
                symmetric: False
            weights: null
        Conv2d:
            input_activations:
                num_bits: 8
                symmetric: True
    ignore: ["ReLU", "input"]
    disable_quantization_observer_epoch: 2.0
    freeze_bn_stats_epoch: 3.0
    model_fuse_fn_name: 'fuse_module'
    strict: True

Tasks

Sample section of ResNet-50 quantized with new default flow

Screenshot 2022-12-16 at 10 44 27 AM

Test Plan

  • Testing included with each feature PR, lifecycle tests cover these features
  • yaml testing included
  • planned to work with research team on generating practical recipes with the updated modifier
  • sample resnet50 onnx export in description

@bfineran bfineran self-assigned this Nov 28, 2022
@bfineran bfineran changed the title QuantizationModifier refactor [WIP] QuantizationModifier refactor Nov 28, 2022
@bfineran bfineran changed the title [WIP] QuantizationModifier refactor [Feature Branch] QuantizationModifier refactor Dec 1, 2022
@bfineran bfineran changed the title [Feature Branch] QuantizationModifier refactor QuantizationModifier refactor Dec 12, 2022
@bfineran bfineran marked this pull request as ready for review December 12, 2022 21:19
bfineran and others added 19 commits December 16, 2022 10:40
… file, add object routing for yaml load (#1059)

* move existing ModifierQuantization and tests to legacy file

* [QuantizationModifier] refactor base - move deprecated code to legacy file, add object routing for yaml load
…emes to generate QConfigs (#1061)

* [QuantizationModifier] pydantic classes for defining quantization schemes to generate QConfigs

* review response
…le from QuantizationScheme (#1185)

* [QuantizationModifier] base refactor flow - quantize entire module from QuantizationScheme

* review response

* testing - lifecycle + QAT application

* activate qat tests
…fic submodules by scheme (#1201)

* [QuantizationModifier] submodule_schemes property impl - target specific submodules by scheme

* generalize helper fn name + quality
…heme by layer type (#1202)

* [QuantizationModifier] module_type_schemes - override quantization scheme by layer type

* yaml pydoc example
* [QuantizationModifier] logging support

* fake quantize bits logging
…1239)

* rename modifier default_scheme -> scheme

* refactor set_quantization_schemes (tests passing with existing UX)

* exclude_module_types -> ignore ; adds submodule exclusion

* refactor submodule and module type schemes into unified submodule_overrides
…xes (#1261)

* [QuantizationModifier] take ownership of add_observers_, unit test fixes

* suggestion from review - with quality override

* review - suggested comment

* fixes for FloatFunctional support (resnet50 broke)
Copy link
Contributor

@KSGulin KSGulin left a comment

Choose a reason for hiding this comment

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

Nice!!

Copy link
Contributor

@corey-nm corey-nm left a comment

Choose a reason for hiding this comment

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

🚀 🎉

@bfineran bfineran merged commit d0300e8 into main Dec 19, 2022
@bfineran bfineran deleted the quantization-refactor/main branch December 19, 2022 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants