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

[PTQ][OV] ChannelAlignment algorithm is ready to be enabled by default #2073

Conversation

daniil-lyakhov
Copy link
Collaborator

@daniil-lyakhov daniil-lyakhov commented Aug 21, 2023

Changes

  • ChannelAlignment algorithm is enabled by default
  • Biases are added only for operations that are affected by CA algorithm

Reason for changes

  • To increase models mertics by using ChannelAlignment algorithm by default

Related tickets

114328
114583

Tests

tests/post_training/test_templates/test_channel_alignment.py is updated

@daniil-lyakhov daniil-lyakhov requested a review from a team as a code owner August 21, 2023 10:55
@github-actions github-actions bot added NNCF Common Pull request that updates NNCF Common NNCF OpenVINO Pull requests that updates NNCF OpenVINO NNCF PTQ Pull requests that updates NNCF PTQ labels Aug 21, 2023
@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

Merging #2073 (79a681d) into develop (f6d958f) will increase coverage by 35.93%.
The diff coverage is 46.66%.

Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #2073       +/-   ##
============================================
+ Coverage         0   35.93%   +35.93%     
============================================
  Files            0      476      +476     
  Lines            0    42446    +42446     
============================================
+ Hits             0    15255    +15255     
- Misses           0    27191    +27191     
Files Changed Coverage Δ
...n/algorithms/channel_alignment/openvino_backend.py 0.00% <0.00%> (ø)
...tization/algorithms/channel_alignment/algorithm.py 27.91% <15.38%> (ø)
...f/common/graph/transformations/command_creation.py 100.00% <100.00%> (ø)
nncf/quantization/advanced_parameters.py 46.04% <100.00%> (ø)
...antization/algorithms/channel_alignment/backend.py 100.00% <100.00%> (ø)
...quantization/algorithms/post_training/algorithm.py 82.65% <100.00%> (ø)

... and 470 files with indirect coverage changes

@daniil-lyakhov
Copy link
Collaborator Author

Full validation showed no degradation with CA algorithm enabled for supported models.
Conformance test showed no degradation as well

Model Backend Metric name Metric value Metric diff Num FQ RAM MiB Quant. time Total time
1 timm/efficientnet_b0 OV Acc@1 0.7682 -0.0047 76 1001 0:00:40 0:13:47
2 timm/efficientnet_b0_BC OV Acc@1 0.7682 -0.0047 76 1195 0:00:55 0:14:07
3 timm/efficientnet_lite0 OV Acc@1 0.7471 -0.0025 60 961 0:00:29 0:11:27
4 timm/mobilenetv2_050_BC OV Acc@1 0.6436 -0.0020 64 835 0:00:22 0:09:08
5 timm/mobilenetv3_small_050 OV Acc@1 0.3879 -0.1755 80 737 0:00:22 0:13:17

timm/mobilenetv3_small_050: Improvement: Metric value is better than reference 0.38792 > 0.38638

@daniil-lyakhov daniil-lyakhov force-pushed the dl/channel_alignment_improvements_full branch 3 times, most recently from 1eb303f to dd84e18 Compare August 25, 2023 11:19
@daniil-lyakhov
Copy link
Collaborator Author

@KodiaqQ, @andrey-churkin, please take a look

@@ -152,7 +152,7 @@ class AdvancedQuantizationParameters:
overflow_fix: OverflowFix = OverflowFix.FIRST_LAYER
quantize_outputs: bool = False
inplace_statistics: bool = True
disable_channel_alignment: bool = True
disable_channel_alignment: bool = False
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, discuss influence of this change on nncf.quantize_with_accuracy_control(...) with @andrey-churkin.

Copy link
Contributor

Choose a reason for hiding this comment

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

These changes do not affect nncf.quantize_with_accuracy_control(...) when tune_hyperparams is set to False. However, when tune_hyperparams is set to True, we cannot apply hyperparameter tuning due to this check.

def get_statistic_points(self, model: TModel, graph: NNCFGraph) -> StatisticPointsContainer:
if self.first_stage_algorithms:
raise NotImplementedError(
"Statistic points are not supported yet for SmoothQuant and ChannelAlignment algorithms."
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@andrey-churkin, what should I do to make tune_hyperparams works again?

for first_stage_algorithm in self.first_stage_algorithms:
algorithm = first_stage_algorithm.algorithm

for algorithm in self.first_stage_algorithms:
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there dependencies in the order of algorithms? I mean, if I apply ChannelAlignment first and then SmoothQuant, does something change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've checked and it looks like the order of this algorithms does not matter

@daniil-lyakhov
Copy link
Collaborator Author

@alexsu52, @andrey-churkin, I've disabled CA by default to prevent Tuning Hyperparameters failing. I suggest to merge this PR as it's including some improvements for CA algorithm

@daniil-lyakhov daniil-lyakhov changed the title [PTQ][OV] Enable ChannelAlignment algorithm by default [PTQ][OV] ChannelAlignment algorithm is ready to be enabled by default Sep 6, 2023
@alexsu52
Copy link
Contributor

alexsu52 commented Sep 7, 2023

@alexsu52, @andrey-churkin, I've disabled CA by default to prevent Tuning Hyperparameters failing. I suggest to merge this PR as it's including some improvements for CA algorithm

I agree. Please update the PR title.

Copy link
Contributor

@alexsu52 alexsu52 left a comment

Choose a reason for hiding this comment

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

LGTM

@KodiaqQ KodiaqQ merged commit c07810b into openvinotoolkit:develop Sep 7, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NNCF Common Pull request that updates NNCF Common NNCF OpenVINO Pull requests that updates NNCF OpenVINO NNCF PTQ Pull requests that updates NNCF PTQ
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants